Tuesday, January 03, 2006

LGrind - a new thing

How to include SOURCE CODE in documents

A 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.tex

This 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.tex

To 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.

No comments:

Manage Hotspot on Windows 7

Managing Hosted Network (Hotspot) on a Laptop running Windows 7 1. Setup Hosted Network netsh wlan show drivers netsh wlan set hostedn...