Playing with TeX

To keep myself preoccupied, I spent way too many hours trying to get TeX [1] to output a document in a very particular format.

My current ongoing project now involves generating a vast number of pages (around 1,400 or so) of summary information (one of the reports being summaried itself was nearly 400 pages in length). The amount of summary data per report is small enough that with a small enough font (around 7pt it seems like) we can fit four summaries per page, thus keeping the page count down to around 1,400 pages (there are a lot of reports). Each summary has a particular layout so I thought it should be relatively easy to get TeX to generate the output.

Eight hours later I realize that I don't know enough TeX to even begin to start this project. For instance, one example of getting two column output is:

\let\lr=L \newbox\leftcolumn
\output={\if L\lr
    \global\setbox\leftcolumn=\columnbox \global\let\lr=R
  \else \doubleformat \global\let\lr=L\fi
  \ifnum\outputpentalty>-20000 \else\dosupereject\fi}
\def\doubleformat{\shipout\vbox\{\makeheadline
    \fullline{\box\leftcolumn\hfil\columnbox}
    \makefootline}
  \advancepageno}
\def\columnbox{\leftline{\pagebody}}

Provided you set \hsize to the width you want a column (\hsize being the horizontal width you are pumping text into). Oh, and don't forget to change \makeheadline and \makefootline to expand across the entire page instead of using the current setting of \hsize.

I shouldn't really fault for TeX for this. It really is quite powerful, but the learning curve is somewhat (okay, overwhelmingly) steep. For basic jobs it's not that hard, and there are even preprogrammed macros to do academic papers (like LaTeX). But the example TeX code is very dense reading.

I'll have to play around with this more later.

[1] http://www.tug.org/

Gemini Mention this post

Contact the author