miércoles, enero 02, 2013

Include code listings as figures in LaTeX


To include code listing as figures (including label and caption fields) in LaTeX you can do the following:


\usepackage{caption
...
\noindent\begin{minipage}{\textwidth}
\begin{lstlisting}
hello world!! here the code.
\end{lstlisting}
\captionof{figure}{a caption text.}
\label{fig:figurelabel}
\end{minipage}