September 23, 2004 8:38 PM
Latex is a god send. Our lab reports usually consist of more code than anything else. To some of my fellow students, report creation involves a repetitive session involving Open, Copy and Paste. Some run cat *.c > out and then spend a lot of time adding headings, comments etc. and editing it to make it presentable. But latex and a little bit of elisp lets me automate this every single time.

Nothing fancy, really. The verbatim package lets me include the contents of any ascii file. Well, using the built in input and verbatim commands can also do the trick. The listing of files (and associated metadata like headings, summary) in a directory is generated by my code archives generator with a slight modification. Instead of outputting html, it outputs latex code.

Here's a sample Latex file:

\documentclass[a4paper,11pt,notitlepage]{article}
\usepackage{verbatim}
\newcommand{\cfile}[2]{
\setcounter{page}{1}
\section{#1}
\verbatiminput{#2}
\subsection{Summary}
\verbatiminput{#2.txt}
\subsection{Output}
\verbatiminput{#2.out}
\clearpage
}
\begin{document}
\cfile{Quicksort}{/home/anirudh/s4/qsort.c}
\cfile{Mergesort}{/home/anirudh/s4/msort.c}
% .... imagine lots more (Lots!)
\cfile{Dijkstra's Shortest Path}{/home/anirudh/s4/dijsp.c}
\end{document}

C-c C-c RET in AucTex mode and 53 pages are ready for presentation in no time. Watch out for overfull \hbox warnings though.

CategoryLatex

Copyright © 2004-2011 Anirudh Sasikumar. All rights reserved.
Last Updated: January 21, 2005 4:25 PM