From 527c3f98d5d64e8d0d435438448248284fe01413 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Tue, 18 Jan 2022 18:33:31 +0100 Subject: [PATCH] new macros, small pic fix on gravitational lensing, troffrc --- Makefile.in | 11 +- bin/troffrc | 69 +++++++ macros.ms | 172 ++++++++++++++---- ...mic-mystery-story_weighing-the-universe.ms | 2 + universe-from-nothing/preface.ms | 2 +- 5 files changed, 217 insertions(+), 39 deletions(-) create mode 100644 bin/troffrc diff --git a/Makefile.in b/Makefile.in index 366d6e8..854f7aa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -21,7 +21,7 @@ EQN = eqn $(EQN_OPTS) # GH_OUTRO: ------------ after ---- ------ ---- -------- -- ---------------- # GH_INTRO/GH_OUTRO: values are separated by ';' # -GH_INTRO := .b1;.nr DI 0;.DS I;.fam C +GH_INTRO := .b1;.nr DI 0;.DS I;.fam FiraCode GH_OUTRO := .fam;.DE;.b2 # export GH_INTRO @@ -53,7 +53,14 @@ REFER = refer $(REFER_OPTS) # -U => unsafe (because of PDF inclusion) # -Tpdf => output device is PDF # -mspdf => include PDF (so, images converted in PDF) in the document -GROFF_OPTS ?= -ms -t -Tpdf -U -mspdf -mpdfmark -M ~/ +# NOTE: a custom troffrc (configuration file) is necessary on OpenBSD +# to have correctly justified paragraphs. Otherwise, the default +# configuration removes this possibility, for bullshit reasons. Sad. +# -M dir => path to custom troffrc +# TODO: no change with or without the following options -P -e +# This has to be inverstigated: how to make PDFs look nice in browsers? +# -P -e => provide "-e" to gropdf to embed fonts +GROFF_OPTS ?= -ms -t -Tpdf -U -mspdf -mpdfmark -M ./bin -P -e GROFF = groff $(GROFF_OPTS) $(SRC).pdf: diff --git a/bin/troffrc b/bin/troffrc new file mode 100644 index 0000000..8624241 --- /dev/null +++ b/bin/troffrc @@ -0,0 +1,69 @@ +.\" Startup file for troff. +. +.\" This is tested by pic. +.nr 0p 0 +. +.\" Load composite mappings. +.do mso composite.tmac +. +.\" Load generic fallback mappings. +.do mso fallbacks.tmac +. +.\" Use .do here, so that it works with -C. +.\" The groff command defines the .X string if the -X option was given. +.ie r.X .do ds troffrc!ps Xps.tmac +.el .do ds troffrc!ps ps.tmac +.do ds troffrc!pdf pdf.tmac +.do ds troffrc!dvi dvi.tmac +.do ds troffrc!X75 X.tmac +.do ds troffrc!X75-12 X.tmac +.do ds troffrc!X100 X.tmac +.do ds troffrc!X100-12 X.tmac +.do ds troffrc!ascii tty.tmac +.do ds troffrc!latin1 tty.tmac +.do ds troffrc!utf8 tty.tmac +.do ds troffrc!cp1047 tty.tmac +.do ds troffrc!lj4 lj4.tmac +.do ds troffrc!lbp lbp.tmac +.do ds troffrc!html html.tmac +.do if d troffrc!\*[.T] \ +. do mso \*[troffrc!\*[.T]] +.do rm troffrc!ps troffrc!Xps troffrc!dvi troffrc!X75 troffrc!X75-12 \ +troffrc!X100 troffrc!X100-12 troffrc!lj4 troff!lbp troffrc!html troffrc!pdf +. +.\" Test whether we work under EBCDIC and map the no-breakable space +.\" character accordingly. +.do ie '\[char97]'a' \ +. do tr \[char160]\~ +.el \ +. do tr \[char65]\~ +. +.\" Set the hyphenation language to 'us'. +.do hla us +. +.\" Disable hyphenation: +.\" Do not load hyphenation patterns and exceptions. +.\"do hpf hyphen.us +.\"do hpfa hyphenex.us +. +.\" Disable adjustment by default, +.\" such that manuals look similar with groff and mandoc(1). +.\".ad l +.\".de ad +.\".. +.\" Handle paper formats. +.do mso papersize.tmac +. +.\" Handle PS images. +.do mso pspic.tmac +.do mso pdfpic.tmac +. +.\" ==================================================================== +.\" Editor settings +.\" ==================================================================== +. +.\" Local Variables: +.\" mode: nroff +.\" fill-column: 72 +.\" End: +.\" vim: set filetype=groff textwidth=72: diff --git a/macros.ms b/macros.ms index 143862d..5f482c5 100644 --- a/macros.ms +++ b/macros.ms @@ -17,12 +17,37 @@ accumulate .defcolor darkgreen rgb 0.1 0.5 0.2 .defcolor darkblue rgb 0.3 0.3 0.7 .defcolor darkred rgb 0.7 0.3 0.3 +.defcolor black rgb 0 0 0 . +. \" with semantic .defcolor citation rgb 0.4 0.4 0.4 .defcolor citationbar rgb 0.3 0.3 0.7 .defcolor explanation rgb 0.7 0.4 0.4 .defcolor explanationbar rgb 0.8 0.3 0.3 . +.defcolor specialcolor_type rgb 0.6 0.3 0.5 +.defcolor specialcolor_constructor rgb 0.1 0.5 0.2 +.defcolor specialcolor_module rgb 0.1 0.5 0.2 +.defcolor specialcolor_function rgb 0.4 0.4 0.7 +.defcolor specialcolor_question rgb 0.0 0.0 0.7 +.defcolor specialcolor_shine rgb 0.3 0.3 0.7 +. +. \" SIZES +.nr specialsize_type 8 +.nr specialsize_constructor 8 +.nr specialsize_module 8 +.nr specialsize_function 8 +.nr specialsize_question 10 \" Current point size, no change. +.nr specialsize_shine 11 +. +. \" FONTS +.ds specialfont_type CW +.ds specialfont_constructor CW +.ds specialfont_module CW +.ds specialfont_function I +.ds specialfont_question I +.ds specialfont_shine B +. . .de BELLOWEXPLANATION1 .sp 0.5 @@ -76,16 +101,26 @@ accumulate .in +1 \" indent a bit .gcolor citation .. +.ig + The CITATION2 macro closes the quote then draws a line + from current line to the start of the quote. +.. .de CITATION2 .mk D \" set second marker to come back here .ft \" back to previous font .in -1 \" remove indent .gcolor \" remove previous color .gcolor citationbar -\r\L'|\\nCu' \" draw line (\r moves upward, \L draw the line, ...) +.\" r = move upward +.\" Z D t = drawing thickness +.\" L = draw the line +\r\ +\Z'\D't 1p''\ +\L'|\\nCu' \" draw line (\r moves upward, \L draw the line, ...) .sp '|\\nDu' \" return to the second marker .gcolor \" remove previous color -.sp -2 \" get two lines back +.sp -3 \" get three lines back +\Z'\D't'' \" get the previous drawing thickness back .KE \" end of the keep .. . @@ -131,16 +166,43 @@ accumulate \v'-.7m\s[\\n(.s*6u/10u]+.7m'\\$1\v'-.7m\s0+.7m'\ \(f/\s[\\n(.s*6u/10u]\\$2\s0 .. +.de FOOTNOTE_TO_COLUMN_WIDTH +.nr pg@fn-colw \\n[pg@colw] \" footnotes' column width +.. .de SINGLE_COLUMN .1C -.nr pg@fn-colw \\n[pg@colw] \" footnotes' column width +.FOOTNOTE_TO_COLUMN_WIDTH .. .de TWO_COLUMNS .2C -.nr pg@fn-colw \\n[pg@colw] \" footnotes' column width +.FOOTNOTE_TO_COLUMN_WIDTH .. .de HORIZONTALLINE \l'15' +.FOOTNOTE_TO_COLUMN_WIDTH +.. +. +. \" Fonts and colors. +. +.de SPECIAL_WORDS +.nr current_size \\n[.s] \" Current point size. +.gcolor specialcolor_\\*[truc] +. +.if !((\\n[current_size] == \\n[specialsize_\\*[truc]]) \ +.ps \\n[specialsize_\\*[truc]] +. +.ie '\\$2'' \{\ +\f[\\*[specialfont_\\*[truc]]]\\$1\f[] +. ps \\n[current_size] +. gcolor black \" FIXME: should be the previous color +.ev +\} +.el \{\ +\f[\\*[specialfont_\\*[truc]]]\\$1\f[]\c +. ps \\n[current_size] +. gcolor black \" FIXME: should be the previous color +\\$2 +\} .. .de SMALLFONT .ps 8 @@ -157,57 +219,43 @@ accumulate .b2 .. .de COMMANDNAME -.I "\\$1" -.. -.de FUNCTION .I "\\$1" "\\$2" .. -.de TYPE -.gcolor darkgreen -.ps 8 -.ft CW -\\$1 -.ft R +.de FUNCTION +.gcolor color_function +\f[CW]\\$1\f[]\c .gcolor -.ps +\\$2 +.. +.de TYPE +.ds truc type +.SPECIAL_WORDS "\\$1" "\\$2" .. .de TYPECLASS .I "\\$1" "\\$2" .. .de OPERATOR -.I "\\$1" "\\$2" +\f[CW]\\$1\f[]\\$2 .. .de QUESTION -.I "\\$1" "\\$2" +.ds truc question +.SPECIAL_WORDS "\\$1" "\\$2" \h'5p' .. .de CONSTRUCTOR -.gcolor darkred -.ps 8 -.ft CW -\\$1 -.ft R -.gcolor -.ps +.ds truc constructor +.SPECIAL_WORDS "\\$1" "\\$2" .. .de MODULE -.gcolor darkblue -.ps 8 -.ft CW -\\$1 -.ft R -.gcolor -.ps +.ds truc module +.SPECIAL_WORDS "\\$1" "\\$2" .. .de SHINE -.gcolor darkblue -.ft B -\\$1 -.ft R -.gcolor +.ds truc shine +.SPECIAL_WORDS "\\$1" "\\$2" .. .de MODULEX -.MODULE "\\$1," +.MODULE \\$1 , .. .de TBD .ft B @@ -264,27 +312,50 @@ Compilé pour la dernière fois le . .de SECTION .NH +.ps +3 +.fam H \" helvetica family \\$* +.fam \" back to previous font family +.ps +.PARAGRAPH_INDENTED .. .de SUBSECTION .NH 2 +.ps +1 +.fam H \" helvetica family \\$* +.fam \" back to previous font family +.ps +.PARAGRAPH_INDENTED .. .de SUBSUBSECTION .NH 3 +.fam H \" helvetica family \\$* +.fam \" back to previous font family +.ps +.PARAGRAPH_INDENTED .. .de SUBSUBSUBSECTION .NH 4 +.fam H \" helvetica family \\$* +.fam \" back to previous font family +.PARAGRAPH_INDENTED .. .de SECTION_NO_NUMBER .SH +.fam H \" helvetica family \\$* +.fam \" back to previous font family +.PARAGRAPH_INDENTED .. .de SUBSECTION_NO_NUMBER .SH 2 +.fam H \" helvetica family \\$* +.fam \" back to previous font family +.PARAGRAPH_INDENTED .. .de PARAGRAPH_INDENTED .PP @@ -326,3 +397,32 @@ Compilé pour la dernière fois le .de VOCABULARY2 .KE .. + + +.\".nr G 0 1 \" numéro des notes +.\".de NOTE1 +.\".\" macro NOTE1 commence les notes +.\"(\\n+G) +.\". ev 1 \" ouvre un environnement dédié aux notes +.\". br \" casse le flux +.\". da print \" divertit le flux vers print +.\". sp \" espace +.\"\\nx) +.\".. +.\".de NOTE2 +.\".\" macro NOTE2 ferme les notes +.\". br \" casse le flux +.\". di \" ferme la diversion +.\". ev \" sort de l'environnement +.\".. +.\".de end +.\".\" macro appellée à la fin du document +.\". br +.\". ev 1 \" en retourne dans l'environnement des notes +.\". print \" execute le contenu de la diversion +.\". br +.\". ev +.\". pl \\n(nlu \" ajuste la taille de la page au nombre de lignes +.\".. +.\".\" définit la macro .end comme macro de fin de document: +.\".\" .em end diff --git a/universe-from-nothing/ch2_a-cosmic-mystery-story_weighing-the-universe.ms b/universe-from-nothing/ch2_a-cosmic-mystery-story_weighing-the-universe.ms index 81a805e..4d36e0e 100644 --- a/universe-from-nothing/ch2_a-cosmic-mystery-story_weighing-the-universe.ms +++ b/universe-from-nothing/ch2_a-cosmic-mystery-story_weighing-the-universe.ms @@ -186,6 +186,7 @@ Stay tuned, kids! .ft H .PS .ps 7 +.vs 9p reset scale = 1.4 mag_massive_obj_x = 1.4 @@ -218,6 +219,7 @@ spline -> from TARGET to MASSIVE_OBJECT.e + (rad_massive_obj-rad_correction,0) t spline -> from TARGET to MASSIVE_OBJECT.w + (-rad_massive_obj+rad_correction,0) to OBSERVER chop rad_dist chop rad_obs . move to TARGET + (0,-0.7) +.vs .ps 14 "Gravitational lensing" .PE diff --git a/universe-from-nothing/preface.ms b/universe-from-nothing/preface.ms index eefe63e..ea4698b 100644 --- a/universe-from-nothing/preface.ms +++ b/universe-from-nothing/preface.ms @@ -1,4 +1,4 @@ -.SECTION Preface +.SECTION_NO_NUMBER Preface .PARAGRAPH_INDENTED The preface is about what simplistic ideas we have of the creation of the universe, mostly religious ones. Religion argues for an infinite regression that could only be solved by some magic being that conveniently appears to be