How to include SOURCE CODE in documentsA program called "lgrind" is available to help you convert program listings to a form easily includable in a LaTeX document. To use this program, type the following:
$ add newtex $ lgrind -i -llanguage filename > filename.texThis will generate a file (filename.tex) of code formatted for inclusion in a LaTeX file. For example, to format a C program called mycode.c:
$ lgrind -i -lc mycode.c > mycode.texTo include the encoded file in your document:
Include a line in your document preamble:
\usepackage{lgrind}or, if you want the code to include function labels on the right hand side,
\usepackage[procnames,noindent]{lgrind}Place the lines
\begin{lgrind}
\input mycode.tex
\end{lgrind}in your .tex file where you want to insert the formatted code.