[texhax] toc and pdfTeX

John Culleton john at wexfordpress.com
Sat Feb 9 02:24:28 CET 2008

On Friday 08 February 2008 01:36:19 pm Robert Wilson wrote:
> Do you mind if I ask why you aren't using LaTeX? I'm new to LaTeX and have
> never used TeX, but in the former, you would just use \tableofcontents. I'm
> curious as to what advantages TeX has over LaTeX.
> Cheers,
> Robert Wilson
> On Feb 8, 2008 12:26 PM, D. R. Evans <doc.evans at gmail.com> wrote:
> > This must be an FAQ, but I can't find an answer (or a pointer to an
> > answer)
> > anywhere :-(
> >
> > I am using pdftex to generate a PDF from a plain ol' vanilla TeX file.
> > Does
> > anyone have any pointers to examples to show how I can go about
> > generating a Table of Contents reasonably easily?
> >
> > (I expected the TeXbook to describe this in some detail, but it doesn't
> > seem to.)
> >
> >  Doc

The advantage to plain pdftex is simplicity and also flexiblity in things like 
font sizes etc.  When I am sizing a book to meet a certain page count I may 
change body font size by very small increments until it fits just right. If I 
have a very complex layout I will use Context. I'll never go back to the 
constraints and verbosity of LaTeX---but YMMD of course. 

For the specific question use 
1. \input eplain.tex

2. add the line \readtocfile up front where you need the TOC
3. Modify  your chapter etc. macros to include the line
where #1 refers to the chapter title
4. If necessary revise the TOC entry writing macros e.g., \writetocentry etc. 
to suit your purposes. 

Each time you change the source file you must run the pdftex comand twice, 
once to build a new TOC file and the second time to put the revised file into 
the document.  Since I am also doing an index usually my script may look 
something like this:
pdftex book.tex
makeindex book.idx
pdftex book.tex

I edit in gvim. I assign different functions to the F keys. F3 runs pdftex 
book.tex.  I always name my main file book.tex. Thus I can be editing away
on the preface file but hit F3 and get a compile of the whole book. F5 calls 
kpdf book.pdf. This is of Linux of course but something similar can be 
cobbled up using .bat files.  


John Culleton
Precision Typesetting
Able Indexers and Typesetters

More information about the texhax mailing list