Mom -- Document processing, tables of contents

Back to Table of Contents | Next: Bibliographies and references

# Tables of contents

- Introduction to tables of contents
  - Tables of contents behaviour
  - Using `psselect` to put the table of contents where you want it
- Instruct mom to output a table of contents
- Control macros for tables of contents
  - Table of contents control macros and defaults

## Introduction to tables of contents

Want a table of contents for your document? Easy. Just enter
.TOC as the very last macro of your document file. Mom will have picked up all document titles (in collated documents), all heads, subheads, and paragraph heads, as well as any endnotes pages that have been output, and assigned them the appropriate page number (and page numbering style). Talk about a no-brainer!

That said, tables of contents have even more control macros than endnotes. As always, the reason for so many control macros is so that if you want to change just about any aspect of the table of contents’ typographic appearance, you can. Mom is all about simplicity and flexibility.

### Tables of contents behaviour

When you output a table of contents (with `.TOC`), mom finishes processing the last page of your document, then breaks to a new page for printing the table of contents.

Mom follows standard typesetting conventions for tables of contents. To this end, if HEADERS are enabled for the document, the first page of the table of contents has no page header, but does have a first page number (roman numeral), always “i”, in the bottom margin. If FOOTERS are enabled for the document, the first page has neither a footer, nor a page number in the top margin. (If you absolutely must have a page footer on the first page of the table of contents, simply invoke `.FOOTER_ON_FIRST_PAGE` immediately before `.TOC`.) Subsequent table of contents pages have both page headers or footers and a page number.

Entries in a table of contents are hierarchically indented, as you would expect. By default, each type of entry (e.g. a head or a subhead) is set in a different font as well. If any of heads, subheads or paragraph heads are numbered in the body of the document, they are also numbered in the table of contents. Head, subhead and paragraph head numbering in the table of contents is not concatenated, as it is in the body of the document, because it's visually redundant in a table of contents.

Tables of contents are never set in columns, regardless of whether the rest of the document is. Lastly, if recto/verso printing is enabled, the table of contents respects it. This sometimes leads to tables of contents that begin with the wrong margins, but the margins can be corrected either by outputting a BLANKPAGE or by using the control macro TOC_RV_SWITCH.

The overall table of contents family, point size and lead can be altered with control macros, as can the family, font, point size and indent of each type of entry (i.e. title, head, subhead, paragraph head). Furthermore, the page numbering style can be changed, as can the amount of visual space reserved for page reference numbers.

##### Using `psselect` to put the table of contents where you want it

Mom always outputs the table of contents at the end of a document. While this is desirable for some language conventions—French, for example—it is not desirable for others.

If you’d like your tables of contents near the start of your document, you have two options: re-arrange the pages by hand (okay for one or two hard copies of the document), or use the `psselect` programme provided by the psutils suite of tools (which you may have to install as a package from your distribution if it is not already on your system).

The procedure for using `psselect` to put the table of contents near the beginning of the document begins by you determining how many pages it contains. You can do this by previewing the document with the PostScript viewer of your choice (gv, okular, evince, etc).

Once you know the number of pages in the table of contents, you use `psselect` to place them where you want.

Say, for example, the table of contents runs to just one page. The command to place a one-page table of contents at the start of a document is:
psselect -p _1,1-_2 The `-p` option instructs `psselect` that what follows is a comma-separated list of the order in which you want pages of a document re-arranged. The underscore character means "counting backwards from the end of the document". Thus, the above says: "Put the last page first (i.e. the table of contents), followed by all pages from the original first page up to the second to last (i.e. the last page before the table of contents)."

If your table of contents runs to two pages, the option to `psselect` would look like this:
psselect -p _1-_2,1-_3 If your table of contents runs to two pages and you have a cover page, the command would look like this:
psselect -p 1,_1-_2,2-_3

Note: `psselect` outputs to stdout, so you have to redirect the output to a new file.
psselect -p <page list> <file>.ps > <new-file>.ps

### Instruct mom to output a table of contents

Macro: TOC

If you want a table of contents, just place `.TOC` at the very end of your document. Mom takes care of the rest.

## Control macros for tables of contents

ERRATUM: In versions of mom prior to 1.3-e_3, the documentation incorrectly stated that table of contents control macros could go anywhere in a mom file prior to invoking `.TOC`.

In fact, table of contents control macros must come before `.START`.

### Table of contents control macros and defaults

1. General table of contents style control
   - TOC_FAMILY – base family for tables of contents
   - TOC_PT_SIZE – base point size for tables of contents
   - TOC_LEAD – leading of tables of contents
2. Table of contents page numbering
   - PAGINATE_TOC – turn table of contents pagination on or off
   - TOC_PAGENUM_STYLE – table of contents page numbering style
3. Changing the table of contents header (title), string and style
   - Changing the header (title) string
     - Table of contents header (title) string control macros and defaults
4. Changing the style of table of contents entries and page number references
   - Note: the table of contents _INDENT control macros
   - Changing the style of table of contents title entries
   - Changing the style of table of contents head entries
   - Changing the style of table of contents subhead entries
   - Changing the style of table of contents paragraph head entries
   - Changing the style of table of contents page number references
5. Additional table of contents control macros
   - Append author(s) to table of contents title entries
   - Alter the wording of a table of contents title entry
   - Establish the number of placeholders to leave for page reference numbers
   - Switch tables of contents page margins

#### 1. General tables of contents style control

TOC_FAMILY establishes the default family for every page element in a table of contents, including the table of contents’ header (title) string (by default, “Contents”) and the page number in the top or bottom margin. The default is the prevailing document family.

All page elements in the table of contents also have their own _FAMILY control macros, which can be used on a case-by-case basis to override the default family set with TOC_FAMILY.

• Does not require a unit of measure; points is assumed

Unlike most other control macros that deal with size of document elements, TOC_PT_SIZE takes as its argument an absolute value, relative to nothing. (Compare this with the _SIZE control macros.) The argument represents the base point size of tables of contents from which the size of all other table of contents elements are calculated.

The default for PRINTSTYLE `TYPESET` is 12.5 points (the same default size used in the body of the document).

• Does not require a unit of measure; points is assumed

Unlike most other control macros that deal with leading of document elements, TOC_LEAD takes as its argument an absolute value, relative to nothing. Therefore, the argument represents the leading of tables of contents in points unless you append an alternative unit of measure. For example,
.TOC_LEAD 14 sets the base leading of tables of contents to 14 points, whereas
.TOC_LEAD .5i sets the base leading of tables of contents to 1/2 inch.

If you want the leading of tables of contents adjusted to fill the page, pass TOC_LEAD the optional argument `ADJUST`. (See DOC_LEAD_ADJUST for an explanation of leading adjustment.)

The default for PRINTSTYLE TYPESET is the prevailing document lead (16 by default), adjusted.

Note: Even if you give mom a `.DOC_LEAD_ADJUST .OFF` command, she will still, by default, adjust the leading of the table of contents. You must enter `TOC_LEAD <lead>` with no `ADJUST` argument to disable this default behaviour.

Additional note: Tables of contents are always double-spaced in PRINTSTYLE `TYPEWRITE`, regardless of whether the body of the document is single-spaced.

#### 2. Table of contents page numbering

The pagination style of tables of contents is controlled by the same macros that control document page numbering, except PAGENUM (tables of contents always start on page 1). The defaults are the same as for the rest of the document, with the exception that tables of contents, by default, have roman numeral page numbers.

Therefore, if you wish to change some aspect of table of contents pagination style, use the document pagination control macros immediately prior to `.TOC`.

A special macro, `TOC_PAGENUM_STYLE` controls the style of table of contents pagination (i.e. the actual table of contents pages' numbers, not the page number references of entries).

By default, mom paginates tables of contents. If you’d like her not to, do
.PAGINATE_TOC OFF (or `NO, X,` etc).

Note: Simply invoking `.PAGINATION OFF` or `.PAGINATE OFF` disables table of contents pagination for the first page of the table of contents only. You must use `.PAGINATE_TOC OFF` to disable table of contents pagination completely, even if pagination is turned off elsewhere in your document.

See PAGENUM_STYLE for an explanation of the arguments.

By default, mom uses roman numerals to number table of contents pages. Use TOC_PAGENUM_STYLE if you’d prefer something else. For example, to have standard digits instead of roman numerals, do the following:
.TOC_PAGENUM_STYLE DIGIT

#### 3. Changing the table of contents header (title) string and style

The table of contents header string is the title that appears at to top of the table of contents. By default, it’s “Contents”.

If you’d like the title of the table of contents to read something other than “Contents”, do, for example
.TOC_HEADER_STRING "Table of Contents"

##### Table of contents header string (title) control macros and defaults

See Arguments to the control macros.

.TOC_HEADER_FAMILY default = prevailing doc family .TOC_HEADER_FONT default = bold .TOC_HEADER_SIZE default = +4 .TOC_HEADER_QUAD default = left

#### 4. Changing the style of table of contents entries and page number references

“Entries” refers to titles in collated documents (TITLE) , heads (HEAD), subheads (SUBHEAD), and paragraph heads (PARAHEAD) as they appear in the table of contents. Their style is managed by the usual control macros, which take the form `TOC_<ELEMENT>_<SPEC>` (e.g. `TOC_HEAD_FAMILY` or `TOC_SUBHEAD_INDENT`).

“Page number references” means the page numbers associated with entries. They take the form `TOC_PN_<SPEC>`.

The following is a list of the control macros for table of contents entries, along with their defaults.

#### 5. Additional table of contents control macros

The following four macros allow you to

- instruct mom to append author(s) to TITLE entries
- alter the wording of TITLE entries
- establish how many placeholders to leave for page number references
- switch table of contents page margins should they be incorrect for recto/verso printing

In certain kinds of collated documents, different authors are responsible for the articles or stories contained within them. In such documents, you may wish to have the author or authors appended to the table of contents’ title entry for each story or article.

If you invoke `.TOC_APPENDS_AUTHOR` without an argument, mom appends the first argument you passed to AUTHOR to table of contents title entries, separated by a front-slash.

If you invoke `.TOC_APPENDS_AUTHOR` with an argument (surrounded by double-quotes), mom will append it to the table of contents title entries instead. This is useful if you have multiple authors you wish to identify by last name only. For example, if three authors—Joe Blough, Jane Doe, and John Deere—are responsible for a single article
.TOC_APPENDS_AUTHOR "Blough et al." would be a good way to identify them in the table of contents.

In collated documents, the title of each chapter appears in the table of contents. It may sometimes happen that you don’t want the title as it appears in the table of contents to be the same as what appears in the docheader. You might, for example, want to shorten it. Or, in the case of chapters where the docheader contains both a chapter number and a chapter title, like this
Chapter 6 Burning Bush — Maybe God Was Right you might want only the chapter title, not the chapter number, to show up in the table of contents. (By default, `.TOC` generates both.)

If you want to change the wording of a title entry in the table of contents, simply invoke
.TOC_TITLE_ENTRY with the desired wording, enclosed in double-quotes. Using the example, above,
.CHAPTER 6 .CHAPTER_TITLE "Burning Bush — Maybe God Was Right" .TOC_TITLE_ENTRY "Burning Bush" .DOCTYPE CHAPTER would identify chapter 6 in the table of contents simply as “Burning Bush”.

By default, mom allows room for 3 digits in the page number references of table of contents entries. If you’d like some other number of placeholders, say 2 (if your document runs to less than 100 pages), do
.TOC_PADDING 2

TOC_RV_SWITCH doesn’t take an argument. It simply instructs mom to switch the left and right margins of recto/verso documents should the table of contents happen to begin on an even page when you want an odd, or vice versa.

The same result can be accomplished by outputting a BLANKPAGE.

Back to Table of Contents | Top | Next: Bibliographies and references