Code Listings for Latex

I wrote an article a few days back about writing a research paper. That became too long and I had to cut it short. However, it turns out that in as much as it had plenty of advice, many of the things were missed. One of those things is about various kinds of codes for Latex. Here I am posting code listings for various kinds of functions in Latex.

The pseudo-code for NUAV is shown in Algorithm~\ref{alg:algo-1}.
\begin{algorithm}
\caption{NUAV testbed}
\label{alg:algo-1}
\begin{algorithmic}
\STATE $NET \gets nnsetup(architecture)$
\STATE $numweights \gets nnnumweights(NET)$
\STATE $Population \gets initPop$
\FOR{$i=1:PopSize$}
\STATE $NET \gets nnassignweights(NET, offspringPop(i))$
\FOR{$j=1:epochs$}
\STATE $inputData \gets getFlightData$
\STATE $outputData \gets FeedForward(inputData)$
\STATE $sendFlightData(outputData)$
\ENDFOR
\STATE $Individual(i) \gets evaluateInd()$
\ENDFOR
\FOR{$i=1:gen$}
\STATE $parents \gets tournamentSelection$
\STATE $childPop \gets geneticOperators(parents)$
\FOR{$j=1:PopSize$}
\STATE $NET \gets nnassignweights(NET, childPop(j))$
\FOR{$k=1:epochs$}
\STATE $inputData \gets getFlightData$
\STATE $outputData \gets FeedForward(inputData)$
\STATE $sendFlightData(outputData)$
\ENDFOR
\STATE $Individual(i) \gets evaluateInd()$
\ENDFOR
\STATE $Population \gets replacement(parentPop, childPop)$
\ENDFOR
\end{algorithmic}
\end{algorithm
}

You can create tables using the tabular environment. Never create a table in a different software and then save it as a figure of some sort. Always create tables using the standard fashion prescribed for latex. Here is an example snippet.

\begin{center}
\begin{tabular}{ c c c }
cell1 & cell2 & cell3 \
cell4 & cell5 & cell6 \
cell7 & cell8 & cell9
\end{tabular}
\end{center
}

Here is a complete tutorial for this.

Tables – ShareLaTeX, Online LaTeX Editor

A comprehensive LaTeX guide with easy to understand examples and how-tos.

 

Photo by martingreffe

If you found an error, highlight it and press Shift + Enter or click here to inform us.

CC BY-NC-ND 4.0 Code Listings for Latex by Psyops Prime is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Leave a Reply