From e5511a9e7bf83f635fcceb92172e8195253f0974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 19 Jun 2021 14:51:45 +0200 Subject: Add footnotes --- g.tmac | 171 ++++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 50 deletions(-) diff --git a/g.tmac b/g.tmac index ae86c64..091d246 100644 --- a/g.tmac +++ b/g.tmac @@ -11,6 +11,9 @@ .\" "/. .\" Place new macros in alphabetical order. "/. .\" "/. +.\" Do not use .ev and .evc outside wrapper "/. +.\" macros like _e. "/. +.\" "/. . .eo \" disable backslash escapes . @@ -26,56 +29,63 @@ . _ds cps -1p \" inline constant-width font size . . \" initialize document -. wh 0 _h -. wh -\n(mbu _f -. sp 1u \" trigger header +. wh 0 _ht +. wh -\n(mbu _ft +. _ht \" trigger header . ns . . \" configure environments -. d \" date -. evc 0 +. _e d \" date +. _ec 0 . nr sp 0.4v . ad c -. h \" heading -. evc 0 +. _e h \" heading +. _ec 0 . nr sp 0.6v . ps +1p . ft B -. l \" literal display -. evc 0 +. _e l \" literal display +. _ec 0 . nr sp 0.3v . nf . in 0.5c . fam C . ps -1p . vs -1p -. n \" name (of author) -. evc 0 +. _e n \" name (of author) +. _ec 0 . nr sp 0.4v . ad c -. p \" paragraph -. evc 0 +. _e p \" paragraph +. _ec 0 . nr sp 0.3v . nr ti 0.5c . ad b -. q \" quotation -. evc 0 +. _e q \" quotation +. _ec 0 . nr sp 0.3v . nr ti 1c . in 0.5c . ps -1p . vs -1p -. s \" section heading -. evc 0 +. _e s \" section heading +. _ec 0 . nr sp 0.6v . ft B -. t \" title -. evc 0 +. _e t \" title +. _ec 0 . ps +4p . vs +2p . ft B . ad c . _e +. +. \" configure footnote environment +. _e _f \" footnote +. evc 0 +. ps -2p +. \" do not change vs! +. _e .. . .\" _ds -- set default string value @@ -92,8 +102,6 @@ . _a . \} . -. br -. . \" save special environment variables . if !'\n[.ev]'0' \{\ . nr \n[.ev]_sp \n(sp @@ -101,54 +109,77 @@ . ev . \} . +. \" parse arguments +. ds _nenv \$1 +. if '\$1'-silent' .ds _nenv \$2 +. . \" keep track of previous and new environment -. ds penv \*[env] -. ds env \$1 +. if '\$1'-silent' \{\ +. ds _penv \*[_env] +. ds _env \*[_nenv] +. \} . . \" activate new environment -. if !'\$1'' \{\ -. ev \$1 +. if !'\*[_nenv]'' \{\ +. ev \*[_nenv] . nr sp \n[\n[.ev]_sp] . nr ti \n[\n[.ev]_ti] . sp \n(spu . \} . -. \" perform post-environment operations -. _pe +. \" post-environment operations +. if '\*[_nenv]'' .return +. +. \" add small space after title +. if '\*[_penv]'t' \{\ +. if '\*[_env]'n' .sp 0.1v +. if '\*[_env]'d' .sp 0.1v +. \} +. +. \" add space after title/name/date +. if '\*[_env]'n' .return +. if '\*[_env]'d' .return +. ie '\*[_penv]'t' .sp 1v +. el .ie '\*[_penv]'n' .sp 1v +. el .if '\*[_penv]'d' .sp 1v +.. +. +. \" _ec -- copy environment +.de _ec +. evc 0 .. . -.\" _f -- page footer -.de _f -' sp 1v +.\" _ft -- footer trap +.de _ft +' sp 2v . tl ''%'' ' bp .. . -.\" _h -- page header -.de _h +.\" _ht -- header trap +.de _ht ' sp \n(mtu .. . -.\" _nr -- set default numeric value -.de _nr -. if \n[\$1]=0 .nr \$1 \$2 -.. +.\" _nt -- footnote trap +.de _nt . -.\" _pe -- post-environment operations -.de _pe +. \" print collected footnotes +___________________ +. br +. _n +. br . -. \" add small space after title -. if '\*[penv]'t' \{\ -. if '\*[env]'n' .sp 0.1v -. if '\*[env]'d' .sp 0.1v -. \} +. \" clear footnotes +. ch _nt +. nr _dn 0 +. box _n +. box +.. . -. \" add space after title/name/date -. if '\*[env]'n' .return -. if '\*[env]'d' .return -. ie '\*[penv]'t' .sp 1v -. el .ie '\*[penv]'n' .sp 1v -. el .if '\*[penv]'d' .sp 1v +.\" _nr -- set default numeric value +.de _nr +. if \n[\$1]=0 .nr \$1 \$2 .. . . @@ -191,6 +222,7 @@ . . \" block . el \{\ +. br . _e q . ti \n(tiu . \} @@ -202,6 +234,7 @@ . .\" d -- date .de d +. br . _e d . af mo 00 . af dy 00 @@ -212,32 +245,70 @@ .. .\" h -- heading .de h +. br . _e h . .. .\" l -- literal display .de l +. br . _e l .. .\" n -- name (of author) .de n +. br . _e n .. . .\" p -- paragraph .de p +. br . _e p -. if '\*[penv]'p' .ti \n(tiu +. if '\*[_penv]'p' .ti \n(tiu .. . .\" s -- section heading .de s +. br . _e s .. . .\" t -- 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 -silent _f +. boxa _n +\n(_n. +.. +. +.\" ) -- end footnote +.de ) +. br +\!.br +. boxa +. _e -silent +. ie !'\$1'' \&\$1 +. el \& +. +. \" print footnote at bottom of page +. nr _dn +\n(dnu +. ch _nt +. if !'\n(dn'0' .wh -\n[_dn]u-1i-1v _nt +.. +. .ec \" re-enable backslash escapes -- cgit v1.2.3