[net.sources] proff macros to emulate nroff mm macros

tony@wldrdg.UUCP (Tony Andrews) (11/20/86)

These macros are for the proff formatter and emulate the nroff
mm macro package. (George Walker recently posted a similar
set of macros to emulate the nroff ms macros.) The following
mm macros are supported:

	P, SP, SK, SA, H, HU, BL, DL, ML, AL, LI, LE, DF, DS, DE, TC

In most cases there are some limitations. These are described
in more detail as comments within the macros. All numbered
headings are set up to emulate the default mm settings. If
you want to change the standard behavior for a particular
heading level, the macros can be easily tweaked.

In addition to the macros listed above, a few of the simpler
mm registers are supported:

	Pt	default paragraph type (0 or 1)
	Pi	standard paragraph indentation
	Li	list indentation
	Si	standard display indentation
	Ds	# of spaces before and after displays


Tony Andrews
...!ihnp4!onecom!wldrdg!tony
Wildridge Consulting, Inc.
Boulder, CO

-------------------------------------------------------------------------
.#
.#	MM macro package for proff
.#
.# Set escape character to backslash
.ec \
.#
.# Set control variables to default values.
.#
.vs Pt 1
.vs Pi 5
.vs Li 5
.vs Si 5
.vs Ds 1
.#
.vs SAc 0
.vs SAd 0
.nojustify
.vs Lm1 o
.vs Lm2 o
.vs Lm3 o
.vs Lm4 o
.vs Lt1 B
.vs Lt2 B
.vs Lt3 B
.vs Lt4 B
.#
.# Basic paragraph macros
.#
.# .P [type]	works properly, but doesn't handle paragraph type 2.
.#		Variable "Pt" sets default type (used if no arg given).
.#
.de P
.doP$1
.en
.# doP called if no argument given to P
.de doP
.doP${Pt}
.en
.# do a non-indented paragraph
.de doP0
.ne 2
.sp 1
.en
.# do an indented paragraph
.de doP1
.ne 2
.sp 1
.ti +${Pi}
.en
.#
.# SP [n]	works, but doesn't accumulate over successive calls
.#
.de SP
.sp $1
.en
.#
.# SK		no argument allowed, can only be used to skip to next page
.#
.de SK
.bp
.en
.#
.# SA [arg]	works as documented, along with .na and .ad
.#
.de SA
.doSA$1
.en
.# doSA - if no arg given to SA; revert to default setting
.de doSA
.vs SAc ${SAd}
.setsa${SAc}
.en
.#
.de doSA0
.vs SAc 0
.vs SAd 0
.setsa0
.en
.#
.de doSA1
.vs SAc 1
.vs SAd 1
.setsa1
.en
.#
.de setsa0
.nojustify
.en
.#
.de setsa1
.justify
.en
.#
.# na and ad for nroff compatibility
.#
.de na
.nojustify
.en
.de ad
.justify
.en
.#
.# Numbered Headings
.#
.# .H level text... (only 8 words allowed following level)
.#
.#  To effectively set the Cl, Hb, Hs, and Ej registers, make minor
.#  modifications to the level-specific macros below. Table of contents
.#  lines are included for all levels, but commented out for levels 3-7.
.#
.de H
.H$1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H1
.nr a +1
.nr b  0
.nr c  0
.nr d  0
.nr e  0
.nr f  0
.nr g  0
.sp 2
.ne 3
.bd
@na. $1 $2 $3 $4 $5 $6 $7 $8 $9
.P
.cl
.cl 1 @na. $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H2
.nr b +1
.nr c  0
.nr d  0
.nr e  0
.nr f  0
.nr g  0
.sp
.ne 3
.bd
@na.@nb $1 $2 $3 $4 $5 $6 $7 $8 $9
.P
.cl
.cl 2 @na.@nb $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H3
.nr c +1
.nr d  0
.nr e  0
.nr f  0
.nr g  0
.sp
.ne 3
.ul
@na.@nb.@nc $1 $2 $3 $4 $5 $6 $7 $8 $9   
.#  .cl 3 @na.@nb.@nc $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H4
.nr d +1
.nr e  0
.nr f  0
.nr g  0
.sp
.ne 3
.ul
@na.@nb.@nc.@nd $1 $2 $3 $4 $5 $6 $7 $8 $9   
.#  .cl 4 @na.@nb.@nc.@nd $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H5
.nr e +1
.nr f  0
.nr g  0
.sp
.ne 3
.ul
@na.@nb.@nc.@nd.@ne $1 $2 $3 $4 $5 $6 $7 $8 $9   
.#  .cl 5 @na.@nb.@nc.@nd.@ne $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H6
.nr f +1
.nr g  0
.sp
.ne 3
.ul
@na.@nb.@nc.@nd.@ne.@nf $1 $2 $3 $4 $5 $6 $7 $8 $9   
.#  .cl 6 @na.@nb.@nc.@nd.@ne.@nf $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.de H6
.nr g +1
.sp
.ne 3
.ul
@na.@nb.@nc.@nd.@ne.@nf.@ng $1 $2 $3 $4 $5 $6 $7 $8 $9   
.#  .cl 7 @na.@nb.@nc.@nd.@ne.@nf.@ng $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.# .HU text... (only 9 words allowed following level)
.#
.# This is basically a copy of the appropriate .Hn macro from above
.# but without a numbered heading. To effectively change the Hu register
.# (default=2), grab the appropriate macro from above and modify slightly.
.#
.de HU
.nr b +1
.nr c  0
.nr d  0
.nr e  0
.nr f  0
.nr g  0
.sp
.ne 3
.bd
$1 $2 $3 $4 $5 $6 $7 $8 $9
.P
.cl
.cl 2 $1 $2 $3 $4 $5 $6 $7 $8 $9
.en
.#
.# Lists
.#
.#  Crude list implementation. No argument allowed for DL, BL, or LI.
.#  ML must have only a single argument. AL is supported but always
.#  generates a numbered list regardless of its arguments. All lists
.#  are indented by the value of variable "Li" (default 5). Lists may
.#  be nested up to four deep, but no more than one may be numbered.
.#  Numbered lists with more than 9 items won't be properly aligned.
.#
.de BL
.lpushm o
.lpusht B
.doL
.en
.#
.de DL
.lpushm -
.lpusht B
.doL
.en
.#
.de ML
.lpushm $1
.lpusht B
.doL
.en
.#
.de AL
.lpusht N
.nr l  0
.doL
.en
.#
.#
.de doL
.in +${Li}
.en
.#
.#
.de LI
.doLI${Lt1}
.en
.#
.de doLIB
.sp
.ti -2
${Lm1}
.en
.#
.de doLIN
.nr l +1
.sp
.ti -4
@nl.
.en
.#
.de LE
.in -${Li}
.lpopm
.lpopt
.en
.#
.de lpushm
.vs Lm4 ${Lm3}
.vs Lm3 ${Lm2}
.vs Lm2 ${Lm1}
.vs Lm1 $1
.en
.de lpopm
.vs Lm1 ${Lm2}
.vs Lm2 ${Lm3}
.vs Lm3 ${Lm4}
.vs Lm4 "List Overflow"
.en
.de lpusht
.vs Lt4 ${Lt3}
.vs Lt3 ${Lt2}
.vs Lt2 ${Lt1}
.vs Lt1 $1
.en
.de lpopt
.vs Lt1 ${Lt2}
.vs Lt2 ${Lt3}
.vs Lt3 ${Lt4}
.vs Lt4 B
.en
.#
.# Displays
.#
.#  The basic characteristic of displays, that they aren't split across
.#  pages, can't be done automatically in proff. This can be done
.#  manually by putting in a .ne before the display.
.#  Floating displays aren't supported either, so DS and DF are identical.
.#  Both the "format" and "fill" arguments to DS and DF are supported.
.#  The Si variable gives the standard indentation amount, and Ds gives
.#  the number of blank lines before and after the display.
.#
.de DF
.DS $1 $2
.en
.#
.de DS
.doDSformat$1
.doDSfill$2
.sp ${Ds}
.en
.#
.de DE
.ce off
.sp ${Ds}
.in -${Ei}
.en
.#
.de doDSformat
.vs Ei 0
.en
.de doDSformat0
.vs Ei 0
.en
.de doDSformat1
.in +${Si}
.vs Ei ${Si}
.en
.de doDSformat2
.vs Ei 0
.ce on
.en
.#
.de doDSfill
.nf
.en
.de doDSfill0
.nf
.en
.de doDSfill1
.fi
.en
.#
.# Table of Contents
.#
.#  TC accepts no arguments. It breaks to a new page, calls the user
.#  macro TX and dumps the table of contents. Page numbers are restarted
.#  at 1 in roman numeral mode. The default TX macro does nothing and
.#  will generally be replaced by something to print the title of the
.#  document. Default headers, footers, line spacing, etc. can be
.#  overridden in the TX macro.
.#
.de TX
.en
.de TC
.ls 1
.bp 1
.pn roman
.he ////
.fo //- # -//
.TX
.sp
.ce
Table of Contents
.sp
.pc
.en