From f702e46e23302bba7ad3286d0ca273863ada380d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 19 Jun 2021 20:15:09 +0200 Subject: Have c copy font family and point size from l environment --- example.t | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ g.tmac | 19 ++++--- 2 files changed, 178 insertions(+), 23 deletions(-) diff --git a/example.t b/example.t index 5f9789f..84e65ec 100644 --- a/example.t +++ b/example.t @@ -1,27 +1,43 @@ .so g.tmac -.p -.ta 3n +3n +3n +3n +. +. _e p +. nr sq \n(sp +. nr sp 0 +. _e +. +._e e +. _ec p +. ta 3n +3n +3n +3n +._e +. +.de e +. nr ei \\$1+1 +. br +. _e e +. ti \n(tiu +\\n(ei. \c +.. +. .t .x Mg , a simple macro package for troff .n John Ankarstr\[u00F6]m .d +. +. .h Introduction .p .i Mg is a simple macro package for troff with the following features: -.p -1. \c +.e 0 It is designed to be easy to understand and to customize by editing the source code. -.p -2. \c +.e It makes use of the extended support for environments offered by many modern troff implementations. -.p -3. \c +.e It is designed to be practically easy to use. Macros are consistently one letter long and written in lowercase. .p @@ -35,8 +51,9 @@ Users of .i mg are encouraged to modify the source code according to their own needs. -.s -Internal design +. +.h +Environments .p .i Mg makes heavy use of named environments, @@ -92,14 +109,147 @@ First paragraph. In addition to the normal environment-relevant settings, .i mg manually associates a few special registers with the current environment: -.p -1. \c +.e 0 .c sp , -the amount of vertical space to add before environment. -.p -2. \c +the amount of vertical space to add before an environment +.e +.c sq , +the amount of vertical space to add before a different type of environment +.e .c ti , -the indentation of the first line in the environment. +the indentation of the first line in some environments +(currently only +.c p ) .p These can be set inside a given environment to control its behavior when invoked. +The only exception is the footnote environment +.c _f ), ( +which is treated specially +and does not support these registers. +. +. +.h +Macros +. +.p +.i Mg +defines a number of macros. +Some of them are used internally by +.i mg +itself; +these carry an underscore prefix +and are not explained here. +The rest provide useful features, +like headings, subheadings and paragraphs. +.s +Inline macros +.p +There is a group of macros that provide +convenient inline formatting. +All take three arguments: +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 +.c b , +bold font +.e +.c c , +constant-width font +.e +.c i , +italic font +.e +.c i , +bold italic font +.p +For example, the following request outputs +.i mg .\(rq: \(lq +.l +\&.i mg . +. +.p +Note that +.c c +uses the font family and point size +set in the +.c l +environment (see below). +.s +Block-level macros +.p +There is a large group of macros that provide +block-level formatting: +.e 0 +.c d , +centered date (or given string) +.e +.c h , +heading +.e +.c l , +literal display (for source code) +.e +.c n , +centered name of author +.e +.c p , +paragraph +.e +.c s , +subheading +.e +.c t , +centered title of document +. +.s +Other macros +.p +Finally, there are a few macros +that belong to neither category. +.e 0 +.c q , +quotation +.e +.c ( , +begin footnote +.e +.c ) , +end footnote +.p +By default, +.c q +behaves like an inline macro, +surrounding text in quotation marks, +but if no arguments are given to it, +it starts an indented block quotation instead. +.p +The footnote macros are used like this\c +.( +Note that +.c ( +and +.c ) +take an optional argument, +which is output immediately before or after +the footnote number. +.) : +.l +.eo +.cc , +a line of text\c +.( +a footnote +.) . +,cc +.ec +.p +Note that +.i mg +does not account for cases where a footnote, because of its height, +pushes the place where it is referenced to the next page. +In such cases, the reference will simply appear on the page +following the footnote. +When this happens, the user must account for it manually. diff --git a/g.tmac b/g.tmac index 6461c60..bb7e2cd 100644 --- a/g.tmac +++ b/g.tmac @@ -25,8 +25,6 @@ . \" configure initial options . _nr mt 1i \" margin top . _nr mb 1i \" margin bottom -. _ds cfam C \" inline constant-width font family -. _ds cps -1p \" inline constant-width font size . . \" initialize document . wh 0 _ht @@ -48,7 +46,7 @@ . _ec 0 . nr sp 0.3v . nf -. in 0.5c +. in 18p . fam C . ps -1p . vs -1p @@ -59,13 +57,13 @@ . _e p \" paragraph . _ec 0 . nr sp 0.3v -. nr ti 0.5c +. nr ti 18p . ad b . _e q \" quotation . _ec 0 . nr sp 0.3v . nr ti 1c -. in 0.5c +. in 18p . ps -1p . vs -1p . _e s \" section heading @@ -217,9 +215,16 @@ ___________________ . .\" c -- constant-width font .de c +. +. \" copy family and point size from l environment +. _E l +. ds _fam \n[.fam] +. nr _s \n(.s +. _E +. \$3\c -. fam \*[cfam] -. ps \*[cps] +. fam \*[_fam] +. ps \n(_s \$1\c . fam . ps -- cgit v1.2.3