From b8fb8ad8ab2e5cbb245b35f20d050d50be2842d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 24 Jun 2021 16:25:32 +0200 Subject: Change name to mu It turns out that Heirloom troff includes an (m)g macro set for groff compatibility. I liked the name mg, because of the association with milligram, but mu is pretty good too. (And mu is the symbol for the SI micro prefix, which is even smaller than milli!) --- Makefile | 4 +- README.pdf | Bin 59049 -> 59334 bytes README.t | 70 +++++----- g.tmac | 422 ----------------------------------------------------------- gx.tmac | 61 --------- hacking.pdf | Bin 24436 -> 24683 bytes hacking.t | 30 +++-- t/Makefile | 10 +- t/ne.t | 2 +- toc/README.t | 4 +- u.tmac | 422 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ux.tmac | 61 +++++++++ 12 files changed, 545 insertions(+), 541 deletions(-) delete mode 100644 g.tmac delete mode 100644 gx.tmac create mode 100644 u.tmac create mode 100644 ux.tmac diff --git a/Makefile b/Makefile index cfdab83..6fc4617 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ PDFROFF ?= troff | dpost | ps2pdf - all: README.pdf hacking.pdf -hacking.pdf: hacking.t g.tmac +hacking.pdf: hacking.t u.tmac perl -pe '$$_=`$$_` if s/^\!//' hacking.t |\ $(PDFROFF) > hacking.pdf -README.pdf: README.t g.tmac +README.pdf: README.t u.tmac TROFFONTS=/usr/pkg/share/fonts/X11/TTF/ \ README.pdf diff --git a/README.pdf b/README.pdf index bfc7f3a..8dc235b 100644 Binary files a/README.pdf and b/README.pdf differ diff --git a/README.t b/README.t index f040334..5a3535a 100644 --- a/README.t +++ b/README.t @@ -1,5 +1,5 @@ -.so g.tmac -.so gx.tmac +.so u.tmac +.so ux.tmac .so toc/toc.tmac .mediasize letter .fp 0 M DejaVuSansMono ttf @@ -69,7 +69,7 @@ . .\" start document .t -.x Mg , +.x µ , a simple macro package for troff .d John Ankarström @@ -87,7 +87,9 @@ John Ankarström . .he Introduction .p -.i Mg +.i µ +or +.i mu is a simple macro package for troff with the following features: .n 1 It is designed to be easy to understand and to customize @@ -100,13 +102,13 @@ It is designed to be practically easy to use. Macros consist of a single lowercase letter. .p While -.i mg +.i µ does provide macros for many common tasks, including footnotes, it is at the end of the day an idiosyncratic macro package, written to serve the author's personal needs. Users of -.i mg +.i µ are encouraged to .n 1 a ) modify the source code @@ -116,19 +118,19 @@ use built-in troff requests for some things that other packages might provide custom macros for. .p All in all, -.i mg +.i µ aspires to abstract as little as possible from the underlying troff requests and registers. In its author's humble opinion, it is the ideal macro package for learning troff. .p In this document, the fundamental concepts of -.i mg +.i µ are explained. The document itself also serves as a demonstration of -.i mg . +.i µ . With a couple of exceptions, it uses -.i mg 's +.i µ 's default settings. The reader is encouraged to inspect the document's source code in order to see how the macro package is used in practice. @@ -137,7 +139,7 @@ in order to see how the macro package is used in practice. .he Environments .te .nr &env \n% .p -.i Mg +.i µ makes heavy use of named environments, supported by implementations such as GNU troff, Heirloom troff and Neatroff. Environments obliviate the need for many special registers @@ -149,7 +151,7 @@ keeps track of the document's font size in the register. For the font size of headings, it has yet another register. -.i Mg +.i µ has no such registers. If the user wishes to modify the default font size, he or she can simply switch to the relevant environment @@ -174,7 +176,7 @@ the default environment (0) is copied, meaning that all environment-relevant settings defined before the first macro call are applied to all -.i mg +.i µ environments. It is thus remarkably simple and intuitive to set, for example, the default font of a document: @@ -186,7 +188,7 @@ Document title First paragraph. .p In addition to the normal environment-relevant settings, -.i mg +.i µ manually associates a few special registers with the current environment: .n 1 .c sp , @@ -211,17 +213,17 @@ and do not support these registers. . .he External macros .p -.i Mg +.i µ defines a number of macros. Some of them are used internally by -.i mg +.i µ itself; these carry an at .c @ ) ( prefix and are going to be explored later. For now, we will focus on the external macros provided by -.i mg . +.i µ . .se Inline macros .p There is a group of macros that provide @@ -245,9 +247,9 @@ italic font bold italic font .p For example, the following request outputs -.i mg .\(rq: \(lq +.i µ .\(rq: \(lq .l -\&.i mg . +\&.i µ . . .p Note that @@ -372,7 +374,7 @@ and .c ) are called at such a position that the collected footnotes cannot fit on the current page, -.i mg +.i µ will print the footnotes on the next page instead. .p The @@ -403,7 +405,7 @@ which takes an exact amount of space as its argument, takes a declarative specification describing the amount of desired space in terms of -.i mg +.i µ environments. For example: .l @@ -415,9 +417,9 @@ For example: . .he Internal macros .p -.i Mg 's +.i µ 's internal macros are generally not meant to be used outside of -.i g.tmac . +.i u.tmac . Documented in this section are the exceptions to this rule. For examples of how these macros are used in practice, see the FAQ section on page \n[&faq]. @@ -433,7 +435,7 @@ and macros control the page header and footer. .p At document initialization, -.i mg +.i µ automatically creates traps for .c @th and @@ -448,7 +450,7 @@ and .c @t , which control the text and spacing of the header and footer. .p -.i Mg +.i µ will avoid creating a trap for .c @tf if any trap has already been set before document initialization. @@ -486,7 +488,7 @@ are equivalent to troff's and .c evc , but perform some extra work to keep track of -.i mg 's +.i µ 's special environment variables (see .i Environments , @@ -512,11 +514,11 @@ in the full GNU troff manual are configured with the standard troff requests. If you set the point size at the beginning of the document, before any -.i mg +.i µ macros have been called, it will be correctly set for the entire document. This works because -.i mg 's +.i µ 's environments initially copy all their settings from 0, the default environment. .p @@ -526,7 +528,7 @@ at 9 points and a vertical spacing of 12 points, you would start the document like this (before you call any -.i mg +.i µ macros): .l \&.fam N @@ -605,7 +607,7 @@ To change the contents of the footer: Some macro packages have a concept of .q keeps , sections that are kept together across page breaks. -.i Mg +.i µ does not (at least yet) define any such macros by default. The simplest solution is to use troff's .c ne @@ -616,7 +618,7 @@ request: .p If you want to keep text of various styles together, you can use -.i mg 's +.i µ 's own .c w macro: @@ -641,7 +643,7 @@ Environments are a feature built into troff, accessed via the .c ev request, but because -.i mg +.i µ extends environments with additional functionality, it provides special macros to be used instead of .c ev : @@ -661,7 +663,7 @@ The .c @e macro can be used to activate any environment that supports -.i mg 's +.i µ 's extensions (see .i Environments , p. \n[&env]). @@ -683,7 +685,7 @@ and defines a corresponding macro: .se How do I include a table of contents in my document? .p Included with the -.i mg +.i µ distribution is a package called .i toc , which includes the following files: diff --git a/g.tmac b/g.tmac deleted file mode 100644 index 8eecd8c..0000000 --- a/g.tmac +++ /dev/null @@ -1,422 +0,0 @@ -.\" "/. -.\" mg macro package for troff "/. -.\" created by John Ankarström "/. -.\" "/. -.\" Permission to use, copy, modify and/or "/. -.\" distribute this software for any purpose "/. -.\" with or without fee is hereby granted. "/. -.\" "/. -.\" For an index of the macros defined in "/. -.\" this file, issue `grep -n [-]- g.tmac'. "/. -.\" "/. -.\" When editing the source of mg, keep the "/. -.\" following rules in mind: "/. -.\" "/. -.\" * Prefix temporary strings and registers "/. -.\" with _. "/. -.\" * Prefix internal registers and environ- "/. -.\" ments with @. "/. -.\" * Prefix internal macros with @ (normal "/. -.\" macros), * (variants of the same "/. -.\" macro) or % (strings). "/. -.\" * Place macros in alphabetical order. "/. -.\" * Do not use .ev and .evc directly; use "/. -.\" (e, @e and @c instead. "/. -.\" "/. -. -.do xflag 3 \" enable modern extensions -.eo \" disable backslash escapes -. -.\" Internal macros ---------------------------- -. -.\" @a -- setup document -.de @a -. nr @a 1 -. -. \" set header/footer traps -. wh 0 @th -. em @tf -. if \n(nl<=0 .@th -. nr _ \n(.p-\n(nl -. if \n(.t=\n_ .wh -1i @tf -. -. \" configure environments -. @e d \" date -. @c 0 -. nr sp 0.4v -. ad c -. @e h \" heading -. @c 0 -. nr sp 1.2v -. ps +1p -. ft B -. @e l \" literal display -. @c 0 -. nr sp 0.3v -. nf -. in 18p -. ft CR -. ps -1p -. vs -1p -. @e n \" name (of author) -. @c 0 -. nr sp 0.4v -. ad c -. @e p \" paragraph -. @c 0 -. nr sp 0.3v -. nr ti 18p -. ad b -. @e q \" quotation -. @c 0 -. nr sp 0.3v -. nr ti 18p -. in 18p -. ps -1p -. vs -1p -. @e s \" section heading -. @c 0 -. nr sp 1v -. ft B -. @e t \" title -. @c 0 -. ps +4p -. vs +2p -. ft B -. ad c -. @e -. -. \" configure special environments -. (e @f \" footnote -. @c 0 -. ps -2p -. vs -1p -. (e @m \" margins (header, footer) -. @c 0 -. (e -. -. \" create formatted dates -. af mo 00 -. af dy 00 -. ds #i \n[year]-\n(mo-\n(dy -. af mo 1 -. af dy 1 -. ds #e \n(dy -. ie \n(mo=1 .ds #e \*(%e January -. el .ie \n(mo=2 .ds #e \*(#e February -. el .ie \n(mo=3 .ds #e \*(#e March -. el .ie \n(mo=4 .ds #e \*(#e April -. el .ie \n(mo=5 .ds #e \*(#e May -. el .ie \n(mo=6 .ds #e \*(#e June -. el .ie \n(mo=7 .ds #e \*(#e July -. el .ie \n(mo=8 .ds #e \*(#e August -. el .ie \n(mo=9 .ds #e \*(#e September -. el .ie \n(mo=10 .ds #e \*(#e October -. el .ie \n(mo=11 .ds #e \*(#e November -. el .ds #e \*(#e December -. ds #e \*(#e \n[year] -.. -. -.\" @c -- copy environment -.de @c -. evc \$1 -. nr sp \n[@\$1_sp] -. nr sq \n[@\$1_sq] -. nr ti \n[@\$1_ti] -.. -. -.\" (e -- set environment -.de (e -. ev \$1 -.. -. -.\" @e -- set extended environment -.de @e -. -. \" initialize document if not initialized -. if '\n(@a'0' .@a -. -. \" save special environment variables -. if !'\n[.ev]'0' \{\ -. nr @\n[.ev]_sp \n(sp \" vertical space before any environment -. nr @\n[.ev]_sq \n(sq \" vertical space before different environment -. nr @\n[.ev]_ti \n(ti \" first line indentation -. ev -. \} -. -. \" keep track of previous and new environment -. ds %penv \*[%env] -. ds %env \$1 -. -. \" post-environment operations -. if !'\$1'' \{\ -. \" add small space after title -. if '\*[%penv]'t' .if '\*[%env]'d' .sp 0.1v -. -. \" add space after title block -. nr _ 0 -. if !'\*[%env]'d' .nr _ 1 -. if !'\*[%penv]'t' .if !'\*[%penv]'d' .nr _ 0 -. if \n_ \{\ -. sp 0.5i -. ns -. \} -. -. \" activate new environment -. ev \$1 -. nr sp \n[@\n[.ev]_sp] -. nr sq \n[@\n[.ev]_sq] -. nr ti \n[@\n[.ev]_ti] -. sp \n(spu -. if !'\*[%env]'\*[%penv]' .sp \n(squ -. \} -.. -. -.\" @f -- footer -.de @f -. sp |\n(.pu-48p -. tl ''%'' -.. -. -.\" @h -- header -.de @h -. sp |36p -. tl '''' -. sp |1i -.. -. -.\" @tf -- footer trap -.de @tf -. -. \" skip automatic trigger if manual mode active, unless forced -. if \n(@m>0 .if !'\$1'f' \{\ -. nr @m -1 -. return -. \} -. -. \" print footer -. br -. (e @m -. @f -' bp -.. -. -.\" @th -- header trap -.de @th -. (e @m -. rt 0 -. @h -. (e \*[%env] -. ns -.. -. -.\" @tn -- footnote trap -.de @tn -. -. nr @m 1 -. \" print collected footnotes -. (e @m -___________________ -. br -. sp 1p -. (e @f -. -. \" escape control characters -. char . \&. -. char ' \&' -. -. @n -. br -. -. \" restore control characters -. char . . -. char ' ' -. -. \" clear footnotes -. ch @tn -. nr @.t 0 -. nr @dn 0 -. rm @n -. @tf f -.. -. -. -.\" Inline macros ------------------------------ -. -.\" b -- bold font -.de b -\&\$3\fB\$1\fP\$2 -.. -. -.\" c -- constant-width font -.de c -. -. \" save original interword spacing -. nr _ss \n[.ss] -. -. \" copy family and (relative) point size from l environment -. (e 0 -. nr _s0 \n(.s -. (e -. (e l -. ds _fl \n(.f -. nr _sl \n(.s -. (e -. -\&\$3\c -. ft \*[_fl] -. ss 7 -. ie d nrf .nrf _s (\n(.s*(\n[_sl]/(\n[_s0]))) -. el .nr _s \n(.s+(\n[_sl]-\n[_s0]) -. ps \n(_sp -\&\$1\c -. ft -. ss \n[_ss] -. ps -\&\$2 -.. -. -.\" i -- italic font -.de i -\&\$3\fI\$1\fP\$2 -.. -. -.\" x -- bold italic font -.de x -\&\$3\f(BI\$1\fP\$2 -.. -. -. -.\" Hybrid macros ------------------------------ -. -.\" q -- quotation -.de q -. -. \" inline -. ie !'\$1'' \&\$3\(lq\$1\(rq\$2 -. -. \" block -. el \{\ -. br -. @e q -. ti \n(tiu -. \} -.. -. -. -.\" Environment macros ------------------------- -. -. -.\" d -- centered date -.de d -. br -. @e d -. if !'\$1'' \*[#\$1] -.. -. -.\" h -- heading -.de h -. br -. w h p -. @e h -. -.. -.\" l -- literal display -.de l -. br -. w ll -. @e l -.. -. -.\" p -- paragraph -.de p -. br -. @e p -. if '\*[%penv]'p' .ti \n(tiu -.. -. -.\" s -- subheading -.de s -. br -. w s p -. @e s -.. -. -.\" t -- centered title -.de t -. br -. @e t -.. -. -. -.\" Other macros ------------------------------- -. -.\" ( -- begin footnote -.de ( -. if !'\$1'' \&\$1\c -. -. \" increment and print number -. nr @n \n(@n+1 -\v'-.3m'\s'\En(.s*80/100'\n(@n\s0\v'.3m'\c -. -. \" switch environment and capture footnote -. (e @f -. boxa @n -\h'9p'\v'-.3m'\s'\En(.s*80/100'\n(@n\s0\v'.3m'\h'2p'\c -.. -. -.\" ) -- end footnote -.de ) -. br -\!.br -. boxa -. (e \*[%env] -. ie !'\$1'' \&\$1 -. el \& -. -. \" get position of footer (or next trap) -. if \n[@.t]=0 .nr @.t \n(nl+\n(.t -. -. -. \" print footnote at bottom of page -. ch @tn -. nr @dn +\n(dnu -. nr _tn \n[@.t]u-\n[@dn]u-12p -. wh \n[_tn]u @tn -.. -. -.\" w -- want space -.de w -. *w 0 \$@ -.. -.de *w -. -. \" parse specification -> _s : accumulated space -. nr _s \$1 \" _e : environment name (e.g. eee -> e) -. ds _e \$2 \" _n : number of lines specified (e.g. eee -> 3) -. substring _e 0 0 -. length _n \$2 -. -. \" add environment spacing -. nr _s +\n[@\*(_e_sp] -. nr _s +\n[@\*(_e_sq] -. -. \" add environment line height (for each line) -. (e \*(_e -. nr _v \n(.v -. (e -. nr _s +(\n(_n*\n(_v) -. shift 2 -. -. \" recurse or request space if done -. ie \n(.$>0 .*w \n(_s \$@ -. el \{\ -. nr _s \n(_s-\n(_v+1u \" do not request too much -. if (\n(_su)>\n(.tu \{\ -. br -. bp -. \} -. \} -.. -. -.ec \" re-enable backslash escapes diff --git a/gx.tmac b/gx.tmac deleted file mode 100644 index d4e4667..0000000 --- a/gx.tmac +++ /dev/null @@ -1,61 +0,0 @@ -.\" "/. -.\" extra stuff for mg "/. -.\" "/. -.\" Permission to use, copy, modify and/or "/. -.\" distribute this software for any purpose "/. -.\" with or without fee is hereby granted. "/. -.\" "/. -. -.eo -. -.\" he -- toc-enabled heading -.de he -. h -\$* -. te .the \n% \$* -.. -. -.\" se -- toc-enabled subheading -.de se -. s -\$* -. te .the \n% \\h'18p'\$* -.. -. -.\" the -- toc entry -.de the -. nr _ \$1 -. shift -. ta \n(.luR -. tc . -\$* \n_ -. tc -. br -.. -. -.\" n -- numbered list item -.de n -. if !'\$1'' \{\ -. nr ni \$1-1 -. af ni 0 -. if !'\$2'' .af ni \$2 -. ds n. . -. if !'\$3'' .ds n. \$3 -. \} -. nr ni +1 -. br -. @e n -. ti \n(tiu -\n(ni\*(n. \c -.. -. -.am @a -. @e n -. @c p -. nr sq \n(sp -. nr sp 0 -. ta 3n +3n +3n +3n -. @e -.. -. -.ec diff --git a/hacking.pdf b/hacking.pdf index b4c3f34..6e88531 100644 Binary files a/hacking.pdf and b/hacking.pdf differ diff --git a/hacking.t b/hacking.t index 4233794..629b976 100644 --- a/hacking.t +++ b/hacking.t @@ -1,4 +1,4 @@ -.so g.tmac +.so u.tmac . .de @h . sp |36p @@ -12,7 +12,7 @@ . .t Hacking on the -.x mg +.x µ macro package .d John Ankarström @@ -20,9 +20,11 @@ John Ankarström . .h What is -.x mg ? +.x µ ? .p -.i Mg +.i µ +or +.i mu is a simple macro package for troff designed to abstract as little as possible from troff itself, while still providing a powerful framework for @@ -31,23 +33,23 @@ writing advanced documents. . .h How is the source code of -.x mg +.x µ organized? .p If you run .c "grep -n [-]-" on the -.i g.tmac +.i u.tmac source file, you are presented with an overview of -.i mg 's +.i µ 's macros: .l .eo -!grep -n [-]- g.tmac +!grep -n [-]- u.tmac .ec .p This is a sufficient summary of the entire -.i mg +.i µ source code, as nothing is performed outside of these macros. All initialization is performed in the .c @a @@ -55,12 +57,12 @@ macro, which is automatically called at the first invocation of any other macro. .p The above summary reflects a categorization in the macros defined by -.i mg . +.i µ . There are internal and external macros. The former are to be used within -.i g.tmac +.i u.tmac itself, while the latter are to be used in -.i mg +.i µ documents. Among the external macros, there are inline, environment (or block-level), hybrid and other macros. @@ -90,7 +92,7 @@ Where is document state stored? .p Most state is stored by troff itself within the different environments. In addition, -.i mg +.i µ associates three extra registers with each environment: .c sp , the amount of space to be added by @@ -158,5 +160,5 @@ contains the total number of collected footnotes. .p Note that none of these registers and strings should be directly accessed or modified by -.i mg +.i µ documents. diff --git a/t/Makefile b/t/Makefile index 49eaac5..08c7543 100644 --- a/t/Makefile +++ b/t/Makefile @@ -6,13 +6,13 @@ PDFROFF ?= troff | dpost | ps2pdf - all: $(TEST) -g.tmac: ../g.tmac - cp g.tmac g.tmac.orig - grep -v '^\. *w ' ../g.tmac > g.tmac +u.tmac: ../u.tmac + cp u.tmac u.tmac.orig + grep -v '^\. *w ' ../u.tmac > u.tmac -.t.T: g.tmac t.tmac +.t.T: u.tmac t.tmac @echo -- $< ----------------------- @<$< $(TROFF) >/dev/null -.t.pdf: g.tmac t.tmac +.t.pdf: u.tmac t.tmac <$< $(PDFROFF) > $@ diff --git a/t/ne.t b/t/ne.t index f0434ae..3665099 100644 --- a/t/ne.t +++ b/t/ne.t @@ -1,4 +1,4 @@ -.so g.tmac +.so u.tmac .so t.tmac . .nr mb 1i diff --git a/toc/README.t b/toc/README.t index b561486..62cebaa 100644 --- a/toc/README.t +++ b/toc/README.t @@ -1,5 +1,5 @@ -.so ../g.tmac -.so ../gx.tmac +.so ../u.tmac +.so ../ux.tmac .so toc.tmac . .t diff --git a/u.tmac b/u.tmac new file mode 100644 index 0000000..52bfbab --- /dev/null +++ b/u.tmac @@ -0,0 +1,422 @@ +.\" "/. +.\" mu macro package for troff "/. +.\" created by John Ankarström "/. +.\" "/. +.\" Permission to use, copy, modify and/or "/. +.\" distribute this software for any purpose "/. +.\" with or without fee is hereby granted. "/. +.\" "/. +.\" For an index of the macros defined in "/. +.\" this file, issue `grep -n [-]- u.tmac'. "/. +.\" "/. +.\" When editing the source of mu, keep the "/. +.\" following rules in mind: "/. +.\" "/. +.\" * Prefix temporary strings and registers "/. +.\" with _. "/. +.\" * Prefix internal registers and environ- "/. +.\" ments with @. "/. +.\" * Prefix internal macros with @ (normal "/. +.\" macros), * (variants of the same "/. +.\" macro) or % (strings). "/. +.\" * Place macros in alphabetical order. "/. +.\" * Do not use .ev and .evc directly; use "/. +.\" (e, @e and @c instead. "/. +.\" "/. +. +.do xflag 3 \" enable modern extensions +.eo \" disable backslash escapes +. +.\" Internal macros ---------------------------- +. +.\" @a -- setup document +.de @a +. nr @a 1 +. +. \" set header/footer traps +. wh 0 @th +. em @tf +. if \n(nl<=0 .@th +. nr _ \n(.p-\n(nl +. if \n(.t=\n_ .wh -1i @tf +. +. \" configure environments +. @e d \" date +. @c 0 +. nr sp 0.4v +. ad c +. @e h \" heading +. @c 0 +. nr sp 1.2v +. ps +1p +. ft B +. @e l \" literal display +. @c 0 +. nr sp 0.3v +. nf +. in 18p +. ft CR +. ps -1p +. vs -1p +. @e n \" name (of author) +. @c 0 +. nr sp 0.4v +. ad c +. @e p \" paragraph +. @c 0 +. nr sp 0.3v +. nr ti 18p +. ad b +. @e q \" quotation +. @c 0 +. nr sp 0.3v +. nr ti 18p +. in 18p +. ps -1p +. vs -1p +. @e s \" section heading +. @c 0 +. nr sp 1v +. ft B +. @e t \" title +. @c 0 +. ps +4p +. vs +2p +. ft B +. ad c +. @e +. +. \" configure special environments +. (e @f \" footnote +. @c 0 +. ps -2p +. vs -1p +. (e @m \" margins (header, footer) +. @c 0 +. (e +. +. \" create formatted dates +. af mo 00 +. af dy 00 +. ds #i \n[year]-\n(mo-\n(dy +. af mo 1 +. af dy 1 +. ds #e \n(dy +. ie \n(mo=1 .ds #e \*(%e January +. el .ie \n(mo=2 .ds #e \*(#e February +. el .ie \n(mo=3 .ds #e \*(#e March +. el .ie \n(mo=4 .ds #e \*(#e April +. el .ie \n(mo=5 .ds #e \*(#e May +. el .ie \n(mo=6 .ds #e \*(#e June +. el .ie \n(mo=7 .ds #e \*(#e July +. el .ie \n(mo=8 .ds #e \*(#e August +. el .ie \n(mo=9 .ds #e \*(#e September +. el .ie \n(mo=10 .ds #e \*(#e October +. el .ie \n(mo=11 .ds #e \*(#e November +. el .ds #e \*(#e December +. ds #e \*(#e \n[year] +.. +. +.\" @c -- copy environment +.de @c +. evc \$1 +. nr sp \n[@\$1_sp] +. nr sq \n[@\$1_sq] +. nr ti \n[@\$1_ti] +.. +. +.\" (e -- set environment +.de (e +. ev \$1 +.. +. +.\" @e -- set extended environment +.de @e +. +. \" initialize document if not initialized +. if '\n(@a'0' .@a +. +. \" save special environment variables +. if !'\n[.ev]'0' \{\ +. nr @\n[.ev]_sp \n(sp \" vertical space before any environment +. nr @\n[.ev]_sq \n(sq \" vertical space before different environment +. nr @\n[.ev]_ti \n(ti \" first line indentation +. ev +. \} +. +. \" keep track of previous and new environment +. ds %penv \*[%env] +. ds %env \$1 +. +. \" post-environment operations +. if !'\$1'' \{\ +. \" add small space after title +. if '\*[%penv]'t' .if '\*[%env]'d' .sp 0.1v +. +. \" add space after title block +. nr _ 0 +. if !'\*[%env]'d' .nr _ 1 +. if !'\*[%penv]'t' .if !'\*[%penv]'d' .nr _ 0 +. if \n_ \{\ +. sp 0.5i +. ns +. \} +. +. \" activate new environment +. ev \$1 +. nr sp \n[@\n[.ev]_sp] +. nr sq \n[@\n[.ev]_sq] +. nr ti \n[@\n[.ev]_ti] +. sp \n(spu +. if !'\*[%env]'\*[%penv]' .sp \n(squ +. \} +.. +. +.\" @f -- footer +.de @f +. sp |\n(.pu-48p +. tl ''%'' +.. +. +.\" @h -- header +.de @h +. sp |36p +. tl '''' +. sp |1i +.. +. +.\" @tf -- footer trap +.de @tf +. +. \" skip automatic trigger if manual mode active, unless forced +. if \n(@m>0 .if !'\$1'f' \{\ +. nr @m -1 +. return +. \} +. +. \" print footer +. br +. (e @m +. @f +' bp +.. +. +.\" @th -- header trap +.de @th +. (e @m +. rt 0 +. @h +. (e \*[%env] +. ns +.. +. +.\" @tn -- footnote trap +.de @tn +. +. nr @m 1 +. \" print collected footnotes +. (e @m +___________________ +. br +. sp 1p +. (e @f +. +. \" escape control characters +. char . \&. +. char ' \&' +. +. @n +. br +. +. \" restore control characters +. char . . +. char ' ' +. +. \" clear footnotes +. ch @tn +. nr @.t 0 +. nr @dn 0 +. rm @n +. @tf f +.. +. +. +.\" Inline macros ------------------------------ +. +.\" b -- bold font +.de b +\&\$3\fB\$1\fP\$2 +.. +. +.\" c -- constant-width font +.de c +. +. \" save original interword spacing +. nr _ss \n[.ss] +. +. \" copy family and (relative) point size from l environment +. (e 0 +. nr _s0 \n(.s +. (e +. (e l +. ds _fl \n(.f +. nr _sl \n(.s +. (e +. +\&\$3\c +. ft \*[_fl] +. ss 7 +. ie d nrf .nrf _s (\n(.s*(\n[_sl]/(\n[_s0]))) +. el .nr _s \n(.s+(\n[_sl]-\n[_s0]) +. ps \n(_sp +\&\$1\c +. ft +. ss \n[_ss] +. ps +\&\$2 +.. +. +.\" i -- italic font +.de i +\&\$3\fI\$1\fP\$2 +.. +. +.\" x -- bold italic font +.de x +\&\$3\f(BI\$1\fP\$2 +.. +. +. +.\" Hybrid macros ------------------------------ +. +.\" q -- quotation +.de q +. +. \" inline +. ie !'\$1'' \&\$3\(lq\$1\(rq\$2 +. +. \" block +. el \{\ +. br +. @e q +. ti \n(tiu +. \} +.. +. +. +.\" Environment macros ------------------------- +. +. +.\" d -- centered date +.de d +. br +. @e d +. if !'\$1'' \*[#\$1] +.. +. +.\" h -- heading +.de h +. br +. w h p +. @e h +. +.. +.\" l -- literal display +.de l +. br +. w ll +. @e l +.. +. +.\" p -- paragraph +.de p +. br +. @e p +. if '\*[%penv]'p' .ti \n(tiu +.. +. +.\" s -- subheading +.de s +. br +. w s p +. @e s +.. +. +.\" t -- centered title +.de t +. br +. @e t +.. +. +. +.\" Other macros ------------------------------- +. +.\" ( -- begin footnote +.de ( +. if !'\$1'' \&\$1\c +. +. \" increment and print number +. nr @n \n(@n+1 +\v'-.3m'\s'\En(.s*80/100'\n(@n\s0\v'.3m'\c +. +. \" switch environment and capture footnote +. (e @f +. boxa @n +\h'9p'\v'-.3m'\s'\En(.s*80/100'\n(@n\s0\v'.3m'\h'2p'\c +.. +. +.\" ) -- end footnote +.de ) +. br +\!.br +. boxa +. (e \*[%env] +. ie !'\$1'' \&\$1 +. el \& +. +. \" get position of footer (or next trap) +. if \n[@.t]=0 .nr @.t \n(nl+\n(.t +. +. +. \" print footnote at bottom of page +. ch @tn +. nr @dn +\n(dnu +. nr _tn \n[@.t]u-\n[@dn]u-12p +. wh \n[_tn]u @tn +.. +. +.\" w -- want space +.de w +. *w 0 \$@ +.. +.de *w +. +. \" parse specification -> _s : accumulated space +. nr _s \$1 \" _e : environment name (e.g. eee -> e) +. ds _e \$2 \" _n : number of lines specified (e.g. eee -> 3) +. substring _e 0 0 +. length _n \$2 +. +. \" add environment spacing +. nr _s +\n[@\*(_e_sp] +. nr _s +\n[@\*(_e_sq] +. +. \" add environment line height (for each line) +. (e \*(_e +. nr _v \n(.v +. (e +. nr _s +(\n(_n*\n(_v) +. shift 2 +. +. \" recurse or request space if done +. ie \n(.$>0 .*w \n(_s \$@ +. el \{\ +. nr _s \n(_s-\n(_v+1u \" do not request too much +. if (\n(_su)>\n(.tu \{\ +. br +. bp +. \} +. \} +.. +. +.ec \" re-enable backslash escapes diff --git a/ux.tmac b/ux.tmac new file mode 100644 index 0000000..caace60 --- /dev/null +++ b/ux.tmac @@ -0,0 +1,61 @@ +.\" "/. +.\" extra stuff for mu "/. +.\" "/. +.\" Permission to use, copy, modify and/or "/. +.\" distribute this software for any purpose "/. +.\" with or without fee is hereby granted. "/. +.\" "/. +. +.eo +. +.\" he -- toc-enabled heading +.de he +. h +\$* +. te .the \n% \$* +.. +. +.\" se -- toc-enabled subheading +.de se +. s +\$* +. te .the \n% \\h'18p'\$* +.. +. +.\" the -- toc entry +.de the +. nr _ \$1 +. shift +. ta \n(.luR +. tc . +\$* \n_ +. tc +. br +.. +. +.\" n -- numbered list item +.de n +. if !'\$1'' \{\ +. nr ni \$1-1 +. af ni 0 +. if !'\$2'' .af ni \$2 +. ds n. . +. if !'\$3'' .ds n. \$3 +. \} +. nr ni +1 +. br +. @e n +. ti \n(tiu +\n(ni\*(n. \c +.. +. +.am @a +. @e n +. @c p +. nr sq \n(sp +. nr sp 0 +. ta 3n +3n +3n +3n +. @e +.. +. +.ec -- cgit v1.2.3