Go to the first, previous, next, last section, table of contents.

Contents

Producing a table of contents that is both useful and aesthetic is one of the most difficult design problems in any work. Naturally, Eplain does not pretend to solve the design problem. Collecting the raw data for a table of contents, however, is much the same across documents. Eplain uses an auxiliary file with extension `.toc' (and the same root name as your document) to save the information.

To write an entry for the table of contents, you say \writetocentry{part}{text}, where part is the type of part this entry is, e.g., `chapter', and text is the text of the title. \writetocentry puts an entry into the .toc file that looks like \tocpartentry{text}{page number}. The text is written unexpanded.

A related command, \writenumberedtocentry, takes one additional argument, the first token of which is expanded at the point of the \writenumberedtocentry, but the rest of the argument is not expanded. The usual application is when the parts of the document are numbered. On the other hand, the one-level expansion allows you to use the argument for other things as well (author's names in a proceedings, say), and not have accents or other control sequences expanded. The downside is that if you want full expansion of the third argument, you don't get it--you must expand it yourself, before you call \writenumberedtocentry.

For example:

\writenumberedtocentry{chapter}{A $\sin$ wave}{\the\chapno}
\writetocentry{section}{A section title}

Supposing \the\chapno expanded to `3' and that the \write's occurred on pages eight and nine, respectively, the above writes the following to the .toc file:

\tocchapterentry{A $\sin$ wave}{3}{8}
\tocsectionentry{A section title}{9}

You read the .toc file with the command \readtocfile. Naturally, whatever \toc... entry commands that were written to the file must be defined when \readtocfile is invoked. Eplain has minimal definitions for \tocchapterentry, \tocsectionentry, and \tocsubsectionentry, just to prevent undefined control sequence errors in common cases. They aren't suitable for anything but preliminary proofs.

After reading the .toc file, \readtocfile opens the file for writing, thereby deleting the information from the previous run. You should therefore arrange that \readtocfile be called before the first call to a \writetoc... macro. On the other hand, if you don't want to rewrite the .toc file, perhaps because you are only running TeX on part of your manuscript, you can set \rewritetocfilefalse.

By default, the `.toc' file has the root \jobname. If your document has more than one contents--for example, if it is a collection of papers, some of which have their own contents--you can tell Eplain to use a different root name by defining the control sequence \tocfilebasename.

In addition to the usual table of contents, you may want to have a list of figures, list of tables, or other such contents-like list. You can do this with \definecontentsfile{abbrev}. All of the above commands are actually a special case that Eplain predefines with

\definecontentsfile{toc}

The abbrev is used both for the file extension and in the control sequence names.


Go to the first, previous, next, last section, table of contents.