Wednesday, October 2, 2019

Writing Article in Latex Step by Step

Writing Article in Latex Step by Step

Step 1: If you are new in LaTeX please visit my blog LaTex Tutorial

ok..

Use the below code to write Title, Author, Address, Abstract and Keywords \

\documentclass[options]{article}
\title{Energy Efficient Clustering and Routing Algorithm for WSN}
\author{Mohit Kumar$^{1}$, Md. Amir Khusru Akhtar$^{2}$  \\
\small $^{1}$ Cambridge Institute of Technology \\
\small $^{2}$Usha Martin University }
\begin{document}
\maketitle
\begin{abstract}
The prevalent applications of WSN have fascinated a plethora of research efforts. WSN still faces several critical challenges. Even though many algorithms have been proposed for WSN, there are still many challenges associated with sensor networks.
\end{abstract}\hspace{10pt}
{\bf Keywords:} Wireless sensor network, clustering, routing, energy consumption, network lifetime
\end{document}

OUTPUT

Step 2: Create a BibTeX file for references (steps shown in below link)


Now, start your Section and Subsection and cite references from the bib file.
An Example of Latex code is shown below:

\documentclass[options]{article}
\usepackage{cite}
\title{Energy Efficient Clustering and Routing Algorithm for WSN}
\author{Mohit Kumar$^{1}$, Md. Amir Khusru Akhtar$^{2}$  \\
\small $^{1}$ Cambridge Institute of Technology \\
\small $^{2}$Usha Martin University }
\begin{document}
\maketitle
\begin{abstract}
The prevalent applications of WSN have fascinated a plethora of research efforts. WSN still faces several critical challenges. Even though many algorithms have been proposed for WSN, there are still many challenges associated with sensor networks. 
\end{abstract}\hspace{10pt}
{\bf Keywords:} Wireless sensor network, clustering, routing, energy consumption, network lifetime
\section{Introduction}
Wireless sensor networks (WSN), are geographically distributed autonomous sensors which are deployed either arbitrarily or using some predefined provision. It is used to monitor the physical or environmental characteristics such as temperature, pressure, humidity, sound etc. shown in figure 1. The collected data ... health, military \cite {wohwesamboOptimizedClusteringAlgorithms2019, akyildizWirelessSensorNetworks2002} etc. The f...and communication capabilities.
\bibliographystyle{plain}
\bibliography{art1}
\end{document}


OUTPUT

Step 3: Write rest of the Article and add figures, tables and equation.
In case you are facing trouble in ( figures, tables and equations,...)
please visit my blog LaTex Tutorial
A sample code is shown below.

\documentclass[options]{article}
\usepackage{cite}
\usepackage{graphicx}
\title{Energy Efficient Clustering and Routing Algorithm for WSN}
\author{Mohit Kumar$^{1}$, Md. Amir Khusru Akhtar$^{2}$  \\
\small $^{1}$ Cambridge Institute of Technology \\
\small $^{2}$Usha Martin University }
\begin{document}
\maketitle
\begin{abstract}
The prevalent applications of WSN have fascinated a plethora of research efforts. WSN still faces s.....ges associated with sensor networks. The euiler equation $e^{\pi i} + 1 = 0 $ has...
\end{abstract}\hspace{10pt}
{\bf Keywords:} Wireless sensor network, clustering, routing, energy consumption, network lifetime
\section{Introduction}
Wireless sensor networks (WSN), ......sion. It ..... such as temperature, pressure, humidity, sound etc. shown in figure \ref{img1}. The collected data ... health, military \cite {wohwesamboOptimizedClusteringAlgorithms2019, akyildizWirelessSensorNetworks2002} etc. The f...and communication capabilities. $$ x_1^2 + x_2^2 = x_3^2 $$
\begin{figure}[h!]
\centering
\includegraphics[width=0.5\textwidth]{fig1.jpg}
\caption{Sensor Network}
\label{img1}
\end{figure}
\section{Related Work}
Lots of works have been proposed in the field of energy efficient clustering and routing but they have serious limitations......

Major factors contributing to overloading of CHs may be classified into three categories shown in Table \ref{tab1}.
\\
\begin{table}[!ht]
\centering
\caption{Componets}

\label{tab1}
\begin{tabular}{|r|r|r|r|}
\hline
Item & 2012 & 2013 & 2014 \\
\hline
Desktop & 23 & 25 & 26 \\
\hline
Laptop & 53 & 55 & 86 \\
\hline
Monitor & 13 & 85 & 28 \\
\hline
\end{tabular}
\end{table}

\section {Numerical Simulation}
This Section Covers....
\subsection {Model 1}
In this ...\begin{equation}
\label{eq01}
e^{\pi i} + 1 = 0
\end{equation}
The is an example of equation in \ref{eq01} Label
\subsubsection{Scenario 1}
We have .....
\begin{itemize}
\item One
\item Two
\begin{itemize}
\item Two one
\item Two two
\end{itemize}  \item Three
\end{itemize}

\section*{Conclusion}
In this paper...........
\bibliographystyle{plain}
\bibliography{art1}
\end{document}

OUTPUT

Creating BibTeX file from Zotero Library

Creating BibTeX file from Zotero Library


Phase 2: Run Zotero and perform the following steps in Zotero

1. Tools > Add-ons
2. Select ‘Extensions’
3. Click on the gear in the top-right corner and select ‘Install Add-on From File…’
4. Choose .xpi that we have downloaded in phase 1, 5. click ‘Install
6. Restart Zotero


Phase 3: Export Library from Zotero
1. File > Export Library
2. Select Format ‘Better BibTeX’ and Click on OK
3. Choose your Location to save your file and  Click on OK

Now your BibTeX file is ready.

Bibliography in LaTeX

Bibliography in LaTeX


Create a BibTeX file (.bib). It should be given the same name as and kept in the same folder as your .tex file.

Ex.  bib file
@article{akhtarMathematicalModelDetection2008,
  title = {Mathematical Model for the Detection of Selfish Nodes in {{MANETs}}},
  volume = {1},
  number = {3},
  journal = {International Journal of Computer science and Informatics},
  author = {Akhtar, Md Amir Khusru and Sahoo, G.},
  year = {2008},
  pages = {25--28}
}

@article{akhtarHumanisticApproachMobile2013,
  title = {Humanistic Approach in Mobile Ad Hoc Network: {{HAMANET}}},
  shorttitle = {Humanistic Approach in Mobile Ad Hoc Network},
  journal = {arXiv preprint arXiv:1312.7660},
  author = {Akhtar, Md and Khusru, Amir and Sahoo, G.},
  year = {2013},
}

.....................

Citing references
Use \cite{citation-key} command where you want to cite a reference in your .tex file.

Inserting the bibliography
Write the given commands where you want to insert the bibliography in your document (normally at the end)
\bibliographystyle{plain}
\bibliography{BibTeX filename}

Ex.
\documentclass{article}
\title{\LaTeX Management}
\author{Dr. Md. Amir Khusru Akhtar}
\usepackage{cite}
\begin{document}
\maketitle
In \LaTeX we can use cite package for multiple citation  \cite{johnsonDSRDynamicSource2001,huPacketLeashesDefense2003,johnsonAcidMineDrainage2005} and single citation \cite{wohwesamboOptimizedClusteringAlgorithms2019}.
\bibliographystyle{plain}
\bibliography{2}
\end{document}

OUTPUT
Ex. 

Use package apacite for apa style

\documentclass{article}
\usepackage{apacite}
\title{DDoS Attack}
\author{Dr. Md. A. K. Akhtar}
\begin{document}
\maketitle
Distributet DoS \cite{huPacketLeashesDefense2003}.
\bibliographystyle{apacite}
\bibliography{2}
\end{document}

Output


Tuesday, October 1, 2019

LaTeX Special Characters

LaTeX Special Characters

PUNCTUATION MARKS
Put a backslash (\) in front of given characters

 \#     \$        \%        \^{}      \&      \_      \{      \}       \~{}

GREEK LETTERS in LOWER-CASE
     \alpha    \eta      \nu       \tau 
     \beta     \theta    \xi       \upsilon
     \gamma    \iota      o        \phi 
     \delta    \kappa    \pi       \chi 
     \epsilon  \lambda   \rho      \psi 
     \zeta     \mu       \sigma    \omega 

Ex. $\alpha$

GREEK LETTERS in UPPER-CASE
     \Gamma    \Lambda   \Sigma    \Psi 
     \Delta    \Xi       \Upsilon  \Omega 
     \Theta    \Pi       \Phi

Ex.
$\Delta$

MATHEMATICAL SYMBOLS/commands
  plus/minus (±) use \pm 
  minus/plus            use \mp
  times (×) use \times
  division (÷) use \div
  tilde (~)         use \sim
  Angstrom(Å) use \AA
  angstrom(å) use \aa
  degree (°) use  $^{\circ}$
  Square root            use  \sqrt{...}
  Fraction                 use \frac{numerator}{denominator}
  Backslash              use  \textbackslash

Mathematics in LaTeX

Mathematical Expressions
In LaTex we have two modes to use mathematical expressions (inline and display mode)

For inline mode use any one of these delimiters.
1.  \( \)
2.  $ $
3.  \begin{math} \end{math}

Ex.
$c=a+b$

In displayed mode we have two versions (numbered and unnumbered)

We can use  any one of these delimiters in display mode
1. \[ \]
2. $$ $$
3. \begin{displaymath} \end{displaymath}
4. \begin{equation} \end{equation}

Ex.
$$ c=a+b $$

Note: include package amsmath
\usepackage{amsmath}

In Latex we can use the symbols ^  for superscripts and symbols  _ for subscripts.

Ex. 
\documentclass[options]{article}
\usepackage{amsmath}
\begin{document}

$$ x_1^2 + x_2^2 = x_3^2 $$

$$ x^{a \beta} - 1 = y_{ijk} + y_{lm}  $$

$$ ((xa)^n)^{p+q} = xa^{\theta}  $$

\[ \int\limits_0^\infty a^2 + b^2 \ dx \]

$$ \sum_{i=0}^{\infty} \frac{2}{n^s}
= \prod_p ^ n \frac{i}{1 - p^{-s}} $$

\end{document}

Output

Label in equation
We can use label for future reference
\documentclass[options]{article}
\usepackage{amsmath}
\begin{document}
\begin{equation} \label{eq01}
e^{\pi i} + 1 = 0
\end{equation}
The is an example of equation in \ref{eq01} Label
\end{document}

OUTPUT
Multiline Equation
use \begin{multline} command for numbered equation and \begin{multline*} for unnumbered equation.

\documentclass[options]{article}
\usepackage{amsmath}
\begin{document}
\begin{multline*}
f(x) = 4x^6 + 4x^5y + 59x^4y^2 + 9x^3y^3\\
- 12x^91y^4 - 2xy^5 + 21y^6 - a^3b^3
\end{multline*}

\begin{multline}
f(x) = 4x^6 + 4x^5y + 5x^4y^2 + 9x^3y^3\\
- 12x^91y^4 - 2xy^5 + 21y^6 - a^3b^3
\end{multline}
\end{document}

Output



Figures in LaTex

Figures

In LaTex we have figure commands to use a figure.  We can add PDF, PNG, JPEG\or GIF files.

\begin{figure}
......
\end{figure}

Ex. 
\documentclass[options]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{img.jpg}
\caption{Here is my image}
\label{image-myimage}
\end{figure}
\end{document}

[width=1\textwidth]  specifies the width of the picture 

For alignment from left or right we need to add
\usepackage[export]{adjustbox}

Ex.
\includegraphics[width=0.5\textwidth, right]{img}

Multiple images in one figure

use package{subcaption} and the environment \subfigure 

Ex.
\documentclass[options]{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{subcaption}
\begin{document}
\begin{figure}[h]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{Table1} 
\caption{Caption1}
\label{fig11}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=5cm]{Table2}
\caption{Caption 2}
\label{fig12}
\end{subfigure}
\caption{Caption for this figure with two images}
\label{fig2}
\end{figure}
\end{document}

Wrapping text around a figure

import package wrapfig shown below

Ex.

\documentclass[options]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\begin{document}
\begin{wrapfigure}{l}{0.25\textwidth}
\includegraphics[width=0.9\linewidth]{Table1} 
\caption{Caption1}
\label{fig1}
\end{wrapfigure}
\end{document}

Note:

\textwidth is the width of the total text block

\columnwidth is the width of a single column of text

\linewidth means the current size of the line of text

\graphicspath{ {./img/} } if you want to put images in a folder named img under the directory of the tex document


use absolute path if the location is different

\graphicspath{ {c:/user/img/} } this command should be written in preamble


for Linux, Mac OS

\graphicspath{ {/home/user/img/} }


for multiple folders

\graphicspath{ {./img1/}{./img2/} }


for scaling

\includegraphics[scale=2]{img-name}

for definining specific width and the height of the image

\includegraphics[width=3cm, height=4cm]{lion-logo}


For rotation

\includegraphics[scale=1.2, angle=45]{lion-logo}


Positioning parameters 

\begin{figure}[t]

h: Places approximately at the same point it occurs in the source 

t: Places at the top of the page

b: Places at the bottom of the page

p: Put on a special page for floats only.

!: Override internal parameters LaTeX determines best positions




Table in LaTeX

Table

In LaTeX we use tabular command to typeset a table. 

\begin{tabular}{...}
......

\end{tabular}

The codes for columns are defined as follows
l left-alignment
r right-alignment
c centre-alignment
| for vertical line
& is used to separate columns
\\  for end of a row
\newline for a new line within a cell 
\hline for a horizontal line.
\cline{i-j} inserts a partial horizontal line between column i and j

Ex. {ll} (i.e. left left ) is used to create 2 columns with left-alignment text without vertical lines , whereas {|l|r|} (i.e. left right )  for 2 columns. The first column is left aligned and second column is right aligned  with vertical lines.

Tabular Code and output 

Ex. 1.
Output Ex. 1

\documentclass[options]{Article}
\begin{document}
\begin{tabular}{|l|r|}
RAM & ROM \\
Printer & Plotter \\
Keyboard & Mouse \\
\end{tabular}
\end{document}


Ex. 2.


Output Ex. 2
\documentclass[options]{Article}
\begin{tabular}{|r|l|}
\hline
One & Two \\
\cline{2-2}
Three & Four \\
\hline \hline
Hello123 & Done \\
\hline
\end{tabular}
\end{document}


Output Ex. 3
Ex. 3.
\documentclass[options]{Article}
\begin{document}
\begin{tabular}{|r|r|r|r|}
\hline
Item & 2012 & 2013 & 2014 \\
\hline
Desktop & 23 & 25 & 26 \\
\hline
Laptop & 53 & 55 & 86 \\
\hline
Monitor & 13 & 85 & 28 \\
\hline
\end{tabular}
\end{document}

Ex. 4.
Output Ex. 4
\documentclass[options]{Article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{l|rrr}
\multicolumn{4}{c}{Table 4}\\
\hline
\multirow{2}{4em}{Item} & \multicolumn{3}{c}{Year} \\
\cline {2-4}
 & 2012 & 2013 & 2014 \\
\hline
Desktop & 23 & 25 & 26 \\
\hline
Laptop & 53 & 55 & 86 \\
\hline
Monitor & 13 & 85 & 28 \\
\end{tabular}

\end{document}