How can I include source code in LaTeX documents?
A program called "lgrind" is available in the newtex locker to help you convert program listings to a form easily includable in a LaTeX document. To use this program, type the following at your athena% prompt:
This will generate a file (filename.tex) of code (-llanguage) formatted for inclusion in a LaTeX file (-latex). For example, to format a C program called mycode.c:
at the bottom of it. You can also format languages other than C:
To include the encoded file in your document:
- Include a line in your document preamble:
or, if you want the code to include function labels on the right hand side,
- Place the lines
in your .tex file where you want to insert the formatted code.