[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] moving TOC to start

From: Tadziu Hoffmann
Subject: Re: [Groff] moving TOC to start
Date: Wed, 5 Oct 2005 15:24:10 +0200
User-agent: Mutt/1.5.6i

> > Here is a toy model of a much better approach.  [...]
> > 
> > (Note also that the technique is not really new -- LaTeX
> > has been using an analogous approach for a *long* time.)
> Indeed.  It would be great if you can volunteer to
> add something like this to the ms macros.

Here is a simple replacement for the toc module in ms.
Not being an ms user myself, however, I suggest that
someone with more experience in ms (and more likely to
be able to test the macros in typical ms documents) do
the fine-tuning.


  * The distinction between TC and PX becomes obsolete.
    The TOC can be placed anywhere in the file (even
    somewhere in the middle).

  * XA has apparently been defined to accept a second
    argument.  However, XS, which is defined in terms
    of XA, does not pass a second argument to XA.
    I assume this second argument is an undocumented
    experimental feature (used for indenting the
    TOC entries in manually generated TOCs).

  * What's not solved satisfactorily is the support for
    eqn material in TOC entries.  This is because the
    font resetting strings being defined by eqn should
    be evaluated at "format"-time, not at "save"-time,
    which suggests saving TOC entries in "escape-off"
    mode.  However, that would disable inclusion of
    section numbers in TOC entries using \*(SN.
    Since section numbers are probably used in TOC
    entries more often than inline equations, I've
    left escapes on.  If necessary the font must be
    reset manually when using eqn in TOC entries.
    It would be preferable to insert section numbers
    automatically, but I guess that could break
    existing ms documents.

---- Cut here (with a very sharp editor) ----
.\" ****************************
.\" ******** module toc ********
.\" ****************************
.\" Table of contents generation.
.nr toc*done 0
.nr toc*flag 0
.de toc*save
.de @XS
.nr toc*flag 1
.ie \\n[.$] \{\
.        ie '\\$1'no' .ds toc*num
.        el .ds toc*num "\\$1
.el .ds toc*num \\n[PN]
.ie \\n[toc*done] .write toc*file .XA \\*[toc*num]
.el \{\
.am toc*save
.XA \\*[toc*num]
.de toc*tmp XE
.de @XA
.if !\\n[toc*flag] address@hidden XA without XS
.nr toc*flag 0
.de XE
.ie !\\n[toc*flag] address@hidden XE without XS
.el address@hidden
.nr toc*flag 0
.de @XE
.ie \\n[toc*done] .writem toc*file toc*tmp
.el \{\
.chop toc*tmp
.am toc*save
.als XA @XA
.de @XA1
.if '\\n(.z'toc*div' .toc*end-entry
.ie \\n[.$] .ds toc*num "\\$1
.el .rm toc*num
.di toc*div
.ta (u;\\n[.l]-\\n[.i]-\w'000') (u;\\n[.l]-\\n[.i])R
.ll -8n
.in (n;0\\$2)
.de toc*end-entry
.if d toc*num \\a\\t\\*[toc*num]
.ne \\n(dnu
.in 0
.rm toc*num
.de PX
.\" .1C
.if !'\\$1'no' \{\
.       ce 1
.       ie (\\n[PS] >= 1000) \
.               ps ((\\n[PS]z / 1000u) + 2z)
.       el \
.               ps \\n[PS]+2
.       ft B
.sp 2v
.sp 1v
.       ft
.       ps
.char \[toc*leader-char] .\h'1m'
.lc \[toc*leader-char]
.als XA @XA1
.if '\\n(.z'toc*div' .toc*end-entry
.so groff.toc
.if '\\n(.z'toc*div' .toc*end-entry
.als XA @XA
.nr toc*done 1
.open toc*file groff.toc
.sp 1v
.de TC
.PX \\$1
---- Cut here (with a very sharp editor) ----

reply via email to

[Prev in Thread] Current Thread [Next in Thread]