From 1419e33327a243e6df5cc80e3d07cfd2529957b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 20 Jun 2021 00:53:31 +0200 Subject: example.t: Improve e macro, remove cc, eo requests The cc and eo requests break mid-listing page breaks. --- example.t | 116 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/example.t b/example.t index d192f86..8546f4a 100644 --- a/example.t +++ b/example.t @@ -1,23 +1,32 @@ .so g.tmac . -. _e p -. nr sq \n(sp -. nr sp 0 -. _e l -. fam M -. vs +1p -._e e -. _ec p -. ta 3n +3n +3n +3n -._e -. +.eo .de e -. nr ei \\$1+1 +. if !'\$1'' \{\ +. nr ei \$1-1 +. af ei 0 +. if !'\$2'' .af ei \$2 +. ds e. . +. if !'\$3'' .ds e. \$3 +. \} +. nr ei +1 . br . _e e . ti \n(tiu -\\n(ei. \c +\n(ei\*(e. \c .. +.ec +. +._e p +._e l +. fam M +. vs +1p +._e e +. _ec p +. nr sq \n(sp +. nr sp 0 +. ta 3n +3n +3n +3n +._e . .t .x Mg , @@ -32,7 +41,7 @@ Introduction .p .i Mg is a simple macro package for troff with the following features: -.e 0 +.e 1 It is designed to be easy to understand and to customize by editing the source code. .e @@ -51,12 +60,25 @@ written to serve the author's personal needs. Users of .i mg are encouraged to -.e 0 +.e 1 a ) modify the source code according to their own needs, as well as .e -use standard troff requests for some things -that other packages provide custom macros for. +use built-in troff requests for some things +that other packages might provide custom macros for. +.p +All in all, +.i mg +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 +are explained. +The reader is encouraged to inspect the document's source code +in order to see how the macro package is used in practice. . .h Environments @@ -69,26 +91,22 @@ that a macro package (and its user) would need to keep track of. For example, .i ms keeps track of the document's font size in the -.i PS +.c PS register. .i Mg , on the other hand, simply sets the font size inside the environment named -.i p +.c p (for paragraph). If the user wishes to modify the default font size, he or she can simply switch to the -.i p +.c p environment and set the font size as desired: .l -.eo -.cc , -.\" set heading font -.h -.fam H -.ps +1p -,cc -.ec +\&.\\" set heading font +\&.h +\&.fam H +\&.ps +1p .p The environments are initialized as soon as the first @@ -104,18 +122,16 @@ environments. It is thus remarkably simple and intuitive to set, for example, the default font of a document: .l -.cc , -.fam N -.t +\&.fam N +\&.t Document title -.p +\&.p First paragraph. -,cc .p In addition to the normal environment-relevant settings, .i mg manually associates a few special registers with the current environment: -.e 0 +.e 1 .c sp , the amount of vertical space to add before an environment .e @@ -142,12 +158,12 @@ Thanks to the reliance on environments, there are only two global variables controlling the state of .i mg : -.e 0 +.e 1 .c mt , -the margin at the beginning of the page +the margin at the top of the page .e .c mb , -the margin at the end of the page +the margin at the bottom of the page . .h External macros @@ -172,7 +188,7 @@ the text to be formatted, the text to be placed immediately after and the text to be placed immediately before. The inline macros are the following: -.e 0 +.e 1 .c b , bold font .e @@ -202,7 +218,7 @@ Block-level macros .p There is a large group of macros that provide block-level formatting: -.e 0 +.e 1 .c d , centered date (or given string) .e @@ -229,7 +245,7 @@ Other macros .p Finally, there are a few macros that belong to neither category. -.e 0 +.e 1 .c q , quotation .e @@ -246,13 +262,11 @@ surrounding text in quotation marks, but if no arguments are given to it, it starts an indented block quotation instead: .l -.cc , -.q +\&.q This is an indented quotation. -.p +\&.p This is an inline -.q quotation . -,cc +\&.q quotation . .p The footnote macros .c ( @@ -269,15 +283,11 @@ which is output immediately before or after the footnote number. .) : .l -.eo -.cc , -.p -A line of text\c -.( +\&.p +A line of text\\c +\&.( A footnote. -.) . -,cc -.ec +\&.) . .p .i Mg does not account for cases where a footnote, because of its height, -- cgit v1.2.3