[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] ms macro - depth of table of contents
From: |
Keith MARSHALL |
Subject: |
Re: [Groff] ms macro - depth of table of contents |
Date: |
Wed, 23 Feb 2005 10:00:45 +0000 |
Ruediger Haertel wrote:
> is there a way to restrict the tables of content (.TC) to a depth?
> Haven't found anything in s.tmac.
.TC will emit *everything* you tell it to, as a consequence of your
use of .XA or .XS/.XE macros, in your document body. Once this
content is defined, there is no way to selectively suppress parts
of it, within .TC
However, you *can* be selective, at the time you define the TOC
entries, by using .if requests in association with a register, which
you can define on the command line, when you invoke groff.
For example, if your document body contains something like ...
.if !rTCDEPTH .nr TCDEPTH 0 \" avoid warnings if undefined
.
.
.XS
Table of contents entry -- always printed
.XE
.
.
.if \n[TCDEPTH]>=3 \{\
. XS
Table of contents entry -- not printed if \en[TCDEPTH] < 3
. XE
. \}
.
.
.TC
Then, if you invoke groff as ...
groff -ms ...
the table of contents, generated by .TC, will include only the first
of the two .XS/.XE entries, but ...
groff -ms -rTCDEPTH=3 ...
will cause it to include both.
Have a look in the `Macro Packages/ms/ms Page Layout/ms TOC' section
of `info groff', for more on the .TC related macros. You could also
look at spdf.tmac, in the `contrib/pdfmark' directory of the current
groff CVS, for a fairly crude example of how I have tied TOC entries
to section headings, with formatting based on heading levels -- see
the definition of the XN macro.
HTH.
Best regards,
Keith.