4. Table of contents

When converting man documents, troff2page automatically generates an untitled table of contents (toc) at the top of the output. Toc entries are generated for each .SH in the input. The toc entry for a section and that section’s header are hyperlinks to each other.

For ms documents, you will need to generate your own table of contents. url.tmac supplies the macro .TAG for capturing page numbers. (This overrides the .TAG macro of groff’s www.tmac, in order to allow forward references.)

    .TAG sec:troffcl

associates the label sec:troffcl with the number of the current page. The string \*[sec:troffcl] is defined to typeset as that page number. Thus, in your hand-crafted toc, you could use

    Extending troff using Common Lisp, \*[sec:troffcl]

In the HTML output, the string \*[sec:troffcl] furthermore is a link to where .TAG sec:troffcl was called.

.TAG takes an optional second argument. The label is then associated with the text of the second argument instead of the current page number.