~ubuntu-branches/ubuntu/utopic/groff/utopic

« back to all changes in this revision

Viewing changes to .pc/mmse-note.patch/man/groff_tmac.man

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-06-30 03:09:27 UTC
  • Revision ID: package-import@ubuntu.com-20140630030927-1kvcmt170q69l6tp
Tags: 1.22.2-6
* Note that groff_mmse(7) is only available in Swedish locales (closes:
  #710431).
* Describe \- as a minus sign rather than a dash in /etc/groff/man.local
  and /etc/groff/mdoc.local (thanks, Bjarni Ingi Gislason; closes:
  #742086).
* Adjust debian/source/lintian-overrides to match Lintian's current output
  correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.ig
 
2
groff_tmac.5
 
3
 
 
4
File position: <groff-source>/man/groff_tmac.man
 
5
 
 
6
This file is part of groff, the GNU roff type-setting system.
 
7
 
 
8
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009
 
9
  Free Software Foundation, Inc.
 
10
written by Bernd Warken <groff-bernd.warken-72@web.de> and
 
11
Werner Lemberg <wl@gnu.org>
 
12
 
 
13
Permission is granted to copy, distribute and/or modify this document
 
14
under the terms of the GNU Free Documentation License, Version 1.3 or
 
15
any later version published by the Free Software Foundation; with the
 
16
Invariant Sections being this .ig-section and AUTHOR, with no
 
17
Front-Cover Texts, and with no Back-Cover Texts.
 
18
 
 
19
A copy of the Free Documentation License is included as a file called
 
20
FDL in the main directory of the groff source package.
 
21
..
 
22
.ig
 
23
A copy of the GNU Free Documentation License is also available in this
 
24
Debian package as /usr/share/doc/groff/copyright.
 
25
..
 
26
.ds Ellipsis \&.\|.\|.\&\"
 
27
.
 
28
.TH GROFF_TMAC @MAN5EXT@ "@MDATE@" "Groff Version @VERSION@"
 
29
.SH NAME
 
30
groff_tmac \- macro files in the roff typesetting system
 
31
.
 
32
.
 
33
.\" --------------------------------------------------------------------
 
34
.SH DESCRIPTION
 
35
.\" --------------------------------------------------------------------
 
36
.
 
37
The
 
38
.BR roff (@MAN7EXT@)
 
39
type-setting system provides a set of macro packages suitable for
 
40
special kinds of documents.
 
41
.
 
42
Each macro package stores its macros and definitions in a file called
 
43
the package's
 
44
.BR "tmac file" .
 
45
The name is deduced from
 
46
.RB ` T\c
 
47
.IB roff MAC\c
 
48
.IR ros '.
 
49
.
 
50
.P
 
51
The tmac files are normal roff source documents, except that they
 
52
usually contain only definitions and setup commands, but no text.
 
53
.
 
54
All tmac files are kept in a single or a small number of directories,
 
55
the
 
56
.B tmac
 
57
directories.
 
58
.
 
59
.
 
60
.\" --------------------------------------------------------------------
 
61
.SH "GROFF MACRO PACKAGES"
 
62
.\" --------------------------------------------------------------------
 
63
.
 
64
.I groff
 
65
provides all classical macro packages, some more full packages, and
 
66
some secondary packages for special purposes.
 
67
.
 
68
Note that it is not possible to use multiple primary macro packages at the
 
69
same time; saying e.g.\&
 
70
.
 
71
.IP
 
72
.EX
 
73
\fIsh#\fP groff \-m man \-m ms foo
 
74
.EE
 
75
.
 
76
.P
 
77
or
 
78
.
 
79
.IP
 
80
.EX
 
81
\fIsh#\fP groff \-m man foo \-m ms bar
 
82
.EE
 
83
.
 
84
.P
 
85
fails.
 
86
Exception to this is the use of man pages written with either the
 
87
.B mdoc
 
88
or the
 
89
.B man
 
90
macro package.
 
91
See below the description of the
 
92
.B andoc.tmac
 
93
file.
 
94
.
 
95
.
 
96
.\" --------------------------------------------------------------------
 
97
.SS "Man\~Pages"
 
98
.\" --------------------------------------------------------------------
 
99
.
 
100
.TP
 
101
.B man
 
102
This is the classical macro package for UNIX manual pages
 
103
(man\~pages); it is quite handy and easy to use; see
 
104
.BR groff_man (@MAN7EXT@).
 
105
.
 
106
.
 
107
.TP
 
108
.B doc
 
109
.TQ
 
110
.B mdoc
 
111
An alternative macro package for man\~pages mainly used in BSD
 
112
systems; it provides many new features, but it is not the standard for
 
113
man\~pages; see
 
114
.BR groff_mdoc (@MAN7EXT@).
 
115
.
 
116
.
 
117
.TP
 
118
.B andoc
 
119
.TQ
 
120
.B mandoc
 
121
Use this file in case you don't know whether the
 
122
.B man
 
123
macros or the
 
124
.B mdoc
 
125
package should be used.
 
126
Multiple man pages (in either format) can be handled.
 
127
.
 
128
.
 
129
.\" --------------------------------------------------------------------
 
130
.SS "Full Packages"
 
131
.\" --------------------------------------------------------------------
 
132
.
 
133
The packages in this section provide a complete set of macros for
 
134
writing documents of any kind, up to whole books.
 
135
.
 
136
They are similar in functionality; it is a matter of taste which one
 
137
to use.
 
138
.
 
139
.
 
140
.TP
 
141
.B me
 
142
The classical
 
143
.I me
 
144
macro package; see
 
145
.BR groff_me (@MAN7EXT@).
 
146
.
 
147
.
 
148
.TP
 
149
.B mm
 
150
The semi-classical
 
151
.I mm
 
152
macro package; see
 
153
.BR groff_mm (@MAN7EXT@).
 
154
.
 
155
.
 
156
.TP
 
157
.B mom
 
158
The new
 
159
.I mom
 
160
macro package, only available in groff.
 
161
.
 
162
As this is not based on other packages, it can be freely designed.
 
163
.
 
164
So it is expected to become quite a nice, modern macro package.
 
165
.
 
166
See
 
167
.BR groff_mom (@MAN7EXT@).
 
168
.
 
169
.
 
170
.TP
 
171
.B ms
 
172
The classical
 
173
.I ms
 
174
macro package; see
 
175
.BR groff_ms (@MAN7EXT@).
 
176
.
 
177
.
 
178
.\" --------------------------------------------------------------------
 
179
.SS "Language-specific Packages"
 
180
.\" --------------------------------------------------------------------
 
181
.
 
182
.TP
 
183
.B cs
 
184
This file adds support for Czech localization, including the main macro
 
185
packages (me, mom, mm, and ms).
 
186
.
 
187
.IP
 
188
Note that
 
189
.B cs.tmac
 
190
sets the input encoding to latin-2.
 
191
.
 
192
.
 
193
.TP
 
194
.B de
 
195
.TQ
 
196
.B den
 
197
German localization support, including the main macro packages (me, mom, mm,
 
198
and ms).
 
199
.
 
200
.IP
 
201
.B de.tmac
 
202
selects hyphenation patterns for traditional orthography, and
 
203
.B den.tmac
 
204
does the same for the new orthography (`Recht\%schreib\%reform').
 
205
.
 
206
It should be used as the last macro package on the command line.
 
207
.
 
208
.
 
209
.TP
 
210
.B fr
 
211
This file adds support for French localization, including the main macro
 
212
packages (me, mom, mm, and ms).
 
213
.
 
214
.
 
215
Example:
 
216
.RS
 
217
.IP
 
218
.EX
 
219
\fIsh#\fP groff -ms -mfr foo.ms > foo.ps
 
220
.EE
 
221
.RE
 
222
.
 
223
.IP
 
224
Note that
 
225
.B fr.tmac
 
226
sets the input encoding to latin-9 to get proper support of the `oe'
 
227
ligature.
 
228
.
 
229
.
 
230
.TP
 
231
.B sv
 
232
Swedish localization support, including the me, mom, and ms macro packages.
 
233
.
 
234
Note that Swedish for the mm macros is handled separately; see
 
235
.BR groff_mmse (@MAN7EXT@).
 
236
.
 
237
It should be used as the last macro package on the command line.
 
238
.
 
239
.
 
240
.\" --------------------------------------------------------------------
 
241
.SS "Input Encodings"
 
242
.\" --------------------------------------------------------------------
 
243
.
 
244
.
 
245
.TP
 
246
.B latin1
 
247
.TQ
 
248
.B latin2
 
249
.TQ
 
250
.B latin5
 
251
.TQ
 
252
.B latin9
 
253
Various input encodings supported directly by groff.
 
254
.
 
255
Normally, this macro is loaded at the very beginning of a document or
 
256
specified as the first macro argument on the command line.
 
257
.
 
258
.B @g@roff
 
259
loads latin1 by default at start-up.
 
260
.
 
261
Note that these macro packages don't work on EBCDIC hosts.
 
262
.
 
263
.
 
264
.TP
 
265
.B cp1047
 
266
Encoding support for EBCDIC.
 
267
.
 
268
On those platforms it is loaded automatically at start-up.
 
269
.
 
270
Due to different character ranges used in
 
271
.B @g@roff
 
272
it doesn't work on architectures which are based on ASCII.
 
273
.
 
274
.
 
275
.P
 
276
Note that it can happen that some input encoding characters are not
 
277
available for a particular output device.
 
278
.
 
279
For example, saying
 
280
.
 
281
.P
 
282
.EX
 
283
groff -Tlatin1 -mlatin9 ...
 
284
.EE
 
285
.
 
286
.P
 
287
fails if you use the Euro character in the input.
 
288
.
 
289
Usually, this limitation is present only for devices which have a
 
290
limited set of output glyphs
 
291
.RB ( \-Tascii ,
 
292
.BR \-Tlatin1 );
 
293
for other devices it is usually sufficient to install proper
 
294
fonts which contain the necessary glyphs.
 
295
.
 
296
.
 
297
.\" --------------------------------------------------------------------
 
298
.SS "Special Packages"
 
299
.\" --------------------------------------------------------------------
 
300
.
 
301
The macro packages in this section are not intended for stand-alone
 
302
usage, but can be used to add special functionality to any other
 
303
macro package or to plain groff.
 
304
.
 
305
.
 
306
.TP
 
307
.B 60bit
 
308
Provide some macros for addition, multiplication, and division of 60bit
 
309
integers (allowing safe multiplication of 30bit integers, for example).
 
310
.
 
311
.
 
312
.TP
 
313
.B ec
 
314
Switch to the EC and TC font families.
 
315
.
 
316
To be used with
 
317
.BR \%grodvi (@MAN1EXT@)
 
318
\[en] this man page also gives more details of how to use it.   
 
319
.
 
320
.
 
321
.TP
 
322
.B papersize
 
323
This macro file is already loaded at start-up by
 
324
.B @g@troff
 
325
so it isn't necessary to call it explicitly.
 
326
.
 
327
It provides an interface to set the paper size on the command line with
 
328
the option \f[B]\%\-dpaper=\f[]\f[I]size\f[].
 
329
.
 
330
Possible values for
 
331
.I size
 
332
are the same as the predefined
 
333
.B papersize
 
334
values in the DESC file (only lowercase; see
 
335
.BR groff_font (@MAN5EXT@)
 
336
for more) except
 
337
.BR a7 - d7 .
 
338
.
 
339
An appended
 
340
.B l
 
341
(ell) character denotes landscape orientation.
 
342
.
 
343
Examples:
 
344
.BR a4 ,
 
345
.BR c3l ,
 
346
.BR letterl .
 
347
.
 
348
.IP
 
349
Most output drivers need additional command line switches
 
350
.B \-p
 
351
and
 
352
.B \-l
 
353
to override the default paper length and orientation as set in the driver
 
354
specific DESC file.
 
355
.
 
356
For example, use the following for PS output on A4 paper in landscape
 
357
orientation:
 
358
.
 
359
.IP
 
360
.EX
 
361
.SM
 
362
\fIsh#\fP groff \-Tps \-dpaper=a4l \-P\-pa4 \-P\-l \-ms foo.ms > foo.ps
 
363
.EE
 
364
.
 
365
.
 
366
.TP
 
367
.B pic
 
368
This file provides proper definitions for the macros
 
369
.B PS
 
370
and
 
371
.BR PE ,
 
372
needed for the
 
373
.BR @g@pic (@MAN1EXT@)
 
374
preprocessor.
 
375
.
 
376
They center each picture.
 
377
.
 
378
Use it only if your macro package doesn't provide proper definitions
 
379
for those two macros (actually, most of them already do).
 
380
.
 
381
.
 
382
.TP
 
383
.B pspic
 
384
A single macro is provided in this file,
 
385
.BR PSPIC ,
 
386
to include a PostScript graphic in a document.
 
387
.
 
388
The following output devices support inclusion of PS images:
 
389
.BR \-Tps ,
 
390
.BR \-Tdvi ,
 
391
.BR \-Thtml ,
 
392
and
 
393
.BR \-Txhtml ;
 
394
for all other devices the image is replaced with a hollow rectangle
 
395
of the same size.
 
396
.
 
397
This macro file is already loaded at start-up by
 
398
.B @g@troff
 
399
so it isn't necessary to call it explicitly.
 
400
.
 
401
.IP
 
402
Syntax:
 
403
.RS
 
404
.IP
 
405
\&\fB.PSPIC\fP \
 
406
[\fB\-L\fP\|\
 
407
|\|\fB\-R\fP\|\
 
408
|\|\fB\-C\fP\|\
 
409
|\|\fB\-I\fP\ \fIn\fP] \
 
410
\fI\|file\fP [\fIwidth\fP [\fIheight\fP]]
 
411
.RE
 
412
.
 
413
.IP
 
414
.I file
 
415
is the name of the PostScript file;
 
416
.I width
 
417
and
 
418
.I height
 
419
give the desired width and height of the image.
 
420
.
 
421
If neither a
 
422
.I width
 
423
nor a
 
424
.I height
 
425
argument is specified, the image's natural width (as given in
 
426
the file's bounding box) or the current line length is used
 
427
as the width, whatever is smaller.
 
428
.
 
429
The
 
430
.I width
 
431
and
 
432
.I height
 
433
arguments may have scaling indicators attached;
 
434
the default scaling indicator is\~\c
 
435
.BR i .
 
436
.
 
437
This macro scales the graphic uniformly
 
438
in the x and y\~directions so that it is no more than
 
439
.I width
 
440
wide
 
441
and
 
442
.I height
 
443
high.
 
444
.
 
445
Option
 
446
.B \-C
 
447
centers the graphic horizontally, which is the default.
 
448
.
 
449
The
 
450
.B \-L
 
451
and
 
452
.B \-R
 
453
options cause the graphic to be left-aligned and right-aligned,
 
454
respectively.
 
455
.
 
456
The
 
457
.B \-I
 
458
option causes the graphic to be indented by\~\c
 
459
.I n
 
460
(default scaling indicator is\~\c
 
461
.BR m ).
 
462
.
 
463
.IP
 
464
For use of
 
465
.B .PSPIC
 
466
within a diversion it is recommended to extend it with
 
467
the following code, assuring that the diversion's width completely
 
468
covers the image's width.
 
469
.
 
470
.RS
 
471
.IP
 
472
.EX
 
473
\&.am PSPIC
 
474
\&.\ \ vpt 0
 
475
\&\[rs]h'(\[rs]\[rs]n[ps-offset]u + \[rs]\[rs]n[ps-deswid]u)'
 
476
\&.\ \ sp -1
 
477
\&.\ \ vpt 1
 
478
\&..
 
479
.EE
 
480
.RE
 
481
.
 
482
.
 
483
.TP
 
484
.B ptx
 
485
A single macro is provided in this file,
 
486
.BR xx ,
 
487
for formatting permuted index entries as produces by the GNU
 
488
.BR ptx (1)
 
489
program.
 
490
.
 
491
In case you need a different formatting, copy the macro into
 
492
your document and adapt it to your needs.
 
493
.
 
494
.
 
495
.TP
 
496
.B trace
 
497
Use this for tracing macro calls.
 
498
.
 
499
It is only useful for debugging.
 
500
.
 
501
See
 
502
.BR groff_trace (@MAN7EXT@) .
 
503
.
 
504
.
 
505
.TP
 
506
.B tty-char
 
507
Overrides the definition of standard troff characters and some groff
 
508
characters for TTY devices.
 
509
.
 
510
The optical appearance is intentionally inferior compared to that of
 
511
normal TTY formatting to allow processing with critical equipment.
 
512
.
 
513
.
 
514
.TP
 
515
.B www
 
516
Additions of elements known from the HTML format, as used in the
 
517
internet (World Wide Web) pages; this includes URL links and mail
 
518
addresses; see
 
519
.BR groff_www (@MAN7EXT@).
 
520
.
 
521
.
 
522
.\" --------------------------------------------------------------------
 
523
.SH NAMING
 
524
.\" --------------------------------------------------------------------
 
525
.
 
526
Classical roff systems were designed before the conventions of the
 
527
modern C 
 
528
.BR getopt (3)
 
529
call evolved, and used a naming scheme for macro packages that looks
 
530
odd to modern eyes. Macro packages were always included with the option
 
531
.BR \-m ;
 
532
when this option was directly followed by its argument without an
 
533
intervening space, this looked like a long option preceded by a single
 
534
minus \[em] a sensation in the computer stone age.
 
535
To make this invocation form work, classical troff
 
536
macro packages used names that started with the letter `m',
 
537
which was omitted in the naming of the macro file.
 
538
.
 
539
.
 
540
.P
 
541
For example, the macro package for the man pages was called
 
542
.IR man ,
 
543
while its macro file
 
544
.IR tmac.an .
 
545
So it could be activated by the argument
 
546
.I an
 
547
to option
 
548
.BR \-m ,
 
549
or
 
550
.BR \-man
 
551
for short.
 
552
.
 
553
.
 
554
.P
 
555
For similar reasons, macro packages that did not start with an `m'
 
556
had a leading `m'
 
557
added in the documentation and in speech; for example, the package
 
558
corresponding to
 
559
.I tmac.doc
 
560
was called
 
561
.I mdoc
 
562
in the documentation, although a more suitable name would be
 
563
.IR doc .
 
564
For, when omitting the space between the option and its argument, the
 
565
command line option for activating this package reads
 
566
.BR \-mdoc .
 
567
.
 
568
.
 
569
.P
 
570
To cope with all situations, actual versions of
 
571
.BR groff (@MAN1EXT@)
 
572
are smart about both naming schemes by providing two macro files
 
573
for the inflicted macro packages; one with a leading `m'
 
574
the other one without it.
 
575
.
 
576
So in
 
577
.IR groff ,
 
578
the
 
579
.I man
 
580
macro package may be specified as on of the following four methods:
 
581
.
 
582
.IP
 
583
.EX
 
584
\fIsh#\fP groff\ \-m\ man
 
585
\fIsh#\fP groff\ \-man
 
586
\fIsh#\fP groff\ \-mman
 
587
\fIsh#\fP groff\ \-m\ an
 
588
.EE
 
589
.
 
590
.
 
591
.P
 
592
Recent packages that do not start with `m'
 
593
do not use an additional `m'
 
594
in the documentation.
 
595
.
 
596
For example, the
 
597
.I www
 
598
macro package may be specified only as one of the two methods:
 
599
.
 
600
.IP
 
601
.EX
 
602
\fIsh#\fP groff\ \-m\ www
 
603
\fIsh#\fP groff\ \-mwww
 
604
.EE
 
605
.
 
606
.
 
607
.P
 
608
Obviously, variants like
 
609
.I \-mmwww
 
610
would not make much sense.
 
611
.
 
612
.
 
613
.P
 
614
A second strange feature of classical troff was to name macro files
 
615
in the form \f[B]tmac.\f[]\f[I]name\f[].
 
616
In modern operating systems, the type of a file is specified as a
 
617
postfix, the file name extension.
 
618
.
 
619
Again, groff copes with this situation by searching both
 
620
.IB anything .tmac
 
621
and
 
622
.BI tmac. anything
 
623
if only
 
624
.I anything
 
625
is specified.
 
626
.
 
627
.
 
628
.P
 
629
The easiest way to find out which macro packages are available on a
 
630
system is to check the man\~page
 
631
.BR groff (@MAN1EXT@),
 
632
or the contents of the
 
633
.I tmac
 
634
directories.
 
635
.
 
636
.
 
637
.P
 
638
In
 
639
.IR groff ,
 
640
most macro packages are described in\~man pages called
 
641
.BR groff_\f[I]name\f[] (@MAN7EXT@),
 
642
with a leading `m'
 
643
for the classical packages.
 
644
.
 
645
.
 
646
.\" --------------------------------------------------------------------
 
647
.SH INCLUSION
 
648
.\" --------------------------------------------------------------------
 
649
.
 
650
There are several ways to use a macro package in a document.
 
651
.
 
652
The classical way is to specify the troff/groff option
 
653
.BR \-m
 
654
.I name
 
655
at run-time; this makes the contents of the macro package
 
656
.I name
 
657
available.
 
658
.
 
659
In groff, the file
 
660
.IB name .tmac
 
661
is searched within the tmac path; if not found,
 
662
.BI tmac. name
 
663
is searched for instead.
 
664
.
 
665
.
 
666
.P
 
667
Alternatively, it is also possible to include a macro file by adding
 
668
the request
 
669
.B .so
 
670
.I filename
 
671
into the document; the argument must be the full file name of an
 
672
existing file, possibly with the directory where it is kept.
 
673
.
 
674
In groff, this was improved by the similar request
 
675
.B .mso
 
676
.IR package ,
 
677
which added searching in the tmac path, just like option
 
678
.BR \-m
 
679
does.
 
680
.
 
681
.
 
682
.P
 
683
Note that in order to resolve the
 
684
.B .so
 
685
and
 
686
.B .mso
 
687
requests, the roff preprocessor
 
688
.BR soelim (@MAN1EXT@)
 
689
must be called if the files to be included need preprocessing.
 
690
.
 
691
This can be done either directly by a pipeline on the command line or
 
692
by using the troff/groff option
 
693
.BR \-s .
 
694
.
 
695
.I man
 
696
calls soelim automatically.
 
697
.
 
698
.
 
699
.P
 
700
For example, suppose a macro file is stored as
 
701
.
 
702
.IP
 
703
.I @MACRODIR@/macros.tmac
 
704
.
 
705
.P
 
706
and is used in some document called
 
707
.IR docu.roff .
 
708
.
 
709
.
 
710
.P
 
711
At run-time, the formatter call for this is
 
712
.
 
713
.IP
 
714
.EX
 
715
\fIsh#\fP groff \-m macros docu.roff
 
716
.EE
 
717
.
 
718
.
 
719
.P
 
720
To include the macro file directly in the document either
 
721
.
 
722
.IP
 
723
.EX
 
724
\&.mso macros.tmac
 
725
.EE
 
726
.
 
727
.P
 
728
is used or
 
729
.
 
730
.IP
 
731
.EX
 
732
\&.so @MACRODIR@/macros.tmac
 
733
.EE
 
734
.
 
735
.
 
736
.P
 
737
In both cases, the formatter should be called with option
 
738
.B \-s
 
739
to invoke
 
740
.BR soelim .
 
741
.IP
 
742
.EX
 
743
\fIsh#\fP groff \-s docu.roff
 
744
.EE
 
745
.
 
746
.
 
747
.P
 
748
If you want to write your own groff macro file, call it
 
749
.IB whatever .tmac
 
750
and put it in some directory of the tmac path, see section
 
751
.BR FILES .
 
752
Then documents can include it with the
 
753
.B .mso
 
754
request or the option
 
755
.BR \-m .
 
756
.
 
757
.
 
758
.ig
 
759
.\" --------------------------------------------------------------------
 
760
.SH CONVENTION
 
761
.\" --------------------------------------------------------------------
 
762
.
 
763
.\" This section does not fit into the framework of this document.
 
764
.
 
765
There is a convention that is supported by many modern roff
 
766
type-setters and
 
767
.BR man (1)
 
768
programs, the
 
769
.I preprocessor word
 
770
described in the following.
 
771
.
 
772
.P
 
773
If the first line in a document is a comment, the first word (after the
 
774
comment characters and a blank) constitutes the
 
775
.B preprocessor
 
776
.BR word .
 
777
That means that the letters of this word are interpreted as
 
778
abbreviations for those preprocessor commands that should be run
 
779
when formatting the document.
 
780
.
 
781
Mostly, only the letters corresponding to the options for the
 
782
preprocessors are recognized, 
 
783
`e'
 
784
(for
 
785
.BR eqn ),
 
786
.\" `G',
 
787
.\" `g',
 
788
`p`
 
789
(for
 
790
.BR pic ),
 
791
`R'
 
792
(for
 
793
.BR refer ),
 
794
`s'
 
795
(for
 
796
.BR soelim ),
 
797
and
 
798
`t'
 
799
(for
 
800
.BR tbl ).
 
801
(see
 
802
.BR roff (@MAN7EXT@)).
 
803
.
 
804
.
 
805
.P
 
806
Besides being a good reminder for the user, some formatters (like the
 
807
.BR man (1)
 
808
program) are even able to automatically start the preprocessors
 
809
specified in the preprocessor word, but do not bet on this.
 
810
.
 
811
.
 
812
.P
 
813
The
 
814
.I man
 
815
program handles some preprocessors automatically, such that in
 
816
man\~pages only the following characters should be used:
 
817
`e', `p', and `t'.
 
818
.
 
819
.
 
820
..
 
821
.\" --------------------------------------------------------------------
 
822
.SH "WRITING MACROS"
 
823
.\" --------------------------------------------------------------------
 
824
.
 
825
A
 
826
.BR roff (@MAN7EXT@)
 
827
document is a text file that is enriched by predefined formatting
 
828
constructs, such as requests, escape sequences, strings, numeric
 
829
registers, and macros from a macro package.
 
830
.
 
831
These elements are described in
 
832
.BR roff (@MAN7EXT@).
 
833
.
 
834
.
 
835
.P
 
836
To give a document a personal style, it is most useful to extend the
 
837
existing elements by defining some macros for repeating tasks; the best
 
838
place for this is near the beginning of the document or in a separate
 
839
file.
 
840
.
 
841
.
 
842
.P
 
843
Macros without arguments are just like strings.
 
844
.
 
845
But the full power of macros reveals when arguments are passed with a
 
846
macro call.
 
847
.
 
848
Within the macro definition, the arguments are available as the escape
 
849
sequences
 
850
.BR \[rs]$1 ,
 
851
\*[Ellipsis],
 
852
.BR \[rs]$9 ,
 
853
.BR \[rs]$[ \*[Ellipsis] ] ,
 
854
.BR \[rs]$* ,
 
855
and
 
856
.BR \[rs]$@ ,
 
857
the name under which the macro was called is in
 
858
.BR \[rs]$0 ,
 
859
and the number of arguments is in register
 
860
.BR \[rs]n[.$] ;
 
861
see
 
862
.BR groff (@MAN7EXT@).
 
863
.
 
864
.
 
865
.\" --------------------------------------------------------------------
 
866
.SS "Copy-in Mode"
 
867
.\" --------------------------------------------------------------------
 
868
.
 
869
The phase when groff reads a macro is called
 
870
.I "copy-in mode"
 
871
or
 
872
.I "copy mode"
 
873
in roff-talk.
 
874
.
 
875
This is comparable to the C\~preprocessing phase during the development
 
876
of a program written in the C\~language.
 
877
.
 
878
.
 
879
.P
 
880
In this phase, groff interprets all backslashes; that means that all
 
881
escape sequences in the macro body are interpreted and replaced by
 
882
their value.
 
883
.
 
884
For constant expressions, this is wanted, but strings and registers
 
885
that might change between calls of the macro must be protected from
 
886
being evaluated.
 
887
.
 
888
This is most easily done by doubling the backslash that introduces the
 
889
escape sequence.
 
890
.
 
891
This doubling is most important for the positional parameters.
 
892
.
 
893
For example, to print information on the arguments that were passed to
 
894
the macro to the terminal, define a macro named `.print_args',
 
895
say.
 
896
.
 
897
.
 
898
.IP
 
899
.ds @1 \[rs]f[I]\[rs]\[rs]$0\[rs]f[]\"
 
900
.ds @2 arguments:\"
 
901
.EX
 
902
\&.ds midpart was called with
 
903
\&.de print_args
 
904
\&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]\[rs]n[.$]\ \*[@2]
 
905
\&.\ \ tm\ \[rs]\[rs]$*
 
906
\&..
 
907
.EE
 
908
.rm @1
 
909
.rm @2
 
910
.
 
911
.
 
912
.P
 
913
When calling this macro by
 
914
.
 
915
.IP
 
916
.EX
 
917
\&.print_args arg1 arg2
 
918
.EE
 
919
.
 
920
.P
 
921
the following text is printed to the terminal:
 
922
.
 
923
.IP
 
924
.EX
 
925
\&\f[CI]print_args\f[] was called with the following 2 arguments:
 
926
arg1 arg2
 
927
.EE
 
928
.
 
929
.
 
930
.P
 
931
Let's analyze each backslash in the macro definition.
 
932
.
 
933
As the positional parameters and the number of arguments change
 
934
with each call of the macro their leading backslash must be doubled,
 
935
which results in
 
936
.I \[rs]\[rs]$*
 
937
and
 
938
.IR \[rs]\[rs][.$] .
 
939
The same applies to the macro name because it could be called with an
 
940
alias name, so
 
941
.IR \[rs]\[rs]$0 .
 
942
.
 
943
.
 
944
.P
 
945
On the other hand,
 
946
.I midpart
 
947
is a constant string, it does not change, so no doubling for
 
948
.IR \[rs]*[midpart] .
 
949
The
 
950
.I \[rs]f
 
951
escape sequences are predefined groff elements for setting the font
 
952
within the text.
 
953
.
 
954
Of course, this behavior does not change, so no doubling with
 
955
.I \[rs]f[I]
 
956
and
 
957
.IR \[rs]f[] .
 
958
.
 
959
.
 
960
.\" --------------------------------------------------------------------
 
961
.SS "Draft Mode"
 
962
.\" --------------------------------------------------------------------
 
963
.
 
964
Writing groff macros is easy when the escaping mechanism is temporarily
 
965
disabled.
 
966
.
 
967
In groff, this is done by enclosing the macro definition(s) into a
 
968
pair of
 
969
.B .eo
 
970
and
 
971
.B .ec
 
972
requests.
 
973
.
 
974
Then the body in the macro definition is just like a normal part of
 
975
the document \[em] text enhanced by calls of requests, macros,
 
976
strings, registers, etc.
 
977
.
 
978
For example, the code above can be written in a simpler way by
 
979
.
 
980
.
 
981
.IP
 
982
.ds @1 \[rs]f[I]\[rs]$0\[rs]f[]\"
 
983
.ds @2 arguments:\"
 
984
.EX
 
985
\&.eo
 
986
\&.ds midpart was called with
 
987
\&.de print_args
 
988
\&.\ \ tm\ \*[@1]\ \[rs]*[midpart]\ \[rs]n[.$]\ \*[@2]
 
989
\&.\ \ tm\ \[rs]$*
 
990
\&..
 
991
\&.ec
 
992
.EE
 
993
.rm @1
 
994
.rm @2
 
995
.
 
996
.
 
997
.P
 
998
Unfortunately, draft mode cannot be used universally.
 
999
.
 
1000
Although it is good enough for defining normal macros, draft mode
 
1001
fails with advanced applications, such as indirectly defined
 
1002
strings, registers, etc.
 
1003
.
 
1004
An optimal way is to define and test all macros in draft mode and then
 
1005
do the backslash doubling as a final step; do not forget to remove the
 
1006
.I .eo
 
1007
request.
 
1008
.
 
1009
.
 
1010
.\" --------------------------------------------------------------------
 
1011
.SS "Tips for Macro Definitions"
 
1012
.\" --------------------------------------------------------------------
 
1013
.
 
1014
.IP \(bu
 
1015
Start every line with a dot, for example, by using the groff request
 
1016
.B .nop
 
1017
for text lines, or write your own macro that handles also text lines
 
1018
with a leading dot.
 
1019
.
 
1020
.RS
 
1021
.IP
 
1022
.EX
 
1023
\&.de Text
 
1024
\&.\ \ if (\[rs]\[rs]n[.$] == 0)\ \[rs]
 
1025
\&.\ \ \ \ return
 
1026
\&.\ \ nop\ \[rs])\[rs]\[rs]$*\[rs])
 
1027
\&..
 
1028
.EE
 
1029
.RE
 
1030
.
 
1031
.IP \(bu
 
1032
Write a comment macro that works both for copy-in and draft mode; for
 
1033
as escaping is off in draft mode, trouble might occur when normal
 
1034
comments are used.
 
1035
.
 
1036
For example, the following macro just ignores its arguments, so it
 
1037
acts like a comment line:
 
1038
.
 
1039
.RS
 
1040
.IP
 
1041
.EX
 
1042
\&.de\ c
 
1043
\&..
 
1044
\&.c\ This\ is\ like\ a\ comment\ line.
 
1045
.EE
 
1046
.RE
 
1047
.
 
1048
.IP \(bu
 
1049
In long macro definitions, make ample use of comment lines or
 
1050
almost-empty lines (this is, lines which have a leading dot
 
1051
and nothing else) for a better structuring.
 
1052
.
 
1053
.IP \(bu
 
1054
To increase readability, use groff's indentation facility for requests
 
1055
and macro calls (arbitrary whitespace after the leading dot).
 
1056
.
 
1057
.
 
1058
.\" --------------------------------------------------------------------
 
1059
.SS "Diversions"
 
1060
.\" --------------------------------------------------------------------
 
1061
.
 
1062
Diversions can be used to implement quite advanced programming
 
1063
constructs.
 
1064
.
 
1065
They are comparable to pointers to large data structures in the
 
1066
C\~programming language, but their usage is quite different.
 
1067
.
 
1068
.
 
1069
.P
 
1070
In their simplest form, diversions are multi-line strings, but
 
1071
they get their power when diversions are used dynamically within macros.
 
1072
.
 
1073
The (formatted) information stored in a diversion can be retrieved by
 
1074
calling the diversion just like a macro.
 
1075
.
 
1076
.
 
1077
.P
 
1078
Most of the problems arising with diversions can be avoided if you remain
 
1079
aware of the fact that diversions always store complete lines.
 
1080
.
 
1081
If diversions are used when the line buffer has not been flushed,
 
1082
strange results are produced; not knowing this, many people get
 
1083
desperate about diversions.
 
1084
.
 
1085
To ensure that a diversion works, line breaks should be added at the
 
1086
right places.
 
1087
.
 
1088
To be on the secure side, enclose everything that has to do with
 
1089
diversions into a pair of line breaks; for example, by explicitly using
 
1090
.B .br
 
1091
requests.
 
1092
.
 
1093
This rule should be applied to diversion definition, both inside and
 
1094
outside, and to all calls of diversions.
 
1095
.
 
1096
This is a bit of overkill, but it works nicely.
 
1097
.
 
1098
.
 
1099
.P
 
1100
[If you really need diversions which should ignore the current partial
 
1101
line, use environments to save the current partial line and/\:or use the
 
1102
.B .box
 
1103
request.]
 
1104
.
 
1105
.
 
1106
.P
 
1107
The most powerful feature using diversions is to start a diversion
 
1108
within a macro definition and end it within another macro.
 
1109
.
 
1110
Then everything between each call of this macro pair is stored within
 
1111
the diversion and can be manipulated from within the macros.
 
1112
.
 
1113
.
 
1114
.\" --------------------------------------------------------------------
 
1115
.SH FILES
 
1116
.\" --------------------------------------------------------------------
 
1117
.
 
1118
All macro names must be named
 
1119
.IB name .tmac
 
1120
to fully use the tmac mechanism.
 
1121
.
 
1122
.BI tmac. name
 
1123
as with classical packages is possible as well, but deprecated.
 
1124
.
 
1125
.
 
1126
.P
 
1127
The macro files are kept in the
 
1128
.IR "tmac directories" ;
 
1129
a colon separated list of these constitutes the
 
1130
.IR "tmac path" .
 
1131
.
 
1132
.
 
1133
.P
 
1134
The search sequence for macro files is (in that order):
 
1135
.
 
1136
.IP \(bu
 
1137
the directories specified with troff/groff's
 
1138
.B \-M
 
1139
command line option
 
1140
.
 
1141
.IP \(bu
 
1142
the directories given in the
 
1143
.B $GROFF_TMAC_PATH
 
1144
environment variable
 
1145
.
 
1146
.IP \(bu
 
1147
the current directory (only if in unsafe mode, which is enabled by the
 
1148
.B \-U
 
1149
command line switch)
 
1150
.
 
1151
.IP \(bu
 
1152
the home directory
 
1153
.
 
1154
.IP \(bu
 
1155
a platform-specific directory, being
 
1156
.
 
1157
.RS
 
1158
.IP
 
1159
.B @SYSTEMMACRODIR@
 
1160
.RE
 
1161
.
 
1162
.IP
 
1163
in this installation
 
1164
.
 
1165
.IP \(bu
 
1166
a site-specific (platform-independent) directory, being
 
1167
.
 
1168
.RS
 
1169
.IP
 
1170
.B @LOCALMACRODIR@
 
1171
.RE
 
1172
.
 
1173
.IP
 
1174
in this installation
 
1175
.
 
1176
.IP \(bu
 
1177
the main tmac directory, being
 
1178
.
 
1179
.RS
 
1180
.IP
 
1181
.B @MACRODIR@
 
1182
.RE
 
1183
.
 
1184
.IP
 
1185
in this installation
 
1186
.
 
1187
.
 
1188
.\" --------------------------------------------------------------------
 
1189
.SH ENVIRONMENT
 
1190
.\" --------------------------------------------------------------------
 
1191
.
 
1192
.TP
 
1193
.B $GROFF_TMAC_PATH
 
1194
A colon separated list of additional tmac directories in which to search
 
1195
for macro files.
 
1196
.
 
1197
See the previous section for a detailed description.
 
1198
.
 
1199
.
 
1200
.\" --------------------------------------------------------------------
 
1201
.SH AUTHOR
 
1202
.\" --------------------------------------------------------------------
 
1203
.
 
1204
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009
 
1205
Free Software Foundation, Inc.
 
1206
.
 
1207
.P
 
1208
This document is distributed under the terms of the FDL (GNU Free
 
1209
Documentation License) version 1.3 or later.
 
1210
.
 
1211
You should have received a copy of the FDL on your system, it is also
 
1212
available on-line at the
 
1213
.UR http://\:www.gnu.org/\:copyleft/\:fdl.html
 
1214
GNU copyleft site
 
1215
.UE .
 
1216
.
 
1217
.P
 
1218
This document is part of
 
1219
.IR groff ,
 
1220
the GNU roff distribution.
 
1221
.
 
1222
It was written by
 
1223
.MT groff-bernd.warken-72@web.de
 
1224
Bernd Warken
 
1225
.ME ;
 
1226
it is maintained by
 
1227
.MT wl@gnu.org
 
1228
Werner Lemberg 
 
1229
.ME .
 
1230
.
 
1231
.
 
1232
.\" --------------------------------------------------------------------
 
1233
.SH "SEE ALSO"
 
1234
.\" --------------------------------------------------------------------
 
1235
.
 
1236
A complete reference for all parts of the groff system is found in the
 
1237
groff
 
1238
.BR info (1)
 
1239
file.
 
1240
.
 
1241
.
 
1242
.TP
 
1243
.BR groff (@MAN1EXT@)
 
1244
an overview of the groff system.
 
1245
.
 
1246
.
 
1247
.TP
 
1248
.BR groff_man (@MAN7EXT@),
 
1249
.TQ
 
1250
.BR groff_mdoc (@MAN7EXT@),
 
1251
.TQ
 
1252
.BR groff_me (@MAN7EXT@),
 
1253
.TQ
 
1254
.BR groff_mm (@MAN7EXT@),
 
1255
.TQ
 
1256
.BR groff_mom (@MAN7EXT@),
 
1257
.TQ
 
1258
.BR groff_ms (@MAN7EXT@),
 
1259
.TQ
 
1260
.BR groff_trace (@MAN7EXT@),
 
1261
.TQ
 
1262
.BR groff_www (@MAN7EXT@).
 
1263
the groff tmac macro packages.
 
1264
.
 
1265
.
 
1266
.TP
 
1267
.BR groff (@MAN7EXT@)
 
1268
the groff language.
 
1269
.
 
1270
.
 
1271
.P
 
1272
The Filesystem Hierarchy Standard is available at the
 
1273
.UR http://\:www.pathname.com/\:fhs/
 
1274
FHS web site
 
1275
.UE .
 
1276
.
 
1277
.\" Local Variables:
 
1278
.\" mode: nroff
 
1279
.\" End: