..
$Id: m.tmac,v 2.26 2005/05/26 06:28:38 wl Exp $
.@revision $Revision: 2.26 $ Copyright (C) 1991-2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. mgm is written by J�rgen H�gg <jh@axis.com> mgm is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. mgm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with groff; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. Please send bugreports with examples to jh@axis.com. Naming convention stolen from mgs. Local names module*name Extern names module@name Env.var environ:name Index array!index .. .do if d PH .nx .mso devtag.tmac ######## init #######
Contents level [0:14], contents saved if heading level <= Cl
.nr Cl 2 Eject page between LIST OF XXXX if Cp == 0
.nr Cp 0 Debugflag
Eject after floating display is output [0:1]
.nr De 0 Floating keep output [0;5]
.nr Df 5 space before and after display if == 1 [0:1]
.nr Ds 1 Eject page
.nr Ej 0 Equation label adjust 0=left, 1=right
.nr Eq 0 Em dash string
Footnote spacing
.nr Fs 1 H1-H7 heading counters
.nr H1 0 1 .nr H2 0 1 .nr H3 0 1 .nr H4 0 1 .nr H5 0 1 .nr H6 0 1 .nr H7 0 1 .nr H8 0 1 .nr H9 0 1 .nr H10 0 1 .nr H11 0 1 .nr H12 0 1 .nr H13 0 1 .nr H14 0 1 Heading break level [0:14]
.nr Hb 2 heading centering level, [0:14]
.nr Hc 0 header format
heading temp. indent [0:2]
0 -> 0 indent, left margin
1 -> indent to right , like .P 1
2 -> indent to line up with text part of preceding heading
.nr Hi 1 header pointsize
heading space level [0:14]
.nr Hs 2 heading numbering type
0 -> multiple (1.1.1 ...)
1 -> single
.nr Ht 0 Unnumbered heading level
.nr Hu 2 hyphenation in body
0 -> no hyphenation
1 -> hyphenation 14 on
.nr Hy 0 text for toc, selfexplanatory. Look in the new variable section
.nr Lf 1 .nr Lt 1 .nr Lx 1 .nr Le 0 List indent, used by .AL
.nr Li 6 List space, if listlevel > Ls then no spacing will occur around lists.
.nr Ls 99 Numbering style [0:5]
numbered paragraphs
0 == not numbered
1 == numbered in first level headings.
.nr Np 0 Format of figure,table,exhibit,equation titles.
0= ". ", 1=" - "
.nr Of 0 Table of contents page numbering style
.nr Oc 0 Page-number, normally same as %.
.nr P 0 paragraph indent
.nr Pi 5 paragraph spacing
.nr Ps 1 paragraph type
0 == left-justified
1 == indented .P
2 == indented .P except after .H, .DE or .LE.
.nr Pt 0 Reference title
Display indent
.nr Si 5
Current state of TOC, empty outside TC, inside
it will be set to co,fg,tb,ec,ex or ap.


---------------------------------------------
Internal global variables

This is for cover macro .MT
.ds @language

.nr @copy_type 0 >0 if Subject/Date/From should be bold, roman otherwise
. ls 2 . nr Pi 10 . nr Pt 1 .\}

. ie \n[E] .ds @sdf_font B . el .ds @sdf_font R .\}
Current pointsize and vertical space, always in points.
.vs \n[S]+2
.nr @ps \n[.ps] .nr @vs \n[.v]
Page length
. ie n .pl \n[L]u . el .pl \n[L]u .\} .nr @pl \n[.p]
page width
. ie n .ll \n[W]u . el .ll \n[W]u .\} .nr @ll \n[.l] .nr @cur-ll \n[@ll] .lt \n[@ll]u
page offset
. ie n .po .75i . el .po .963i .\}
.nr @po \n[.o]
non-zero if escape mechanism is turned off. Used by VERBON/OFF
.nr @verbose-flag 0 ---------------------------------------------
New variables

Appendix name
print appendixheader, 0 == don't
.nr Aph 1
Current appendix text
Controls the space before and after static displays if defined.
Lsp is used otherwise
.nr Dsp 1v

Add a dot after level one heading number if >0
.nr H1dot 1
header prespace level. If level <= Hps, then two lines will be printed
before the header instead of one.
.nr Hps 1
These variables controls the number of lines preceding .H.
Hps1 is the number of lines when level > Hps
.nr Hps1 0.5v
Hps2 is the number of lines when level <= Hps
.nr Hps2 1v
Hss is the number of lines (Lsp) after the header.
.nr Hss 1
H1txt will be updated by .H and .HU, containing the heading text.
Will also be updated in table of contents & friends


header text for the index
command to sort the index

flag for mkindex
Change these in the national configuration file
Flag for space between mark and prefix 1==space, 0==no space
Can also be controlled by using '.LI mark 2'
.nr Limsp 1
Lsp controls the height of an empty line. Normally 0.5v
Normally used for nroff compatibility.
.nr Lsp 0.5v for GETR

header- and footer-size will only change to the current
if Pgps is > 0.
.nr Pgps 1
section-page if Sectp > 0
.nr Sectp 0 . nr Sectp 1 . nr Ej 1 .\} section-figure if Sectf > 0
.nr Sectf 0
argument to .nm in .VERBON.
indent for VERBON
.nr Verbin 5n
Letter section
Formal closing (.FC)

Approval line
Approval date-string


Copy to (.NS)

Text printed below the footer. Controlled by @copy_type (C).
Max lines in return address
.nr Letwam 14 --------------------------
test for mgm macro. This can be used if the text must test
what macros is used.
.nr .mgm 1
Due to security problems with groff I had to rewrite
the reference system. It's not as elegant as before, you
have to run groff with '-z -rRef=1' and put stderr into the filename
for .INITR

Output references to stderr if non-zero
. nr Ref 0 .\}
---------------------------------------------
set local variables.
---------------------------------------------
####### module init ######
reset all things
'in 0 'ti 0 .vs \\n[@vs]u .. 'tm WARNING:(\\n[.F]) input line \\n[.c]:\\$* .. 'tm ****************** 'tm ERROR:(\\n[.F]) input line \\n[.c]:\\$* 'tm ****************** .ab "Input aborted, syntax error" .. .tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ

\\$1 .tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz

.. ####### module debug #################################
'tm \\$1:\\n[.F]:\\n[c.] ll=\\n[.l] vs=\\n[.v] ps=\\n[.s],\\n[.ps] \ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%] .. .nr debug*n 1n .nr debug*m 1m 'tm \\$1:\\n[.F]:\\n[c.] ll=\\n[.l] vs=\\n[.v] ps=\\n[.s] in=\\n[.i]\ ad=\\n[.j] fi=\\n[.u] pl=\\n[.p] page=\\n[%] .o=\\n[.o] 'tm _______ .d=\\n[.d] .f=\\n[.f] .h=\\n[.h] .k=\\n[.k] .n=\\n[.n]\ .p=\\n[.p] .t=\\n[.t] .z=\\n[.z] nl=\\n[nl] dn=\\n[dn] n=\\n[debug*n] .. ####### module par #################################
.nr par@ind-flag 1 \" indent on following P if Pt=2 .nr hd*last-pos -1 .nr hd*last-hsize -1 .nr par*number 0 1 .af par*number 01 .nr par*number2 0 1 .af par*number2 01 .nr par*num-count 0 1 .af par*num-count 01 reset numbered paragraphs, arg1 = headerlevel
.. ------------
paragraph
skip P if previous heading
. tm Paragraph nl=\\n[nl], last=\\n[hd*last-pos] . tm Paragraph .k=\\n[.k], hsize=\\n[hd*last-hsize] .\} . if \\n[D]>2 .tm Paragraph set ind-flag=1 . nr par@ind-flag 1 .\} any collected unprinted text?
.par@doit \\$* .. ------------
skip P if previous heading
. tm Paragraph nl=\\n[nl], last=\\n[hd*last-pos] . tm Paragraph .k=\\n[.k], hsize=\\n[hd*last-hsize] .\} . if \\n[D]>2 .tm Paragraph set ind-flag=1 . nr par@ind-flag 1 .\} .par@doit \\$* \\n[H2].\\n+[par*number2] \c .nr par@ind-flag 1 .. ------------

(u;\\n[Ps]*\\n[Lsp]) . if \\$1=1 .ti +\\n[Pi]n .\} . if \\n[Pt]=1 .ti +\\n[Pi]n . if (\\n[Pt]=2)&\\n[par@ind-flag] .ti +\\n[Pi]n .\} .. ####### module line #######################################


. \" go here if no output since the last .SP . nr line*output \\n[line*temp]-\\n[line*ac\\n[.z]] . if \\n[line*output]<0 .nr line*output 0 . nr line*ac\\n[.z] +\\n[line*output] .\} . nr line*ac\\n[.z] \\n[line*temp] . nr line*output \\n[line*temp] . \" no extra space in the beginning of a page . if (\\n[.d]<0):(\\n[pg*head-mark]=\\n[.d]) .nr line*output 0 .\} .nr line*lp\\n[.z] \\n[.d] .. ######## module misc ###############
.nr misc@adjust 14 . if \\$1-1 .@error "SA: bad arg: \\$1" . nr misc@adjust 0\\$1 .\} .. -------------
switch environment, keep all important settings.
.nr misc*ll \\n[.l] .ev \\$1 .lt \\n[misc*ll]u .. -------------
.misc@push stackname value
.. -------------
.misc@pop stackname
value returned in the string misc*pop
.misc@pop-set misc*st-\\$1 \\*[misc*st-\\$1] .. -------------
.shift .shift .. -------------
.misc@pop-nr stackname varname
.misc@pop \\$1 .nr \\$2 \\*[misc*pop] .. -------------
.misc@pop-ds stackname varname
.misc@pop \\$1 .. -----------
reset tabs
.. -------------
.PGFORM linelength [ pagelength [ pageoffset [1]]]
Break here to avoid problems with new linesetting of the previous line.
Hope this doesn't break anything else :-)
Don't break if arg_4 is a '1'.
. ll \\$1 . nr @ll \\n[.l] . nr @cur-ll \\n[@ll] . lt \\n[@ll]u .\} . ll \\n[@ll]u . lt \\n[@ll]u .\}
. pl \\$2 . nr @pl \\n[.p] .\}
. po \\$3 . nr @po \\n[.o] .\} 'in 0 .pg@move-trap . tm Traps: . ptr .\} .. -------------
.MOVE y [[x] linelength]
move to line y, indent to x
move to Y-pos
calc linelength
. ie \\n[.$]>1 .nr pg*i (n;\\n[@ll]u-\\$2) . el .nr pg*i \\n[@ll]u .\} move to X-pos, if any
set linelength
.. -------------
.. -------------
.nr misc*S-ps \n[@ps] .nr misc*S-vs \n[@vs] .nr misc*S-ps1 \n[@ps] .nr misc*S-vs1 \n[@vs] . ds misc*a P . ds misc*b P .\} . ie \\n[.$]=1 .ds misc*b D . el \{\ . ie \w@\\$2@=0 .ds misc*b C . el .ds misc*b \\$2 . \} . ie \w@\\$1@=0 .ds misc*a C . el .ds misc*a \\$1 .\}
set point size
. ie '\\*[misc*a]'P' .ps \\n[misc*S-ps]u . el \{\ . ie '\\*[misc*a]'D' .ps \\n[S] . el .ps \\*[misc*a] . if \\n[D]>2 .tm S: .ps \\*[misc*a] . \} .\}
set vertical spacing
. ie '\\*[misc*b]'P' .vs \\n[misc*S-vs]u . el \{\ . ie '\\*[misc*b]'D' .vs \\n[.ps]s+2p . el .vs \\*[misc*b] . if \\n[D]>2 .tm S: .vs \\*[misc*b] . \} .\} .nr @ps \\n[.ps] .nr @psu \\n[.ps]s .nr @vs \\n[.v] .nr @vsp \\n[.v]u/1p .nr @res 1i
. tmc "S(\\$*): ma:\\*[misc*a], mb:\\*[misc*b] . tm1 " => ps:\\n[.s]p (\\n[@psu]u), vs:\\n[@vsp]p (\\n[@vs]u) (res:\\n[@res]) .\} .nr misc*S-ps \\n[misc*S-ps1] .nr misc*S-vs \\n[misc*S-vs1] .nr misc*S-ps1 \\n[@ps] .nr misc*S-vs1 \\n[@vs] .pg@move-trap .. ------------
.ev 0 .hc \\$1 .ev .ev 1 .hc \\$1 .ev .ev 2 .hc \\$1 .ev .. ------------
.di misc*rd 'fl .rd \\$1\t

.di . di misc*rd2 . ds \\$3 "\\*[misc*rd] . br . di .\} .. ------------
VERBON [flag [pointsize [font]]]
flag
bit function
0 escape on
1 add an empty line before verbose text
2 add an empty line after verbose text
3 numbered lines (controlled by the string Verbnm)
4 indent text by the numbervariable Verbin.

.nr misc*verb 0\\$1 .misc@ev-keep misc*verb-ev

. ss \\$2
. ps \\$2
. vs \\$2
.\}
. eo
. nr @verbose-flag 1 \" tell pageheader to set ec/eo
.\}
..
.ec

.ev .nr @verbose-flag 0 .. ######## module pict #################
.nr pict*width 0 .nr pict*height 0 .nr pict*mode 0 .nr pict*ind 0 .nr pict*id 0 1 I assume that the number variable pict*id is the same
between two runs.

.nr pict*ind 0 .nr pict*box 0 .while \\n[.$]>0 \{\ . if '-B'\\$1' \{\ . nr pict*box 1 . shift . continue . \} . if '-L'\\$1' \{\ . nr pict*mode 0 . shift . continue . \} . if '-R'\\$1' \{\ . nr pict*mode 1 . shift . continue . \} . if '-I'\\$1' \{\ . nr pict*ind (m;\\$2) . nr pict*mode 2 . shift 2 . continue . \} . if '-C'\\$1' \{\ . nr pict*mode 3 . shift . continue . \} . ds pict*f \\$1 . nr pict*id +1 . shift . if \\n[.$]>0 \{\ . nr pict*width (i;\\$1) . shift . \} . if \\n[.$]>0 \{\ . nr pict*height (i;\\$1) . shift . \} .\} let mmroff know the filename and id
. tm .\\\\" PIC id \\n[pict*id] . tm .\\\\" PIC file \\*[pict*f] .\} these are defined by mmroff in the second pass
. ds pict*f \\*[pict*file!\\n[pict*id]] . nr pict*llx \\n[pict*llx!\\n[pict*id]] . nr pict*lly \\n[pict*lly!\\n[pict*id]] . nr pict*urx \\n[pict*urx!\\n[pict*id]] . nr pict*ury \\n[pict*ury!\\n[pict*id]] . \" . nr pict*w (p;\\n[pict*urx]-\\n[pict*llx]) . if \\n[pict*w]<0 .nr pict*w 0-\\n[pict*w] . nr pict*h (p;\\n[pict*ury]-\\n[pict*lly]) . if \\n[pict*h]<0 .nr pict*h 0-\\n[pict*h] . if \\n[pict*width]>0 \{\ . nr pict*rs (u;1000*\\n[pict*width]/\\n[pict*w]) . nr pict*w (u;\\n[pict*w]*\\n[pict*rs]/1000) . nr pict*h (u;\\n[pict*h]*\\n[pict*rs]/1000) . \} . if \\n[pict*height]>0 \{\ . nr pict*rs (u;1000*\\n[pict*height]/\\n[pict*h]) . nr pict*h (u;\\n[pict*h]*\\n[pict*rs]/1000) . \} . if '0'\\n[pict*mode]' \{\ . nr pict*in \\n[.i]u . \} . if '1'\\n[pict*mode]' \{\ . nr pict*in (u;\\n[.l]-\\n[.i]-\\n[pict*w]) . \} . if '2'\\n[pict*mode]' \{\ . nr pict*in \\n[pict*ind]u . \} . if '3'\\n[pict*mode]' \{\ . nr pict*in (u;(\\n[.l]-\\n[.i]-\\n[pict*w])/2) . \} . ds pict*h " . if \\n[pict*h]>0 .ds pict*h \\n[pict*h] . \" . ne \\n[pict*h]u-1v . \" . \" these lines are copied and modified from tmac.pspic. . \" Originally written by James Clark . br . ie \\n[pict*box]>0 \{\ \v'-1v'\h'\\n[pict*in]u'\ \Z'\D'p 0 \\n[pict*h]u \\n[pict*w]u 0 0 -\\n[pict*h]u''\ \v'\\n[pict*h]u'\X'ps: import \\*[pict*f] \ \\n[pict*llx] \\n[pict*lly] \ \\n[pict*urx] \\n[pict*ury] \ \\n[pict*w] \\n[pict*h]' .\} . el \{\ \v'-1v'\h'\\n[pict*in]u'\ \X'ps: invis'\ \Z'\D'p 0 \\n[pict*h]u \\n[pict*w]u 0 0 -\\n[pict*h]u''\ \X'ps: endinvis'\ \v'\\n[pict*h]u'\X'ps: import \\*[pict*f] \ \\n[pict*llx] \\n[pict*lly] \ \\n[pict*urx] \\n[pict*ury] \ \\n[pict*w] \\n[pict*h]' . \} . br . sp \\n[pict*h]u-1v .\} .. external picture
-L left adjust
.nr pict*adj 0 \" centered . shift 1 \" left adjust . nr pict*adj 1 .\} .nr pict*w \\$1 .nr pict*h \\$2 .nr pict*ind 0

\D'l \\n[pict*w]u 0'\ \D'l 0 -\\n[pict*h]u'\ \D'l -\\n[pict*w]u 0'\ \D'l 0 \\n[pict*h]u'\ \v'-(u;\\n[pict*h]/2)'\ \h'(u;(\\n[pict*w]-\w'\\*[pict*name]'/2))'\\*[pict*name] .. ######## module acc #################
-----------
accents. These are copied from mgs, written by James Clark.
\h'(u;-\En[skw]+(-\En[.w]-\w'\\$2'/2)+\En[.csk])'\\$2' .. .. .acc@over-def ` \` .acc@over-def ' \' .acc@over-def ^ ^ .acc@over-def ~ ~ .acc@over-def : \(ad .acc@over-def ; \(ad .acc@under-def , \(ac ######## module uni #################
unimplemented macros
'tm "OK: not implemented" .. 'tm "PM: not implemented" .. ######## module hd #################
support for usermacro
.nr hd*h1-page 1 \" last page-number for level 1 header. .nr hd*htype 0 .nr hd*need 0 .aln ;0 hd*htype .als }0 hd*mark .als }2 hd*suf-space .aln ;3 hd*need -------------
.hd@split varable index name val1 val2 ...
.nr hd*sp-tmp \\$2+3 .. .H 0 "\\$1" .. -------------

.df@print-float 2\" $$$ could be wrong... terminate all lists
.LC .nr hd*level 0\\$1 .nr hd*arg1 0\\$1
clear lower counters
.nr hd*i 1 1 .while \\n+[hd*i]<15 .if \\n[hd*level]<\\n[hd*i] .nr H\\n[hd*i] 0 1
save last text for use in TP

This is a little fix to be able to get correct H1 heading number
in page headers. Special attention was needed when other formats are used.
. ds hd*format \\g[H1] . af H1 0 . nr H1h \\n[H1] 1 . af H1 \\*[hd*format] .\}
Check if it's time for new page. Only if text has
appeared before.

increment current counter
.nr H\\n[hd*level] +1
update pagenumber if section-page is used

hd*mark is the text written to the left of the header.


.nr hd*i 2 1 .while \\n+[hd*i]<15 .if \\n[hd*level]>(\\n[hd*i]-1) .as hd*mark .\\n[H\\n[hd*i]]
special case, no dot after level one heading if not H1dot true

.as hd*mark \" add spaces between mark and heading
.nr hd*htype 0 \" hd*htype = check break and space . \" 0 = run-in, 1 = break only, 2 = space . \" two spaces if hd*htype == 0 .nr hd*need 2v \" hd*need = header need space ---------- user macro HX ------------
User exit macro to override numbering.
May change hd*mark (}0), hd*suf-space (}2) and hd*need (;3)
Can also change Hps1/2.
--------------------------------------
pre-space

.par@reset-num \\n[hd*level]\" reset numbered paragraph start diversion to measure size of header
.di hd*div \\*[hd*mark]\\$2\\$3\\*[hd*suf-space]

.di
size and font calculations
.hd@split hd*font \\n[hd*level] HF \\*[HF]\" get font for this level .hd@split hd*new-ps \\n[hd*level] HP \\*[HP]\" get point size . if \\n[hd*htype] \{\ . if '\\*[hd*font]'3' \{\ . ps -1 . vs -1 . \} . if '\\*[hd*font]'B' \{\ . ps -1 . vs -1 . \} . \} .\} . ps \\*[hd*new-ps] . vs \\*[hd*new-ps]+2 .\}
---------- user macro HY -------------
user macro to reset indents
VTAG-NH \\n[hd*level] \" HTML: mark beginning of heading --------------------------------------
.nr hd*mark-size \w@\\*[hd*mark]@
finally, output the header
\\*[hd*mark]\c and the rest of the header
\\$2\\$3 . br .\} restore pointsize and vertical size.
.vs \\n[@vs]u
table of contents
set adjust to previous value
.SA do break or space
. \" indent if Hi=1 and Pt=1 . if (\\n[Hi]=1)&(\\n[Pt]=1) .ti +\\n[Pi]n . \" indent size of mark if Hi=2 . if \\n[hd*htype]&(\\n[Hi]>1) .ti +\\n[hd*mark-size]u .\} .nr par@ind-flag 0 \" no indent on .P if Pt=2
check if it is time to reset footnotes

check if it is time to reset indexes
. nr lix*fg-nr 0 1 . nr lix*tb-nr 0 1 . nr lix*ec-nr 0 1 . nr lix*ex-nr 0 1 .\} ---------- user macro HZ ----------
.nr hd*last-pos \\n[nl] .nr hd*last-hsize \\n[.k] .nr par@ind-flag 0 VTAG-EO-H \" HTML: end of heading .. --------
.nr hd*i 0 1 .while \\n+[hd*i]<15 .af H\\n[hd*i] \\$[\\n[hd*i]] 1 .. ----------------------
set page-nr, called from header


Set section-page-string
.. ########### module pg ####################
set end of text trap
.wh 0 pg@header .em pg@end-of-text
. ds pg*header '''' . ds pg*footer ''\\*[hd*sect-pg]'' .\}
.nr pg*top-margin 0 .nr pg*foot-margin 0 .nr pg*block-size 0 .nr pg*footer-size 5v\" 1v+footer+even/odd footer+2v .nr pg*header-size 7v\" 3v+header+even/odd header+2v .nr pg*extra-footer-size 0 .nr pg*extra-header-size 0 .nr ft*note-size 0 .nr pg*cur-column 0 .nr pg*cols-per-page 1 .nr pg*cur-po \n[@po] .nr pg*head-mark 0
.nr pg*ps \n[@ps] .nr pg*vs \n[@vs] -------------------------
footer TRAPS: set, enable and disable
.nr pg*foot-trap \\n[@pl]u-(\\n[pg*block-size]u+\\n[ft*note-size]u+\\n[pg*foot-margin]u+\\n[pg*footer-size]u+\\n[pg*extra-footer-size]u)

last-pos points to the position of the footer and bottom
block below foot-notes.
.nr pg*last-pos \\n[@pl]u-(\\n[pg*block-size]u+\\n[pg*foot-margin]u+\\n[pg*footer-size]u+\\n[pg*extra-footer-size]u) .. Disable in HTML mode
.wh \\n[pg*foot-trap]u pg@footer .\} .. .ch pg@footer .. move to new trap (if changed).
.pg@disable-trap .pg@set-new-trap .pg@enable-trap .. set trap for pageheader.
.nr pg*top-enabled 1 .. remove trap for pageheader.
.nr pg*top-enabled 0 .. no header on the next page
.nr pg*top-enabled (-1) .. set first trap for pagefooter
.pg@enable-top-trap .pg@set-new-trap .pg@enable-trap -------------------------
stop output and begin on next page. Fix footnotes and all that.
.debug next-page
.pg@footer
.. -------------------------
support for PX, TP and EOP.
.als }t pg*header .als }e pg*even-header .als }o pg*odd-header .als TPh pg*header .als TPeh pg*even-header .als TPoh pg*odd-header
.als EOPf pg*footer .als EOPef pg*even-footer .als EOPof pg*odd-footer ------------------------------------------------------------
HEADER
Disable in HTML mode
check if Hy has been changed
.tl '<pagenr \\n[%]>''' .\} assign current page-number to P
.hd@set-page reset spacing
.nr line*lp\\n[.z] 0 .nr line*ac\\n[.z] 0
suppress pageheader if pagenumber == 1 and N == [124]
must be fixed!!
. pg@disable-top-trap
. if \\n[pg*extra-header-size] 'sp \\n[pg*extra-header-size]u . if \\n[pg*top-margin] 'sp \\n[pg*top-margin]u . ev pg*tl-ev . pg@set-env . ie d let@header .let@header . el \{\ . ie d TP .TP . el \{\ ' sp 3 . ie ((\\n[%]=1)&((\\n[N]=1):(\\n[N]=2))) .sp . el .tl \\*[pg*header] . ie o .tl \\*[pg*odd-header] . el .tl \\*[pg*even-header] ' sp 2 . \} . \} . ev . \" why no-space?? . if d PX \{\ . ns . PX . rs . \} . \" check for pending footnotes . ft@check-old . \" . \" back to normal text processing . pg@enable-trap . \" mark for multicolumn . nr pg*head-mark \\n[nl]u . \" reset NCOL pointer at each new page. . nr pg*last-ncol 0 . \" set multicolumn . \" . pg@set-po . \" print floating displays . df@print-float 4 . tbl@top-hook . ns .\} .nr hd*cur-bline \\n[nl] \" .H needs to know if output has occured .\} .. ---------------------------------------------------------
FOOTER
.ec .pg@disable-trap .debug footer
.tbl@bottom-hook increment pageoffset for MC
move to the exact start of footer.
'sp |\\n[pg*foot-trap]u+1v
print footnotes

.pg@inc-po next column
.pg@set-po .pg@enable-trap .. -------------------------
jump to the position just below the foot-notes.
'sp |\\n[pg*last-pos]u+1v check if there are any bottom block

print the footer and eject new page
.ev pg*tl-ev .pg@set-env user defined end-of-page macro
. ie o .tl \\*[pg*odd-footer] . el .tl \\*[pg*even-footer] . ie (\\n[%]=1)&(\\n[N]=1) .tl \\*[pg*header] . el .tl \\*[pg*footer] . tl ''\\*[Pg_type!\\n[@copy_type]]'' .\} .ev be sure that floating displays and footnotes will be
printed at the end of the document.
. ev ne ' bp . ev .\} .. -------------------------

Initialize the title environment
'na 'nh 'in 0 'ti 0 . ps \\n[@ps]u . vs \\n[@vs]u .\} . ps \\n[pg*ps]u . vs \\n[pg*vs]u .\} .lt \\n[@ll]u .. -------------------------
.pg@set-new-size .. .pg@set-new-size .. .pg@set-new-size .. .pg@set-new-size .. .pg@set-new-size .. .pg@set-new-size .. .. .. .nr pg*ps \\n[@ps] .nr pg*vs \\n[@vs] .pg@move-trap .. -------------------------
end of page processing
.debug footnotes
output footnotes. set trap for block

.. -------------------------
print bottom block
.ev pg*block-ev 'nf 'in 0 .pg*block-div

.ev .. -------------------------
define bottom block
.misc@ev-keep pg*block-ev

.di pg*block-div .. -------------------------

.di .nr pg*block-size \\n[dn]u .ev .pg@move-trap .. -------------------------
print out all pending text
.df@eot-print .ref@eot-print .. -------------------------
set top and bottom margins
-T sets pg*footer-size and pg*header-size instead
. shift . if \\n[.$]=0 \{\ . nr pg*footer-size 5v . nr pg*header-size 7v . \} . if \\n[.$]>0 .nr pg*header-size (v;\\$1) . if \\n[.$]>1 .nr pg*footer-size (v;\\$2) .\} . if \\n[.$]=0 \{\ . nr pg*extra-footer-size 0 . nr pg*extra-header-size 0 . \} . if \\n[.$]>0 .nr pg*extra-header-size (v;\\$1) . if \\n[.$]>1 .nr pg*extra-footer-size (v;\\$2) . if \\n[D]>2 \{\ . tm extra top \\n[pg*extra-footer-size] . tm extra bottom \\n[pg*extra-header-size] . \} .\} .pg@move-trap .. ---------------------
multicolumn output.
. ll \\n[pg*column-size]u .\} .. . ie \\n+[pg*cur-column]>=\\n[pg*cols-per-page] \{\ . nr pg*cur-column 0 1 . nr pg*cur-po \\n[@po]u . po \\n[@po]u . ll \\n[@ll]u . \} . el \{\ . nr pg*cur-po +(\\n[pg*column-size]u+\\n[pg*column-sep]u) . po \\n[pg*cur-po]u ' sp |\\n[pg*head-mark]u . tbl@top-hook . \} .\} .. An argument disables the page-break.

.nr pg*cols-per-page 1 .nr pg*column-sep 0 .nr pg*column-size \\n[@ll] .nr pg*ncol-i \\n[pg*cur-column]\" temp variable .nr pg*cur-column 0 1 .nr pg*cur-po \\n[@po]u

GFORM . if d ft*div \{\ . if \\n[pg*ncol-i]>0 \{\ . @warning 1C: footnotes will be messy . \} . \} . if \\n[pg*last-ncol]>0 \{\ . sp |\\n[pg*last-ncol]u . nr pg*last-ncol 0 . \} .\} ..

.nr pg*head-mark \\n[nl]u .nr pg*cols-per-page 2 .nr pg*column-sep \\n[@ll]/15 .nr pg*column-size (\\n[@ll]u*7)/15 .nr pg*cur-column 0 1 .nr pg*cur-po \\n[@po]u .lt \\n[pg*column-size]u
.. MC column-size [ column-separation ]

.nr pg*head-mark \\n[nl]u
calculate the number of columns/page
.nr pg*cols-per-page 0 .nr pg*i \\n[pg*column-size] .while \\n[pg*i]<=\\n[.l] \{\ . nr pg*cols-per-page \\n[pg*cols-per-page]+1 . nr pg*i \\n[pg*i]+\\n[pg*column-sep]+\\n[pg*column-size] .\} .nr pg*cur-column 0 1 .nr pg*cur-po \\n[@po]u .lt \\n[pg*column-size]u
.. begin a new column

.pg@footer .. skip pages

.bp .nr pg*i 0 1 force new page by writing something invisible.
.while \\n+[pg*i]<=(0\\$1) \{\ \& . bp .\} .. -------------------------------
MULB width1 space1 width2 space2 width3 space3 ...

.nr pg*i 0 1 .nr pg*mul-x 0 1 .nr pg*mul-ind 0 .nr pg*mul-last 0 .while \\n[.$] \{\ . nr pg*mul!\\n+[pg*i] (n;0\\$1) . nr pg*muls!\\n[pg*i] (n;0\\$2) . shift 2 .\} .nr pg*mul-max-col \\n[pg*i] .nr pg*mul-font \\n[.f] .ev pg*mul-ev .vs \\n[@vs]u .fam \\*[pg*mul-fam]

.di pg*mul-div .MULN .. -----------

.nr pg*mul-ind +(u;\\n[pg*mul!\\n[pg*mul-x]]+\\n[pg*muls!\\n[pg*mul-x]]) .. -----------
MULE

.di .ev

.pg*mul-div

.. -----------

. bp +1 . bp +1 .\} .. ########### module footnotes ###################
.nr ft*note-size 0 .nr ft*busy 0 .nr ft*nr 0 1 .nr ft*wide 0 .nr ft*hyphen 0\" hyphenation value .nr ft*adjust 1\" >0 if adjust true .nr ft*indent 1\" >0 if text indent true (not imp. $$$) .nr ft*just 0\" 0=left justification, 1=right (not imp. $$$) .nr ft*exist 0\" not zero if there are any footnotes to be printed .nr ft*clear-at-header 0\" >0 if footnotes should be reset at first level head.

-----------------
init footnote environment
indentcontrol not implemented $$$
label justification not implemented $$$
'in 0 'fi .lt \\n[@cur-ll]u .vs (p;\\n[@vs]u-1) .. -----------------
set footnote format
no support for two column processing (yet). $$$

. ie \\$1>11 .nr ft*format 0 . el .nr ft*format \\$1 . \" . nr ft*hyphen (\\n[ft*format]%2)*14 . nr ft*format \\n[ft*format]/2 . \" . nr ft*adjust 1-(\\n[ft*format]%2) . nr ft*format \\n[ft*format]/2 . \" . nr ft*indent 1-(\\n[ft*format]%2) . nr ft*format \\n[ft*format]/2 . \" . nr ft*just \\n[ft*format]%2 .\} .. ---------------
Footnote and display width control $$$
.nr ft*i 0 1 .while \\n+[ft*i]<=\\n[.$] \{\ . ds ft*x \\$[\\n[ft*i]] . if '\\*[ft*x]'N' \{\ . nr ft*wide 0 . nr ft*first-fn 0 . nr ds*wide 0 . nr ds*float-break 1 . \} . if '\\*[ft*x]'-WF' .nr ft*wide 0 . if '\\*[ft*x]'WF' .nr ft*wide 1 . if '\\*[ft*x]'-FF' .nr ft*first-fn 0 . if '\\*[ft*x]'FF' .nr ft*first-fn 1 . if '\\*[ft*x]'-WD' \{\ . nr ds*wide 0 . if r ft*df-save \{\ . nr Df \\n[ft*df-save] . rm ft*df-save . \} . \} . if '\\*[ft*x]'WD' \{\ . nr ds*wide 1 . nr ft*df-save \\n[Df] . nr Df 4 . \} . if '\\*[ft*x]'-FB' .nr ds*float-break 0 . if '\\*[ft*x]'FB' .nr ds*float-break 1 . if \\n[D]>1 .tm WC WF=\\n[ft*wide] WD=\\n[ds*wide] .\} .. -----------------
begin footnote
Change environment, switch to diversion and print the foot-note mark.
.nr ft*busy 1 .ev ft*ev .di ft*tmp-div .nr ft*space (u;\\n[Fs]*\\n[Lsp]) print mark
\\*[ft*mark] .nr ft*exist 1 .. -----------------
init footnote diversion
.di ft*div \l'20n'

.di .nr ft*note-size \\n[dn] .. -----------------
end footnote
End the diversion, back to previous environment, and adjust
the trap to the new foot-note size.
.nr ft*busy 0

.di 'in 0 'nf . da ft*next-div . ft*tmp-div . br . di .\} . if !d ft*div .ft@init-footnote . da ft*div . ft*tmp-div . di . nr ft*note-size +\\n[dn] .\} .ev .pg@move-trap .. -----------------
print footnotes, see pg@footer
.ev ft*print-ev 'nf 'in 0

.ev .nr ft*note-size 0 .pg@move-trap .. -----------------
check if any pending footnotes, see pg@header
. ev ft*ev . ft@init . ft@init-footnote . nf . in 0 . da ft*div . ft*next-div . di . nr ft*note-size +\\n[dn] . rm ft*next-div . ev . nr ft*exist 0 . pg@move-trap .\} .. ########### module display ###################
.nr ds*wide 0\" >0 if wide displays wanted .nr df*fnr 0 1\" floating display counter .nr df*o-fnr 1\" floating display counter, already printed .nr ds*snr 0 1\" static display counter .nr ds*lvl 0 1\" display level .nr ds*float-busy 0\" >0 if printing float .nr df*float 0 >0 if previous display was floating --------------------------------------------
.. --------------------------------------------
floating display start
nested DF/DE is not allowed.

.nr df*old-ll \\n[.l] .nr ds*ftmp \\n[.f] .misc@ev-keep df*ev
.di df*div 'in 0

\\n[Lsp]u .nr df*float 1 .. --------------------------------------------

\\n[Lsp]u .di .nr df*width!\\n+[df*fnr] \\n[dl] .nr df*height!\\n[df*fnr] \\n[dn] .nr df*wide!\\n[df*fnr] \\n[ds*wide] .nr df*format!\\n[df*fnr] \\n[ds*format] .ev form=\\n[ds*format] move div to the floating display list
.rn df*div df*fdiv!\\n[df*fnr]
.nr par@ind-flag 0 print float if queue is empty and the display fits into
the current page
.nr df*float 0 .. -------------
called by end-of-text

. if \\n[D]>2 .tm Print remaining displays. still some floats left, make non-empty environment
. misc@ev-keep ne . init@reset \c . df@print-float 3 . ev .\} .. ---------------
print according to Df and De.
.df@print-float type
type called from
1 .DE
2 end of section
3 end of document
4 beginning of new page

. nr ds*float-busy 1 at .DE
. if \\n[D]>3 .tm print-float: .t=\\n[.t], h=\\n[df*height!\\n[df*o-fnr]] . \" Df = 1 or 5 . if (\\$1=1)&((\\n[Df]=1):(\\n[Df]=5)) \{\ . if \\n[.t]>\\n[df*height!\\n[df*o-fnr]] \{\ . \" Print only new displays. . if \\n[df*o-fnr]=\\n[df*fnr] \{\ . br . ds@print-one-float . \} . \} . \} . \" Df = 3 . if (\\$1=1)&(\\n[Df]=3) \{\ . if \\n[.t]>\\n[df*height!\\n[df*o-fnr]] \{\ . br . ds@print-one-float . \} . \} print all if Df<2 and end of section
. if (\\$1=2)&(\\n[Sectp]>0)&(\\n[Df]<2) \{\ . br . ds@print-all-floats . \} print all if end of document. Where should they go instead?
. if \\$1=3 \{\ . br . ds@print-all-floats .\} new page
. if (\\$1=4)&(\\n[Df]>1) \{\ . if \\n[Df]=2 .ds@print-one-float . if \\n[Df]=3 .ds@print-one-float . if \\n[Df]>3 \{\ . ie \\n[De] .ds@print-all-floats . el .ds@print-this-page . \} . \} . nr ds*float-busy 0 .\} .. ---------------
DF out
print a floating diversion
.nr df*old-ll \\n[.l] .nr df*old-in \\n[.i] .ev ds*fev

.nr df*i \\n[df*o-fnr]
.nr df*f \\n[df*format!\\n[df*i]]



.df*fdiv!\\n[df*o-fnr]
.ev .nr df*o-fnr +1 .. ---------------
print one floating display if there is one.
. if \\n[D]>3 .tm print-one-float: .t=\\n[.t], h=\\n[df*height!\\n[df*o-fnr]] . if \\n[.t]<\\n[df*height!\\n[df*o-fnr]] .pg@next-page . ds@output-float . if \\n[De] .pg@next-page .\} .. ---------------
print all queued floats.
if De>0 do a page eject between the floats.
.while \\n[df*o-fnr]<=\\n[df*fnr] \{\ . if \\n[D]>3 .tm print-all-floats: .t=\\n[.t], h=\\n[df*height!\\n[df*o-fnr]] . if \\n[.t]<\\n[df*height!\\n[df*o-fnr]] .pg@next-page . br \c . ds@output-float . if \\n[De] .pg@next-page .\} .. ---------------
print as many floats as will fit on the current page
.while \\n[df*o-fnr]<=\\n[df*fnr] \{\ . if \\n[D]>3 .tm print-this-page: .t=\\n[.t], h=\\n[df*height!\\n[df*o-fnr]] . if \\n[.t]<\\n[df*height!\\n[df*o-fnr]] .break . ds@output-float .\} .. ---------------------------------------------------
get format of the display
. ie r ds*format!\\$1 .nr ds*format \\n[ds*format!\\$1] . el .@error "DS/DF:wrong format:\\$1" .\} fill or not to fill, that is the...
.nr ds*fill 0 . ie r ds*fill!\\$2 .nr ds*fill \\n[ds*fill!\\$2] . el .@error "\\*[ds*type]:wrong fill:\\$2" .\} .nr ds*rindent 0 .. -----------------------------
.ds@set-new-ev previous-line-length
.lt \\$1u . ll -\\n[ds*rindent]n . lt -\\n[ds*rindent]n .\} . ll \\n[@ll]u . lt \\n[@ll]u .\}
.. --------------------------------------------------------
.nr ds*format 0\" dummy value for .En/.EQ .nr ds*format! 0\" no indent .nr ds*format!0 0\" no indent .nr ds*format!L 0\" no indent .nr ds*format!I 1\" indent .nr ds*format!1 1\" indent .nr ds*format!C 2\" center each line .nr ds*format!2 2\" center each line .nr ds*format!CB 3\" center as block .nr ds*format!3 3\" center as block .nr ds*format!R 4\" right justify each line .nr ds*format!4 4\" right justify each line .nr ds*format!RB 5\" right justify as block .nr ds*format!5 5\" right justify as block ---------------
.nr ds*fill! 0\" no fill .nr ds*fill!N 0\" no fill .nr ds*fill!0 0\" no fill .nr ds*fill!F 1\" fill on .nr ds*fill!1 1\" fill on --------------------------------------------
static display start
nested DS/DE is allowed. No limit on depth.

.nr XXX \\n[nl] .nr ds*lvl +1
.nr ds*old-ll \\n[.l] .nr ds*old-in \\n[.i] .misc@push ds-ll \\n[.l] .misc@push ds-form \\n[ds*format] .nr ds*i \\n[.i] .nr ds*ftmp \\n[.f] .misc@ev-keep ds*ev!\\n+[ds*snr]
indent in a diversion doesn't seem like a good idea.
'in 0 .di ds*div!\\n[ds*snr]
.nr df*float 0 .. --------------------------------------------

.di **********
.nr ds*width \\n[dl] .nr ds*height \\n[dn] .misc@pop-nr ds-ll ds*old-ll .misc@pop-nr ds-form ds*format
**********
'nf calculate needed space
.nr ds*need \\n[ds*height] .nr ds*i \\n[pg*foot-trap]-\\n[pg*header-size]u-\\n[pg*extra-header-size]u Eject page if display will fit one page and
there are less than half of the page left.

check if pending equation label
.eq@check \\n[ds*need] 'in \\n[ds*old-in]u **********

Print static display
.nr ds*i \\n[Lsp]

.nr ds*snr -1 .nr par@ind-flag 0 .ev .. ########### module list ###################
.LI text-indent mark-indent pad type [mark [LI-space [LB-space] ] ]

.nr li*tind 0 .nr li*mind 0 .nr li*pad 0 .nr li*type 0 .nr li*li-spc 0 .nr li*lvl 0 1 .aln :g li*lvl .nr li*cur-vpos 0 --------------------------
the major list-begin macro.
If type == -1 a 'break' will occur.
.misc@push cind \\n[.i] .misc@push tind \\n[li*tind] .misc@push mind \\n[li*mind] .misc@push pad \\n[li*pad] .misc@push type \\n[li*type] .misc@push li-spc \\n[li*li-spc] .nr li*lvl +1
.nr li*tind (n;0\\$1)\" text-indent .nr li*mind (n;0\\$2)\" mark-indent .nr li*pad (n;0\\$3)\" pad .nr li*type 0\\$4\" type init listcounter
.nr li*cnt!\\n[li*lvl] 0 1 assign format
.af li*cnt!\\n[li*lvl] 1
.. ---------------

.nr li*cnt!\\n[li*lvl] +1 . ie (\\$2=2):(\\n[Limsp]=0) .ds li*c-mark \\$1\\*[li*c-mark] . el .ds li*c-mark \\$1 \\*[li*c-mark] .\}
determine where the text begins
.nr li*text-begin \\n[li*tind]>?\w@\\*[li*c-mark] @ .nr x \w@\\*[li*c-mark] @
determine where the mark begin

no indentation if hanging indent
\Z'\h'\\n[li*in]u'\\*[li*c-mark]'\h'\\n[li*text-begin]u'\c ..
-------------
.nr li*lvl -1 .misc@pop-nr cind li*tmp .misc@pop-nr tind li*tind .misc@pop-nr mind li*mind .misc@pop-nr pad li*pad .misc@pop-nr type li*type .misc@pop-nr li-spc li*li-spc .. .li@pop .. -------------
list status clear.
terminate all lists to level i
.while \\n[li*lvl]>\\n[li*i] .li@pop .nr par@ind-flag 0 .. -------------
. ie \\n[.$]=2 .LB 0\\$2 0 2 1 "\\$1" . el \{\ . ie !'\\$2'' .LB \\$2 0 2 1 "\\$1" 0 1 . el .LB \\n[Li] 0 2 1 "\\$1" 0 1 . \} .\} .. .nr li*ml-width \w@\\$1@u+1n . ie '\\$2'' .LB \\n[li*ml-width]u 0 1 0 "\\$1" 0 1 . el .LB \\n[Li] 0 1 0 "\\$1" 0 1 .\} .. .. Bullet (for .BL)
. ie '\\$1'' .LB \\n[Pi] 0 1 0 \\*[BU] 0 1 . el .LB 0\\$1 0 1 0 \\*[BU] 0 1 .\} .. . ie '\\$1'' .LB \\n[Pi] 0 1 0 \(em 0 1 . el .LB 0\\$1 0 1 0 \(em 0 1 .\} .. . ie '\\$1'' .LB 6 0 2 4 1 0 1 . el .LB 0\\$1 0 2 4 1 0 1 .\} .. Broken Variable List. As .VL but text begin on the next line
.. ####### module tbl #######################################
This module is copied from groff_ms and modified for mgm.
Yes, it does not resemble the original anymore :-).
Don't know if I missed something important.
Groff_ms is written by James Clark.
.nr tbl*have-header 0 .nr tbl*header-written 0

.. . ie \\n[.t]-\\n[tbl*header-ht]-1v .tbl@print-header . el .sp \\n[.t]u .\} .. . nr T. 1 draw bottom and side lines of boxed tables.
. T# .\} .nr tbl*header-written 0 .. .ev tbl*ev 'nf .tbl*header-div .ev

#T .nr tbl*header-written 1 .. . nr T. 0 . T# . br . di . nr tbl*header-ht \\n[dn] . ne \\n[dn]u+1v . nr tbl*have-header 1 . ie '\\$1'N' .if !\\n[tbl*header-written] .tbl@print-header . el .tbl@print-header .\} .. . nr tbl*have-header 0 .\} reset tabs
.TAB .. .. ####### module pic #######################################
.nr pic*in 0

.5 . if !\\n[ds*lvl] .ne (u;\\$1)+1v should be contained between .DS/.DE
. if \\n[ds*lvl]&((\\n[ds*format]=2):(\\n[ds*format]=3)) \{\ . nr pic*in \\n[.i] . in +(u;\\n[.l]-\\n[.i]-\\$2/2)
. \} . \} .\} ..

.5 .. ####### module eq #######################################

.nr eq*number 0 1 .. . mk . \" space down to middle of equation ' sp (u;\\$1/2) . ie (\\n[Eq]%2) \{\ . \" label to the left \h'|0'\\*[eq*label] . \} . el \{\ . \" label to the right \h'|\\n[.l]u'\\*[eq*label] . \} . rt .\} .. .. ########### module toc ###################
table of contents
.nr toc*slevel 1 .nr toc*spacing \n[Lsp]u .nr toc*tlevel 2 .nr toc*tab 0 -----------
Table of contents with friends (module lix)

print any pending displays and references
.df@print-float 3
.pg@clear-hd .EF "" .OF "" .pg@next-page -------------

. nr toc*pn 1 1
. af toc*pn i
. aln ;g toc*pn
. PF "''\\\\\\\\n[toc*pn]''"
. am pg@header
. nr toc*pn +1
\\..
.\}
.nr toc*i 4 1
.while \\n+[toc*i]<10 \{\
. if !'\\$\\n[toc*i]'' \{\
. ce
\\$\\n[toc*i]
. br
. \}
.\}
. ce
\\*[Licon]
. br
. SP 3
.\}

print LIST OF XXX
.. -----------
.toc@read-Ci lev1 lev2 lev3 lev4 ... lev7
.nr toc*i 0 1 .while \\n+[toc*i]<15 \{\ . nr toc*hl!\\n[toc*i] \\$[\\n[toc*i]] .\} .. -----------
. toc@save \\$1 "\\*[hd*mark]" "\\$2" \\*[hd*sect-pg] .\} .. .als )E toc@entry -----------
collect maxsize of mark if string Ci don't exist.
. if !r toc*hl!\\$1 .nr toc*hl!\\$1 0 . if \\n[toc*hl!\\$1]<=\w@\\$2@ \{\ . nr toc*hl!\\$1 \w@\\$2@u . \} .\} .am toc*list .toc@set level headernumber text pagenr
.toc@set \\$1 "\\$2" "\\$3" \\$4 \\.. .. -----------
level mark text pagenumber

.nr toc*ind 0 .nr toc*i 0 1 . nr toc*ind +\\n[toc*hl!\\$1]u .\} . while \\n+[toc*i]<\\$1 \{\ . nr toc*ind +\\n[toc*hl!\\n[toc*i]]u . \} .\} .nr toc*text \\n[toc*ind]u+\\n[toc*hl!\\$1]u
length of headernum space
.nr toc*i \\n[toc*hl!\\$1]-\w@\\$2@
ragged right ---------------------------------
\\$2 . sp -1 \\$3 \\$4 . br .\} . \" unnumbered heading -------------------- . ie '\\$2'' \{\ . in \\n[toc*ind]u \\$3\h'1m' . \} . \" normal heading ------------------------ . el \{\ \\$2 . sp -1 \\$3\h'1m' . \} . ll \\n[@ll]u . sp -1 . nr toc*sep (u;\\n[.l]-\\n[.n]-\\n[.i]-\w@\\$4@)-1m \h'|\\n[.n]u'\l'\\n[toc*sep]u.'\h'1m'\\$4 .\} .. ########################### module lix ############################
LIST OF figures, tables, exhibits and equations
.nr lix*fg-nr 0 1 .nr lix*tb-nr 0 1 .nr lix*ec-nr 0 1 .nr lix*ex-nr 0 1 .aln Fg lix*fg-nr .aln Tb lix*tb-nr .aln Ec lix*ec-nr .aln Ex lix*ex-nr ------------
.lix@print-line fg Lf \\n+[lix*fg-nr] "\\$1" "\\$2" "\\$3" "\\$4" .. .lix@print-line tb Lt \\n+[lix*tb-nr] "\\$1" "\\$2" "\\$3" "\\$4" .. .lix@print-line ec Le \\n+[lix*ec-nr] "\\$1" "\\$2" "\\$3" "\\$4" .. .lix@print-line ex Lx \\n+[lix*ex-nr] "\\$1" "\\$2" "\\$3" "\\$4" .. ------------
print line with 'figure' in the text
type stringvar number text override flag refname


.nr lix*in \\n[.i] . if !0\\$6 .ds lix*label \\*[Li\\$1] \\$5\\*[lix*numb]\\*[lix*ds-form] . if 0\\$6=1 .ds lix*label \\*[Li\\$1] \\*[lix*numb]\\$5\\*[lix*ds-form] . if 0\\$6=2 .ds lix*label \\*[Li\\$1] \\$5\\*[lix*ds-form] .\} print line if not between DS/DE
. lix@print-text "\\*[lix*label]" "\\*[lix*text]" \\$1 \\$2 \\$7 .\} . lix@embedded-text "\\*[lix*label]" "\\*[lix*text]" \\$1 \\$2 \\$7 .\}
.. -----------
label text type stringvar refname

\\n[Lsp]u .misc@ev-keep lix

. in +\w@\\$1@u . ti 0 .\} \\$1\\$2

.ev save line for LIST OF XXX, wth is the width of the label
find the maximum width
save reference to the figure
.. hide printout until diversion is evaluated
\!.ie \\\\n[Sectp] .ds lix*pgnr \\\\*[hd*sect-pg] \!.el .ds lix*pgnr \\\\n[%] \!.SP \\\\n[Lsp]u \!.misc@ev-keep lix \!.ll \\n[.l]u \!.init@reset \!.fi \!.ie (\w@\\$1\\$2@)>(\\\\n[.l]-\\\\n[.i]) \{\ . in +\w@\\$1@u \!. ti 0 \!\\$1\\$2 \!.\} \!.el \{\ . ce 1 \!\\$1\\$2 \!.\} \!.br \!.ev save line for LIST OF XXX, wth is the width of the label
\!.if !r lix*wth\\$3 .nr lix*wth\\$3 0 find the maximum width
\!.if \w@\\*[lix*label]@>\\\\n[lix*wth\\$3] .nr lix*wth\\$3 \w@\\*[lix*label]@ \!.if \\\\n[\\$4] .lix@ds-save \\$3 \\\\*[lix*pgnr] "\\*[lix*text]" "\\*[lix*label]" save reference to the figure
\!.if !'\\$5'' .SETR \\$5 \\*[lix*numb] .. ------------
print complete list of XXXX
arg: fg,tb,ec,ex text
print LIST OF XXXX
execute user-defined macros
. ce \\$3 . SP 3 .\}

.lix*ds\\$1 .. ------------
save line of list in macro
type pagenumber text
.am lix*ds\\$1 .lix@dsln \\$1 \\$2 "\\$3" "\\$4" \\$5 \\.. .. ------------
print appended macro
lix@dsln type pagenumber text headernr
.nr lix*i \\n[lix*wth\\$1]-\w@\\$4@ \\$4 \\$3\h'1m' .nr lix*sep (u;\\n[.l]-\\n[.n]-\\n[.i]-\w@\\$2@)-1m \h'|\\n[.n]u'\l'\\n[lix*sep]u.'\h'1m'\\$2

\\n[toc*spacing]u .. ########################### module fnt ############################
some font macros.
.ul 0 .. -----------
.ul 0 .nr fnt*prev \\n[.f] .nr fnt*i 2 1 .while \\n+[fnt*i]<=\\n[.$] \{\ . if \\n[fnt*i]>3 .as fnt*tmp \, . ie (\\n[fnt*i]%2)=1 .as fnt*tmp \\$1\\$[\\n[fnt*i]] . el .as fnt*tmp \\$2\\$[\\n[fnt*i]] . if \\n[fnt*i]<\\n[.$] .as fnt*tmp \/ .\} \\*[fnt*tmp]\f[\\n[fnt*prev]] .. -----------
.. .. .. .. .. .. .. .. ########################### module box ############################
draw a box around some text. Text will be kept on the same page.

.nr box*ll 0 .B1 and .B2 works like .DS
.nr box*ll \\n[.l] .nr box*ind \\n[.i] .nr box*hyp \\n[.hy] .nr box*wid \\n[.l]-\\n[.i]
jump to new environment.
.ev box*ev .di box*div .vs \\n[@vs]u ..

.di .nr box*height \\n[dn] .nr box*y-pos \\n[.d]u

.box*div
\v'-1v+.25m'\ \D'l \\n[box*wid]u 0'\ \D'l 0 -\\n[box*height]u'\ \D'l -\\n[box*wid]u 0'\ \D'l 0 \\n[box*height]u'

.ev .nr box*ll 0 .. ########################### module ref ############################
.nr ref*nr 0 1 .aln :R ref*nr .nr ref*nr-width 5n .nr ref*flag 0 \" for end-of-text
start reference
------------
.nr ref*flag 1 .am ref*mac .ref@start-print \\n[ref*nr] \\.. .eo .am ref*mac RF .. ------------
.ec .am ref*mac .ref@stop-print \\.. .. ------------
.di ref*div \\$1. ..

.di .ev ref*ev2

.ref*div
.ev
..
-----------
.nr ref*i 0\\$2

2 .ref@print-refs .. -----------
called by end-of-text!
.if \\n[ref*flag] \{
. if \\n[D]>2 .tm Print references, called by eot . nr ref*flag 0 . br . misc@ev-keep ne . init@reset \c ' bp . ev . ref@print-refs .\} .. -----------
prints the references
.toc@save 1 "" "\\*[Rp]" \\n[%]

\\*[Rp] .nr ref*ll \\n[.l] .misc@ev-keep ref*ev .ref*mac .ev .nr ref*flag 0 1 .. ########################### module app ############################

.nr app*nr 0 1 .af app*nr A .nr app*dnr 0 1 .nr app*flag 0 ------------
.APP name text
name == "" -> autonumber
.if \\n[.$]<2 .@error "APP: too few arguments"
.app@set-ind "\\$1"

.app@index "\\*[app*ind]" "\\$2" .. ------------
.APPSK name pages text
name == "" -> autonumber
.app@set-ind "\\$1"

.app@index "\\*[app*ind]" "\\$3" .. ------------
. if !\\n[app*flag] \{\ . nr H1 0 1 . af H1 A . af H1h A . nr app*flag 1 . \} . ds app*ind \\n+[app*nr] . nr H1 \\n+[app*dnr] . nr H1h \\n[app*dnr] .\} clear lower counters
.nr app*i 1 1 .while \\n+[app*i]<15 .nr H\\n[app*i] 0 1 .. ------------
.toc@save 1 "" "\\*[App] \\$1: \\$2" \\n[%] .. ------------
app@heaer name text
.bp

(u;\\n[Lsp]*4)

1 \s+4\\*[App] \\$1\s0

(u;\\n[Lsp]*2) \s+2\\$2\s0

(u;\\n[Lsp]*4) .. .als APPX app@header ########################### module cov ############################
title stored in diversion cov*title
abstract stored in diversion cov*abstract
arg to abstract stored in cov*abs-arg
indent stored in cov*abs-ind
number of authors stored in cov*au
author(s) stored in cov*au!x!y
author(s) title stored in cov*at!x!y
x is the author-index [1-cov*au], y is the argument-index [1-9].
author(s) firm stored in cov*firm
new date (if .ND exists) is stored in cov*new-date



.nr cov*au 0 .pg@disable-top-trap .eo .. -------------------
.ec .. -------------------
.AU name [initials [loc [dept [ext [room [arg [arg [arg]]]]]]]]
.cov@title-end .pg@disable-top-trap .nr cov*au +1 .nr cov*i 0 1 .while \\n[.$]>=\\n+[cov*i] \{\ . ds cov*au!\\n[cov*au]!\\n[cov*i] "\\$[\\n[cov*i]] .\} . if d cov*location-\\$3] \{\ . ds cov*au!3!\\n[cov*au] \\*[cov*location-\\$3] . \} .\} .. -------------------
.AT title1 [title2 [... [title9] ]]]]
Well, thats all that COVEND look for.
Must appear directly after .AU
.nr cov*i 0 1 .while \\n[.$]>=\\n+[cov*i] \{\ . ds cov*at!\\n[cov*au]!\\n[cov*i] "\\$[\\n[cov*i]] .\} .. -------------------
.cov@title-end .. .. .pg@disable-top-trap .nr cov*abs-arg 0\\$1 .nr cov*abs-ind (n;0\\$2) .. .. fixed for 2000, now uses \n[year].
. \" support for ISO-date . nr cov*mm \\n[mo] . nr cov*dd \\n[dy] . af cov*mm 01 . af cov*dd 01 . ie '0'\\$1' \{\ . ds cov*new-date \\*[MO\\n[mo]] \\n[dy], \\n[year] . \} . el \{\ . ds cov*new-date \\n[year]-\\n[cov*mm]-\\n[cov*dd] . \} .. SODATE 0 .als DT cov*new-date .. switch to ISO-date if register Iso exist: YYYY-MM-DD
-------------------
save technical numbers.
.nr cov*i 0 1 .while \\n[.$]>=\\n+[cov*i] .ds cov*mt-tm!\\n[cov*i] \\$[\\n[cov*i]] .nr cov*mt-tm-max \\n[.$] .. -----------------------
cover sheet
the file must have the following last lines (somewhere):
.pg@enable-top-trap
.bp 1
.pg@enable-trap
------------
. ie d cov*mt-file!\\$1 .ds cov*mt-type \\$1 . el .ds cov*mt-type 6 .\} .mso \\*[cov*str]\\*[cov*mt-file!\\*[cov*mt-type]] .. .pg@disable-top-trap .mso \\*[cov*str] .. ########################### module qrf ############################
forward and backward reference thru special files.

check if stderr-method is wanted
This was needed when I discovered that groff was considered unsafe
and groff -U didn't work. It's a workaround like the original
index method, but not in my view elegant enough.

init reference system
.nr qrf*pass 2 . tm .\\\\" Rfilename: \\*[qrf*file] .\} .. ---------------
set a reference.
. ds qrf*name qrf*ref-\\$1 . if \\n[D]>2 .tm SETR: ref \\*[qrf*name]=\\*[hd*mark],\\n[%] . \" heading-number . ds \\*[qrf*name]-hn \\*[hd*mark] . \" page-number . ds \\*[qrf*name]-pn \\n[%] . \" . if \\n[Ref] \{\ . tm .ds \\*[qrf*name]-hn \\*[hd*mark] . tm .ds \\*[qrf*name]-pn \\n[%] . if !'\\$2'' .tm .ds \\*[qrf*name]-xx \\$2 . \} .\} .. ---------------
get misc-string
If two arg -> set var. arg to misc-string.
. if d \\*[qrf*name]-xx \{\ . ie \\n[.$]>1 .ds \\$2 \\*[\\*[qrf*name]-xx] . el \\*[\\*[qrf*name]-xx]\c . \} .\} .. ---------------
get header-number
If two arg -> set var. arg to header-number.
. ie \\n[.$]>1 .ds \\$2 \\*[\\*[qrf*name]-hn] . el \\*[\\*[qrf*name]-hn]\c .\} .. ---------------
get page-number
If two arg -> set var. arg to page-number.
. ie \\n[.$]>1 .ds \\$2 \\*[\\*[qrf*name]-pn] . el \\*[\\*[qrf*name]-pn]\c .\} .. ----------
. tm "GETR: No .INITR in this file" .\} . GETHN \\$1 Qrfh . GETPN \\$1 Qrfp \\*[Qrf] .\} .. ########################### module ind ############################
Support for mgs-style indexing, borrowed from mgs.
. tm \\$1\t\\$2\t\\$3\t\\$4 ... \\n[%] .. --------------------
Another type of index system
INITI type filename [macro]
ignore if INITI has already been used
. if d ind*file .@error "INITI:file already set" . ds ind*file \\$2.ind . if \\n[D]>1 .tm INITI: source \\*[ind*file] .\} . if \\n[.$]>2 .tm .\\\\" Imacro: \\$3 .\} .. ---------------

.while \\n[.$]>0 \{\ . shift . as ind*line \t\\$1 .\} .as ind*line \\*[ind*ref] .. print index
. if !\\n[Cp] .pg@next-page . \" print INDEX . \" execute user-defined macros . if d TXIND .TXIND . ie d TYIND .TYIND . el \{\ . SK . ce \\*[Index] . SP 3 . 2C . nf . \} ' so \\*[ind*file] . ie d TZIND .TZIND . el \{\ . fi . 1C . \} .\} .. ########################### module let ############################
Letter macros
------------------------
Formal closing
.df@print-float 3 .. -------
\\$1 .. ------------------------
Signature line
.. ------------------------
.df@print-float 3 .nr let*i 0 1 .nr let*j 0 .while \\n+[let*i]<=\\n[let*wa-n] \{\ .let@sg_\\*[let*type] "\\*[let*wa-name!\\n[let*i]]" "\\*[let*wa-title!\\n[let*i]]" \\n[let*i] \\n[let*j] \\$@ .\} .. ------------------------
Memorandum signature
.df@print-float 3 .nr let*i 0 1 .while \\n+[let*i]<=\\n[cov*au] \{\ . if \\n[let*i]>1 .as let*tmp / . as let*tmp \\*[cov*au!\\n[let*k]!2] .\}

.nr let*i 0 1
.while \\n+[let*i]<=\\n[cov*au] \{\
. SP 3v
. if \\n[let*i]=\\n[let*k] \{\
\Z'\h'-(u;\\n[.l]/2)'\\*[let*tmp]'\c
. \}
\\*[cov*au!\\n[let*i]!1]
.\}
.. ------------------------
Approval signature
\Z'\\$1'\h'29m'\f[\\*[@sdf_font]]\\*[Letdate]
.. ------------------------
Letter signature
\Z'\\$1'
.. ------------------------
Letter type
let@header is called from the header. It is supposed
to remove the alias itself.
.nr Pi 5 .nr Pt 0 .shift .als let@header let@head_\\*[let*type] .let@init_\\*[let*type] \\$@ .. -----------
Blocked letter
.. .let@print-head 1 ..
\\$1
\\$2
.. .als let@fc_BL let@mt-closing -----------
Semiblocked letter
.nr Pt 1 .. .let@print-head 1 .. .als let@sg_SB let@sg_BL .als let@fc_SB let@mt-closing -----------
Full-blocked letter
.. .let@print-head ..
\\$1
\\$2
.. \\$1 .. -----------
Simplified letter
.. .let@print-head ..
.misc@toupper "\\$1, \\$2"
.. .. --------------------------------------
Print the letter-head
 ---- WA
---- datum
\\*[cov*new-date] ---- Confidential
. ti 0 . ie !''\\*[let*lo-CN]' \\*[let*lo-CN] . el \\*[LetCN] . sp .\} ---- Reference
\\*[LetRN] \\*[let*lo-RN] . sp .\} ---- IA
.nr let*i 0 1 .while \\n+[let*i]<=\\n[let*ia-n] \{\ \\*[let*ia-name!\\n[let*i]] \\*[let*ia-title!\\n[let*i]] .\} ---- Attention
. sp \\*[LetAT] \\*[let*lo-AT] .\} ---- Salutation
. sp . ti 0 . ie !''\\*[let*lo-SA]' \\*[let*lo-SA] . el \\*[LetSA] .\} ---- Subject
. ie '\\*[let*type]'SP' \{\ . sp 2 . misc@toupper \\*[let*lo-SJ] . sp . \} . el \{\ . sp . if '\\*[let*type]'SB' .ti +5m \\*[LetSJ] \f[\\*[@sdf_font]]\\*[let*lo-SJ] . \} .\} .. -------------------
.IA [name [title]]
.nr let*ia-n 0 1 .ev let@ev 'nf .di let@ia-div .eo .. .di .ec .ev .. -------------------
.WA [name [title]]
.nr let*wa-n 0 1 .ev let@ev 'nf .di let@wa-div .it \\n[Letwam] let@wa-drain .eo .. ------
.it .di .di let@wa-junk .. ------
.it .ec .di .ev .. -------------------
Copy to
. ie \\n[.$]>0 \{\ . ie !\w'\\$1' .ds let*str \\*[Letns!\\*[Letnsdef]] . el \{\ . ie d Letns!\\$1 .ds let*str \\*[Letns!\\$1] . el .ds let*str \\*[Letns!copy](\\$1)\\*[Letns!to] . \} . \} . el .ds let*str \\*[Letns!\\*[Letnsdef]] .\}
\\*[let*str]
..
.. -------------------
Letter options
.. --------------------
Start with a clean slate