aboutsummaryrefslogtreecommitdiff
path: root/example.t
blob: d192f866a1c5c0f9dd99091c1570cab4f335555e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
.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
.
.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:
.e 0
It is designed to be easy to understand and to customize
by editing the source code.
.e
It makes use of the extended support for environments
offered by many modern troff implementations.
.e
It is designed to be practically easy to use.
Macros are consistently one letter long and written in lowercase.
.p
While
.i mg
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
are encouraged to
.e 0
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.
.
.h
Environments
.p
.i Mg
makes heavy use of named environments,
supported by implementations such as GNU troff and Neatroff.
Environments obliviate the need for many special registers
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
register.
.i Mg ,
on the other hand,
simply sets the font size inside the environment named
.i p
(for paragraph).
If the user wishes to modify the default font size,
he or she can simply switch to the
.i p
environment and set the font size as desired:
.l
.eo
.cc ,
.\" set heading font
.h
.fam H
.ps +1p
,cc
.ec
.p
The environments are initialized
as soon as the first
.q block-level
macro is called.
At the initialization of each environment,
the default environment (0) is copied,
meaning that all environment-relevant settings
defined before the first macro call
are applied to all
.i mg
environments.
It is thus remarkably simple and intuitive to set,
for example, the default font of a document:
.l
.cc ,
.fam N
.t
Document title
.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
.c sp ,
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 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
Global variables
.p
Thanks to the reliance on environments,
there are only two global variables
controlling the state of
.i mg :
.e 0
.c mt ,
the margin at the beginning of the page
.e
.c mb ,
the margin at the end of the page
.
.h
External 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 going to be explored later.
For now, we will focus on the external macros provided by
.i mg .
.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:
.l
.cc ,
.q
This is an indented quotation.
.p
This is an inline
.q quotation .
,cc
.p
The footnote macros
.c (
and
.c )
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 ,
.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,
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.
.
.h
Internal macros
.p
.i Mg 's
internal macros are generally not meant to be used outside of
.i g.tmac .
The exception to this rule is
.c _E ,
.c _e
and
.c _ec ,
which are a group of macros controlling the environment,
as it may be desirable to define custom environments
for advanced documents.