groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / doc / groff.texinfo
CommitLineData
92d0a6a6
JR
1\input texinfo @c -*-texinfo-*-
2
3@c
4@c Please convert this manual with `texi2dvi -e groff.texinfo' due to
5@c problems in texinfo regarding expansion of user-defined macros.
6@c
4d3e9548 7@c You need texinfo 4.8 or newer to format this document!
92d0a6a6
JR
8@c
9
10@c %**start of header (This is for running Texinfo on a region.)
4d3e9548 11@setfilename groff.info
92d0a6a6
JR
12@settitle The GNU Troff Manual
13@setchapternewpage odd
14@footnotestyle separate
15@c %**end of header (This is for running Texinfo on a region.)
16
465b256c
JR
17@documentlanguage en
18@documentencoding ISO-8859-1
19
92d0a6a6
JR
20
21@smallbook
22
23@finalout
24
25
26@copying
4d3e9548 27This manual documents GNU @code{troff} version 1.20.1.
92d0a6a6 28
4d3e9548
JL
29Copyright @copyright{} 1994-2000, 2001, 2002, 2003, 2004, 2005, 2006,
302007, 2008, 2009
92d0a6a6
JR
31Free Software Foundation, Inc.
32
33@quotation
34Permission is granted to copy, distribute and/or modify this document
4d3e9548 35under the terms of the GNU Free Documentation License, Version 1.3 or
92d0a6a6
JR
36any later version published by the Free Software Foundation; with no
37Invariant Sections, with the Front-Cover texts being `A GNU Manual,''
4d3e9548
JL
38and with the Back-Cover Texts as in (a) below. A copy of the license is
39included in the section entitled `GNU Free Documentation License.''
92d0a6a6 40
4d3e9548
JL
41(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
42modify this GNU manual. Buying copies from the FSF supports it in
43developing GNU and promoting software freedom.''
92d0a6a6
JR
44@end quotation
45@end copying
46
47
48@c We use the following indices:
49@c
50@c cindex: concepts
51@c rqindex: requests
52@c esindex: escapes
53@c vindex: registers
54@c kindex: commands in font files
55@c pindex: programs and files
56@c tindex: environment variables
57@c maindex: macros
58@c stindex: strings
59@c opindex: operators
60@c
61@c tindex and cindex are merged.
62
63@defcodeindex rq
64@defcodeindex es
65@defcodeindex ma
66@defcodeindex st
67@defcodeindex op
68@syncodeindex tp cp
69
70
71@c To avoid uppercasing in @deffn while converting to info, we define
72@c our special @Var{}.
92d0a6a6
JR
73
74@macro Var{arg}
465b256c 75@r{@slanted{\arg\}}
92d0a6a6 76@end macro
92d0a6a6
JR
77
78
79@c To assure correct HTML translation, some ugly hacks are necessary.
80@c While processing a @def... request, the HTML translator looks at the
4d3e9548
JL
81@c next line to decide whether to start indentation, and if the line
82@c starts with @def... (e.g. @deffnx), indentation is started. We must
83@c therefore ensure that a @def... is seen, during macro expansion.
92d0a6a6
JR
84@c
85@c The following macros have to be used:
86@c
87@c One item:
88@c
89@c @Def...
90@c
91@c Two items:
92@c
93@c @Def...List
94@c @Def...ListEnd
95@c
96@c More than two:
97@c
98@c @Def...List
99@c @Def...Item
100@c @Def...Item
101@c ...
102@c @Def...ListEnd
103@c
104@c The definition block must end with
105@c
106@c @endDef...
107@c
108@c The above is valid for texinfo 4.0f and above.
109
110
111@c a dummy macro to assure the `@def...'
112
113@macro defdummy
465b256c 114@c
92d0a6a6
JR
115@end macro
116
117
118@c definition of requests
119
120@macro Defreq{name, arg}
121@deffn Request @t{.\name\} \arg\
122@rqindex \name\
465b256c 123@c
92d0a6a6
JR
124@end macro
125
126@macro DefreqList{name, arg}
127@deffn Request @t{.\name\} \arg\
128@defdummy
129@rqindex \name\
465b256c 130@c
92d0a6a6
JR
131@end macro
132
133@macro DefreqItem{name, arg}
134@deffnx Request @t{.\name\} \arg\
135@defdummy
136@rqindex \name\
465b256c 137@c
92d0a6a6
JR
138@end macro
139
140@macro DefreqListEnd{name, arg}
141@deffnx Request @t{.\name\} \arg\
142@rqindex \name\
465b256c 143@c
92d0a6a6
JR
144@end macro
145
146@macro endDefreq
147@end deffn
148@end macro
149
150
151@c definition of escapes
152
153@macro Defesc{name, delimI, arg, delimII}
154@deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
155@esindex \name\
465b256c 156@c
92d0a6a6
JR
157@end macro
158
159@macro DefescList{name, delimI, arg, delimII}
160@deffn Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
161@defdummy
162@esindex \name\
465b256c 163@c
92d0a6a6
JR
164@end macro
165
166@macro DefescItem{name, delimI, arg, delimII}
167@deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
168@defdummy
169@esindex \name\
465b256c 170@c
92d0a6a6
JR
171@end macro
172
173@macro DefescListEnd{name, delimI, arg, delimII}
174@deffnx Escape @t{\name\\delimI\}@Var{\arg\}@t{\delimII\}
175@esindex \name\
465b256c 176@c
92d0a6a6
JR
177@end macro
178
179@macro endDefesc
180@end deffn
181@end macro
182
183
184@c definition of registers
185
186@macro Defreg{name}
187@deffn Register @t{\\n[\name\]}
188@vindex \name\
465b256c 189@c
92d0a6a6
JR
190@end macro
191
192@macro DefregList{name}
193@deffn Register @t{\\n[\name\]}
194@defdummy
195@vindex \name\
465b256c 196@c
92d0a6a6
JR
197@end macro
198
199@macro DefregItem{name}
200@deffnx Register @t{\\n[\name\]}
201@defdummy
202@vindex \name\
465b256c 203@c
92d0a6a6
JR
204@end macro
205
206@macro DefregListEnd{name}
207@deffnx Register @t{\\n[\name\]}
208@vindex \name\
465b256c 209@c
92d0a6a6
JR
210@end macro
211
212@macro endDefreg
213@end deffn
214@end macro
215
216
217@c definition of registers specific to macro packages, preprocessors, etc.
218
219@macro Defmpreg{name, package}
220@deffn Register @t{\\n[\name\]}
221@vindex \name\ @r{[}\package\@r{]}
465b256c 222@c
92d0a6a6
JR
223@end macro
224
225@macro DefmpregList{name, package}
226@deffn Register @t{\\n[\name\]}
227@defdummy
228@vindex \name\ @r{[}\package\@r{]}
465b256c 229@c
92d0a6a6
JR
230@end macro
231
232@macro DefmpregItem{name, package}
233@deffnx Register @t{\\n[\name\]}
234@defdummy
235@vindex \name\ @r{[}\package\@r{]}
465b256c 236@c
92d0a6a6
JR
237@end macro
238
239@macro DefmpregListEnd{name, package}
240@deffnx Register @t{\\n[\name\]}
241@vindex \name\ @r{[}\package\@r{]}
465b256c 242@c
92d0a6a6
JR
243@end macro
244
245@macro endDefmpreg
246@end deffn
247@end macro
248
249
250@c definition of macros
251
252@macro Defmac{name, arg, package}
253@defmac @t{.\name\} \arg\
254@maindex \name\ @r{[}\package\@r{]}
465b256c 255@c
92d0a6a6
JR
256@end macro
257
258@macro DefmacList{name, arg, package}
259@defmac @t{.\name\} \arg\
260@defdummy
261@maindex \name\ @r{[}\package\@r{]}
465b256c 262@c
92d0a6a6
JR
263@end macro
264
265@macro DefmacItem{name, arg, package}
266@defmacx @t{.\name\} \arg\
267@defdummy
268@maindex \name\ @r{[}\package\@r{]}
465b256c 269@c
92d0a6a6
JR
270@end macro
271
272@macro DefmacListEnd{name, arg, package}
273@defmacx @t{.\name\} \arg\
274@maindex \name\ @r{[}\package\@r{]}
465b256c 275@c
92d0a6a6
JR
276@end macro
277
278@macro endDefmac
279@end defmac
280@end macro
281
282
283@c definition of strings
284
285@macro Defstr{name, package}
286@deffn String @t{\\*[\name\]}
287@stindex \name\ @r{[}\package\@r{]}
465b256c 288@c
92d0a6a6
JR
289@end macro
290
291@macro DefstrList{name, package}
292@deffn String @t{\\*[\name\]}
293@defdummy
294@stindex \name\ @r{[}\package\@r{]}
465b256c 295@c
92d0a6a6
JR
296@end macro
297
298@macro DefstrItem{name, package}
299@deffnx String @t{\\*[\name\]}
300@defdummy
301@stindex \name\ @r{[}\package\@r{]}
465b256c 302@c
92d0a6a6
JR
303@end macro
304
305@macro DefstrListEnd{name, package}
306@deffnx String @t{\\*[\name\]}
307@stindex \name\ @r{[}\package\@r{]}
465b256c 308@c
92d0a6a6
JR
309@end macro
310
311@macro endDefstr
312@end deffn
313@end macro
314
315
316@c our example macro
317
318@macro Example
319@example
320@group
321@end macro
322
323@macro endExample
324@end group
325@end example
326@end macro
327
328
329@c <text>
330
331@tex
465b256c
JR
332\gdef\Langlemacro{\angleleft}
333\gdef\Ranglemacro{\angleright}
92d0a6a6
JR
334@end tex
335
465b256c
JR
336@iftex
337@set Langlemacro @Langlemacro
338@set Ranglemacro @Ranglemacro
339@end iftex
340
341@ifnottex
342@set Langlemacro <
343@set Ranglemacro >
344@end ifnottex
345
92d0a6a6 346@macro angles{text}
465b256c 347@value{Langlemacro}@r{\text\}@value{Ranglemacro}
92d0a6a6
JR
348@end macro
349
350
351@c a <= sign
465b256c
JR
352@c
353@c A value defined with @set is embedded into three group levels if
354@c called with @value, so we need seven \aftergroup to put \le outside
4d3e9548
JL
355@c of the groups -- this is necessary to get proper mathematical
356@c spacing.
92d0a6a6
JR
357
358@tex
465b256c
JR
359\gdef\LEmacro{\aftergroup\aftergroup\aftergroup\aftergroup
360 \aftergroup\aftergroup\aftergroup\le}
92d0a6a6
JR
361@end tex
362
465b256c
JR
363@iftex
364@set LEmacro @LEmacro
365@end iftex
366
367@ifnottex
368@set LEmacro <=
369@end ifnottex
370
92d0a6a6 371@macro LE
465b256c 372@value{LEmacro}
92d0a6a6
JR
373@end macro
374
375
4d3e9548 376@c Special care is required with parentheses, brackets, and braces:
92d0a6a6
JR
377@c
378@c . Real parentheses in @deffn produce an error while compiling with
379@c TeX.
380@c . Real brackets use the wrong font in @deffn, overriding @t{}.
381@c
465b256c
JR
382@c . @{ and @} fail with info if used in a macro.
383@c
92d0a6a6
JR
384@c Since macros aren't expanded in @deffn during -E, the following
385@c definitions are for non-TeX only.
386@c
465b256c
JR
387@c This is true for texinfo 4.0 and above.
388
389@iftex
390@set Lparenmacro @lparen
391@set Rparenmacro @rparen
392@set Lbrackmacro @lbrack
393@set Rbrackmacro @rbrack
394@set Lbracemacro @{
395@set Rbracemacro @}
396@end iftex
92d0a6a6 397
465b256c
JR
398@ifnottex
399@set Lparenmacro (
400@set Rparenmacro )
401@set Lbrackmacro [
402@set Rbrackmacro ]
403@set Lbracemacro @{
404@set Rbracemacro @}
405@end ifnottex
406
407@macro Lparen{}
408@value{Lparenmacro}
409@end macro
410@macro Rparen{}
411@value{Rparenmacro}
412@end macro
413@macro Lbrack{}
414@value{Lbrackmacro}
92d0a6a6 415@end macro
465b256c
JR
416@macro Rbrack{}
417@value{Rbrackmacro}
92d0a6a6 418@end macro
465b256c
JR
419@macro Lbrace{}
420@value{Lbracemacro}
92d0a6a6 421@end macro
465b256c
JR
422@macro Rbrace{}
423@value{Rbracemacro}
92d0a6a6
JR
424@end macro
425
426
465b256c
JR
427@c This suppresses the word `Appendix' in the appendix headers.
428
92d0a6a6
JR
429@tex
430\gdef\gobblefirst#1#2{#2}
431\gdef\putwordAppendix{\gobblefirst}
432@end tex
433
434
465b256c 435@c We map some latin-1 characters to corresponding texinfo macros.
4d3e9548 436@c Newer versions of texinfo.tex have similar code included already.
465b256c
JR
437
438@tex
439\global\catcode`^^e4\active % ä
440\gdef^^e4{\"a}
441\global\catcode`^^c4\active % Ä
442\gdef^^c4{\"A}
443\global\catcode`^^e9\active % é
444\gdef^^e9{\'e}
445\global\catcode`^^c9\active % É
446\gdef^^c9{\'E}
447\global\catcode`^^f6\active % ö
448\gdef^^f6{\"o}
449\global\catcode`^^d6\active % Ö
450\gdef^^d6{\"O}
451\global\catcode`^^fc\active % ü
452\gdef^^fc{\"u}
453\global\catcode`^^dc\active % Ü
454\gdef^^dc{\"U}
455\global\catcode`^^e6\active % æ
456\gdef^^e6{\ae}
457\global\catcode`^^c6\active % Æ
458\gdef^^c6{\AE}
459\global\catcode`^^df\active % ß
460\gdef^^df{\ss}
461@end tex
462
463
92d0a6a6
JR
464@c Note: We say `Roman numerals' but `roman font'.
465
466
467@dircategory Typesetting
468@direntry
469* Groff: (groff). The GNU troff document formatting system.
470@end direntry
471
472
473@titlepage
474@title groff
475@subtitle The GNU implementation of @code{troff}
4d3e9548
JL
476@subtitle Edition 1.20.1
477@subtitle Spring 2009
92d0a6a6
JR
478@author by Trent A.@tie{}Fisher
479@author and Werner Lemberg (@email{bug-groff@@gnu.org})
480
481@page
482@vskip 0pt plus 1filll
483@insertcopying
484@end titlepage
485
92d0a6a6
JR
486@contents
487
4d3e9548 488@ifnottex
92d0a6a6
JR
489@node Top, Introduction, (dir), (dir)
490@top GNU troff
4d3e9548 491@end ifnottex
92d0a6a6 492
465b256c
JR
493@menu
494* Introduction::
495* Invoking groff::
496* Tutorial for Macro Users::
497* Macro Packages::
498* gtroff Reference::
499* Preprocessors::
500* Output Devices::
501* File formats::
502* Installation::
503* Copying This Manual::
504* Request Index::
505* Escape Index::
506* Operator Index::
507* Register Index::
508* Macro Index::
509* String Index::
510* Glyph Name Index::
511* Font File Keyword Index::
512* Program and File Index::
513* Concept Index::
514@end menu
515
4d3e9548 516@ifnottex
92d0a6a6 517@insertcopying
4d3e9548 518@end ifnottex
92d0a6a6
JR
519
520
521
522@c =====================================================================
523@c =====================================================================
524
525@node Introduction, Invoking groff, Top, Top
526@chapter Introduction
527@cindex introduction
528
529GNU @code{troff} (or @code{groff}) is a system for typesetting
4d3e9548
JL
530documents. @code{troff} is very flexible and has been used extensively
531for some thirty years. It is well entrenched in the @acronym{UNIX}
532community.
92d0a6a6
JR
533
534@menu
535* What Is groff?::
536* History::
537* groff Capabilities::
538* Macro Package Intro::
539* Preprocessor Intro::
540* Output device intro::
541* Credits::
542@end menu
543
544
545@c =====================================================================
546
547@node What Is groff?, History, Introduction, Introduction
548@section What Is @code{groff}?
549@cindex what is @code{groff}?
550@cindex @code{groff} -- what is it?
551
552@code{groff} belongs to an older generation of document preparation
553systems, which operate more like compilers than the more recent
554interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
555systems. @code{groff} and its contemporary counterpart, @TeX{}, both
556work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
557normal text files with embedded formatting commands. These files can
558then be processed by @code{groff} to produce a typeset document on a
559variety of devices.
560
4d3e9548
JL
561@code{groff} should not be confused with a @dfn{word processor}, an
562integrated system of editor and text formatter. Also, many word
563processors follow the @acronym{WYSIWYG} paradigm discussed earlier.
92d0a6a6
JR
564
565Although @acronym{WYSIWYG} systems may be easier to use, they have a
566number of disadvantages compared to @code{troff}:
567
568@itemize @bullet
569@item
570They must be used on a graphics display to work on a document.
571
572@item
573Most of the @acronym{WYSIWYG} systems are either non-free or are not
574very portable.
575
576@item
577@code{troff} is firmly entrenched in all @acronym{UNIX} systems.
578
579@item
4d3e9548
JL
580It is difficult to have a wide range of capabilities within the confines
581of a GUI/window system.
92d0a6a6
JR
582
583@item
584It is more difficult to make global changes to a document.
585@end itemize
586
587@quotation
588``GUIs normally make it simple to accomplish simple actions and
589impossible to accomplish complex actions.'' --Doug Gwyn (22/Jun/91 in
590@code{comp.unix.wizards})
591@end quotation
592
593
594@c =====================================================================
595
596@node History, groff Capabilities, What Is groff?, Introduction
597@section History
598@cindex history
599
4d3e9548 600@cindex @code{RUNOFF}, the program
92d0a6a6
JR
601@cindex @code{rf}, the program
602@code{troff} can trace its origins back to a formatting program called
4d3e9548
JL
603@code{RUNOFF}, written by Jerry Saltzer, which ran on the @acronym{CTSS}
604(@emph{Compatible Time Sharing System}, a project of MIT, the
605Massachusetts Institute of Technology) in the
606mid-sixties.@footnote{Jerome H.@: Saltzer, a grad student then, later a
607Professor of Electrical Engineering, now retired. Saltzer's PhD thesis
608was the first application for @code{RUNOFF} and is available from the
609MIT Libraries.} The name came from the use of the phrase ``run off a
610document'', meaning to print it out.
611@c
612@c Tom Van Vleck <thvv@multicians.org> writes about the following:
613@c
614@c I am not sure about this.. I think the BCPL runoff was the port to
615@c the 635 architecture, and that the order of events is
616@c 1. CTSS runoff
617@c 2. BCPL runoff on Multics
618@c 3. BCPL runoff on 635
619@c 4. rf on PDP-7
620@c
621Bob Morris ported it to the 635 architecture and called the program
622@code{roff} (an abbreviation of @code{runoff}). It was rewritten as
623@code{rf} for the @w{PDP-7} (before having @acronym{UNIX}), and at the
624same time (1969), Doug McIllroy rewrote an extended and simplified
625version of @code{roff} in the @acronym{BCPL} programming language.
92d0a6a6
JR
626
627@cindex @code{roff}, the program
4d3e9548
JL
628In 1971, the UNIX developers wanted to get a @w{PDP-11}, and to justify
629the cost, proposed the development of a document formatting system for
630the @acronym{AT&T} patents division. This first formatting program was
631a reimplementation of McIllroy's @code{roff}, written by J.@tie{}F.@:
632Ossanna.
92d0a6a6
JR
633
634@cindex @code{nroff}, the program
635When they needed a more flexible language, a new version of @code{roff}
636called @code{nroff} (``Newer @code{roff}'') was written. It had a much
637more complicated syntax, but provided the basis for all future versions.
638When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
639version of @code{nroff} that would drive it. It was dubbed
640@code{troff}, for ``typesetter @code{roff}'', although many people have
641speculated that it actually means ``Times @code{roff}'' because of the
642use of the Times font family in @code{troff} by default. As such, the
643name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
644
645With @code{troff} came @code{nroff} (they were actually the same program
646except for some @samp{#ifdef}s), which was for producing output for line
647printers and character terminals. It understood everything @code{troff}
648did, and ignored the commands which were not applicable (e.g.@: font
649changes).
650
651Since there are several things which cannot be done easily in
652@code{troff}, work on several preprocessors began. These programs would
653transform certain parts of a document into @code{troff}, which made a
654very natural use of pipes in @acronym{UNIX}.
655
4d3e9548
JL
656The @code{eqn} preprocessor allowed mathematical formulæ to be specified
657in a much simpler and more intuitive manner. @code{tbl} is a
92d0a6a6
JR
658preprocessor for formatting tables. The @code{refer} preprocessor (and
659the similar program, @code{bib}) processes citations in a document
660according to a bibliographic database.
661
662Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
663language and produced output specifically for the CAT phototypesetter.
664He rewrote it in C, although it was now 7000@tie{}lines of uncommented
665code and still dependent on the CAT. As the CAT became less common, and
666was no longer supported by the manufacturer, the need to make it support
667other devices became a priority. However, before this could be done,
4d3e9548
JL
668Ossanna died by a severe heart attack in a hospital while recovering
669from a previous one.
92d0a6a6
JR
670
671@pindex ditroff
672@cindex @code{ditroff}, the program
673So, Brian Kernighan took on the task of rewriting @code{troff}. The
4d3e9548
JL
674newly rewritten version produced device independent code which was very
675easy for postprocessors to read and translate to the appropriate printer
676codes. Also, this new version of @code{troff} (called @code{ditroff}
677for ``device independent @code{troff}'') had several extensions, which
678included drawing functions.
92d0a6a6
JR
679
680Due to the additional abilities of the new version of @code{troff},
681several new preprocessors appeared. The @code{pic} preprocessor
682provides a wide range of drawing functions. Likewise the @code{ideal}
683preprocessor did the same, although via a much different paradigm. The
684@code{grap} preprocessor took specifications for graphs, but, unlike
685other preprocessors, produced @code{pic} code.
686
687James Clark began work on a GNU implementation of @code{ditroff} in
4d3e9548
JL
688early@tie{}1989. The first version, @code{groff}@tie{}0.3.1, was
689released June@tie{}1990. @code{groff} included:
92d0a6a6
JR
690
691@itemize @bullet
692@item
693A replacement for @code{ditroff} with many extensions.
694
695@item
696The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
697
698@item
699Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
700X@tie{}Windows. GNU @code{troff} also eliminated the need for a
701separate @code{nroff} program with a postprocessor which would produce
702@acronym{ASCII} output.
703
704@item
705A version of the @file{me} macros and an implementation of the
706@file{man} macros.
707@end itemize
708
709Also, a front-end was included which could construct the, sometimes
710painfully long, pipelines required for all the post- and preprocessors.
711
712Development of GNU @code{troff} progressed rapidly, and saw the
713additions of a replacement for @code{refer}, an implementation of the
714@file{ms} and @file{mm} macros, and a program to deduce how to format a
715document (@code{grog}).
716
717It was declared a stable (i.e.@: non-beta) package with the release of
718version@tie{}1.04 around November@tie{}1991.
719
4d3e9548
JL
720Beginning in@tie{}1999, @code{groff} has new maintainers (the package
721was an orphan for a few years). As a result, new features and programs
722like @code{grn}, a preprocessor for gremlin images, and an output device
723to produce @acronym{HTML} and @acronym{XHTML} have been added.
92d0a6a6
JR
724
725
726@c =====================================================================
727
728@node groff Capabilities, Macro Package Intro, History, Introduction
729@section @code{groff} Capabilities
730@cindex @code{groff} capabilities
731@cindex capabilities of @code{groff}
732
733So what exactly is @code{groff} capable of doing? @code{groff} provides
734a wide range of low-level text formatting operations. Using these, it
735is possible to perform a wide range of formatting tasks, such as
736footnotes, table of contents, multiple columns, etc. Here's a list of
737the most important operations supported by @code{groff}:
738
739@itemize @bullet
740@item
741text filling, adjusting, and centering
742
743@item
744hyphenation
745
746@item
747page control
748
749@item
750font and glyph size control
751
752@item
753vertical spacing (e.g.@: double-spacing)
754
755@item
756line length and indenting
757
758@item
759macros, strings, diversions, and traps
760
761@item
762number registers
763
764@item
765tabs, leaders, and fields
766
767@item
768input and output conventions and character translation
769
770@item
771overstrike, bracket, line drawing, and zero-width functions
772
773@item
774local horizontal and vertical motions and the width function
775
776@item
777three-part titles
778
779@item
780output line numbering
781
782@item
783conditional acceptance of input
784
785@item
786environment switching
787
788@item
789insertions from the standard input
790
791@item
792input/output file switching
793
794@item
795output and error messages
796@end itemize
797
798
799@c =====================================================================
800
801@node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
802@section Macro Packages
803@cindex macro packages
804
805Since @code{groff} provides such low-level facilities, it can be quite
806difficult to use by itself. However, @code{groff} provides a
807@dfn{macro} facility to specify how certain routine operations
808(e.g.@tie{}starting paragraphs, printing headers and footers, etc.)@:
4d3e9548
JL
809should be done. These macros can be collected together into a
810@dfn{macro package}. There are a number of macro packages available;
811the most common (and the ones described in this manual) are @file{man},
92d0a6a6
JR
812@file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
813
814
815@c =====================================================================
816
817@node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
818@section Preprocessors
819@cindex preprocessors
820
821Although @code{groff} provides most functions needed to format a
822document, some operations would be unwieldy (e.g.@: to draw pictures).
823Therefore, programs called @dfn{preprocessors} were written which
824understand their own language and produce the necessary @code{groff}
825operations. These preprocessors are able to differentiate their own
826input from the rest of the document via markers.
827
828To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
829from the preprocessor into @code{groff}. Any number of preprocessors
830may be used on a given document; in this case, the preprocessors are
831linked together into one pipeline. However, with @code{groff}, the user
832does not need to construct the pipe, but only tell @code{groff} what
833preprocessors to use.
834
835@code{groff} currently has preprocessors for producing tables
836(@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
837(@code{pic} and @code{grn}), and for processing bibliographies
838(@code{refer}). An associated program which is useful when dealing with
839preprocessors is @code{soelim}.
840
841A free implementation of @code{grap}, a preprocessor for drawing graphs,
842can be obtained as an extra package; @code{groff} can use @code{grap}
843also.
844
845There are other preprocessors in existence, but, unfortunately, no free
846implementations are available. Among them are preprocessors for drawing
847mathematical pictures (@code{ideal}) and chemical structures
848(@code{chem}).
849
850
851@c =====================================================================
852
853@node Output device intro, Credits, Preprocessor Intro, Introduction
854@section Output Devices
855@cindex postprocessors
856@cindex output devices
857@cindex devices for output
858
4d3e9548
JL
859@code{groff} actually produces device independent code which may be fed
860into a postprocessor to produce output for a particular device.
861Currently, @code{groff} has postprocessors for @sc{PostScript} devices,
862character terminals, X@tie{}Windows (for previewing), @TeX{} DVI format,
863HP LaserJet@tie{}4 and Canon LBP printers (which use @acronym{CAPSL}),
864@acronym{HTML}, and @acronym{XHTML}.
92d0a6a6
JR
865
866
867@c =====================================================================
868
869@node Credits, , Output device intro, Introduction
870@section Credits
871@cindex credits
872
873Large portions of this manual were taken from existing documents, most
874notably, the manual pages for the @code{groff} package by James Clark,
875and Eric Allman's papers on the @file{me} macro package.
876
877The section on the @file{man} macro package is partly based on
878Susan@tie{}G.@: Kleinmann's @file{groff_man} manual page written for the
879Debian GNU/Linux system.
880
881Larry Kollar contributed the section in the @file{ms} macro package.
882
883
884
885@c =====================================================================
886@c =====================================================================
887
888@node Invoking groff, Tutorial for Macro Users, Introduction, Top
889@chapter Invoking @code{groff}
890@cindex invoking @code{groff}
891@cindex @code{groff} invocation
892
893This section focuses on how to invoke the @code{groff} front end. This
894front end takes care of the details of constructing the pipeline among
895the preprocessors, @code{gtroff} and the postprocessor.
896
897It has become a tradition that GNU programs get the prefix @samp{g} to
898distinguish it from its original counterparts provided by the host (see
899@ref{Environment}, for more details). Thus, for example, @code{geqn} is
900GNU @code{eqn}. On operating systems like GNU/Linux or the Hurd, which
901don't contain proprietary versions of @code{troff}, and on
902MS-DOS/MS-Windows, where @code{troff} and associated programs are not
903available at all, this prefix is omitted since GNU @code{troff} is the
904only used incarnation of @code{troff}. Exception: @samp{groff} is never
905replaced by @samp{roff}.
906
907In this document, we consequently say @samp{gtroff} when talking about
908the GNU @code{troff} program. All other implementations of @code{troff}
4d3e9548
JL
909are called @acronym{AT&T} @code{troff} which is the common origin of all
910@code{troff} derivates (with more or less compatible changes).
92d0a6a6
JR
911Similarly, we say @samp{gpic}, @samp{geqn}, etc.
912
913@menu
914* Groff Options::
915* Environment::
916* Macro Directories::
917* Font Directories::
918* Paper Size::
919* Invocation Examples::
920@end menu
921
922
923@c =====================================================================
924
925@node Groff Options, Environment, Invoking groff, Invoking groff
926@section Options
927@cindex options
928
929@pindex groff
930@pindex gtroff
931@pindex gpic
932@pindex geqn
933@pindex ggrn
934@pindex grap
935@pindex gtbl
936@pindex grefer
937@pindex gsoelim
938@code{groff} normally runs the @code{gtroff} program and a postprocessor
939appropriate for the selected device. The default device is @samp{ps}
940(but it can be changed when @code{groff} is configured and built). It
941can optionally preprocess with any of @code{gpic}, @code{geqn},
942@code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
943
944This section only documents options to the @code{groff} front end. Many
945of the arguments to @code{groff} are passed on to @code{gtroff},
946therefore those are also included. Arguments to pre- or postprocessors
947can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
948gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
949gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
950grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
951grolbp}, and @ref{Invoking gxditview}.
952
953The command line format for @code{groff} is:
954
955@Example
956groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
957 [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
958 [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
959 [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
960 [ @var{files}@dots{} ]
961@endExample
962
963The command line format for @code{gtroff} is as follows.
964
965@Example
966gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
967 [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
968 [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
969 [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
970@endExample
971
972@noindent
973Obviously, many of the options to @code{groff} are actually passed on to
974@code{gtroff}.
975
4d3e9548
JL
976Options without an argument can be grouped behind a
977single@tie{}@option{-}. A filename of@tie{}@file{-} denotes the
978standard input. It is possible to have whitespace between an option and
979its parameter.
92d0a6a6
JR
980
981The @code{grog} command can be used to guess the correct @code{groff}
982command to format a file.
983
984Here's the description of the command-line options:
985
986@cindex command-line options
987@table @samp
988@item -h
989Print a help message.
990
991@item -e
992Preprocess with @code{geqn}.
993
994@item -t
995Preprocess with @code{gtbl}.
996
997@item -g
998Preprocess with @code{ggrn}.
999
1000@item -G
1001Preprocess with @code{grap}.
1002
1003@item -p
1004Preprocess with @code{gpic}.
1005
1006@item -s
1007Preprocess with @code{gsoelim}.
1008
1009@item -c
1010Suppress color output.
1011
1012@item -R
1013Preprocess with @code{grefer}. No mechanism is provided for passing
1014arguments to @code{grefer} because most @code{grefer} options have
1015equivalent commands which can be included in the file. @xref{grefer},
1016for more details.
1017
1018@pindex troffrc
1019@pindex troffrc-end
1020Note that @code{gtroff} also accepts a @option{-R} option, which is not
1021accessible via @code{groff}. This option prevents the loading of the
1022@file{troffrc} and @file{troffrc-end} files.
1023
1024@item -v
1025Make programs run by @code{groff} print out their version number.
1026
1027@item -V
4d3e9548
JL
1028Print the pipeline on @code{stdout} instead of executing it. If
1029specified more than once, print the pipeline on @code{stderr} and
1030execute it.
92d0a6a6
JR
1031
1032@item -z
1033Suppress output from @code{gtroff}. Only error messages are printed.
1034
1035@item -Z
1036Do not postprocess the output of @code{gtroff}. Normally @code{groff}
1037automatically runs the appropriate postprocessor.
1038
1039@item -P@var{arg}
1040Pass @var{arg} to the postprocessor. Each argument should be passed
1041with a separate @option{-P} option. Note that @code{groff} does not
1042prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1043
1044@item -l
1045Send the output to a spooler for printing. The command used for this is
1046specified by the @code{print} command in the device description file
1047(see @ref{Font Files}, for more info). If not present, @option{-l} is
1048ignored.
1049
1050@item -L@var{arg}
1051Pass @var{arg} to the spooler. Each argument should be passed with a
4d3e9548
JL
1052separate @option{-L} option. Note that @code{groff} does not prepend a
1053@samp{-} to @var{arg} before passing it to the postprocessor. If the
1054@code{print} keyword in the device description file is missing,
92d0a6a6
JR
1055@option{-L} is ignored.
1056
1057@item -T@var{dev}
1058Prepare output for device @var{dev}. The default device is @samp{ps},
1059unless changed when @code{groff} was configured and built. The
1060following are the output devices currently available:
1061
1062@table @code
1063@item ps
1064For @sc{PostScript} printers and previewers.
1065
1066@item dvi
1067For @TeX{} DVI format.
1068
1069@item X75
1070For a 75@dmn{dpi} X11 previewer.
1071
1072@item X75-12
1073For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1074document.
1075
1076@item X100
1077For a 100@dmn{dpi} X11 previewer.
1078
1079@item X100-12
1080For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font in the
1081document.
1082
1083@item ascii
1084@cindex encoding, output, @acronym{ASCII}
1085@cindex @acronym{ASCII}, output encoding
1086@cindex output encoding, @acronym{ASCII}
1087For typewriter-like devices using the (7-bit) @acronym{ASCII}
1088character set.
1089
1090@item latin1
1091@cindex encoding, output, @w{latin-1} (ISO @w{8859-1})
1092@cindex @w{latin-1} (ISO @w{8859-1}), output encoding
1093@cindex ISO @w{8859-1} (@w{latin-1}), output encoding
1094@cindex output encoding, @w{latin-1} (ISO @w{8859-1})
1095For typewriter-like devices that support the @w{Latin-1}
1096(ISO@tie{}@w{8859-1}) character set.
1097
1098@item utf8
1099@cindex encoding, output, @w{utf-8}
1100@cindex @w{utf-8}, output encoding
1101@cindex output encoding, @w{utf-8}
1102For typewriter-like devices which use the Unicode (ISO@tie{}10646)
1103character set with @w{UTF-8} encoding.
1104
1105@item cp1047
1106@cindex encoding, output, @acronym{EBCDIC}
1107@cindex @acronym{EBCDIC}, output encoding
1108@cindex output encoding, @acronym{EBCDIC}
1109@cindex encoding, output, cp1047
1110@cindex cp1047, output encoding
1111@cindex output encoding, cp1047
1112@cindex IBM cp1047 output encoding
1113For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1114cp1047.
1115
1116@item lj4
1117For HP LaserJet4-compatible (or other PCL5-compatible) printers.
1118
1119@item lbp
1120For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1121printers).
1122
1123@pindex pre-grohtml
1124@pindex post-grohtml
1125@cindex @code{grohtml}, the program
1126@item html
4d3e9548
JL
1127@itemx xhtml
1128To produce @acronym{HTML} and @acronym{XHTML} output, respectively.
1129Note that this driver consists of two parts, a preprocessor
1130(@code{pre-grohtml}) and a postprocessor (@code{post-grohtml}).
92d0a6a6
JR
1131@end table
1132
1133@cindex output device name string register (@code{.T})
1134@cindex output device usage number register (@code{.T})
1135The predefined @code{gtroff} string register @code{.T} contains the
1136current output device; the read-only number register @code{.T} is set
4d3e9548
JL
1137to@tie{}1 if this option is used (which is always true if @code{groff}
1138is used to call @code{gtroff}). @xref{Built-in Registers}.
92d0a6a6
JR
1139
1140The postprocessor to be used for a device is specified by the
1141@code{postpro} command in the device description file. (@xref{Font
1142Files}, for more info.) This can be overridden with the @option{-X}
1143option.
1144
1145@item -X
1146Preview with @code{gxditview} instead of using the usual postprocessor.
1147This is unlikely to produce good results except with @option{-Tps}.
1148
1149Note that this is not the same as using @option{-TX75} or
1150@option{-TX100} to view a document with @code{gxditview}: The former
1151uses the metrics of the specified device, whereas the latter uses
1152X-specific fonts and metrics.
1153
1154@item -N
1155Don't allow newlines with @code{eqn} delimiters. This is the same as
1156the @option{-N} option in @code{geqn}.
1157
1158@item -S
1159@cindex @code{open} request, and safer mode
1160@cindex @code{opena} request, and safer mode
1161@cindex @code{pso} request, and safer mode
1162@cindex @code{sy} request, and safer mode
1163@cindex @code{pi} request, and safer mode
1164@cindex safer mode
1165@cindex mode, safer
1166Safer mode. Pass the @option{-S} option to @code{gpic} and disable the
1167@code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1168requests. For security reasons, this is enabled by default.
1169
1170@item -U
1171@cindex mode, unsafe
1172@cindex unsafe mode
1173Unsafe mode. This enables the @code{open}, @code{opena}, @code{pso},
1174@code{sy}, and @code{pi} requests.
1175
1176@item -a
1177@cindex @acronym{ASCII} approximation output register (@code{.A})
1178Generate an @acronym{ASCII} approximation of the typeset output. The
1179read-only register @code{.A} is then set to@tie{}1. @xref{Built-in
1180Registers}. A typical example is
1181
1182@Example
1183groff -a -man -Tdvi troff.man | less
1184@endExample
1185
1186@noindent
1187which shows how lines are broken for the DVI device. Note that this
1188option is rather useless today since graphic output devices are
1189available virtually everywhere.
1190
1191@item -b
1192Print a backtrace with each warning or error message. This backtrace
1193should help track down the cause of the error. The line numbers given
1194in the backtrace may not always be correct: @code{gtroff} can get
1195confused by @code{as} or @code{am} requests while counting line numbers.
1196
1197@item -i
1198Read the standard input after all the named input files have been
1199processed.
1200
1201@item -w@var{name}
1202Enable warning @var{name}. Available warnings are described in
1203@ref{Debugging}. Multiple @option{-w} options are allowed.
1204
1205@item -W@var{name}
1206Inhibit warning @var{name}. Multiple @option{-W} options are allowed.
1207
1208@item -E
1209Inhibit all error messages.
1210
1211@item -C
1212Enable compatibility mode. @xref{Implementation Differences}, for the
1213list of incompatibilities between @code{groff} and @acronym{AT&T}
1214@code{troff}.
1215
1216@item -d@var{c}@var{s}
1217@itemx -d@var{name}=@var{s}
4d3e9548
JL
1218Define @var{c} or @var{name} to be a string@tie{}@var{s}.
1219@var{c}@tie{}must be a one-letter name; @var{name} can be of arbitrary
1220length. All string assignments happen before loading any macro file
1221(including the start-up file).
92d0a6a6
JR
1222
1223@item -f@var{fam}
1224Use @var{fam} as the default font family. @xref{Font Families}.
1225
1226@item -m@var{name}
1227Read in the file @file{@var{name}.tmac}. Normally @code{groff} searches
1228for this in its macro directories. If it isn't found, it tries
1229@file{tmac.@var{name}} (searching in the same directories).
1230
1231@item -n@var{num}
1232Number the first page @var{num}.
1233
1234@item -o@var{list}
1235@cindex print current page register (@code{.P})
1236Output only pages in @var{list}, which is a comma-separated list of page
4d3e9548
JL
1237ranges; @samp{@var{n}} means print page@tie{}@var{n},
1238@samp{@var{m}-@var{n}} means print every page between @var{m}
1239and@tie{}@var{n}, @samp{-@var{n}} means print every page up
1240to@tie{}@var{n}, @samp{@var{n}-} means print every page beginning
1241with@tie{}@var{n}. @code{gtroff} exits after printing the last page in
1242the list. All the ranges are inclusive on both ends.
92d0a6a6
JR
1243
1244Within @code{gtroff}, this information can be extracted with the
1245@samp{.P} register. @xref{Built-in Registers}.
1246
1247If your document restarts page numbering at the beginning of each
1248chapter, then @code{gtroff} prints the specified page range for each
1249chapter.
1250
1251@item -r@var{c}@var{n}
1252@itemx -r@var{name}=@var{n}
4d3e9548
JL
1253Set number register@tie{}@var{c} or @var{name} to the
1254value@tie{}@var{n}. @var{c}@tie{}must be a one-letter name; @var{name}
1255can be of arbitrary length. @var{n}@tie{}can be any @code{gtroff}
1256numeric expression. All register assignments happen before loading any
1257macro file (including the start-up file).
92d0a6a6
JR
1258
1259@item -F@var{dir}
1260Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1261(@var{name} is the name of the device), for the @file{DESC} file, and
1262for font files before looking in the standard directories (@pxref{Font
1263Directories}). This option is passed to all pre- and postprocessors
1264using the @env{GROFF_FONT_PATH} environment variable.
1265
1266@item -M@var{dir}
1267Search directory @file{@var{dir}} for macro files before the standard
1268directories (@pxref{Macro Directories}).
1269
1270@item -I@var{dir}
1271This option may be used to specify a directory to search for files.
1272It is passed to the following programs:
1273
1274@itemize
1275@item
1276@code{gsoelim} (see @ref{gsoelim} for more details);
1277it also implies @code{groff}'s @option{-s} option.
1278
1279@item
1280@code{gtroff}; it is used to search files named in the @code{psbb} and
1281@code{so} requests.
1282
1283@item
1284@code{grops}; it is used to search files named in the
1285@w{@code{\X'ps: import}} and @w{@code{\X'ps: file}} escapes.
1286@end itemize
1287
4d3e9548
JL
1288The current directory is always searched first. This option may be
1289specified more than once; the directories are searched in the order
1290specified. No directory search is performed for files specified using
1291an absolute path.
92d0a6a6
JR
1292@end table
1293
1294
1295@c =====================================================================
1296
1297@node Environment, Macro Directories, Groff Options, Invoking groff
1298@section Environment
1299@cindex environment variables
1300@cindex variables in environment
1301
1302There are also several environment variables (of the operating system,
1303not within @code{gtroff}) which can modify the behavior of @code{groff}.
1304
1305@table @code
1306@item GROFF_COMMAND_PREFIX
1307@tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1308@cindex command prefix
1309@cindex prefix, for commands
4d3e9548
JL
1310If this is set to@tie{}@var{X}, then @code{groff} runs
1311@code{@var{X}troff} instead of @code{gtroff}. This also applies to
1312@code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{refer}, and
1313@code{soelim}. It does not apply to @code{grops}, @code{grodvi},
1314@code{grotty}, @code{pre-grohtml}, @code{post-grohtml}, @code{grolj4},
1315and @code{gxditview}.
92d0a6a6 1316
4d3e9548
JL
1317The default command prefix is determined during the installation
1318process. If a non-GNU troff system is found, prefix @samp{g} is used,
1319none otherwise.
92d0a6a6
JR
1320
1321@item GROFF_TMAC_PATH
1322@tindex GROFF_TMAC_PATH@r{, environment variable}
1323A colon-separated list of directories in which to search for macro files
1324(before the default directories are tried). @xref{Macro Directories}.
1325
1326@item GROFF_TYPESETTER
1327@tindex GROFF_TYPESETTER@r{, environment variable}
1328The default output device.
1329
1330@item GROFF_FONT_PATH
1331@tindex GROFF_FONT_PATH@r{, environment variable}
1332A colon-separated list of directories in which to search for the
1333@code{dev}@var{name} directory (before the default directories are
1334tried). @xref{Font Directories}.
1335
1336@item GROFF_BIN_PATH
1337@tindex GROFF_BIN_PATH@r{, environment variable}
1338This search path, followed by @code{PATH}, is used for commands executed
1339by @code{groff}.
1340
1341@item GROFF_TMPDIR
1342@tindex GROFF_TMPDIR@r{, environment variable}
1343@tindex TMPDIR@r{, environment variable}
1344The directory in which @code{groff} creates temporary files. If this is
1345not set and @env{TMPDIR} is set, temporary files are created in that
1346directory. Otherwise temporary files are created in a system-dependent
1347default directory (on Unix and GNU/Linux systems, this is usually
1348@file{/tmp}). @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1349@code{post-grohtml} can create temporary files in this directory.
1350@end table
1351
1352Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1353rather than colons, to separate the directories in the lists described
1354above.
1355
1356
1357@c =====================================================================
1358
1359@node Macro Directories, Font Directories, Environment, Invoking groff
1360@section Macro Directories
1361@cindex macro directories
1362@cindex directories for macros
1363@cindex searching macros
1364@cindex macros, searching
1365
1366All macro file names must be named @code{@var{name}.tmac} or
1367@code{tmac.@var{name}} to make the @option{-m@var{name}} command line
1368option work. The @code{mso} request doesn't have this restriction; any
1369file name can be used, and @code{gtroff} won't try to append or prepend
1370the @samp{tmac} string.
1371
1372@cindex tmac, directory
1373@cindex directory, for tmac files
1374@cindex tmac, path
1375@cindex path, for tmac files
1376@cindex searching macro files
1377@cindex macro files, searching
1378@cindex files, macro, searching
1379Macro files are kept in the @dfn{tmac directories}, all of which
1380constitute the @dfn{tmac path}. The elements of the search path for
1381macro files are (in that order):
1382
1383@itemize @bullet
1384@item
1385The directories specified with @code{gtroff}'s or @code{groff}'s
1386@option{-M} command line option.
1387
1388@item
1389@tindex GROFF_TMAC_PATH@r{, environment variable}
4d3e9548 1390The directories given in the @env{GROFF_TMAC_PATH} environment variable.
92d0a6a6
JR
1391
1392@item
1393@cindex safer mode
1394@cindex mode, safer
1395@cindex unsafe mode
1396@cindex mode, unsafe
1397@cindex current directory
1398@cindex directory, current
1399The current directory (only if in unsafe mode using the @option{-U}
1400command line switch).
1401
1402@item
1403@cindex home directory
1404@cindex directory, home
1405The home directory.
1406
1407@item
1408@cindex site-specific directory
1409@cindex directory, site-specific
1410@cindex platform-specific directory
1411@cindex directory, platform-specific
1412A platform-dependent directory, a site-specific (platform-independent)
1413directory, and the main tmac directory; the default locations are
1414
1415@Example
1416/usr/local/lib/groff/site-tmac
1417/usr/local/share/groff/site-tmac
4d3e9548 1418/usr/local/share/groff/1.20.1/tmac
92d0a6a6
JR
1419@endExample
1420
1421@noindent
4d3e9548
JL
1422assuming that the version of @code{groff} is 1.20.1, and the
1423installation prefix was @file{/usr/local}. It is possible to fine-tune
1424those directories during the installation process.
92d0a6a6
JR
1425@end itemize
1426
1427
1428@c =====================================================================
1429
1430@node Font Directories, Paper Size, Macro Directories, Invoking groff
1431@section Font Directories
1432@cindex font directories
1433@cindex directories for fonts
1434@cindex searching fonts
1435@cindex fonts, searching
1436
1437Basically, there is no restriction how font files for @code{groff} are
1438named and how long font names are; however, to make the font family
1439mechanism work (@pxref{Font Families}), fonts within a family should
1440start with the family name, followed by the shape. For example, the
1441Times family uses @samp{T} for the family name and @samp{R}, @samp{B},
1442@samp{I}, and @samp{BI} to indicate the shapes `roman', `bold',
1443`italic', and `bold italic', respectively. Thus the final font names
1444are @samp{TR}, @samp{TB}, @samp{TI}, and @samp{TBI}.
1445
1446@cindex font path
1447@cindex path, for font files
1448All font files are kept in the @dfn{font directories} which constitute
4d3e9548 1449the @dfn{font path}. The file search functions always append the
92d0a6a6 1450directory @code{dev}@var{name}, where @var{name} is the name of the
4d3e9548
JL
1451output device. Assuming, say, DVI output, and @file{/foo/bar} as a font
1452directory, the font files for @code{grodvi} must be in
92d0a6a6
JR
1453@file{/foo/bar/devdvi}.
1454
1455The elements of the search path for font files are (in that order):
1456
1457@itemize @bullet
1458@item
1459The directories specified with @code{gtroff}'s or @code{groff}'s
1460@option{-F} command line option. All device drivers and some
1461preprocessors also have this option.
1462
1463@item
1464@tindex GROFF_FONT_PATH@r{, environment variable}
4d3e9548 1465The directories given in the @env{GROFF_FONT_PATH} environment variable.
92d0a6a6
JR
1466
1467@item
1468@cindex site-specific directory
1469@cindex directory, site-specific
1470A site-specific directory and the main font directory; the default
1471locations are
1472
1473@Example
1474/usr/local/share/groff/site-font
4d3e9548 1475/usr/local/share/groff/1.20.1/font
92d0a6a6
JR
1476@endExample
1477
1478@noindent
4d3e9548
JL
1479assuming that the version of @code{groff} is 1.20.1, and the
1480installation prefix was @file{/usr/local}. It is possible to fine-tune
1481those directories during the installation process.
92d0a6a6
JR
1482@end itemize
1483
1484
1485@c =====================================================================
1486
1487@node Paper Size, Invocation Examples, Font Directories, Invoking groff
1488@section Paper Size
1489@cindex paper size
1490@cindex size, paper
1491@cindex landscape page orientation
1492@cindex orientation, landscape
1493@cindex page orientation, landscape
1494
1495In groff, the page size for @code{gtroff} and for output devices are
1496handled separately. @xref{Page Layout}, for vertical manipulation of
1497the page size. @xref{Line Layout}, for horizontal changes.
1498
1499A default paper size can be set in the device's @file{DESC} file. Most
1500output devices also have a command line option @option{-p} to override
1501the default paper size and option @option{-l} to use landscape
1502orientation. @xref{DESC File Format}, for a description of the
1503@code{papersize} keyword which takes the same argument as @option{-p}.
1504
1505@pindex papersize.tmac
1506@pindex troffrc
1507A convenient shorthand to set a particular paper size for @code{gtroff}
1508is command line option @option{-dpaper=@var{size}}. This defines string
1509@code{paper} which is processed in file @file{papersize.tmac} (loaded in
1510the start-up file @file{troffrc} by default). Possible values for
1511@var{size} are the same as the predefined values for the
1512@code{papersize} keyword (but only in lowercase) except
1513@code{a7}-@code{d7}. An appended @samp{l} (ell) character denotes
1514landscape orientation.
1515
1516For example, use the following for PS output on A4 paper in landscape
1517orientation:
1518
1519@Example
1520groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
1521@endExample
1522
1523Note that it is up to the particular macro package to respect default
1524page dimensions set in this way (most do).
1525
1526
1527@c =====================================================================
1528
1529@node Invocation Examples, , Paper Size, Invoking groff
1530@section Invocation Examples
1531@cindex invocation examples
1532@cindex examples of invocation
1533
1534This section lists several common uses of @code{groff} and the
1535corresponding command lines.
1536
1537@Example
1538groff file
1539@endExample
1540
1541@noindent
1542This command processes @file{file} without a macro package or a
1543preprocessor. The output device is the default, @samp{ps}, and the
1544output is sent to @code{stdout}.
1545
1546@Example
1547groff -t -mandoc -Tascii file | less
1548@endExample
1549
1550@noindent
1551This is basically what a call to the @code{man} program does.
1552@code{gtroff} processes the manual page @file{file} with the
1553@file{mandoc} macro file (which in turn either calls the @file{man} or
1554the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1555the @acronym{ASCII} output device. Finally, the @code{less} pager
1556displays the result.
1557
1558@Example
1559groff -X -m me file
1560@endExample
1561
1562@noindent
1563Preview @file{file} with @code{gxditview}, using the @file{me} macro
1564package. Since no @option{-T} option is specified, use the default
1565device (@samp{ps}). Note that you can either say @w{@samp{-m me}} or
1566@w{@samp{-me}}; the latter is an anachronism from the early days of
1567@acronym{UNIX}.@footnote{The same is true for the other main macro
1568packages that come with @code{groff}: @file{man}, @file{mdoc},
1569@file{ms}, @file{mm}, and @file{mandoc}. This won't work in general;
1570for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1571@w{@samp{-m trace}} must be used.}
1572
1573@Example
1574groff -man -rD1 -z file
1575@endExample
1576
1577@noindent
1578Check @file{file} with the @file{man} macro package, forcing
1579double-sided printing -- don't produce any output.
1580
1581@menu
1582* grog::
1583@end menu
1584
1585@c ---------------------------------------------------------------------
1586
1587@node grog, , Invocation Examples, Invocation Examples
1588@subsection @code{grog}
1589
1590@pindex grog
1591@code{grog} reads files, guesses which of the @code{groff} preprocessors
1592and/or macro packages are required for formatting them, and prints the
1593@code{groff} command including those options on the standard output. It
1594generates one or more of the options @option{-e}, @option{-man},
1595@option{-me}, @option{-mm}, @option{-mom}, @option{-ms}, @option{-mdoc},
1596@option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1597@option{-s}, and @option{-t}.
1598
4d3e9548
JL
1599A special file name@tie{}@file{-} refers to the standard input.
1600Specifying no files also means to read the standard input. Any
1601specified options are included in the printed command. No space is
1602allowed between options and their arguments. The only options
1603recognized are @option{-C} (which is also passed on) to enable
1604compatibility mode, and @option{-v} to print the version number and
1605exit.
92d0a6a6
JR
1606
1607For example,
1608
1609@Example
1610grog -Tdvi paper.ms
1611@endExample
1612
1613@noindent
1614guesses the appropriate command to print @file{paper.ms} and then prints
1615it to the command line after adding the @option{-Tdvi} option. For
1616direct execution, enclose the call to @code{grog} in backquotes at the
1617@acronym{UNIX} shell prompt:
1618
1619@Example
1620`grog -Tdvi paper.ms` > paper.dvi
1621@endExample
1622
1623@noindent
1624As seen in the example, it is still necessary to redirect the output to
1625something meaningful (i.e.@: either a file or a pager program like
1626@code{less}).
1627
1628
1629
1630@c =====================================================================
1631@c =====================================================================
1632
1633@node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1634@chapter Tutorial for Macro Users
1635@cindex tutorial for macro users
1636@cindex macros, tutorial for users
1637@cindex user's tutorial for macros
1638@cindex user's macro tutorial
1639
1640Most users tend to use a macro package to format their papers. This
1641means that the whole breadth of @code{groff} is not necessary for most
1642people. This chapter covers the material needed to efficiently use a
1643macro package.
1644
1645@menu
1646* Basics::
1647* Common Features::
1648@end menu
1649
1650
1651@c =====================================================================
1652
1653@node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1654@section Basics
1655@cindex basics of macros
1656@cindex macro basics
1657
1658This section covers some of the basic concepts necessary to understand
1659how to use a macro package.@footnote{This section is derived from
1660@cite{Writing Papers with nroff using -me} by Eric P.@tie{}Allman.}
1661References are made throughout to more detailed information, if desired.
1662
1663@code{gtroff} reads an input file prepared by the user and outputs a
1664formatted document suitable for publication or framing. The input
1665consists of text, or words to be printed, and embedded commands
1666(@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1667format the output. For more detail on this, see @ref{Embedded
1668Commands}.
1669
1670The word @dfn{argument} is used in this chapter to mean a word or number
1671which appears on the same line as a request, and which modifies the
1672meaning of that request. For example, the request
1673
1674@Example
1675.sp
1676@endExample
1677
1678@noindent
1679spaces one line, but
1680
1681@Example
1682.sp 4
1683@endExample
1684
1685@noindent
1686spaces four lines. The number@tie{}4 is an argument to the @code{sp}
1687request which says to space four lines instead of one. Arguments are
1688separated from the request and from each other by spaces (@emph{no}
1689tabs). More details on this can be found in @ref{Request and Macro
1690Arguments}.
1691
1692The primary function of @code{gtroff} is to collect words from input
1693lines, fill output lines with those words, justify the right-hand margin
1694by inserting extra spaces in the line, and output the result. For
1695example, the input:
1696
1697@Example
1698Now is the time
1699for all good men
1700to come to the aid
1701of their party.
1702Four score and seven
1703years ago, etc.
1704@endExample
1705
1706@noindent
1707is read, packed onto output lines, and justified to produce:
1708
1709@quotation
1710Now is the time for all good men to come to the aid of their party.
1711Four score and seven years ago, etc.
1712@end quotation
1713
1714@cindex break
1715@cindex line break
1716Sometimes a new output line should be started even though the current
1717line is not yet full; for example, at the end of a paragraph. To do
1718this it is possible to cause a @dfn{break}, which starts a new output
1719line. Some requests cause a break automatically, as normally do blank
1720input lines and input lines beginning with a space.
1721
1722Not all input lines are text to be formatted. Some input lines are
1723requests which describe how to format the text. Requests always have a
1724period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1725the input line.
1726
1727The text formatter also does more complex things, such as automatically
1728numbering pages, skipping over page boundaries, putting footnotes in the
1729correct place, and so forth.
1730
1731Here are a few hints for preparing text for input to @code{gtroff}.
1732
1733@itemize @bullet
1734@item
1735First, keep the input lines short. Short input lines are easier to
1736edit, and @code{gtroff} packs words onto longer lines anyhow.
1737
1738@item
1739In keeping with this, it is helpful to begin a new line after every
1740comma or phrase, since common corrections are to add or delete sentences
1741or phrases.
1742
1743@item
1744End each sentence with two spaces -- or better, start each sentence on a
1745new line. @code{gtroff} recognizes characters that usually end a
1746sentence, and inserts sentence space accordingly.
1747
1748@item
1749Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1750enough to hyphenate words as needed, but is not smart enough to take
1751hyphens out and join a word back together. Also, words such as
1752``mother-in-law'' should not be broken over a line, since then a space
1753can occur where not wanted, such as ``@w{mother- in}-law''.
1754@end itemize
1755
1756@cindex double-spacing (@code{ls})
1757@cindex spacing
1758@code{gtroff} double-spaces output text automatically if you use the
1759request @w{@samp{.ls 2}}. Reactivate single-spaced mode by typing
4d3e9548
JL
1760@w{@samp{.ls 1}}.@footnote{If you need finer granularity of the vertical
1761space, use the @code{pvs} request (@pxref{Changing Type Sizes}).}
92d0a6a6 1762
4d3e9548
JL
1763A number of requests allow to change the way the output looks, sometimes
1764called the @dfn{layout} of the output page. Most of these requests
1765adjust the placing of @dfn{whitespace} (blank lines or spaces).
92d0a6a6
JR
1766
1767@cindex new page (@code{bp})
1768The @code{bp} request starts a new page, causing a line break.
1769
1770@cindex blank line (@code{sp})
1771@cindex empty line (@code{sp})
1772@cindex line, empty (@code{sp})
1773The request @w{@samp{.sp @var{N}}} leaves @var{N}@tie{}lines of blank
1774space. @var{N}@tie{}can be omitted (meaning skip a single line) or can
1775be of the form @var{N}i (for @var{N}@tie{}inches) or @var{N}c (for
1776@var{N}@tie{}centimeters). For example, the input:
1777
1778@Example
1779.sp 1.5i
1780My thoughts on the subject
1781.sp
1782@endExample
1783
1784@noindent
1785leaves one and a half inches of space, followed by the line ``My
1786thoughts on the subject'', followed by a single blank line (more
1787measurement units are available, see @ref{Measurements}).
1788
1789@cindex centering lines (@code{ce})
1790@cindex lines, centering (@code{ce})
1791Text lines can be centered by using the @code{ce} request. The line
1792after @code{ce} is centered (horizontally) on the page. To center more
1793than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1794of lines to center), followed by the @var{N}@tie{}lines. To center many
1795lines without counting them, type:
1796
1797@Example
1798.ce 1000
1799lines to center
1800.ce 0
1801@endExample
1802
1803@noindent
1804The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1805lines, in other words, stop centering.
1806
1807@cindex line break (@code{br})
1808@cindex break (@code{br})
1809All of these requests cause a break; that is, they always start a new
1810line. To start a new line without performing any other action, use
1811@code{br}.
1812
1813
1814@c =====================================================================
1815
1816@node Common Features, , Basics, Tutorial for Macro Users
1817@section Common Features
1818@cindex common features
1819@cindex features, common
1820
1821@code{gtroff} provides very low-level operations for formatting a
1822document. There are many common routine operations which are done in
1823all documents. These common operations are written into @dfn{macros}
1824and collected into a @dfn{macro package}.
1825
1826All macro packages provide certain common capabilities which fall into
1827the following categories.
1828
1829@menu
1830* Paragraphs::
1831* Sections and Chapters::
1832* Headers and Footers::
1833* Page Layout Adjustment::
1834* Displays::
1835* Footnotes and Annotations::
1836* Table of Contents::
1837* Indices::
1838* Paper Formats::
1839* Multiple Columns::
1840* Font and Size Changes::
1841* Predefined Strings::
1842* Preprocessor Support::
1843* Configuration and Customization::
1844@end menu
1845
1846@c ---------------------------------------------------------------------
1847
1848@node Paragraphs, Sections and Chapters, Common Features, Common Features
1849@subsection Paragraphs
1850@cindex paragraphs
1851
4d3e9548
JL
1852One of the most common and most used capability is starting a paragraph.
1853There are a number of different types of paragraphs, any of which can be
1854initiated with macros supplied by the macro package. Normally,
1855paragraphs start with a blank line and the first line indented, like the
1856text in this manual. There are also block style paragraphs, which omit
1857the indentation:
92d0a6a6
JR
1858
1859@Example
1860Some men look at constitutions with sanctimonious
1861reverence, and deem them like the ark of the covenant, too
1862sacred to be touched.
1863@endExample
1864
1865@noindent
1866And there are also indented paragraphs which begin with a tag or label
1867at the margin and the remaining text indented.
1868
1869@Example
1870one This is the first paragraph. Notice how the first
1871 line of the resulting paragraph lines up with the
1872 other lines in the paragraph.
1873@endExample
1874@Example
1875longlabel
1876 This paragraph had a long label. The first
1877 character of text on the first line does not line up
1878 with the text on second and subsequent lines,
1879 although they line up with each other.
1880@endExample
1881
1882A variation of this is a bulleted list.
1883
1884@Example
1885. Bulleted lists start with a bullet. It is possible
1886 to use other glyphs instead of the bullet. In nroff
1887 mode using the ASCII character set for output, a dot
1888 is used instead of a real bullet.
1889@endExample
1890
1891@c ---------------------------------------------------------------------
1892
1893@node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1894@subsection Sections and Chapters
1895
1896Most macro packages supply some form of section headers. The simplest
1897kind is simply the heading on a line by itself in bold type. Others
1898supply automatically numbered section heading or different heading
1899styles at different levels. Some, more sophisticated, macro packages
1900supply macros for starting chapters and appendices.
1901
1902@c ---------------------------------------------------------------------
1903
1904@node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1905@subsection Headers and Footers
1906
1907Every macro package gives some way to manipulate the @dfn{headers} and
4d3e9548
JL
1908@dfn{footers} (also called @dfn{titles}) on each page. This is text put
1909at the top and bottom of each page, respectively, which contain data
1910like the current page number, the current chapter title, and so on. Its
1911appearance is not affected by the running text. Some packages allow for
1912different ones on the even and odd pages (for material printed in a book
1913form).
92d0a6a6
JR
1914
1915The titles are called @dfn{three-part titles}, that is, there is a
1916left-justified part, a centered part, and a right-justified part. An
1917automatically generated page number may be put in any of these fields
1918with the @samp{%} character (see @ref{Page Layout}, for more details).
1919
1920@c ---------------------------------------------------------------------
1921
1922@node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1923@subsection Page Layout
1924
1925Most macro packages let the user specify top and bottom margins and
1926other details about the appearance of the printed pages.
1927
1928@c ---------------------------------------------------------------------
1929
1930@node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
1931@subsection Displays
1932@cindex displays
1933
4d3e9548
JL
1934@dfn{Displays} are sections of text to be set off from the body of the
1935paper. Major quotes, tables, and figures are types of displays, as are
1936all the examples used in this document.
92d0a6a6
JR
1937
1938@cindex quotes, major
1939@cindex major quotes
1940@dfn{Major quotes} are quotes which are several lines long, and hence
1941are set in from the rest of the text without quote marks around them.
1942
1943@cindex list
1944A @dfn{list} is an indented, single-spaced, unfilled display. Lists
1945should be used when the material to be printed should not be filled and
1946justified like normal text, such as columns of figures or the examples
1947used in this paper.
1948
1949@cindex keep
1950A @dfn{keep} is a display of lines which are kept on a single page if
1951possible. An example for a keep might be a diagram. Keeps differ from
1952lists in that lists may be broken over a page boundary whereas keeps are
1953not.
1954
1955@cindex keep, floating
1956@cindex floating keep
4d3e9548
JL
1957@dfn{Floating keeps} move relative to the text. Hence, they are good
1958for things which are referred to by name, such as ``See figure@tie{}3''.
1959A floating keep appears at the bottom of the current page if it fits;
92d0a6a6
JR
1960otherwise, it appears at the top of the next page. Meanwhile, the
1961surrounding text `flows' around the keep, thus leaving no blank areas.
1962
1963@c ---------------------------------------------------------------------
1964
1965@node Footnotes and Annotations, Table of Contents, Displays, Common Features
1966@subsection Footnotes and Annotations
1967@cindex footnotes
1968@cindex annotations
1969
1970There are a number of requests to save text for later printing.
1971
1972@dfn{Footnotes} are printed at the bottom of the current page.
1973
1974@cindex delayed text
1975@dfn{Delayed text} is very similar to a footnote except that it is
1976printed when called for explicitly. This allows a list of references to
1977appear (for example) at the end of each chapter, as is the convention in
1978some disciplines.
1979
1980Most macro packages which supply this functionality also supply a means
1981of automatically numbering either type of annotation.
1982
1983@c ---------------------------------------------------------------------
1984
1985@node Table of Contents, Indices, Footnotes and Annotations, Common Features
1986@subsection Table of Contents
1987@cindex table of contents
1988@cindex contents, table of
1989
1990@dfn{Tables of contents} are a type of delayed text having a tag
1991(usually the page number) attached to each entry after a row of dots.
1992The table accumulates throughout the paper until printed, usually after
1993the paper has ended. Many macro packages provide the ability to have
1994several tables of contents (e.g.@: a standard table of contents, a list
1995of tables, etc).
1996
1997@c ---------------------------------------------------------------------
1998
1999@node Indices, Paper Formats, Table of Contents, Common Features
2000@subsection Indices
2001@cindex index, in macro package
2002
2003While some macro packages use the term @dfn{index}, none actually
2004provide that functionality. The facilities they call indices are
2005actually more appropriate for tables of contents.
2006
2007@pindex makeindex
2008To produce a real index in a document, external tools like the
2009@code{makeindex} program are necessary.
2010
2011@c ---------------------------------------------------------------------
2012
2013@node Paper Formats, Multiple Columns, Indices, Common Features
2014@subsection Paper Formats
2015@cindex paper formats
2016
2017Some macro packages provide stock formats for various kinds of
2018documents. Many of them provide a common format for the title and
2019opening pages of a technical paper. The @file{mm} macros in particular
2020provide formats for letters and memoranda.
2021
2022@c ---------------------------------------------------------------------
2023
2024@node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2025@subsection Multiple Columns
2026
2027Some macro packages (but not @file{man}) provide the ability to have two
2028or more columns on a page.
2029
2030@c ---------------------------------------------------------------------
2031
2032@node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2033@subsection Font and Size Changes
2034
2035The built-in font and size functions are not always intuitive, so all
2036macro packages provide macros to make these operations simpler.
2037
2038@c ---------------------------------------------------------------------
2039
2040@node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2041@subsection Predefined Strings
2042
2043Most macro packages provide various predefined strings for a variety of
2044uses; examples are sub- and superscripts, printable dates, quotes and
2045various special characters.
2046
2047@c ---------------------------------------------------------------------
2048
2049@node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2050@subsection Preprocessor Support
2051
2052All macro packages provide support for various preprocessors and may
2053extend their functionality.
2054
2055For example, all macro packages mark tables (which are processed with
2056@code{gtbl}) by placing them between @code{TS} and @code{TE} macros.
4d3e9548
JL
2057The @file{ms} macro package has an option, @samp{.TS@tie{}H}, that
2058prints a caption at the top of a new page (when the table is too long to
2059fit on a single page).
92d0a6a6
JR
2060
2061@c ---------------------------------------------------------------------
2062
2063@node Configuration and Customization, , Preprocessor Support, Common Features
2064@subsection Configuration and Customization
2065
2066Some macro packages provide means of customizing many of the details of
2067how the package behaves. This ranges from setting the default type size
2068to changing the appearance of section headers.
2069
2070
2071
2072@c =====================================================================
2073@c =====================================================================
2074
2075@node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2076@chapter Macro Packages
2077@cindex macro packages
2078@cindex packages, macros
2079
2080This chapter documents the main macro packages that come with
2081@code{groff}.
2082
4d3e9548
JL
2083Different main macro packages can't be used at the same time; for
2084example
92d0a6a6
JR
2085
2086@Example
2087groff -m man foo.man -m ms bar.doc
2088@endExample
2089
2090@noindent
4d3e9548
JL
2091doesn't work. Note that option arguments are processed before
2092non-option arguments; the above (failing) sample is thus reordered to
92d0a6a6
JR
2093
2094@Example
2095groff -m man -m ms foo.man bar.doc
2096@endExample
2097
2098@menu
2099* man::
2100* mdoc::
2101* ms::
2102* me::
2103* mm::
2104@end menu
2105
2106
2107@c =====================================================================
2108
2109@node man, mdoc, Macro Packages, Macro Packages
2110@section @file{man}
2111@cindex manual pages
2112@cindex man pages
2113@pindex an.tmac
2114@pindex man.tmac
2115@pindex man-old.tmac
2116
2117This is the most popular and probably the most important macro package
2118of @code{groff}. It is easy to use, and a vast majority of manual pages
2119are based on it.
2120
2121@menu
2122* Man options::
2123* Man usage::
2124* Man font macros::
2125* Miscellaneous man macros::
2126* Predefined man strings::
2127* Preprocessors in man pages::
2128* Optional man extensions::
2129@end menu
2130
2131@c ---------------------------------------------------------------------
2132
2133@node Man options, Man usage, man, man
2134@subsection Options
2135
2136The command line format for using the @file{man} macros with
2137@code{groff} is:
2138
2139@Example
2140groff -m man [ -rLL=@var{length} ] [ -rLT=@var{length} ] [ -rFT=@var{dist} ]
2141 [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [-rHY=@var{flags} ]
2142 [ -rP@var{nnn} ] [ -rS@var{xx} ] [ -rX@var{nnn} ]
2143 [ -rIN=@var{length} ] [ -rSN=@var{length} ] [ @var{files}@dots{} ]
2144@endExample
2145
2146@noindent
2147It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2148
2149@table @code
2150@item -rcR=1
2151This option (the default if a TTY output device is used) creates a
4d3e9548
JL
2152single, very long page instead of multiple pages. Use @code{-rcR=0} to
2153disable it.
92d0a6a6
JR
2154
2155@item -rC1
2156If more than one manual page is given on the command line, number the
2157pages continuously, rather than starting each at@tie{}1.
2158
2159@item -rD1
2160Double-sided printing. Footers for even and odd pages are formatted
2161differently.
2162
2163@item -rFT=@var{dist}
2164Set the position of the footer text to @var{dist}. If positive, the
2165distance is measured relative to the top of the page, otherwise it is
2166relative to the bottom. The default is @minus{}0.5@dmn{i}.
2167
2168@item -rHY=@var{flags}
2169Set hyphenation flags. Possible values are 1@tie{}to hyphenate without
4d3e9548
JL
2170restrictions, 2@tie{}to not hyphenate the last word on a page, 4@tie{}to
2171not hyphenate the last two characters of a word, and 8@tie{}to not
2172hyphenate the first two characters of a word. These values are
2173additive; the default is@tie{}14.
92d0a6a6
JR
2174
2175@item -rIN=@var{length}
4d3e9548
JL
2176Set the body text indentation to @var{length}. If not specified, the
2177indentation defaults to 7@dmn{n} (7@tie{}characters) in nroff mode and
21787.2@dmn{n} otherwise. For nroff, this value should always be an integer
2179multiple of unit @samp{n} to get consistent indentation.
92d0a6a6
JR
2180
2181@item -rLL=@var{length}
4d3e9548
JL
2182Set line length to @var{length}. If not specified, the line length is
2183set to respect any value set by a prior @samp{ll} request (which
2184@emph{must} be in effect when the @samp{TH} macro is invoked), if this
2185differs from the built-in default for the formatter; otherwise it
2186defaults to 78@dmn{n} in nroff mode (this is 78 characters per line) and
21876.5@dmn{i} in troff mode.@footnote{Note that the use of a @samp{.ll
2188@var{length}} request to initialize the line length, prior to use of the
2189@samp{TH} macro, is supported for backward compatibility with some
2190versions of the @code{man} program. @emph{Always} use the
2191@option{-rLL=@var{length}} option, or an equivalent @samp{.nr LL
2192@var{length}} request, in preference to such a @samp{.ll @var{length}}
2193request. In particular, note that in nroff mode, the request @samp{.ll
219465n}, (with any @var{length} expression which evaluates equal to
219565@dmn{n}, i.e., the formatter's default line length in nroff mode),
2196does @emph{not} set the line length to 65@dmn{n} (it is adjusted to the
2197@code{man} macro package's default setting of 78@dmn{n}), whereas the
2198use of the @option{-rLL=65n} option, or the @samp{.nr LL 65n} request
2199@emph{does} establish a line length of 65@dmn{n}.}
92d0a6a6
JR
2200
2201@item -rLT=@var{length}
2202Set title length to @var{length}. If not specified, the title length
2203defaults to the line length.
2204
2205@item -rP@var{nnn}
2206Page numbering starts with @var{nnn} rather than with@tie{}1.
2207
2208@item -rS@var{xx}
2209Use @var{xx} (which can be 10, 11, or@tie{}12@dmn{pt}) as the base
2210document font size instead of the default value of@tie{}10@dmn{pt}.
2211
2212@item -rSN=@var{length}
4d3e9548
JL
2213Set the indentation for sub-subheadings to @var{length}. If not
2214specified, the indentation defaults to 3@dmn{n}.
92d0a6a6
JR
2215
2216@item -rX@var{nnn}
2217After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2218@var{nnn}c, etc. For example, the option @option{-rX2} produces the
2219following page numbers: 1, 2, 2a, 2b, 2c, etc.
2220@end table
2221
2222@c ---------------------------------------------------------------------
2223
2224@node Man usage, Man font macros, Man options, man
2225@subsection Usage
2226@cindex @code{man} macros
2227@cindex macros for manual pages [@code{man}]
2228
2229@pindex man.local
2230This section describes the available macros for manual pages. For
2231further customization, put additional macros and requests into the file
2232@file{man.local} which is loaded immediately after the @file{man}
2233package.
2234
2235@Defmac {TH, title section [@Var{extra1} [@Var{extra2} [@Var{extra3}]]], man}
2236Set the title of the man page to @var{title} and the section to
2237@var{section}, which must have a value between 1 and@tie{}8. The value
4d3e9548
JL
2238of @var{section} may also have a string appended, e.g.@: @samp{.pm}, to
2239indicate a specific subsection of the man pages.
92d0a6a6
JR
2240
2241Both @var{title} and @var{section} are positioned at the left and right
2242in the header line (with @var{section} in parentheses immediately
2243appended to @var{title}. @var{extra1} is positioned in the middle of
2244the footer line. @var{extra2} is positioned at the left in the footer
2245line (or at the left on even pages and at the right on odd pages if
2246double-sided printing is active). @var{extra3} is centered in the
2247header line.
2248
4d3e9548
JL
2249For @acronym{HTML} and @acronym{XHTML} output, headers and footers are
2250completely suppressed.
92d0a6a6 2251
4d3e9548
JL
2252Additionally, this macro starts a new page; the new line number
2253is@tie{}1 again (except if the @option{-rC1} option is given on the
2254command line) -- this feature is intended only for formatting multiple
2255man pages; a single man page should contain exactly one @code{TH} macro
2256at the beginning of the file.
92d0a6a6
JR
2257@endDefmac
2258
2259@Defmac {SH, [@Var{heading}], man}
2260Set up an unnumbered section heading sticking out to the left. Prints
2261out all the text following @code{SH} up to the end of the line (or the
4d3e9548
JL
2262text in the next line if there is no argument to @code{SH}) in bold face
2263(or the font specified by the string @code{HF}), one size larger than
2264the base document size. Additionally, the left margin and the
2265indentation for the following text is reset to its default value.
92d0a6a6
JR
2266@endDefmac
2267
2268@Defmac {SS, [@Var{heading}], man}
2269Set up an unnumbered (sub)section heading. Prints out all the text
2270following @code{SS} up to the end of the line (or the text in the next
2271line if there is no argument to @code{SS}) in bold face (or the font
4d3e9548
JL
2272specified by the string @code{HF}), at the same size as the base
2273document size. Additionally, the left margin and the indentation for
2274the following text is reset to its default value.
92d0a6a6
JR
2275@endDefmac
2276
2277@Defmac {TP, [@Var{nnn}], man}
2278Set up an indented paragraph with label. The indentation is set to
4d3e9548
JL
2279@var{nnn} if that argument is supplied (the default unit is @samp{n} if
2280omitted), otherwise it is set to the previous indentation value
92d0a6a6
JR
2281specified with @code{TP}, @code{IP}, or @code{HP} (or to the default
2282value if none of them have been used yet).
2283
2284The first line of text following this macro is interpreted as a string
2285to be printed flush-left, as it is appropriate for a label. It is not
2286interpreted as part of a paragraph, so there is no attempt to fill the
2287first line with text from the following input lines. Nevertheless, if
4d3e9548
JL
2288the label is not as wide as the indentation the paragraph starts at the
2289same line (but indented), continuing on the following lines. If the
2290label is wider than the indentation the descriptive part of the
2291paragraph begins on the line following the label, entirely indented.
2292Note that neither font shape nor font size of the label is set to a
2293default value; on the other hand, the rest of the text has default font
2294settings.
92d0a6a6
JR
2295@endDefmac
2296
2297@DefmacList {LP, , man}
2298@DefmacItem {PP, , man}
2299@DefmacListEnd {P, , man}
4d3e9548
JL
2300These macros are mutual aliases. Any of them causes a line break at the
2301current position, followed by a vertical space downwards by the amount
2302specified by the @code{PD} macro. The font size and shape are reset to
2303the default value (10@dmn{pt} roman if no @option{-rS} option is given
2304on the command line). Finally, the current left margin and the
92d0a6a6
JR
2305indentation is restored.
2306@endDefmac
2307
2308@Defmac {IP, [@Var{designator} [@Var{nnn}]], man}
2309Set up an indented paragraph, using @var{designator} as a tag to mark
4d3e9548
JL
2310its beginning. The indentation is set to @var{nnn} if that argument is
2311supplied (default unit is @samp{n}), otherwise it is set to the previous
2312indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2313the default value if none of them have been used yet). Font size and
2314face of the paragraph (but not the designator) are reset to their
2315default values.
92d0a6a6
JR
2316
2317To start an indented paragraph with a particular indentation but without
2318a designator, use @samp{""} (two double quotes) as the first argument of
2319@code{IP}.
2320
2321For example, to start a paragraph with bullets as the designator and
23224@tie{}en indentation, write
2323
2324@Example
2325.IP \(bu 4
2326@endExample
2327@endDefmac
2328
2329@Defmac {HP, [@Var{nnn}], man}
2330@cindex hanging indentation [@code{man}]
2331@cindex @code{man} macros, hanging indentation
2332Set up a paragraph with hanging left indentation. The indentation is
2333set to @var{nnn} if that argument is supplied (default unit is
2334@samp{n}), otherwise it is set to the previous indentation value
4d3e9548
JL
2335specified with @code{TP}, @code{IP}, or @code{HP} (or the default value
2336if non of them have been used yet). Font size and face are reset to
2337their default values.
92d0a6a6
JR
2338@endDefmac
2339
2340@Defmac {RS, [@Var{nnn}], man}
2341@cindex left margin, how to move [@code{man}]
2342@cindex @code{man} macros, moving left margin
2343Move the left margin to the right by the value @var{nnn} if specified
2344(default unit is @samp{n}); otherwise it is set to the previous
4d3e9548
JL
2345indentation value specified with @code{TP}, @code{IP}, or @code{HP} (or
2346to the default value if none of them have been used yet). The
92d0a6a6
JR
2347indentation value is then set to the default.
2348
2349Calls to the @code{RS} macro can be nested.
2350@endDefmac
2351
2352@Defmac {RE, [@Var{nnn}], man}
4d3e9548
JL
2353Move the left margin back to level @var{nnn}, restoring the previous
2354left margin. If no argument is given, it moves one level back. The
2355first level (i.e., no call to @code{RS} yet) has number@tie{}1, and each
2356call to @code{RS} increases the level by@tie{}1.
92d0a6a6
JR
2357@endDefmac
2358
2359@cindex line breaks, with vertical space [@code{man}]
2360@cindex @code{man} macros, line breaks with vertical space
2361To summarize, the following macros cause a line break with the insertion
2362of vertical space (which amount can be changed with the @code{PD}
2363macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2364@code{P}), @code{IP}, and @code{HP}.
2365
2366@cindex line breaks, without vertical space [@code{man}]
2367@cindex @code{man} macros, line breaks without vertical space
2368The macros @code{RS} and @code{RE} also cause a break but do not insert
2369vertical space.
2370
2371@cindex default indentation, resetting [@code{man}]
2372@cindex indentaion, resetting to default [@code{man}]
2373@cindex @code{man} macros, resetting default indentation
4d3e9548
JL
2374Finally, the macros @code{SH}, @code{SS}, @code{LP} (@code{PP},
2375@code{P}), and @code{RS} reset the indentation to its default value.
92d0a6a6
JR
2376
2377@c ---------------------------------------------------------------------
2378
2379@node Man font macros, Miscellaneous man macros, Man usage, man
2380@subsection Macros to set fonts
2381@cindex font selection [@code{man}]
2382@cindex @code{man} macros, how to set fonts
2383
4d3e9548
JL
2384The standard font is roman; the default text size is 10@tie{}point. If
2385command line option @option{-rS=@var{n}} is given, use @var{n}@dmn{pt}
2386as the default text size.
92d0a6a6
JR
2387
2388@Defmac {SM, [@Var{text}], man}
2389Set the text on the same line or the text on the next line in a font
2390that is one point size smaller than the default font.
2391@endDefmac
2392
2393@Defmac {SB, [@Var{text}], man}
2394@cindex bold face [@code{man}]
2395@cindex @code{man} macros, bold face
2396Set the text on the same line or the text on the next line in bold face
2397font, one point size smaller than the default font.
2398@endDefmac
2399
2400@Defmac {BI, text, man}
2401Set its arguments alternately in bold face and italic, without a space
2402between the arguments. Thus,
2403
2404@Example
2405.BI this "word and" that
2406@endExample
2407
2408@noindent
2409produces ``thisword andthat'' with ``this'' and ``that'' in bold face,
2410and ``word and'' in italics.
2411@endDefmac
2412
2413@Defmac {IB, text, man}
2414Set its arguments alternately in italic and bold face, without a space
2415between the arguments.
2416@endDefmac
2417
2418@Defmac {RI, text, man}
4d3e9548
JL
2419Set its arguments alternately in roman and italic, without a space
2420between the arguments.
92d0a6a6
JR
2421@endDefmac
2422
2423@Defmac {IR, text, man}
4d3e9548
JL
2424Set its arguments alternately in italic and roman, without a space
2425between the arguments.
92d0a6a6
JR
2426@endDefmac
2427
2428@Defmac {BR, text, man}
2429Set its arguments alternately in bold face and roman, without a space
2430between the arguments.
2431@endDefmac
2432
2433@Defmac {RB, text, man}
2434Set its arguments alternately in roman and bold face, without a space
2435between the arguments.
2436@endDefmac
2437
2438@Defmac {B, [@Var{text}], man}
2439Set @var{text} in bold face. If no text is present on the line where
2440the macro is called, then the text of the next line appears in bold
2441face.
2442@endDefmac
2443
2444@Defmac {I, [@Var{text}], man}
2445@cindex italic fonts [@code{man}]
2446@cindex @code{man} macros, italic fonts
2447Set @var{text} in italic. If no text is present on the line where the
2448macro is called, then the text of the next line appears in italic.
2449@endDefmac
2450
2451@c ---------------------------------------------------------------------
2452
2453@node Miscellaneous man macros, Predefined man strings, Man font macros, man
2454@subsection Miscellaneous macros
2455
2456@pindex grohtml
2457@cindex @code{man} macros, default indentation
2458@cindex default indentation [@code{man}]
2459The default indentation is 7.2@dmn{n} in troff mode and 7@dmn{n} in
2460nroff mode except for @code{grohtml} which ignores indentation.
2461
2462@Defmac {DT, , man}
2463@cindex tab stops [@code{man}]
2464@cindex @code{man} macros, tab stops
2465Set tabs every 0.5@tie{}inches. Since this macro is always executed
2466during a call to the @code{TH} macro, it makes sense to call it only if
2467the tab positions have been changed.
2468@endDefmac
2469
2470@Defmac {PD, [@Var{nnn}], man}
2471@cindex empty space before a paragraph [@code{man}]
2472@cindex @code{man} macros, empty space before a paragraph
2473Adjust the empty space before a new paragraph (or section). The
4d3e9548
JL
2474optional argument gives the amount of space (default unit is @samp{v});
2475without parameter, the value is reset to its default value (1@tie{}line
2476in nroff mode, 0.4@dmn{v}@tie{}otherwise).
92d0a6a6
JR
2477
2478This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2479well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2480@endDefmac
2481
4d3e9548 2482The following two macros are included for BSD compatibility.
92d0a6a6
JR
2483
2484@Defmac {AT, [@Var{system} [@Var{release}]], man}
2485@cindex @code{man}macros, BSD compatibility
4d3e9548
JL
2486Alter the footer for use with @acronym{AT&T} manpages. This command
2487exists only for compatibility; don't use it. The first argument
2488@var{system} can be:
92d0a6a6
JR
2489
2490@table @code
2491@item 3
24927th Edition (the default)
2493
2494@item 4
2495System III
2496
2497@item 5
2498System V
2499@end table
2500
2501An optional second argument @var{release} to @code{AT} specifies the
2502release number (such as ``System V Release 3'').
2503@endDefmac
2504
2505@Defmac {UC, [@Var{version}], man}
2506@cindex @code{man}macros, BSD compatibility
4d3e9548
JL
2507Alters the footer for use with @acronym{BSD} manpages. This command
2508exists only for compatibility; don't use it. The argument can be:
92d0a6a6
JR
2509
2510@table @code
2511@item 3
25123rd Berkeley Distribution (the default)
2513
2514@item 4
25154th Berkeley Distribution
2516
2517@item 5
25184.2 Berkeley Distribution
2519
2520@item 6
25214.3 Berkeley Distribution
2522
2523@item 7
25244.4 Berkeley Distribution
2525@end table
2526@endDefmac
2527
2528@c ---------------------------------------------------------------------
2529
2530@node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2531@subsection Predefined strings
2532
2533The following strings are defined:
2534
2535@Defstr {S, man}
2536Switch back to the default font size.
2537@endDefstr
2538
2539@Defstr {HF, man}
2540The typeface used for headings.
2541The default is @samp{B}.
2542@endDefstr
2543
2544@Defstr {R, man}
2545The `registered' sign.
2546@endDefstr
2547
2548@Defstr {Tm, man}
2549The `trademark' sign.
2550@endDefstr
2551
2552@DefstrList {lq, man}
2553@DefstrListEnd {rq, man}
2554@cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2555@cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2556Left and right quote. This is equal to @code{\(lq} and @code{\(rq},
2557respectively.
2558@endDefstr
2559
2560@c ---------------------------------------------------------------------
2561
2562@node Preprocessors in man pages, Optional man extensions, Predefined man strings, man
2563@subsection Preprocessors in @file{man} pages
2564
2565@cindex preprocessor, calling convention
2566@cindex calling convention of preprocessors
2567If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2568become common usage to make the first line of the man page look like
2569this:
2570
2571@Example
2572'\" @var{word}
2573@endExample
2574
2575@pindex geqn@r{, invocation in manual pages}
2576@pindex grefer@r{, invocation in manual pages}
2577@pindex gtbl@r{, invocation in manual pages}
2578@pindex man@r{, invocation of preprocessors}
2579@noindent
2580Note the single space character after the double quote. @var{word}
2581consists of letters for the needed preprocessors: @samp{e} for
2582@code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2583Modern implementations of the @code{man} program read this first line
2584and automatically call the right preprocessor(s).
2585
2586@c ---------------------------------------------------------------------
2587
2588@node Optional man extensions, , Preprocessors in man pages, man
2589@subsection Optional @file{man} extensions
2590
2591@pindex man.local
4d3e9548
JL
2592Use the file @file{man.local} for local extensions to the @code{man}
2593macros or for style changes.
92d0a6a6
JR
2594
2595@unnumberedsubsubsec Custom headers and footers
2596@cindex @code{man} macros, custom headers and footers
2597
4d3e9548
JL
2598In groff versions 1.18.2 and later, you can specify custom headers and
2599footers by redefining the following macros in @file{man.local}.
92d0a6a6
JR
2600
2601@Defmac {PT, , man}
4d3e9548
JL
2602Control the content of the headers. Normally, the header prints the
2603command name and section number on either side, and the optional fifth
2604argument to @code{TH} in the center.
92d0a6a6
JR
2605@endDefmac
2606
2607@Defmac {BT, , man}
4d3e9548
JL
2608Control the content of the footers. Normally, the footer prints the
2609page number and the third and fourth arguments to @code{TH}.
92d0a6a6 2610
4d3e9548
JL
2611Use the @code{FT} number register to specify the footer position. The
2612default is @minus{}0.5@dmn{i}.
92d0a6a6
JR
2613@endDefmac
2614
2615@unnumberedsubsubsec Ultrix-specific man macros
2616@cindex Ultrix-specific @code{man} macros
2617@cindex @code{man} macros, Ultrix-specific
2618
2619@pindex man.ultrix
4d3e9548
JL
2620The @code{groff} source distribution includes a file named
2621@file{man.ultrix}, containing macros compatible with the Ultrix variant
2622of @code{man}. Copy this file into @file{man.local} (or use the
2623@code{mso} request to load it) to enable the following macros.
92d0a6a6
JR
2624
2625@Defmac {CT, @Var{key}, man}
2626Print @samp{<CTRL/@var{key}>}.
2627@endDefmac
2628
2629@Defmac {CW, , man}
2630Print subsequent text using the constant width (Courier) typeface.
2631@endDefmac
2632
2633@Defmac {Ds, , man}
2634Begin a non-filled display.
2635@endDefmac
2636
2637@Defmac {De, , man}
2638End a non-filled display started with @code{Ds}.
2639@endDefmac
2640
2641@Defmac {EX, [@Var{indent}], man}
4d3e9548
JL
2642Begin a non-filled display using the constant width (Courier) typeface.
2643Use the optional @var{indent} argument to indent the display.
92d0a6a6
JR
2644@endDefmac
2645
2646@Defmac {EE, , man}
2647End a non-filled display started with @code{EX}.
2648@endDefmac
2649
2650@Defmac {G, [@Var{text}], man}
4d3e9548
JL
2651Set @var{text} in Helvetica. If no text is present on the line where
2652the macro is called, then the text of the next line appears in
2653Helvetica.
92d0a6a6
JR
2654@endDefmac
2655
2656@Defmac {GL, [@Var{text}], man}
4d3e9548
JL
2657Set @var{text} in Helvetica Oblique. If no text is present on the line
2658where the macro is called, then the text of the next line appears in
2659Helvetica Oblique.
92d0a6a6
JR
2660@endDefmac
2661
2662@Defmac {HB, [@Var{text}], man}
4d3e9548
JL
2663Set @var{text} in Helvetica Bold. If no text is present on the line
2664where the macro is called, then all text up to the next @code{HB}
2665appears in Helvetica Bold.
92d0a6a6
JR
2666@endDefmac
2667
2668@Defmac {TB, [@Var{text}], man}
2669Identical to @code{HB}.
2670@endDefmac
2671
2672@Defmac {MS, @Var{title} @Var{sect} [@Var{punct}], man}
4d3e9548
JL
2673Set a manpage reference in Ultrix format. The @var{title} is in Courier
2674instead of italic. Optional punctuation follows the section number
2675without an intervening space.
92d0a6a6
JR
2676@endDefmac
2677
2678@Defmac {NT, [@code{C}] [@Var{title}], man}
4d3e9548
JL
2679Begin a note. Print the optional @Var{title}, or the word ``Note'',
2680centered on the page. Text following the macro makes up the body of the
2681note, and is indented on both sides. If the first argument is @code{C},
2682the body of the note is printed centered (the second argument replaces
92d0a6a6
JR
2683the word ``Note'' if specified).
2684@endDefmac
2685
2686@Defmac {NE, , man}
2687End a note begun with @code{NT}.
2688@endDefmac
2689
2690@Defmac {PN, @Var{path} [@Var{punct}], man}
4d3e9548
JL
2691Set the path name in constant width (Courier), followed by optional
2692punctuation.
92d0a6a6
JR
2693@endDefmac
2694
2695@Defmac {Pn, [@Var{punct}] @Var{path} [@Var{punct}], man}
4d3e9548
JL
2696If called with two arguments, identical to @code{PN}. If called with
2697three arguments, set the second argument in constant width (Courier),
92d0a6a6
JR
2698bracketed by the first and third arguments in the current font.
2699@endDefmac
2700
2701@Defmac {R, , man}
2702Switch to roman font and turn off any underlining in effect.
2703@endDefmac
2704
2705@Defmac {RN, , man}
2706Print the string @samp{<RETURN>}.
2707@endDefmac
2708
2709@Defmac {VS, [@code{4}], man}
4d3e9548
JL
2710Start printing a change bar in the margin if the number@tie{}@code{4} is
2711specified. Otherwise, this macro does nothing.
92d0a6a6
JR
2712@endDefmac
2713
2714@Defmac {VE, , man}
2715End printing the change bar begun by @code{VS}.
2716@endDefmac
2717
2718@unnumberedsubsubsec Simple example
2719
4d3e9548
JL
2720The following example @file{man.local} file alters the @code{SH} macro
2721to add some extra vertical space before printing the heading. Headings
2722are printed in Helvetica Bold.
92d0a6a6
JR
2723
2724@Example
2725.\" Make the heading fonts Helvetica
2726.ds HF HB
2727.
2728.\" Put more whitespace in front of headings.
2729.rn SH SH-orig
2730.de SH
2731. if t .sp (u;\\n[PD]*2)
2732. SH-orig \\$*
2733..
2734@endExample
2735
4d3e9548 2736
92d0a6a6
JR
2737@c =====================================================================
2738
2739@node mdoc, ms, man, Macro Packages
2740@section @file{mdoc}
2741@cindex @code{mdoc} macros
2742
2743@c XXX documentation
2744@c XXX this is a placeholder until we get stuff knocked into shape
2745See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2746at the command line).
2747
2748
2749@c =====================================================================
2750
2751@node ms, me, mdoc, Macro Packages
2752@section @file{ms}
2753@cindex @code{ms} macros
2754
465b256c
JR
2755The @file{-ms} macros are suitable for reports, letters, books, user
2756manuals, and so forth. The package provides macros for cover pages,
4d3e9548
JL
2757section headings, paragraphs, lists, footnotes, pagination, and a table
2758of contents.
92d0a6a6
JR
2759
2760@menu
2761* ms Intro::
2762* General ms Structure::
2763* ms Document Control Registers::
2764* ms Cover Page Macros::
2765* ms Body Text::
2766* ms Page Layout::
2767* Differences from AT&T ms::
465b256c 2768* Naming Conventions::
92d0a6a6
JR
2769@end menu
2770
2771@c ---------------------------------------------------------------------
2772
2773@node ms Intro, General ms Structure, ms, ms
2774@subsection Introduction to @file{ms}
2775
465b256c
JR
2776The original @file{-ms} macros were included with @acronym{AT&T}
2777@code{troff} as well as the @file{man} macros. While the @file{man}
4d3e9548
JL
2778package is intended for brief documents that can be read on-line as well
2779as printed, the @file{ms} macros are suitable for longer documents that
2780are meant to be printed rather than read on-line.
92d0a6a6 2781
465b256c 2782The @file{ms} macro package included with @code{groff} is a complete,
4d3e9548
JL
2783bottom-up re-implementation. Several macros (specific to @acronym{AT&T}
2784or Berkeley) are not included, while several new commands are.
2785@xref{Differences from AT&T ms}, for more information.
92d0a6a6
JR
2786
2787@c ---------------------------------------------------------------------
2788
2789@node General ms Structure, ms Document Control Registers, ms Intro, ms
2790@subsection General structure of an @file{ms} document
2791@cindex @code{ms} macros, general structure
2792
465b256c
JR
2793The @file{ms} macro package expects a certain amount of structure, but
2794not as much as packages such as @file{man} or @file{mdoc}.
92d0a6a6 2795
465b256c
JR
2796The simplest documents can begin with a paragraph macro (such as
2797@code{LP} or @code{PP}), and consist of text separated by paragraph
2798macros or even blank lines. Longer documents have a structure as
2799follows:
92d0a6a6
JR
2800
2801@table @strong
2802@item Document type
465b256c
JR
2803If you invoke the @code{RP} (report) macro on the first line of the
2804document, @code{groff} prints the cover page information on its own
2805page; otherwise it prints the information on the first page with your
2806document text immediately following. Other document formats found in
4d3e9548
JL
2807@acronym{AT&T} @code{troff} are specific to @acronym{AT&T} or Berkeley,
2808and are not supported in @code{groff}.
92d0a6a6
JR
2809
2810@item Format and layout
465b256c
JR
2811By setting number registers, you can change your document's type (font
2812and size), margins, spacing, headers and footers, and footnotes.
92d0a6a6
JR
2813@xref{ms Document Control Registers}, for more details.
2814
2815@item Cover page
4d3e9548
JL
2816A cover page consists of a title, the author's name and institution, an
2817abstract, and the date.@footnote{Actually, only the title is required.}
2818@xref{ms Cover Page Macros}, for more details.
92d0a6a6
JR
2819
2820@item Body
465b256c
JR
2821Following the cover page is your document. You can use the @file{ms}
2822macros to write reports, letters, books, and so forth. The package is
4d3e9548
JL
2823designed for structured documents, consisting of paragraphs interspersed
2824with headings and augmented by lists, footnotes, tables, and other
2825common constructs. @xref{ms Body Text}, for more details.
92d0a6a6
JR
2826
2827@item Table of contents
465b256c 2828Longer documents usually include a table of contents, which you can
4d3e9548
JL
2829invoke by placing the @code{TC} macro at the end of your document. The
2830@file{ms} macros have minimal indexing facilities, consisting of the
2831@code{IX} macro, which prints an entry on standard error. Printing the
2832table of contents at the end is necessary since @code{groff} is a
2833single-pass text formatter, thus it cannot determine the page number of
2834each section until that section has actually been set and printed.
2835Since @file{ms} output is intended for hardcopy, you can manually
2836relocate the pages containing the table of contents between the cover
2837page and the body text after printing.
92d0a6a6
JR
2838@end table
2839
2840@c ---------------------------------------------------------------------
2841
2842@node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2843@subsection Document control registers
2844@cindex @code{ms} macros, document control registers
2845
465b256c
JR
2846The following is a list of document control number registers. For the
2847sake of consistency, set registers related to margins at the beginning
4d3e9548
JL
2848of your document, or just after the @code{RP} macro. You can set other
2849registers later in your document, but you should keep them together at
2850the beginning to make them easy to find and edit as necessary.
92d0a6a6
JR
2851
2852@unnumberedsubsubsec Margin Settings
2853
2854@Defmpreg {PO, ms}
465b256c
JR
2855Defines the page offset (i.e., the left margin). There is no explicit
2856right margin setting; the combination of the @code{PO} and @code{LL}
2857registers implicitly define the right margin width.
92d0a6a6
JR
2858
2859Effective: next page.
2860
2861Default value: 1@dmn{i}.
2862@endDefmpreg
2863
2864@Defmpreg {LL, ms}
465b256c 2865Defines the line length (i.e., the width of the body text).
92d0a6a6
JR
2866
2867Effective: next paragraph.
2868
2869Default: 6@dmn{i}.
2870@endDefmpreg
2871
2872@Defmpreg {LT, ms}
465b256c
JR
2873Defines the title length (i.e., the header and footer width). This
2874is usually the same as @code{LL}, but not necessarily.
92d0a6a6
JR
2875
2876Effective: next paragraph.
2877
2878Default: 6@dmn{i}.
2879@endDefmpreg
2880
2881@Defmpreg {HM, ms}
2882Defines the header margin height at the top of the page.
2883
2884Effective: next page.
2885
2886Default: 1@dmn{i}.
2887@endDefmpreg
2888
2889@Defmpreg {FM, ms}
2890Defines the footer margin height at the bottom of the page.
2891
2892Effective: next page.
2893
2894Default: 1@dmn{i}.
2895@endDefmpreg
2896
2897@unnumberedsubsubsec Text Settings
2898
2899@Defmpreg {PS, ms}
4d3e9548
JL
2900Defines the point size of the body text. If the value is larger than or
2901equal to 1000, divide it by 1000 to get a fractional point size. For
2902example, @samp{.nr PS 10250} sets the document's point size to
465b256c 290310.25@dmn{p}.
92d0a6a6
JR
2904
2905Effective: next paragraph.
2906
2907Default: 10@dmn{p}.
2908@endDefmpreg
2909
2910@Defmpreg {VS, ms}
465b256c
JR
2911Defines the space between lines (line height plus leading). If the
2912value is larger than or equal to 1000, divide it by 1000 to get a
2913fractional point size. Due to backwards compatibility, @code{VS} must
2914be smaller than 40000 (this is 40.0@dmn{p}).
92d0a6a6
JR
2915
2916Effective: next paragraph.
2917
2918Default: 12@dmn{p}.
2919@endDefmpreg
2920
465b256c 2921@Defmpreg {PSINCR, ms}
4d3e9548
JL
2922Defines an increment in point size, which is applied to section headings
2923at nesting levels below the value specified in @code{GROWPS}. The value
2924of @code{PSINCR} should be specified in points, with the @dmn{p} scaling
2925factor, and may include a fractional component; for example,
2926@w{@samp{.nr PSINCR 1.5p}} sets a point size increment of 1.5@dmn{p}.
465b256c
JR
2927
2928Effective: next section heading.
2929
2930Default: 1@dmn{p}.
2931@endDefmpreg
2932
2933@Defmpreg {GROWPS, ms}
2934Defines the heading level below which the point size increment set by
2935@code{PSINCR} becomes effective. Section headings at and above the
4d3e9548
JL
2936level specified by @code{GROWPS} are printed at the point size set by
2937@code{PS}; for each level below the value of @code{GROWPS}, the point
2938size is increased in steps equal to the value of @code{PSINCR}. Setting
2939@code{GROWPS} to any value less than@tie{}2 disables the incremental
2940heading size feature.
465b256c
JR
2941
2942Effective: next section heading.
2943
2944Default: 0.
2945@endDefmpreg
2946
2947@Defmpreg {HY, ms}
2948Defines the hyphenation level. @code{HY} sets safely the value of the
4d3e9548
JL
2949low-level @code{hy} register. Setting the value of @code{HY} to@tie{}0
2950is equivalent to using the @code{nh} request.
465b256c
JR
2951
2952Effective: next paragraph.
2953
2954Default: 14.
2955@endDefmpreg
2956
2957@Defmpreg {FAM, ms}
2958Defines the font family used to typeset the document.
2959
2960Effective: next paragraph.
2961
2962Default: as defined in the output device.
2963@endDefmpreg
2964
92d0a6a6
JR
2965@unnumberedsubsubsec Paragraph Settings
2966
2967@Defmpreg {PI, ms}
465b256c 2968Defines the initial indentation of a (@code{PP} macro) paragraph.
92d0a6a6
JR
2969
2970Effective: next paragraph.
2971
2972Default: 5@dmn{n}.
2973@endDefmpreg
2974
2975@Defmpreg {PD, ms}
2976Defines the space between paragraphs.
2977
2978Effective: next paragraph.
2979
2980Default: 0.3@dmn{v}.
2981@endDefmpreg
2982
2983@Defmpreg {QI, ms}
465b256c
JR
2984Defines the indentation on both sides of a quoted (@code{QP} macro)
2985paragraph.
92d0a6a6
JR
2986
2987Effective: next paragraph.
2988
2989Default: 5@dmn{n}.
2990@endDefmpreg
2991
465b256c
JR
2992@Defmpreg {PORPHANS, ms}
2993Defines the minimum number of initial lines of any paragraph which
4d3e9548
JL
2994should be kept together, to avoid orphan lines at the bottom of a page.
2995If a new paragraph is started close to the bottom of a page, and there
2996is insufficient space to accommodate @code{PORPHANS} lines before an
2997automatic page break, then the page break is forced, before the start of
2998the paragraph.
465b256c
JR
2999
3000Effective: next paragraph.
3001
3002Default: 1.
3003@endDefmpreg
3004
3005@Defmpreg {HORPHANS, ms}
3006Defines the minimum number of lines of the following paragraph which
3007should be kept together with any section heading introduced by the
4d3e9548
JL
3008@code{NH} or @code{SH} macros. If a section heading is placed close to
3009the bottom of a page, and there is insufficient space to accommodate
3010both the heading and at least @code{HORPHANS} lines of the following
3011paragraph, before an automatic page break, then the page break is forced
3012before the heading.
465b256c
JR
3013
3014Effective: next paragraph.
3015
3016Default: 1.
3017@endDefmpreg
3018
92d0a6a6
JR
3019@unnumberedsubsubsec Footnote Settings
3020
3021@Defmpreg {FL, ms}
3022Defines the length of a footnote.
3023
3024Effective: next footnote.
3025
3026Default: @math{@code{@\n[LL]} * 5 / 6}.
3027@endDefmpreg
3028
3029@Defmpreg {FI, ms}
465b256c 3030Defines the footnote indentation.
92d0a6a6
JR
3031
3032Effective: next footnote.
3033
3034Default: 2@dmn{n}.
3035@endDefmpreg
3036
3037@Defmpreg {FF, ms}
3038The footnote format:
3039@table @code
3040@item 0
465b256c
JR
3041Print the footnote number as a superscript; indent the footnote
3042(default).
92d0a6a6
JR
3043
3044@item 1
465b256c
JR
3045Print the number followed by a period (like 1.@:) and indent the
3046footnote.
92d0a6a6
JR
3047
3048@item 2
465b256c 3049Like 1, without an indentation.
92d0a6a6
JR
3050
3051@item 3
465b256c 3052Like 1, but print the footnote number as a hanging paragraph.
92d0a6a6
JR
3053@end table
3054
3055Effective: next footnote.
3056
3057Default: 0.
3058@endDefmpreg
3059
3060@Defmpreg {FPS, ms}
465b256c
JR
3061Defines the footnote point size. If the value is larger than or equal
3062to 1000, divide it by 1000 to get a fractional point size.
92d0a6a6
JR
3063
3064Effective: next footnote.
3065
3066Default: @math{@code{@\n[PS]} - 2}.
3067@endDefmpreg
3068
3069@Defmpreg {FVS, ms}
465b256c
JR
3070Defines the footnote vertical spacing. If the value is larger than or
3071equal to 1000, divide it by 1000 to get a fractional point size.
92d0a6a6
JR
3072
3073Effective: next footnote.
3074
3075Default: @math{@code{@\n[FPS]} + 2}.
3076@endDefmpreg
3077
3078@Defmpreg {FPD, ms}
3079Defines the footnote paragraph spacing.
3080
3081Effective: next footnote.
3082
3083Default: @math{@code{@\n[PD]} / 2}.
3084@endDefmpreg
3085
3086@unnumberedsubsubsec Miscellaneous Number Registers
3087
3088@Defmpreg {MINGW, ms}
3089Defines the minimum width between columns in a multi-column document.
3090
3091Effective: next page.
3092
3093Default: 2@dmn{n}.
3094@endDefmpreg
3095
3096@c ---------------------------------------------------------------------
3097
3098@node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
3099@subsection Cover page macros
3100@cindex @code{ms} macros, cover page
3101@cindex cover page macros, [@code{ms}]
3102
4d3e9548
JL
3103Use the following macros to create a cover page for your document in the
3104order shown.
92d0a6a6
JR
3105
3106@Defmac {RP, [@code{no}], ms}
465b256c 3107Specifies the report format for your document. The report format
4d3e9548
JL
3108creates a separate cover page. The default action (no @code{RP} macro)
3109is to print a subset of the cover page on page@tie{}1 of your document.
465b256c
JR
3110
3111If you use the word @code{no} as an optional argument, @code{groff}
3112prints a title page but does not repeat any of the title page
3113information (title, author, abstract, etc.@:) on page@tie{}1 of the
3114document.
3115@endDefmac
3116
3117@Defmac {P1, , ms}
3118(P-one) Prints the header on page@tie{}1. The default is to suppress
3119the header.
92d0a6a6
JR
3120@endDefmac
3121
3122@Defmac {DA, [@dots{}], ms}
465b256c
JR
3123(optional) Prints the current date, or the arguments to the macro if
3124any, on the title page (if specified) and in the footers. This is the
3125default for @code{nroff}.
92d0a6a6
JR
3126@endDefmac
3127
3128@Defmac {ND, [@dots{}], ms}
465b256c
JR
3129(optional) Prints the current date, or the arguments to the macro if
3130any, on the title page (if specified) but not in the footers. This is
3131the default for @code{troff}.
92d0a6a6
JR
3132@endDefmac
3133
3134@Defmac {TL, , ms}
4d3e9548
JL
3135Specifies the document title. @code{groff} collects text following the
3136@code{TL} macro into the title, until reaching the author name or
465b256c 3137abstract.
92d0a6a6
JR
3138@endDefmac
3139
3140@Defmac {AU, , ms}
465b256c
JR
3141Specifies the author's name, which appears on the line (or lines)
3142immediately following. You can specify multiple authors as follows:
92d0a6a6
JR
3143
3144@Example
3145.AU
3146John Doe
3147.AI
3148University of West Bumblefuzz
3149.AU
3150Martha Buck
3151.AI
3152Monolithic Corporation
3153
3154...
3155@endExample
3156@endDefmac
3157
3158@Defmac {AI, , ms}
465b256c
JR
3159Specifies the author's institution. You can specify multiple
3160institutions in the same way that you specify multiple authors.
92d0a6a6
JR
3161@endDefmac
3162
3163@Defmac {AB, [@code{no}], ms}
465b256c
JR
3164Begins the abstract. The default is to print the word
3165@acronym{ABSTRACT}, centered and in italics, above the text of the
3166abstract. The word @code{no} as an optional argument suppresses this
3167heading.
92d0a6a6
JR
3168@endDefmac
3169
3170@Defmac {AE, , ms}
465b256c 3171Ends the abstract.
92d0a6a6
JR
3172@endDefmac
3173
3174The following is example mark-up for a title page.
3175@cindex title page, example markup
3176@cindex example markup, title page
3177
3178@Example
3179@cartouche
3180.RP
3181.TL
3182The Inevitability of Code Bloat
3183in Commercial and Free Software
3184.AU
3185J. Random Luser
3186.AI
3187University of West Bumblefuzz
3188.AB
3189This report examines the long-term growth
3190of the code bases in two large, popular software
3191packages; the free Emacs and the commercial
3192Microsoft Word.
3193While differences appear in the type or order
3194of features added, due to the different
3195methodologies used, the results are the same
3196in the end.
3197.PP
3198The free software approach is shown to be
3199superior in that while free software can
3200become as bloated as commercial offerings,
3201free software tends to have fewer serious
3202bugs and the added features are in line with
3203user demand.
3204.AE
3205
3206... the rest of the paper follows ...
3207@end cartouche
3208@endExample
3209
3210@c ---------------------------------------------------------------------
3211
3212@node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
3213@subsection Body text
3214@cindex @code{ms} macros, body text
3215
4d3e9548
JL
3216This section describes macros used to mark up the body of your document.
3217Examples include paragraphs, sections, and other groups.
92d0a6a6
JR
3218
3219@menu
3220* Paragraphs in ms::
3221* Headings in ms::
3222* Highlighting in ms::
3223* Lists in ms::
465b256c 3224* Indentation values in ms::
92d0a6a6
JR
3225* Tabstops in ms::
3226* ms Displays and Keeps::
3227* ms Insertions::
3228* Example multi-page table::
3229* ms Footnotes::
3230@end menu
3231
3232@c ---------------------------------------------------------------------
3233
3234@node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
3235@subsubsection Paragraphs
3236@cindex @code{ms} macros, paragraph handling
3237
3238The following paragraph types are available.
3239
465b256c
JR
3240@DefmacList {PP, , ms}
3241@DefmacListEnd {LP, , ms}
3242Sets a paragraph with an initial indentation.
92d0a6a6
JR
3243@endDefmac
3244
3245@Defmac {QP, , ms}
465b256c
JR
3246Sets a paragraph that is indented at both left and right margins. The
3247effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
92d0a6a6
JR
3248The next paragraph or heading returns margins to normal.
3249@endDefmac
3250
3251@Defmac {XP, , ms}
465b256c 3252Sets a paragraph whose lines are indented, except for the first line.
92d0a6a6
JR
3253This is a Berkeley extension.
3254@endDefmac
3255
3256The following markup uses all four paragraph macros.
3257
3258@Example
3259@cartouche
3260.NH 2
3261Cases used in the study
3262.LP
3263The following software and versions were
3264considered for this report.
3265.PP
3266For commercial software, we chose
3267.B "Microsoft Word for Windows" ,
3268starting with version 1.0 through the
3269current version (Word 2000).
3270.PP
3271For free software, we chose
3272.B Emacs ,
3273from its first appearance as a standalone
3274editor through the current version (v20).
3275See [Bloggs 2002] for details.
3276.QP
3277Franklin's Law applied to software:
3278software expands to outgrow both
3279RAM and disk space over time.
3280.LP
3281Bibliography:
3282.XP
3283Bloggs, Joseph R.,
3284.I "Everyone's a Critic" ,
3285Underground Press, March 2002.
3286A definitive work that answers all questions
3287and criticisms about the quality and usability of
3288free software.
3289@end cartouche
3290@endExample
3291
465b256c
JR
3292The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3293operates in conjunction with each of these macros, to inhibit the
3294printing of orphan lines at the bottom of any page.
3295
92d0a6a6
JR
3296@c ---------------------------------------------------------------------
3297
3298@node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3299@subsubsection Headings
3300@cindex @code{ms} macros, headings
3301
4d3e9548
JL
3302Use headings to create a hierarchical structure for your document. The
3303@file{ms} macros print headings in @strong{bold}, using the same font
3304family and point size as the body text.
92d0a6a6
JR
3305
3306The following describes the heading macros:
3307
3308@DefmacList {NH, @Var{curr-level}, ms}
3309@DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
4d3e9548
JL
3310Numbered heading. The argument is either a numeric argument to indicate
3311the level of the heading, or the letter@tie{}@code{S} followed by
3312numeric arguments to set the heading level explicitly.
92d0a6a6
JR
3313
3314If you specify heading levels out of sequence, such as invoking
465b256c
JR
3315@samp{.NH 3} after @samp{.NH 1}, @code{groff} prints a warning on
3316standard error.
92d0a6a6
JR
3317@endDefmac
3318
465b256c
JR
3319@DefstrList {SN, ms}
3320@DefstrItem {SN-DOT, ms}
3321@DefstrListEnd {SN-NO-DOT, ms}
3322After invocation of @code{NH}, the assigned section number is made
4d3e9548
JL
3323available in the strings @code{SN-DOT} (as it appears in a printed
3324section heading with default formatting, followed by a terminating
3325period), and @code{SN-NO-DOT} (with the terminating period omitted).
3326The string @code{SN} is also defined, as an alias for @code{SN-DOT}; if
3327preferred, you may redefine it as an alias for @code{SN-NO-DOT}, by
3328including the initialization
465b256c 3329@Example
465b256c
JR
3330.als SN SN-NO-DOT
3331@endExample
3332
3333@noindent
4d3e9548
JL
3334at any time @strong{before} you would like the change to take effect.
3335@endDefstr
465b256c 3336
4d3e9548
JL
3337@Defstr {SN-STYLE, ms}
3338You may control the style used to print section numbers, within numbered
3339section headings, by defining an appropriate alias for the string
3340@code{SN-STYLE}. The default style, in which the printed section number
3341is followed by a terminating period, is obtained by defining the alias
465b256c 3342@Example
4d3e9548 3343.als SN-STYLE SN-DOT
465b256c
JR
3344@endExample
3345
3346@noindent
4d3e9548
JL
3347If you prefer to omit the terminating period, from section numbers
3348appearing in numbered section headings, you may define the alias
3349@Example
3350.als SN-STYLE SN-NO-DOT
3351@endExample
3352
3353@noindent
3354Any such change in section numbering style becomes effective from the
3355next use of @code{.NH}, following redefinition of the alias for
3356@code{SN-STYLE}.
465b256c
JR
3357@endDefstr
3358
3359@Defmac {SH, [@Var{match-level}], ms}
92d0a6a6 3360Unnumbered subheading.
465b256c
JR
3361
3362The optional @var{match-level} argument is a GNU extension. It is a
4d3e9548
JL
3363number indicating the level of the heading, in a manner analogous to the
3364@var{curr-level} argument to @code{.NH}. Its purpose is to match the
3365point size, at which the heading is printed, to the size of a numbered
3366heading at the same level, when the @code{GROWPS} and @code{PSINCR}
3367heading size adjustment mechanism is in effect. @xref{ms Document
3368Control Registers}.
92d0a6a6
JR
3369@endDefmac
3370
465b256c
JR
3371The @code{HORPHANS} register (@pxref{ms Document Control Registers})
3372operates in conjunction with the @code{NH} and @code{SH} macros, to
3373inhibit the printing of orphaned section headings at the bottom of any
3374page.
3375
92d0a6a6
JR
3376@c ---------------------------------------------------------------------
3377
3378@node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3379@subsubsection Highlighting
3380@cindex @code{ms} macros, highlighting
3381
465b256c
JR
3382The @file{ms} macros provide a variety of methods to highlight or
3383emphasize text:
92d0a6a6
JR
3384
3385@Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
4d3e9548
JL
3386Sets its first argument in @strong{bold type}. If you specify a second
3387argument, @code{groff} prints it in the previous font after the bold
3388text, with no intervening space (this allows you to set punctuation
3389after the highlighted text without highlighting the punctuation).
3390Similarly, it prints the third argument (if any) in the previous font
3391@strong{before} the first argument. For example,
92d0a6a6
JR
3392
3393@Example
3394.B foo ) (
3395@endExample
3396
3397prints (@strong{foo}).
3398
465b256c
JR
3399If you give this macro no arguments, @code{groff} prints all text
3400following in bold until the next highlighting, paragraph, or heading
3401macro.
92d0a6a6
JR
3402@endDefmac
3403
3404@Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
465b256c
JR
3405Sets its first argument in roman (or regular) type. It operates
3406similarly to the @code{B}@tie{}macro otherwise.
92d0a6a6
JR
3407@endDefmac
3408
3409@Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
465b256c
JR
3410Sets its first argument in @emph{italic type}. It operates similarly
3411to the @code{B}@tie{}macro otherwise.
92d0a6a6
JR
3412@endDefmac
3413
3414@Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
465b256c
JR
3415Sets its first argument in a @code{constant width face}. It operates
3416similarly to the @code{B}@tie{}macro otherwise.
92d0a6a6
JR
3417@endDefmac
3418
3419@Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
465b256c
JR
3420Sets its first argument in bold italic type. It operates similarly to
3421the @code{B}@tie{}macro otherwise.
92d0a6a6
JR
3422@endDefmac
3423
3424@Defmac {BX, [@Var{txt}], ms}
465b256c
JR
3425Prints its argument and draws a box around it. If you want to box a
3426string that contains spaces, use a digit-width space (@code{\0}).
92d0a6a6
JR
3427@endDefmac
3428
3429@Defmac {UL, [@Var{txt} [@Var{post}]], ms}
465b256c
JR
3430Prints its first argument with an underline. If you specify a second
3431argument, @code{groff} prints it in the previous font after the
3432underlined text, with no intervening space.
92d0a6a6
JR
3433@endDefmac
3434
3435@Defmac {LG, , ms}
465b256c
JR
3436Prints all text following in larger type (two points larger than the
3437current point size) until the next font size, highlighting, paragraph,
3438or heading macro. You can specify this macro multiple times to
3439enlarge the point size as needed.
92d0a6a6
JR
3440@endDefmac
3441
3442@Defmac {SM, , ms}
465b256c
JR
3443Prints all text following in smaller type (two points smaller than the
3444current point size) until the next type size, highlighting, paragraph,
3445or heading macro. You can specify this macro multiple times to reduce
3446the point size as needed.
92d0a6a6
JR
3447@endDefmac
3448
3449@Defmac {NL, , ms}
465b256c
JR
3450Prints all text following in the normal point size (that is, the value
3451of the @code{PS} register).
92d0a6a6
JR
3452@endDefmac
3453
465b256c
JR
3454@DefstrList {@Lbrace{}, ms}
3455@DefstrListEnd {@Rbrace{}, ms}
3456Text enclosed with @code{\*@{} and @code{\*@}} is printed as a
3457superscript.
3458@endDefstr
3459
92d0a6a6
JR
3460@c ---------------------------------------------------------------------
3461
465b256c 3462@node Lists in ms, Indentation values in ms, Highlighting in ms, ms Body Text
92d0a6a6
JR
3463@subsubsection Lists
3464@cindex @code{ms} macros, lists
3465
465b256c 3466The @code{IP} macro handles duties for all lists.
92d0a6a6
JR
3467
3468@Defmac {IP, [@Var{marker} [@Var{width}]], ms}
4d3e9548
JL
3469The @var{marker} is usually a bullet glyph (@code{\[bu]}) for unordered
3470lists, a number (or auto-incrementing number register) for numbered
3471lists, or a word or phrase for indented (glossary-style) lists.
465b256c
JR
3472
3473The @var{width} specifies the indentation for the body of each list
3474item; its default unit is @samp{n}. Once specified, the indentation
3475remains the same for all list items in the document until specified
3476again.
3477
3478The @code{PORPHANS} register (@pxref{ms Document Control Registers})
3479operates in conjunction with the @code{IP} macro, to inhibit the
3480printing of orphaned list markers at the bottom of any page.
92d0a6a6
JR
3481@endDefmac
3482
3483The following is an example of a bulleted list.
3484@cindex example markup, bulleted list [@code{ms}]
3485@cindex bulleted list, example markup [@code{ms}]
3486
3487@Example
3488A bulleted list:
3489.IP \[bu] 2
3490lawyers
3491.IP \[bu]
3492guns
3493.IP \[bu]
3494money
3495@endExample
3496
3497Produces:
3498
3499@Example
3500A bulleted list:
3501
3502o lawyers
3503
3504o guns
3505
3506o money
3507@endExample
3508
92d0a6a6
JR
3509The following is an example of a numbered list.
3510@cindex example markup, numbered list [@code{ms}]
3511@cindex numbered list, example markup [@code{ms}]
3512
3513@Example
3514.nr step 1 1
3515A numbered list:
3516.IP \n[step] 3
3517lawyers
3518.IP \n+[step]
3519guns
3520.IP \n+[step]
3521money
3522@endExample
3523
3524Produces:
3525
3526@Example
3527A numbered list:
3528
35291. lawyers
3530
35312. guns
3532
35333. money
3534@endExample
3535
465b256c 3536Note the use of the auto-incrementing number register in this example.
92d0a6a6 3537
92d0a6a6
JR
3538The following is an example of a glossary-style list.
3539@cindex example markup, glossary-style list [@code{ms}]
3540@cindex glossary-style list, example markup [@code{ms}]
3541
3542@Example
3543A glossary-style list:
3544.IP lawyers 0.4i
3545Two or more attorneys.
3546.IP guns
3547Firearms, preferably
3548large-caliber.
3549.IP money
3550Gotta pay for those
3551lawyers and guns!
3552@endExample
3553
3554Produces:
3555
3556@Example
3557A glossary-style list:
3558
3559lawyers
3560 Two or more attorneys.
3561
3562guns Firearms, preferably large-caliber.
3563
3564money
3565 Gotta pay for those lawyers and guns!
3566@endExample
3567
465b256c
JR
3568In the last example, the @code{IP} macro places the definition on the
3569same line as the term if it has enough space; otherwise, it breaks to
4d3e9548
JL
3570the next line and starts the definition below the term. This may or may
3571not be the effect you want, especially if some of the definitions break
3572and some do not. The following examples show two possible ways to force
3573a break.
92d0a6a6 3574
465b256c
JR
3575The first workaround uses the @code{br} request to force a break after
3576printing the term or label.
92d0a6a6
JR
3577
3578@Example
3579@cartouche
3580A glossary-style list:
3581.IP lawyers 0.4i
3582Two or more attorneys.
3583.IP guns
3584.br
3585Firearms, preferably large-caliber.
3586.IP money
3587Gotta pay for those lawyers and guns!
3588@end cartouche
3589@endExample
3590
92d0a6a6 3591The second workaround uses the @code{\p} escape to force the break.
4d3e9548
JL
3592Note the space following the escape; this is important. If you omit the
3593space, @code{groff} prints the first word on the same line as the term
3594or label (if it fits) @strong{then} breaks the line.
92d0a6a6
JR
3595
3596@Example
3597@cartouche
3598A glossary-style list:
3599.IP lawyers 0.4i
3600Two or more attorneys.
3601.IP guns
3602\p Firearms, preferably large-caliber.
3603.IP money
3604Gotta pay for those lawyers and guns!
3605@end cartouche
3606@endExample
3607
92d0a6a6 3608To set nested lists, use the @code{RS} and @code{RE} macros.
465b256c 3609@xref{Indentation values in ms}, for more information.
92d0a6a6
JR
3610@cindex @code{ms} macros, nested lists
3611@cindex nested lists [@code{ms}]
3612
3613For example:
3614
3615@Example
3616@cartouche
3617.IP \[bu] 2
3618Lawyers:
3619.RS
3620.IP \[bu]
3621Dewey,
3622.IP \[bu]
3623Cheatham,
3624.IP \[bu]
3625and Howe.
3626.RE
3627.IP \[bu]
3628Guns
3629@end cartouche
3630@endExample
3631
3632Produces:
3633
3634@Example
3635o Lawyers:
3636
3637 o Dewey,
3638
3639 o Cheatham,
3640
3641 o and Howe.
3642
3643o Guns
3644@endExample
3645
3646@c ---------------------------------------------------------------------
3647
465b256c
JR
3648@node Indentation values in ms, Tabstops in ms, Lists in ms, ms Body Text
3649@subsubsection Indentation values
92d0a6a6 3650
4d3e9548
JL
3651In many situations, you may need to indentation a section of text while
3652still wrapping and filling. @xref{Lists in ms}, for an example of
3653nested lists.
92d0a6a6
JR
3654
3655@DefmacList {RS, , ms}
3656@DefmacListEnd {RE, , ms}
4d3e9548
JL
3657These macros begin and end an indented section. The @code{PI} register
3658controls the amount of indentation, allowing the indented text to line
3659up under hanging and indented paragraphs.
92d0a6a6
JR
3660@endDefmac
3661
465b256c
JR
3662@xref{ms Displays and Keeps}, for macros to indentation and turn off
3663filling.
92d0a6a6
JR
3664
3665@c ---------------------------------------------------------------------
3666
465b256c 3667@node Tabstops in ms, ms Displays and Keeps, Indentation values in ms, ms Body Text
92d0a6a6
JR
3668@subsubsection Tab Stops
3669
4d3e9548
JL
3670Use the @code{ta} request to define tab stops as needed. @xref{Tabs and
3671Fields}.
92d0a6a6 3672
4d3e9548 3673@Defmac {TA, , ms}
92d0a6a6 3674Use this macro to reset the tab stops to the default for @file{ms}
4d3e9548
JL
3675(every 5n). You can redefine the @code{TA} macro to create a different
3676set of default tab stops.
92d0a6a6
JR
3677@endDefmac
3678
3679@c ---------------------------------------------------------------------
3680
3681@node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3682@subsubsection Displays and keeps
3683@cindex @code{ms} macros, displays
3684@cindex @code{ms} macros, keeps
3685@cindex keeps [@code{ms}]
3686@cindex displays [@code{ms}]
3687
465b256c
JR
3688Use displays to show text-based examples or figures (such as code
3689listings).
92d0a6a6 3690
4d3e9548
JL
3691Displays turn off filling, so lines of code are displayed as-is without
3692inserting @code{br} requests in between each line. Displays can be
3693@dfn{kept} on a single page, or allowed to break across pages.
92d0a6a6
JR
3694
3695@DefmacList {DS, @t{L}, ms}
3696@DefmacItem {LD, , ms}
3697@DefmacListEnd {DE, , ms}
465b256c
JR
3698Left-justified display. The @samp{.DS L} call generates a page break,
3699if necessary, to keep the entire display on one page. The @code{LD}
3700macro allows the display to break across pages. The @code{DE} macro
3701ends the display.
92d0a6a6
JR
3702@endDefmac
3703
3704@DefmacList {DS, @t{I}, ms}
3705@DefmacItem {ID, , ms}
3706@DefmacListEnd {DE, , ms}
4d3e9548
JL
3707Indents the display as defined by the @code{DI} register. The @samp{.DS
3708I} call generates a page break, if necessary, to keep the entire display
3709on one page. The @code{ID} macro allows the display to break across
3710pages. The @code{DE} macro ends the display.
92d0a6a6
JR
3711@endDefmac
3712
3713@DefmacList {DS, @t{B}, ms}
3714@DefmacItem {BD, , ms}
3715@DefmacListEnd {DE, , ms}
4d3e9548
JL
3716Sets a block-centered display: the entire display is left-justified, but
3717indented so that the longest line in the display is centered on the
3718page. The @samp{.DS B} call generates a page break, if necessary, to
3719keep the entire display on one page. The @code{BD} macro allows the
3720display to break across pages. The @code{DE} macro ends the display.
92d0a6a6
JR
3721@endDefmac
3722
3723@DefmacList {DS, @t{C}, ms}
3724@DefmacItem {CD, , ms}
3725@DefmacListEnd {DE, , ms}
465b256c
JR
3726Sets a centered display: each line in the display is centered. The
3727@samp{.DS C} call generates a page break, if necessary, to keep the
3728entire display on one page. The @code{CD} macro allows the display to
3729break across pages. The @code{DE} macro ends the display.
92d0a6a6
JR
3730@endDefmac
3731
3732@DefmacList {DS, @t{R}, ms}
3733@DefmacItem {RD, , ms}
3734@DefmacListEnd {DE, , ms}
465b256c 3735Right-justifies each line in the display. The @samp{.DS R} call
4d3e9548
JL
3736generates a page break, if necessary, to keep the entire display on one
3737page. The @code{RD} macro allows the display to break across pages.
3738The @code{DE} macro ends the display.
92d0a6a6
JR
3739@endDefmac
3740
3741@DefmacList {Ds, , ms}
3742@DefmacListEnd {De, , ms}
465b256c
JR
3743These two macros were formerly provided as aliases for @code{DS} and
3744@code{DE}, respectively. They have been removed, and should no longer
3745be used. The original implementations of @code{DS} and @code{DE} are
4d3e9548
JL
3746retained, and should be used instead. X11 documents which actually use
3747@code{Ds} and @code{De} always load a specific macro file from the X11
3748distribution (@file{macros.t}) which provides proper definitions for the
3749two macros.
92d0a6a6
JR
3750@endDefmac
3751
92d0a6a6 3752On occasion, you may want to @dfn{keep} other text together on a page.
465b256c
JR
3753For example, you may want to keep two paragraphs together, or a
3754paragraph that refers to a table (or list, or other item) immediately
3755following. The @file{ms} macros provide the @code{KS} and @code{KE}
92d0a6a6
JR
3756macros for this purpose.
3757
3758@DefmacList {KS, , ms}
3759@DefmacListEnd {KE, , ms}
4d3e9548
JL
3760The @code{KS} macro begins a block of text to be kept on a single page,
3761and the @code{KE} macro ends the block.
92d0a6a6
JR
3762@endDefmac
3763
3764@DefmacList {KF, , ms}
3765@DefmacListEnd {KE, , ms}
465b256c
JR
3766Specifies a @dfn{floating keep}; if the keep cannot fit on the current
3767page, @code{groff} holds the contents of the keep and allows text
4d3e9548
JL
3768following the keep (in the source file) to fill in the remainder of the
3769current page. When the page breaks, whether by an explicit @code{bp}
3770request or by reaching the end of the page, @code{groff} prints the
3771floating keep at the top of the new page. This is useful for printing
3772large graphics or tables that do not need to appear exactly where
3773specified.
92d0a6a6
JR
3774@endDefmac
3775
4d3e9548
JL
3776You can also use the @code{ne} request to force a page break if there is
3777not enough vertical space remaining on the page.
92d0a6a6 3778
4d3e9548
JL
3779Use the following macros to draw a box around a section of text (such as
3780a display).
92d0a6a6
JR
3781
3782@DefmacList {B1, , ms}
3783@DefmacListEnd {B2, , ms}
465b256c 3784Marks the beginning and ending of text that is to have a box drawn
4d3e9548
JL
3785around it. The @code{B1} macro begins the box; the @code{B2} macro ends
3786it. Text in the box is automatically placed in a diversion (keep).
92d0a6a6
JR
3787@endDefmac
3788
3789@c ---------------------------------------------------------------------
3790
3791@node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3792@subsubsection Tables, figures, equations, and references
3793@cindex @code{ms} macros, tables
3794@cindex @code{ms} macros, figures
3795@cindex @code{ms} macros, equations
3796@cindex @code{ms} macros, references
3797@cindex tables [@code{ms}]
3798@cindex figures [@code{ms}]
3799@cindex equations [@code{ms}]
3800@cindex references [@code{ms}]
3801
465b256c 3802The @file{ms} macros support the standard @code{groff} preprocessors:
92d0a6a6
JR
3803@code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3804@pindex tbl
3805@pindex pic
3806@pindex eqn
3807@pindex refer
4d3e9548
JL
3808You mark text meant for preprocessors by enclosing it in pairs of tags
3809as follows.
92d0a6a6
JR
3810
3811@DefmacList {TS, [@code{H}], ms}
3812@DefmacListEnd {TE, , ms}
465b256c
JR
3813Denotes a table, to be processed by the @code{tbl} preprocessor. The
3814optional argument@tie{}@code{H} to @code{TS} instructs @code{groff} to
4d3e9548
JL
3815create a running header with the information up to the @code{TH} macro.
3816@code{groff} prints the header at the beginning of the table; if the
3817table runs onto another page, @code{groff} prints the header on the next
3818page as well.
92d0a6a6
JR
3819@endDefmac
3820
3821@DefmacList {PS, , ms}
3822@DefmacListEnd {PE, , ms}
4d3e9548
JL
3823Denotes a graphic, to be processed by the @code{pic} preprocessor. You
3824can create a @code{pic} file by hand, using the @acronym{AT&T}
465b256c
JR
3825@code{pic} manual available on the Web as a reference, or by using a
3826graphics program such as @code{xfig}.
92d0a6a6
JR
3827@endDefmac
3828
3829@DefmacList {EQ, [@Var{align}], ms}
3830@DefmacListEnd {EN, , ms}
3831Denotes an equation, to be processed by the @code{eqn} preprocessor.
3832The optional @var{align} argument can be @code{C}, @code{L},
3833or@tie{}@code{I} to center (the default), left-justify, or indent the
3834equation.
3835@endDefmac
3836
3837@DefmacList {[, , ms}
3838@DefmacListEnd {], , ms}
3839Denotes a reference, to be processed by the @code{refer} preprocessor.
3840The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3841reference to the preprocessor and the format of the bibliographic
3842database.
3843@endDefmac
3844
3845@menu
3846* Example multi-page table::
3847@end menu
3848
3849@c ---------------------------------------------------------------------
3850
3851@node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3852@subsubsection An example multi-page table
3853@cindex example markup, multi-page table [@code{ms}]
3854@cindex multi-page table, example markup [@code{ms}]
3855
465b256c
JR
3856The following is an example of how to set up a table that may print
3857across two or more pages.
92d0a6a6
JR
3858
3859@Example
3860@cartouche
3861.TS H
3862allbox expand;
3863cb | cb .
3864Text ...of heading...
3865_
3866.TH
3867.T&
3868l | l .
3869... the rest of the table follows...
3870.CW
3871.TE
3872@end cartouche
3873@endExample
3874
3875@c ---------------------------------------------------------------------
3876
3877@node ms Footnotes, , Example multi-page table, ms Body Text
3878@subsubsection Footnotes
3879@cindex @code{ms} macros, footnotes
3880@cindex footnotes [@code{ms}]
3881
465b256c 3882The @file{ms} macro package has a flexible footnote system. You can
4d3e9548
JL
3883specify either numbered footnotes or symbolic footnotes (that is, using
3884a marker such as a dagger symbol).
92d0a6a6
JR
3885
3886@Defstr {*, ms}
3887Specifies the location of a numbered footnote marker in the text.
3888@endDefesc
3889
3890@DefmacList {FS, , ms}
3891@DefmacListEnd {FE, , ms}
465b256c
JR
3892Specifies the text of the footnote. The default action is to create a
3893numbered footnote; you can create a symbolic footnote by specifying a
4d3e9548
JL
3894@dfn{mark} glyph (such as @code{\[dg]} for the dagger glyph) in the body
3895text and as an argument to the @code{FS} macro, followed by the text of
3896the footnote and the @code{FE} macro.
92d0a6a6
JR
3897@endDefmac
3898
4d3e9548
JL
3899You can control how @code{groff} prints footnote numbers by changing the
3900value of the @code{FF} register. @xref{ms Document Control Registers}.
465b256c
JR
3901
3902@cindex footnotes, and keeps [@code{ms}]
3903@cindex keeps, and footnotes [@code{ms}]
3904@cindex footnotes, and displays [@code{ms}]
3905@cindex displays, and footnotes [@code{ms}]
3906Footnotes can be safely used within keeps and displays, but you should
3907avoid using numbered footnotes within floating keeps. You can set a
3908second @code{\**} marker between a @code{\**} and its corresponding
3909@code{.FS} entry; as long as each @code{FS} macro occurs @emph{after}
3910the corresponding @code{\**} and the occurrences of @code{.FS} are in
3911the same order as the corresponding occurrences of @code{\**}.
92d0a6a6
JR
3912
3913@c ---------------------------------------------------------------------
3914
3915@node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3916@subsection Page layout
3917@cindex @code{ms} macros, page layout
3918@cindex page layout [@code{ms}]
3919
4d3e9548
JL
3920The default output from the @file{ms} macros provides a minimalist page
3921layout: it prints a single column, with the page number centered at the
3922top of each page. It prints no footers.
92d0a6a6 3923
465b256c
JR
3924You can change the layout by setting the proper number registers and
3925strings.
92d0a6a6
JR
3926
3927@menu
3928* ms Headers and Footers::
3929* ms Margins::
3930* ms Multiple Columns::
3931* ms TOC::
3932* ms Strings and Special Characters::
3933@end menu
3934
3935@c ---------------------------------------------------------------------
3936
3937@node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3938@subsubsection Headers and footers
3939@cindex @code{ms} macros, headers
3940@cindex @code{ms} macros, footers
3941@cindex headers [@code{ms}]
3942@cindex footers [@code{ms}]
3943
465b256c
JR
3944For documents that do not distinguish between odd and even pages, set
3945the following strings:
92d0a6a6
JR
3946
3947@DefstrList {LH, ms}
3948@DefstrItem {CH, ms}
3949@DefstrListEnd {RH, ms}
3950Sets the left, center, and right headers.
3951@endDefstr
3952
3953@DefstrList {LF, ms}
3954@DefstrItem {CF, ms}
3955@DefstrListEnd {RF, ms}
3956Sets the left, center, and right footers.
3957@endDefstr
3958
465b256c
JR
3959For documents that need different information printed in the even and
3960odd pages, use the following macros:
92d0a6a6
JR
3961
3962@DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3963@DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3964@DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3965@DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
465b256c 3966The @code{OH} and @code{EH} macros define headers for the odd and even
4d3e9548
JL
3967pages; the @code{OF} and @code{EF} macros define footers for the odd and
3968even pages. This is more flexible than defining the individual strings.
92d0a6a6
JR
3969
3970You can replace the quote (@code{'}) marks with any character not
3971appearing in the header or footer text.
3972@endDefmac
3973
4d3e9548
JL
3974To specify custom header and footer processing, redefine the following
3975macros:
3976
3977@DefmacList {PT,, ms}
3978@DefmacItem {HD,, ms}
3979@DefmacListEnd {BT,, ms}
3980The @code{PT} macro defines a custom header; the @code{BT} macro defines
3981a custom footer. These macros must handle odd/even/first page
3982differences if necessary.
3983
3984The @code{HD} macro defines additional header processing to take place
3985after executing the @code{PT} macro.
3986@endDefmac
3987
92d0a6a6
JR
3988@c ---------------------------------------------------------------------
3989
3990@node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3991@subsubsection Margins
3992@cindex @code{ms} macros, margins
3993
4d3e9548
JL
3994You control margins using a set of number registers. @xref{ms Document
3995Control Registers}, for details.
92d0a6a6
JR
3996
3997@c ---------------------------------------------------------------------
3998
3999@node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
4000@subsubsection Multiple columns
4001@cindex @code{ms} macros, multiple columns
4002@cindex multiple columns [@code{ms}]
4003
4d3e9548
JL
4004The @file{ms} macros can set text in as many columns as do reasonably
4005fit on the page. The following macros are available; all of them force
4006a page break if a multi-column mode is already set. However, if the
4007current mode is single-column, starting a multi-column mode does
4008@emph{not} force a page break.
92d0a6a6
JR
4009
4010@Defmac {1C, , ms}
4011Single-column mode.
4012@endDefmac
4013
4014@Defmac {2C, , ms}
4015Two-column mode.
4016@endDefmac
4017
4018@Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
4d3e9548
JL
4019Multi-column mode. If you specify no arguments, it is equivalent to the
4020@code{2C} macro. Otherwise, @var{width} is the width of each column and
4021@var{gutter} is the space between columns. The @code{MINGW} number
4022register controls the default gutter width.
92d0a6a6
JR
4023@endDefmac
4024
4025@c ---------------------------------------------------------------------
4026
4027@node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
4028@subsubsection Creating a table of contents
4029@cindex @code{ms} macros, creating table of contents
4030@cindex table of contents, creating [@code{ms}]
4031
465b256c
JR
4032The facilities in the @file{ms} macro package for creating a table of
4033contents are semi-automated at best. Assuming that you want the table
4034of contents to consist of the document's headings, you need to repeat
4035those headings wrapped in @code{XS} and @code{XE} macros.
92d0a6a6
JR
4036
4037@DefmacList {XS, [@Var{page}], ms}
4038@DefmacItem {XA, [@Var{page}], ms}
4039@DefmacListEnd {XE, , ms}
465b256c 4040These macros define a table of contents or an individual entry in the
4d3e9548
JL
4041table of contents, depending on their use. The macros are very simple;
4042they cannot indent a heading based on its level. The easiest way to
4043work around this is to add tabs to the table of contents string. The
4044following is an example:
92d0a6a6
JR
4045
4046@Example
4047@cartouche
4048.NH 1
4049Introduction
4050.XS
4051Introduction
4052.XE
4053.LP
4054...
4055.CW
4056.NH 2
4057Methodology
4058.XS
4059Methodology
4060.XE
4061.LP
4062...
4063@end cartouche
4064@endExample
4065
465b256c 4066You can manually create a table of contents by beginning with the
4d3e9548
JL
4067@code{XS} macro for the first entry, specifying the page number for that
4068entry as the argument to @code{XS}. Add subsequent entries using the
4069@code{XA} macro, specifying the page number for that entry as the
465b256c 4070argument to @code{XA}. The following is an example:
92d0a6a6
JR
4071
4072@Example
4073@cartouche
4074.XS 1
4075Introduction
4076.XA 2
4077A Brief History of the Universe
4078.XA 729
4079Details of Galactic Formation
4080...
4081.XE
4082@end cartouche
4083@endExample
4084@endDefmac
4085
4086@Defmac {TC, [@code{no}], ms}
465b256c
JR
4087Prints the table of contents on a new page, setting the page number
4088to@tie{}@strong{i} (Roman lowercase numeral one). You should usually
4089place this macro at the end of the file, since @code{groff} is a
4090single-pass formatter and can only print what has been collected up to
4091the point that the @code{TC} macro appears.
4092
4d3e9548
JL
4093The optional argument @code{no} suppresses printing the title specified
4094by the string register @code{TOC}.
92d0a6a6
JR
4095@endDefmac
4096
4d3e9548 4097@Defmac {PX, [@code{no}], ms}
465b256c 4098Prints the table of contents on a new page, using the current page
4d3e9548
JL
4099numbering sequence. Use this macro to print a manually-generated table
4100of contents at the beginning of your document.
92d0a6a6 4101
4d3e9548
JL
4102The optional argument @code{no} suppresses printing the title specified
4103by the string register @code{TOC}.
92d0a6a6
JR
4104@endDefmac
4105
465b256c
JR
4106The @cite{Groff and Friends HOWTO} includes a @code{sed} script that
4107automatically inserts @code{XS} and @code{XE} macro entries after each
4108heading in a document.
92d0a6a6 4109
465b256c
JR
4110Altering the @code{NH} macro to automatically build the table of
4111contents is perhaps initially more difficult, but would save a great
4112deal of time in the long run if you use @file{ms} regularly.
92d0a6a6
JR
4113
4114@c ---------------------------------------------------------------------
4115
4116@node ms Strings and Special Characters, , ms TOC, ms Page Layout
4117@subsubsection Strings and Special Characters
4118@cindex @code{ms} macros, strings
4119@cindex @code{ms} macros, special characters
4120@cindex @code{ms} macros, accent marks
4121@cindex accent marks [@code{ms}]
4122@cindex special characters [@code{ms}]
4123@cindex strings [@code{ms}]
4124
4d3e9548
JL
4125The @file{ms} macros provide the following predefined strings. You can
4126change the string definitions to help in creating documents in languages
4127other than English.
92d0a6a6
JR
4128
4129@Defstr {REFERENCES, ms}
465b256c
JR
4130Contains the string printed at the beginning of the references
4131(bibliography) page. The default is @samp{References}.
92d0a6a6
JR
4132@endDefstr
4133
4134@Defstr {ABSTRACT, ms}
465b256c
JR
4135Contains the string printed at the beginning of the abstract. The
4136default is @samp{ABSTRACT}.
92d0a6a6
JR
4137@endDefstr
4138
4139@Defstr {TOC, ms}
4140Contains the string printed at the beginning of the table of contents.
4141@endDefstr
4142
4143@DefstrList {MONTH1, ms}
4144@DefstrItem {MONTH2, ms}
4145@DefstrItem {MONTH3, ms}
4146@DefstrItem {MONTH4, ms}
4147@DefstrItem {MONTH5, ms}
4148@DefstrItem {MONTH6, ms}
4149@DefstrItem {MONTH7, ms}
4150@DefstrItem {MONTH8, ms}
4151@DefstrItem {MONTH9, ms}
4152@DefstrItem {MONTH10, ms}
4153@DefstrItem {MONTH11, ms}
4154@DefstrListEnd {MONTH12, ms}
465b256c
JR
4155Prints the full name of the month in dates. The default is
4156@samp{January}, @samp{February}, etc.
92d0a6a6
JR
4157@endDefstr
4158
4159The following special characters are available@footnote{For an
4d3e9548 4160explanation what special characters are see @ref{Special Characters}.}:
92d0a6a6
JR
4161
4162@Defstr {-, ms}
4163Prints an em dash.
4164@endDefstr
4165
465b256c
JR
4166@DefstrList {Q, ms}
4167@DefstrListEnd {U, ms}
4168Prints typographer's quotes in troff, and plain quotes in nroff.
4169@code{\*Q} is the left quote and @code{\*U} is the right quote.
92d0a6a6
JR
4170@endDefstr
4171
4172Improved accent marks are available in the @file{ms} macros.
4173
4174@Defmac {AM, , ms}
4d3e9548
JL
4175Specify this macro at the beginning of your document to enable extended
4176accent marks and special characters. This is a Berkeley extension.
92d0a6a6 4177
465b256c
JR
4178To use the accent marks, place them @strong{after} the character being
4179accented.
4180
4181Note that groff's native support for accents is superior to the
4182following definitions.
92d0a6a6
JR
4183@endDefmac
4184
465b256c
JR
4185The following accent marks are available after invoking the @code{AM}
4186macro:
92d0a6a6
JR
4187
4188@Defstr {\', ms}
4189Acute accent.
4190@endDefstr
4191
4192@Defstr {\`, ms}
4193Grave accent.
4194@endDefstr
4195
4196@Defstr {^, ms}
4197Circumflex.
4198@endDefstr
4199
4200@Defstr {\,, ms}
4201Cedilla.
4202@endDefstr
4203
4204@Defstr {~, ms}
4205Tilde.
4206@endDefstr
4207
4208@deffn String @t{\*[:]}
4209@ifnotinfo
4210@stindex : @r{[}ms@r{]}
4211@end ifnotinfo
4212@ifinfo
4213@stindex \*[@r{<colon>}] @r{[}ms@r{]}
4214@end ifinfo
4215Umlaut.
4216@end deffn
4217
4218@Defstr {v, ms}
4219Hacek.
4220@endDefstr
4221
4222@Defstr {_, ms}
4223Macron (overbar).
4224@endDefstr
4225
4226@Defstr {., ms}
4227Underdot.
4228@endDefstr
4229
4230@Defstr {o, ms}
4231Ring above.
4232@endDefstr
4233
465b256c
JR
4234The following are standalone characters available after invoking the
4235@code{AM} macro:
92d0a6a6
JR
4236
4237@Defstr {?, ms}
4238Upside-down question mark.
4239@endDefstr
4240
4241@Defstr {!, ms}
4242Upside-down exclamation point.
4243@endDefstr
4244
4245@Defstr {8, ms}
465b256c 4246German ß ligature.
92d0a6a6
JR
4247@endDefstr
4248
4249@Defstr {3, ms}
4250Yogh.
4251@endDefstr
4252
4253@Defstr {Th, ms}
4254Uppercase thorn.
4255@endDefstr
4256
4257@Defstr {th, ms}
4258Lowercase thorn.
4259@endDefstr
4260
4261@Defstr {D-, ms}
4262Uppercase eth.
4263@endDefstr
4264
4265@Defstr {d-, ms}
4266Lowercase eth.
4267@endDefstr
4268
4269@Defstr {q, ms}
4270Hooked o.
4271@endDefstr
4272
4273@Defstr {ae, ms}
465b256c 4274Lowercase æ ligature.
92d0a6a6
JR
4275@endDefstr
4276
4277@Defstr {Ae, ms}
465b256c 4278Uppercase Æ ligature.
92d0a6a6
JR
4279@endDefstr
4280
4281@c ---------------------------------------------------------------------
4282
465b256c 4283@node Differences from AT&T ms, Naming Conventions, ms Page Layout, ms
92d0a6a6
JR
4284@subsection Differences from @acronym{AT&T} @file{ms}
4285@cindex @code{ms} macros, differences from @acronym{AT&T}
4286@cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
4287
4d3e9548
JL
4288This section lists the (minor) differences between the @code{groff -ms}
4289macros and @acronym{AT&T} @code{troff -ms} macros.
465b256c
JR
4290
4291@itemize @bullet
4292@item
4293The internals of @code{groff -ms} differ from the internals of
4294@acronym{AT&T} @code{troff -ms}. Documents that depend upon
4d3e9548
JL
4295implementation details of @acronym{AT&T} @code{troff -ms} may not format
4296properly with @code{groff -ms}.
465b256c
JR
4297
4298@item
4299The general error-handling policy of @code{groff -ms} is to detect and
4300report errors, rather than silently to ignore them.
4301
4302@item
4d3e9548
JL
4303@code{groff -ms} does not work in compatibility mode (this is, with the
4304@option{-C} option).
465b256c
JR
4305
4306@item
4307There is no special support for typewriter-like devices.
4308
4309@item
4310@code{groff -ms} does not provide cut marks.
4311
4312@item
4313Multiple line spacing is not supported. Use a larger vertical spacing
4314instead.
4315
4316@item
4d3e9548
JL
4317Some @acronym{UNIX} @code{ms} documentation says that the @code{CW} and
4318@code{GW} number registers can be used to control the column width and
4319gutter width, respectively. These number registers are not used in
465b256c
JR
4320@code{groff -ms}.
4321
4322@item
4d3e9548
JL
4323Macros that cause a reset (paragraphs, headings, etc.@:) may change the
4324indentation. Macros that change the indentation do not increment or
4325decrement the indentation, but rather set it absolutely. This can cause
4326problems for documents that define additional macros of their own. The
4327solution is to use not the @code{in} request but instead the @code{RS}
4328and @code{RE} macros.
465b256c
JR
4329
4330@item
4331To make @code{groff -ms} use the default page offset (which also
4332specifies the left margin), the @code{PO} register must stay undefined
4333until the first @file{-ms} macro is evaluated. This implies that
4d3e9548
JL
4334@code{PO} should not be used early in the document, unless it is changed
4335also: Remember that accessing an undefined register automatically
4336defines it.
465b256c
JR
4337@end itemize
4338
4339@Defmpreg {GS, ms}
4340This number register is set to@tie{}1 by the @code{groff -ms} macros,
4341but it is not used by the @code{AT&T} @code{troff -ms} macros.
4342Documents that need to determine whether they are being formatted with
4d3e9548
JL
4343@code{AT&T} @code{troff -ms} or @code{groff -ms} should use this number
4344register.
465b256c 4345@endDefmpreg
92d0a6a6 4346
4d3e9548
JL
4347Emulations of a few ancient Bell Labs macros can be re-enabled by
4348calling the otherwise undocumented @code{SC} section-header macro.
4349Calling @code{SC} enables @code{UC} for marking up a product or
4350application name, and the pair @code{P1}/@code{P2} for surrounding code
4351example displays.
4352
4353These are not enabled by default because (a)@tie{}they were not
4354documented, in the original @code{ms} manual, and (b)@tie{}the @code{P1}
4355and @code{UC} macros collide with different macros with the same names
4356in the Berkeley version of @code{ms}.
4357
4358These @code{groff} emulations are sufficient to give back the 1976
4359Kernighan@tie{}& Cherry paper @cite{Typsetting Mathematics -- User's
4360Guide} its section headings, and restore some text that had gone missing
4361as arguments of undefined macros. No warranty express or implied is
4362given as to how well the typographic details these produce match the
4363original Bell Labs macros.
4364
92d0a6a6
JR
4365@menu
4366* Missing ms Macros::
4367* Additional ms Macros::
4368@end menu
4369
4370@c ---------------------------------------------------------------------
4371
4372@node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
4373@subsubsection @code{troff} macros not appearing in @code{groff}
4374
465b256c
JR
4375Macros missing from @code{groff -ms} are cover page macros specific to
4376Bell Labs and Berkeley. The macros known to be missing are:
92d0a6a6
JR
4377
4378@table @code
4379@item .TM
4380Technical memorandum; a cover sheet style
4381
4382@item .IM
4383Internal memorandum; a cover sheet style
4384
4385@item .MR
4386Memo for record; a cover sheet style
4387
4388@item .MF
4389Memo for file; a cover sheet style
4390
4391@item .EG
4392Engineer's notes; a cover sheet style
4393
4394@item .TR
4395Computing Science Tech Report; a cover sheet style
4396
4397@item .OK
4398Other keywords
4399
4400@item .CS
4401Cover sheet information
4402
4403@item .MH
4404A cover sheet macro
4405@end table
4406
4407@c ---------------------------------------------------------------------
4408
4409@node Additional ms Macros, , Missing ms Macros, Differences from AT&T ms
4410@subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4411
4d3e9548
JL
4412The @code{groff -ms} macros have a few minor extensions compared to the
4413@acronym{AT&T} @code{troff -ms} macros.
92d0a6a6
JR
4414
4415@Defmac {AM, , ms}
4d3e9548
JL
4416Improved accent marks. @xref{ms Strings and Special Characters}, for
4417details.
92d0a6a6
JR
4418@endDefmac
4419
4420@Defmac {DS, @t{I}, ms}
4d3e9548
JL
4421Indented display. The default behavior of @acronym{AT&T} @code{troff
4422-ms} was to indent; the @code{groff} default prints displays flush left
4423with the body text.
92d0a6a6
JR
4424@endDefmac
4425
4426@Defmac {CW, , ms}
4427Print text in @code{constant width} (Courier) font.
4428@endDefmac
4429
4430@Defmac {IX, , ms}
4d3e9548
JL
4431Indexing term (printed on standard error). You can write a script to
4432capture and process an index generated in this manner.
92d0a6a6
JR
4433@endDefmac
4434
92d0a6a6
JR
4435The following additional number registers
4436appear in @code{groff -ms}:
4437
4438@Defmpreg {MINGW, ms}
4d3e9548
JL
4439Specifies a minimum space between columns (for multi-column output);
4440this takes the place of the @code{GW} register that was documented but
4441apparently not implemented in @acronym{AT&T} @code{troff}.
92d0a6a6
JR
4442@endDefmpreg
4443
4d3e9548
JL
4444Several new string registers are available as well. You can change
4445these to handle (for example) the local language. @xref{ms Strings and
4446Special Characters}, for details.
92d0a6a6 4447
465b256c
JR
4448@c ---------------------------------------------------------------------
4449
4450@node Naming Conventions, , Differences from AT&T ms, ms
4451@subsection Naming Conventions
4452@cindex @code{ms} macros, naming conventions
4453@cindex naming conventions, @code{ms} macros
4454
4455The following conventions are used for names of macros, strings and
4456number registers. External names available to documents that use the
4457@code{groff -ms} macros contain only uppercase letters and digits.
4458
4459Internally the macros are divided into modules; naming conventions are
4460as follows:
4461
4462@itemize @bullet
4463@item
4464Names used only within one module are of the form
4465@var{module}@code{*}@var{name}.
4466
4467@item
4d3e9548
JL
4468Names used outside the module in which they are defined are of the form
4469@var{module}@code{@@}@var{name}.
465b256c
JR
4470
4471@item
4472Names associated with a particular environment are of the form
4473@var{environment}@code{:}@var{name}; these are used only within the
4474@code{par} module.
4475
4476@item
4477@var{name} does not have a module prefix.
4478
4479@item
4480Constructed names used to implement arrays are of the form
4481@var{array}@code{!}@var{index}.
4482@end itemize
4483
4484Thus the groff ms macros reserve the following names:
4485
4486@itemize @bullet
4487@item
4d3e9548 4488Names containing the characters @code{*}, @code{@@}, and@tie{}@code{:}.
465b256c
JR
4489
4490@item
4491Names containing only uppercase letters and digits.
4492@end itemize
4493
92d0a6a6
JR
4494
4495@c =====================================================================
4496
4497@node me, mm, ms, Macro Packages
4498@section @file{me}
4499@cindex @code{me} macro package
4500
4501@c XXX documentation
4502@c XXX this is a placeholder until we get stuff knocked into shape
4d3e9548
JL
4503See the @file{meintro.me} and @file{meref.me} documents in groff's
4504@file{doc} directory.
92d0a6a6
JR
4505
4506
4507@c =====================================================================
4508
4509@node mm, , me, Macro Packages
4510@section @file{mm}
4511@cindex @code{mm} macro package
4512
4513@c XXX documentation
4514@c XXX this is a placeholder until we get stuff knocked into shape
4d3e9548
JL
4515See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at the
4516command line).
4517
92d0a6a6
JR
4518
4519
4520@c =====================================================================
4521@c =====================================================================
4522
4523@node gtroff Reference, Preprocessors, Macro Packages, Top
4524@chapter @code{gtroff} Reference
4525@cindex reference, @code{gtroff}
4526@cindex @code{gtroff}, reference
4527
4528This chapter covers @strong{all} of the facilities of @code{gtroff}.
4529Users of macro packages may skip it if not interested in details.
4530
4531
4532@menu
4533* Text::
4534* Measurements::
4535* Expressions::
4536* Identifiers::
4537* Embedded Commands::
4538* Registers::
4539* Manipulating Filling and Adjusting::
4540* Manipulating Hyphenation::
4541* Manipulating Spacing::
4542* Tabs and Fields::
4543* Character Translations::
4544* Troff and Nroff Mode::
4545* Line Layout::
4546* Line Control::
4547* Page Layout::
4548* Page Control::
4549* Fonts and Symbols::
4550* Sizes::
4551* Strings::
4552* Conditionals and Loops::
4553* Writing Macros::
4554* Page Motions::
4555* Drawing Requests::
4556* Traps::
4557* Diversions::
4558* Environments::
4559* Suppressing output::
4560* Colors::
4561* I/O::
4562* Postprocessor Access::
4563* Miscellaneous::
4564* Gtroff Internals::
4565* Debugging::
4566* Implementation Differences::
4567@end menu
4568
4569
4570@c =====================================================================
4571
4572@node Text, Measurements, gtroff Reference, gtroff Reference
4573@section Text
4574@cindex text, @code{gtroff} processing
4575
4576@code{gtroff} input files contain text with control commands
4577interspersed throughout. But, even without control codes, @code{gtroff}
4578still does several things with the input text:
4579
4580@itemize @bullet
4581@item
4582filling and adjusting
4583
4584@item
4585adding additional space after sentences
4586
4587@item
4588hyphenating
4589
4590@item
4591inserting implicit line breaks
4592@end itemize
4593
4594@menu
4595* Filling and Adjusting::
4596* Hyphenation::
4597* Sentences::
4598* Tab Stops::
4599* Implicit Line Breaks::
4600* Input Conventions::
4601* Input Encodings::
4602@end menu
4603
4604@c ---------------------------------------------------------------------
4605
4606@node Filling and Adjusting, Hyphenation, Text, Text
4607@subsection Filling and Adjusting
4608@cindex filling
4609@cindex adjusting
4610
4611When @code{gtroff} reads text, it collects words from the input and fits
4612as many of them together on one output line as it can. This is known as
4613@dfn{filling}.
4614
4615@cindex leading spaces
4616@cindex spaces, leading and trailing
4617@cindex extra spaces
4618@cindex trailing spaces
4d3e9548
JL
4619Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust} it.
4620This means it widens the spacing between words until the text reaches
4621the right margin (in the default adjustment mode). Extra spaces between
4622words are preserved, but spaces at the end of lines are ignored. Spaces
4623at the front of a line cause a @dfn{break} (breaks are explained in
4624@ref{Implicit Line Breaks}).
92d0a6a6
JR
4625
4626@xref{Manipulating Filling and Adjusting}.
4627
4628@c ---------------------------------------------------------------------
4629
4630@node Hyphenation, Sentences, Filling and Adjusting, Text
4631@subsection Hyphenation
4632@cindex hyphenation
4633
4634Since the odds are not great for finding a set of words, for every
4635output line, which fit nicely on a line without inserting excessive
4d3e9548
JL
4636amounts of space between words, @code{gtroff} hyphenates words so that
4637it can justify lines without inserting too much space between words. It
4638uses an internal hyphenation algorithm (a simplified version of the
4639algorithm used within @TeX{}) to indicate which words can be hyphenated
4640and how to do so. When a word is hyphenated, the first part of the word
4641is added to the current filled line being output (with an attached
4642hyphen), and the other portion is added to the next line to be filled.
92d0a6a6
JR
4643
4644@xref{Manipulating Hyphenation}.
4645
4646@c ---------------------------------------------------------------------
4647
4648@node Sentences, Tab Stops, Hyphenation, Text
4649@subsection Sentences
4650@cindex sentences
4651
4652Although it is often debated, some typesetting rules say there should be
4653different amounts of space after various punctuation marks. For
4654example, the @cite{Chicago typsetting manual} says that a period at the
4655end of a sentence should have twice as much space following it as would
4656a comma or a period as part of an abbreviation.
4657
4658@c XXX exact citation of Chicago manual
4659
4660@cindex sentence space
4661@cindex space between sentences
4662@cindex french-spacing
4663@code{gtroff} does this by flagging certain characters (normally
4664@samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4665When @code{gtroff} encounters one of these characters at the end of a
4666line, it appends a normal space followed by a @dfn{sentence space} in
4667the formatted output. (This justifies one of the conventions mentioned
4668in @ref{Input Conventions}.)
4669
4670@cindex transparent characters
4671@cindex character, transparent
4672@cindex @code{dg} glyph, at end of sentence
4673@cindex @code{rq} glyph, at end of sentence
4674@cindex @code{"}, at end of sentence
4675@cindex @code{'}, at end of sentence
4676@cindex @code{)}, at end of sentence
4677@cindex @code{]}, at end of sentence
4678@cindex @code{*}, at end of sentence
4679In addition, the following characters and symbols are treated
4680transparently while handling end-of-sentence characters: @samp{"},
4681@samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{\[dg]}, and @code{\[rq]}.
4682
4683See the @code{cflags} request in @ref{Using Symbols}, for more details.
4684
4685@cindex @code{\&}, at end of sentence
4686To prevent the insertion of extra space after an end-of-sentence
4687character (at the end of a line), append @code{\&}.
4688
4689@c ---------------------------------------------------------------------
4690
4691@node Tab Stops, Implicit Line Breaks, Sentences, Text
4692@subsection Tab Stops
4693@cindex tab stops
4694@cindex stops, tabulator
4695@cindex tab character
4696@cindex character, tabulator
4697
4698@cindex @acronym{EBCDIC} encoding
4699@cindex encoding, @acronym{EBCDIC}
4700@code{gtroff} translates @dfn{tabulator characters}, also called
4701@dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4702@acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4703tabulator stop. These tab stops are initially located every half inch
4704across the page. Using this, simple tables can be made easily.
4705However, it can often be deceptive as the appearance (and width) of the
4706text on a terminal and the results from @code{gtroff} can vary greatly.
4707
4708Also, a possible sticking point is that lines beginning with tab
4d3e9548
JL
4709characters are still filled, again producing unexpected results. For
4710example, the following input
92d0a6a6
JR
4711
4712@multitable {12345678} {12345678} {12345678} {12345678}
4713@item
4714@tab 1 @tab 2 @tab 3
4715@item
4716@tab @tab 4 @tab 5
4717@end multitable
4718
4719@noindent
4720produces
4721
4722@multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4723@item
4724@tab 1 @tab 2 @tab 3 @tab @tab 4 @tab 5
4725@end multitable
4726
4727@xref{Tabs and Fields}.
4728
4729@c ---------------------------------------------------------------------
4730
4731@node Implicit Line Breaks, Input Conventions, Tab Stops, Text
4732@subsection Implicit Line Breaks
4733@cindex implicit line breaks
4734@cindex implicit breaks of lines
4735@cindex line, implicit breaks
4736@cindex break, implicit
4737@cindex line break
4738
4739An important concept in @code{gtroff} is the @dfn{break}. When a break
4d3e9548
JL
4740occurs, @code{gtroff} outputs the partially filled line (unjustified),
4741and resumes collecting and filling text on the next output line.
92d0a6a6
JR
4742
4743@cindex blank line
4744@cindex empty line
4745@cindex line, blank
4746@cindex blank line macro (@code{blm})
4d3e9548
JL
4747There are several ways to cause a break in @code{gtroff}. A blank line
4748not only causes a break, but it also outputs a one-line vertical space
4749(effectively a blank line). Note that this behaviour can be modified
4750with the blank line macro request @code{blm}. @xref{Blank Line Traps}.
92d0a6a6
JR
4751
4752@cindex fill mode
4753@cindex mode, fill
4d3e9548
JL
4754A line that begins with a space causes a break and the space is output
4755at the beginning of the next line. Note that this space isn't adjusted,
4756even in fill mode.
92d0a6a6 4757
4d3e9548
JL
4758The end of file also causes a break -- otherwise the last line of the
4759document may vanish!
92d0a6a6
JR
4760
4761Certain requests also cause breaks, implicitly or explicitly. This is
4762discussed in @ref{Manipulating Filling and Adjusting}.
4763
4764@c ---------------------------------------------------------------------
4765
4766@node Input Conventions, Input Encodings, Implicit Line Breaks, Text
4767@subsection Input Conventions
4768@cindex input conventions
4769@cindex conventions for input
4770
4771Since @code{gtroff} does filling automatically, it is traditional in
4772@code{groff} not to try and type things in as nicely formatted
4773paragraphs. These are some conventions commonly used when typing
4774@code{gtroff} text:
4775
4776@itemize @bullet
4777@item
4d3e9548
JL
4778Break lines after punctuation, particularly at the end of a sentence and
4779in other logical places. Keep separate phrases on lines by themselves,
4780as entire phrases are often added or deleted when editing.
92d0a6a6
JR
4781
4782@item
4783Try to keep lines less than 40-60@tie{}characters, to allow space for
4784inserting more text.
4785
4786@item
4787Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4788don't try using spaces to get proper indentation).
4789@end itemize
4790
4791@c ---------------------------------------------------------------------
4792
4793@node Input Encodings, , Input Conventions, Text
4794@subsection Input Encodings
4795
4796Currently, the following input encodings are available.
4797
4798@table @asis
4799@item cp1047
4800@cindex encoding, input, @acronym{EBCDIC}
4801@cindex @acronym{EBCDIC}, input encoding
4802@cindex input encoding, @acronym{EBCDIC}
4803@cindex encoding, input, cp1047
4804@cindex cp1047, input encoding
4805@cindex input encoding, cp1047
4806@cindex IBM cp1047 input encoding
4807@pindex cp1047.tmac
4808This input encoding works only on @acronym{EBCDIC} platforms (and vice
4809versa, the other input encodings don't work with @acronym{EBCDIC}); the
4810file @file{cp1047.tmac} is by default loaded at start-up.
4811
4812@item latin-1
4813@cindex encoding, input, @w{latin-1} (ISO @w{8859-1})
4814@cindex @w{latin-1} (ISO @w{8859-1}), input encoding
4815@cindex ISO @w{8859-1} (@w{latin-1}), input encoding
4816@cindex input encoding, @w{latin-1} (ISO @w{8859-1})
4817@pindex latin1.tmac
4818This is the default input encoding on non-@acronym{EBCDIC} platforms;
4819the file @file{latin1.tmac} is loaded at start-up.
4820
4821@item latin-2
4822@cindex encoding, input, @w{latin-2} (ISO @w{8859-2})
4823@cindex @w{latin-2} (ISO @w{8859-2}), input encoding
4824@cindex ISO @w{8859-2} (@w{latin-2}), input encoding
4825@cindex input encoding, @w{latin-2} (ISO @w{8859-2})
4826@pindex latin2.tmac
4827To use this encoding, either say @w{@samp{.mso latin2.tmac}} at the very
4828beginning of your document or use @samp{-mlatin2} as a command line
4829argument for @code{groff}.
4830
4d3e9548
JL
4831@item latin-5
4832@cindex encoding, input, @w{latin-5} (ISO @w{8859-9})
4833@cindex @w{latin-2} (ISO @w{8859-9}), input encoding
4834@cindex ISO @w{8859-9} (@w{latin-2}), input encoding
4835@cindex input encoding, @w{latin-2} (ISO @w{8859-9})
4836@pindex latin2.tmac
4837For Turkish. Either say @w{@samp{.mso latin9.tmac}} at the very
4838beginning of your document or use @samp{-mlatin9} as a command line
4839argument for @code{groff}.
4840
92d0a6a6
JR
4841@item latin-9 (latin-0)
4842@cindex encoding, input, @w{latin-9} (@w{latin-0}, ISO @w{8859-15})
4843@cindex @w{latin-9} (@w{latin-0}, ISO @w{8859-15}), input encoding
4844@cindex ISO @w{8859-15} (@w{latin-9}, @w{latin-0}), input encoding
4845@cindex input encoding, @w{latin-9} (@w{latin-9}, ISO @w{8859-15})
4846@pindex latin9.tmac
4847This encoding is intended (at least in Europe) to replace @w{latin-1}
4848encoding. The main difference to @w{latin-1} is that @w{latin-9}
4849contains the Euro character. To use this encoding, either say
4850@w{@samp{.mso latin9.tmac}} at the very beginning of your document or
4851use @samp{-mlatin9} as a command line argument for @code{groff}.
4852@end table
4853
4854Note that it can happen that some input encoding characters are not
4855available for a particular output device. For example, saying
4856
4857@Example
4858groff -Tlatin1 -mlatin9 ...
4859@endExample
4860
4861@noindent
4d3e9548 4862fails if you use the Euro character in the input. Usually, this
92d0a6a6
JR
4863limitation is present only for devices which have a limited set of
4864output glyphs (e.g.@: @option{-Tascii} and @option{-Tlatin1}); for other
4865devices it is usually sufficient to install proper fonts which contain
4866the necessary glyphs.
4867
4868@pindex freeeuro.pfa
4869@pindex ec.tmac
4870Due to the importance of the Euro glyph in Europe, the groff package now
4871comes with a @sc{PostScript} font called @file{freeeuro.pfa} which
4d3e9548 4872provides various glyph shapes for the Euro. In other words,
92d0a6a6
JR
4873@w{latin-9} encoding is supported for the @option{-Tps} device out of
4874the box (@w{latin-2} isn't).
4875
4876By its very nature, @option{-Tutf8} supports all input encodings;
4877@option{-Tdvi} has support for both @w{latin-2} and @w{latin-9} if the
4878command line @option{-mec} is used also to load the file @file{ec.tmac}
4879(which flips to the EC fonts).
4880
4881
4882@c =====================================================================
4883
4884@node Measurements, Expressions, Text, gtroff Reference
4885@section Measurements
4886@cindex measurements
4d3e9548
JL
4887@cindex scaling indicator
4888@cindex indicator, scaling
92d0a6a6
JR
4889
4890@cindex units of measurement
4891@cindex basic unit (@code{u})
4892@cindex machine unit (@code{u})
4893@cindex measurement unit
4894@cindex @code{u} unit
4895@cindex unit, @code{u}
4896@code{gtroff} (like many other programs) requires numeric parameters to
4897specify various measurements. Most numeric parameters@footnote{those
4898that specify vertical or horizontal motion or a type size} may have a
4899@dfn{measurement unit} attached. These units are specified as a single
4900character which immediately follows the number or expression. Each of
4901these units are understood, by @code{gtroff}, to be a multiple of its
4902@dfn{basic unit}. So, whenever a different measurement unit is
4903specified @code{gtroff} converts this into its @dfn{basic units}. This
4904basic unit, represented by a @samp{u}, is a device dependent measurement
4905which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4906inch. The values may be given as fractional numbers; however,
4907fractional basic units are always rounded to integers.
4908
4909Some of the measurement units are completely independent of any of the
4910current settings (e.g.@: type size) of @code{gtroff}.
4911
4912@table @code
4913@item i
4914@cindex inch unit (@code{i})
4915@cindex @code{i} unit
4916@cindex unit, @code{i}
4917Inches. An antiquated measurement unit still in use in certain
4918backwards countries with incredibly low-cost computer equipment. One
4919inch is equal to@tie{}2.54@dmn{cm}.
4920
4921@item c
4922@cindex centimeter unit (@code{c})
4923@cindex @code{c} unit
4924@cindex unit, @code{c}
4925Centimeters. One centimeter is equal to@tie{}0.3937@dmn{in}.
4926
4927@item p
4928@cindex point unit (@code{p})
4929@cindex @code{p} unit
4930@cindex unit, @code{p}
4931Points. This is a typesetter's measurement used for measure type size.
4932It is 72@tie{}points to an inch.
4933
4934@item P
4935@cindex pica unit (@code{P})
4936@cindex @code{P} unit
4937@cindex unit, @code{P}
4938Pica. Another typesetting measurement. 6@tie{}Picas to an inch (and
493912@tie{}points to a pica).
4940
4941@item s
4942@itemx z
4943@cindex @code{s} unit
4944@cindex unit, @code{s}
4945@cindex @code{z} unit
4946@cindex unit, @code{z}
4947@xref{Fractional Type Sizes}, for a discussion of these units.
4948
4949@item f
4950@cindex @code{f} unit
4951@cindex unit, @code{f}
4d3e9548 4952Fractions. Value is 65536.
92d0a6a6
JR
4953@xref{Colors}, for usage.
4954@end table
4955
4d3e9548
JL
4956The other measurements understood by @code{gtroff} depend on settings
4957currently in effect in @code{gtroff}. These are very useful for
4958specifying measurements which should look proper with any size of text.
92d0a6a6
JR
4959
4960@table @code
4961@item m
4962@cindex em unit (@code{m})
4963@cindex @code{m} unit
4964@cindex unit, @code{m}
4965Ems. This unit is equal to the current font size in points. So called
4966because it is @emph{approximately} the width of the letter@tie{}@samp{m}
4967in the current font.
4968
4969@item n
4970@cindex en unit (@code{n})
4971@cindex @code{n} unit
4972@cindex unit, @code{n}
4973Ens. In @code{groff}, this is half of an em.
4974
4975@item v
4976@cindex vertical space unit (@code{v})
4977@cindex space, vertical, unit (@code{v})
4978@cindex @code{v} unit
4979@cindex unit, @code{v}
4980Vertical space. This is equivalent to the current line spacing.
4981@xref{Sizes}, for more information about this.
4982
4983@item M
4984@cindex @code{M} unit
4985@cindex unit, @code{M}
4986100ths of an em.
4987@end table
4988
4989@menu
4990* Default Units::
4991@end menu
4992
4993@c ---------------------------------------------------------------------
4994
4995@node Default Units, , Measurements, Measurements
4996@subsection Default Units
4997@cindex default units
4998@cindex units, default
4999
5000Many requests take a default unit. While this can be helpful at times,
5001it can cause strange errors in some expressions. For example, the line
5002length request expects em units. Here are several attempts to get a
5003line length of 3.5@tie{}inches and their results:
5004
5005@Example
50063.5i @result{} 3.5i
50077/2 @result{} 0i
50087/2i @result{} 0i
5009(7 / 2)u @result{} 0i
50107i/2 @result{} 0.1i
50117i/2u @result{} 3.5i
5012@endExample
5013
5014@noindent
5015Everything is converted to basic units first. In the above example it
5016is assumed that 1@dmn{i} equals@tie{}240@dmn{u}, and 1@dmn{m}
5017equals@tie{}10@dmn{p} (thus 1@dmn{m} equals@tie{}33@dmn{u}). The value
50187@dmn{i}/2 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
50191680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
50200.1@dmn{i}. As can be seen, a scaling indicator after a closing
5021parenthesis is simply ignored.
5022
5023@cindex measurements, specifying safely
4d3e9548
JL
5024Thus, the safest way to specify measurements is to always attach a
5025scaling indicator. If you want to multiply or divide by a certain
5026scalar value, use @samp{u} as the unit for that value.
92d0a6a6
JR
5027
5028
5029@c =====================================================================
5030
5031@node Expressions, Identifiers, Measurements, gtroff Reference
5032@section Expressions
5033@cindex expressions
5034
5035@code{gtroff} has most arithmetic operators common to other languages:
5036
5037@itemize @bullet
5038@item
5039@cindex arithmetic operators
5040@cindex operators, arithmetic
5041@opindex +
5042@opindex -
5043@opindex /
5044@opindex *
5045@opindex %
5046Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
5047(division), @samp{*} (multiplication), @samp{%} (modulo).
5048
5049@code{gtroff} only provides integer arithmetic. The internal type used
5050for computing results is @samp{int}, which is usually a 32@dmn{bit}
5051signed integer.
5052
5053@item
5054@cindex comparison operators
5055@cindex operators, comparison
5056@opindex <
5057@opindex >
5058@opindex >=
5059@opindex <=
5060@opindex =
5061@opindex ==
5062Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
5063(less than or equal), @samp{>=} (greater than or equal), @samp{=}
5064(equal), @samp{==} (the same as @samp{=}).
5065
5066@item
5067@cindex logical operators
5068@cindex operators, logical
5069@opindex &
5070@ifnotinfo
5071@opindex :
5072@end ifnotinfo
5073@ifinfo
5074@opindex @r{<colon>}
5075@end ifinfo
5076Logical: @samp{&} (logical and), @samp{:} (logical or).
5077
5078@item
5079@cindex unary operators
5080@cindex operators, unary
5081@opindex -
5082@opindex +
5083@opindex !
5084@cindex @code{if} request, and the @samp{!} operator
5085@cindex @code{while} request, and the @samp{!} operator
5086Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
5087(just for completeness; does nothing in expressions), @samp{!} (logical
4d3e9548
JL
5088not; this works only within @code{if} and @code{while}
5089requests).@footnote{Note that, for example, @samp{!(-1)} evaluates to
5090`true' because @code{gtroff} treats both negative numbers and zero as
5091`false'.} See below for the use of unary operators in motion requests.
92d0a6a6
JR
5092
5093@item
5094@cindex extremum operators (@code{>?}, @code{<?})
5095@cindex operators, extremum (@code{>?}, @code{<?})
5096@opindex >?
5097@opindex <?
5098Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
5099
5100Example:
5101
5102@Example
5103.nr x 5
5104.nr y 3
5105.nr z (\n[x] >? \n[y])
5106@endExample
5107
5108@noindent
5109The register@tie{}@code{z} now contains@tie{}5.
5110
5111@item
5112@cindex scaling operator
5113@cindex operator, scaling
4d3e9548
JL
5114Scaling: @code{(@var{c};@var{e})}. Evaluate@tie{}@var{e}
5115using@tie{}@var{c} as the default scaling indicator. If @var{c} is
5116missing, ignore scaling indicators in the evaluation of@tie{}@var{e}.
92d0a6a6
JR
5117@end itemize
5118
5119@cindex parentheses
5120@cindex order of evaluation in expressions
5121@cindex expression, order of evaluation
5122@opindex (
5123@opindex )
5124Parentheses may be used as in any other language. However, in
5125@code{gtroff} they are necessary to ensure order of evaluation.
5126@code{gtroff} has no operator precedence; expressions are evaluated left
4d3e9548
JL
5127to right. This means that @code{gtroff} evaluates @samp{3+5*4} as if it
5128were parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might
5129be expected.
92d0a6a6
JR
5130
5131@cindex @code{+}, and page motion
5132@cindex @code{-}, and page motion
5133@cindex motion operators
5134@cindex operators, motion
5135For many requests which cause a motion on the page, the unary operators
5136@samp{+} and @samp{-} work differently if leading an expression. They
5137then indicate a motion relative to the current position (down or up,
5138respectively).
5139
5140@cindex @code{|}, and page motion
5141@cindex absolute position operator (@code{|})
5142@cindex position, absolute, operator (@code{|})
5143Similarly, a leading @samp{|} operator indicates an absolute position.
5144For vertical movements, it specifies the distance from the top of the
5145page; for horizontal movements, it gives the distance from the beginning
5146of the @emph{input} line.
5147
5148@cindex @code{bp} request, using @code{+} and@tie{}@code{-}
5149@cindex @code{in} request, using @code{+} and@tie{}@code{-}
5150@cindex @code{ll} request, using @code{+} and@tie{}@code{-}
5151@cindex @code{lt} request, using @code{+} and@tie{}@code{-}
5152@cindex @code{nm} request, using @code{+} and@tie{}@code{-}
5153@cindex @code{nr} request, using @code{+} and@tie{}@code{-}
5154@cindex @code{pl} request, using @code{+} and@tie{}@code{-}
5155@cindex @code{pn} request, using @code{+} and@tie{}@code{-}
5156@cindex @code{po} request, using @code{+} and@tie{}@code{-}
5157@cindex @code{ps} request, using @code{+} and@tie{}@code{-}
5158@cindex @code{pvs} request, using @code{+} and@tie{}@code{-}
5159@cindex @code{rt} request, using @code{+} and@tie{}@code{-}
5160@cindex @code{ti} request, using @code{+} and@tie{}@code{-}
5161@cindex @code{\H}, using @code{+} and@tie{}@code{-}
5162@cindex @code{\R}, using @code{+} and@tie{}@code{-}
5163@cindex @code{\s}, using @code{+} and@tie{}@code{-}
5164@samp{+} and @samp{-} are also treated differently by the following
5165requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
5166@code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
5167@code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
5168Here, leading plus and minus signs indicate increments and decrements.
5169
5170@xref{Setting Registers}, for some examples.
5171
5172@Defesc {\\B, ', anything, '}
5173@cindex numeric expression, valid
5174@cindex valid numeric expression
4d3e9548
JL
5175Return@tie{}1 if @var{anything} is a valid numeric expression; or@tie{}0
5176if @var{anything} is empty or not a valid numeric expression.
92d0a6a6
JR
5177@endDefesc
5178
5179@cindex space characters, in expressions
5180@cindex expressions, and space characters
5181Due to the way arguments are parsed, spaces are not allowed in
5182expressions, unless the entire expression is surrounded by parentheses.
5183
5184@xref{Request and Macro Arguments}, and @ref{Conditionals and Loops}.
5185
5186
5187@c =====================================================================
5188
5189@node Identifiers, Embedded Commands, Expressions, gtroff Reference
5190@section Identifiers
5191@cindex identifiers
5192
5193Like any other language, @code{gtroff} has rules for properly formed
5194@dfn{identifiers}. In @code{gtroff}, an identifier can be made up of
5195almost any printable character, with the exception of the following
5196characters:
5197
5198@itemize @bullet
5199@item
5200@cindex whitespace characters
5201@cindex newline character
5202@cindex character, whitespace
5203Whitespace characters (spaces, tabs, and newlines).
5204
5205@item
5206@cindex character, backspace
5207@cindex backspace character
5208@cindex @acronym{EBCDIC} encoding of backspace
5209Backspace (@acronym{ASCII}@tie{}@code{0x08} or
5210@acronym{EBCDIC}@tie{}@code{0x16}) and character code @code{0x01}.
5211
5212@item
5213@cindex invalid input characters
5214@cindex input characters, invalid
5215@cindex characters, invalid input
5216@cindex Unicode
5217The following input characters are invalid and are ignored if
5218@code{groff} runs on a machine based on @acronym{ASCII}, causing a
5219warning message of type @samp{input} (see @ref{Debugging}, for more
5220details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
5221@code{0x80}-@code{0x9F}.
5222
5223And here are the invalid input characters if @code{groff} runs on an
5224@acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
5225@code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
5226@code{0x30}-@code{0x3F}.
5227
5228Currently, some of these reserved codepoints are used internally, thus
5229making it non-trivial to extend @code{gtroff} to cover Unicode or other
5230character sets and encodings which use characters of these ranges.
5231
4d3e9548
JL
5232Note that invalid characters are removed before parsing; an identifier
5233@code{foo}, followed by an invalid character, followed by @code{bar} is
5234treated as @code{foobar}.
92d0a6a6
JR
5235@end itemize
5236
5237For example, any of the following is valid.
5238
5239@Example
5240br
5241PP
5242(l
5243end-list
5244@@_
5245@endExample
5246
5247@cindex @code{]}, as part of an identifier
5248@noindent
5249Note that identifiers longer than two characters with a closing bracket
5250(@samp{]}) in its name can't be accessed with escape sequences which
5251expect an identifier as a parameter. For example, @samp{\[foo]]}
5252accesses the glyph @samp{foo}, followed by @samp{]}, whereas
5253@samp{\C'foo]'} really asks for glyph @samp{foo]}.
5254
5255@cindex @code{refer}, and macro names starting with @code{[} or @code{]}
5256@cindex @code{[}, macro names starting with, and @code{refer}
5257@cindex @code{]}, macro names starting with, and @code{refer}
5258@cindex macro names, starting with @code{[} or @code{]}, and @code{refer}
4d3e9548
JL
5259To avoid problems with the @code{refer} preprocessor, macro names should
5260not start with @samp{[} or @samp{]}. Due to backwards compatibility,
5261everything after @samp{.[} and @samp{.]} is handled as a special
5262argument to @code{refer}. For example, @samp{.[foo} makes @code{refer}
5263to start a reference, using @samp{foo} as a parameter.
92d0a6a6
JR
5264
5265@Defesc {\\A, ', ident, '}
5266Test whether an identifier @var{ident} is valid in @code{gtroff}. It
5267expands to the character@tie{}1 or@tie{}0 according to whether its
5268argument (usually delimited by quotes) is or is not acceptable as the
5269name of a string, macro, diversion, number register, environment, or
5270font. It returns@tie{}0 if no argument is given. This is useful for
5271looking up user input in some sort of associative table.
5272
5273@Example
5274\A'end-list'
5275 @result{} 1
5276@endExample
5277@endDefesc
5278
5279@xref{Escapes}, for details on parameter delimiting characters.
5280
5281Identifiers in @code{gtroff} can be any length, but, in some contexts,
5282@code{gtroff} needs to be told where identifiers end and text begins
5283(and in different ways depending on their length):
5284
5285@itemize @bullet
5286@item
5287Single character.
5288
5289@cindex @code{(}, starting a two-character identifier
5290@item
5291Two characters. Must be prefixed with @samp{(} in some situations.
5292
5293@cindex @code{[}, starting an identifier
5294@cindex @code{]}, ending an identifier
5295@item
5296Arbitrary length (@code{gtroff} only). Must be bracketed with @samp{[}
5297and@tie{}@samp{]} in some situations. Any length identifier can be put
5298in brackets.
5299@end itemize
5300
5301@cindex undefined identifiers
5302@cindex identifiers, undefined
5303Unlike many other programming languages, undefined identifiers are
4d3e9548
JL
5304silently ignored or expanded to nothing. When @code{gtroff} finds an
5305undefined identifier, it emits a warning, doing the following:
92d0a6a6
JR
5306
5307@itemize @bullet
5308@item
4d3e9548
JL
5309If the identifier is a string, macro, or diversion, @code{gtroff}
5310defines it as empty.
92d0a6a6
JR
5311
5312@item
4d3e9548
JL
5313If the identifier is a number register, @code{gtroff} defines it with a
5314value of@tie{}0.
92d0a6a6
JR
5315@end itemize
5316
5317@xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
5318
5319Note that macros, strings, and diversions share the same name space.
5320
5321@Example
5322.de xxx
5323. nop foo
5324..
5325.
5326.di xxx
5327bar
5328.br
5329.di
5330.
5331.xxx
5332 @result{} bar
5333@endExample
5334
5335@noindent
5336As can be seen in the previous example, @code{gtroff} reuses the
4d3e9548
JL
5337identifier @samp{xxx}, changing it from a macro to a diversion. No
5338warning is emitted! The contents of the first macro definition is lost.
92d0a6a6
JR
5339
5340@xref{Interpolating Registers}, and @ref{Strings}.
5341
5342
5343@c =====================================================================
5344
5345@node Embedded Commands, Registers, Identifiers, gtroff Reference
5346@section Embedded Commands
5347@cindex embedded commands
5348@cindex commands, embedded
5349
5350Most documents need more functionality beyond filling, adjusting and
5351implicit line breaking. In order to gain further functionality,
5352@code{gtroff} allows commands to be embedded into the text, in two ways.
5353
5354The first is a @dfn{request} which takes up an entire line, and does
5355some large-scale operation (e.g.@: break lines, start new pages).
5356
4d3e9548
JL
5357The other is an @dfn{escape} which can be usually embedded anywhere in
5358the text; most requests can accept it even as an argument. Escapes
5359generally do more minor operations like sub- and superscripts, print a
5360symbol, etc.
92d0a6a6
JR
5361
5362@menu
5363* Requests::
5364* Macros::
5365* Escapes::
5366@end menu
5367
5368@c ---------------------------------------------------------------------
5369
5370@node Requests, Macros, Embedded Commands, Embedded Commands
5371@subsection Requests
5372@cindex requests
5373
5374@cindex control character (@code{.})
5375@cindex character, control (@code{.})
5376@cindex no-break control character (@code{'})
5377@cindex character, no-break control (@code{'})
5378@cindex control character, no-break (@code{'})
5379A request line begins with a control character, which is either a single
5380quote (@samp{'}, the @dfn{no-break control character}) or a period
5381(@samp{.}, the normal @dfn{control character}). These can be changed;
5382see @ref{Character Translations}, for details. After this there may be
5383optional tabs or spaces followed by an identifier which is the name of
5384the request. This may be followed by any number of space-separated
5385arguments (@emph{no} tabs here).
5386
5387@cindex structuring source code of documents or macro packages
5388@cindex documents, structuring the source code
5389@cindex macro packages, structuring the source code
4d3e9548
JL
5390Since a control character followed by whitespace only is ignored, it is
5391common practice to use this feature for structuring the source code of
5392documents or macro packages.
92d0a6a6
JR
5393
5394@Example
5395.de foo
5396. tm This is foo.
5397..
5398.
5399.
5400.de bar
5401. tm This is bar.
5402..
5403@endExample
5404
5405@cindex blank line
5406@cindex blank line macro (@code{blm})
4d3e9548
JL
5407Another possibility is to use the blank line macro request @code{blm} by
5408assigning an empty macro to it.
92d0a6a6
JR
5409
5410@Example
5411.de do-nothing
5412..
5413.blm do-nothing \" activate blank line macro
5414
5415.de foo
5416. tm This is foo.
5417..
5418
5419
5420.de bar
5421. tm This is bar.
5422..
5423
5424.blm \" deactivate blank line macro
5425@endExample
5426
5427@xref{Blank Line Traps}.
5428
5429@cindex zero width space character (@code{\&})
5430@cindex character, zero width space (@code{\&})
5431@cindex space character, zero width (@code{\&})
5432@cindex @code{\&}, escaping control characters
5433To begin a line with a control character without it being interpreted,
5434precede it with @code{\&}. This represents a zero width space, which
5435means it does not affect the output.
5436
5437In most cases the period is used as a control character. Several
5438requests cause a break implicitly; using the single quote control
5439character prevents this.
5440
4d3e9548
JL
5441@Defreg {.br}
5442A read-only number register which is set to@tie{}1 if a macro is called
5443with the normal control character (as defined with the @code{cc}
5444request), and set to@tie{}0 otherwise.
5445
5446@cindex modifying requests
5447@cindex requests, modifying
5448This allows to reliably modify requests.
5449
5450@Example
5451.als bp*orig bp
5452.de bp
5453. tm before bp
5454. ie \\n[.br] .bp*orig
5455. el 'bp*orig
5456. tm after bp
5457..
5458@endExample
5459
5460Using this register outside of a macro makes no sense (it always returns
5461zero in such cases).
5462
5463If a macro is called as a string (this is, using @code{\*}), the value
5464of the @code{.br} register is inherited from the calling macro.
5465@endDefreg
5466
92d0a6a6
JR
5467@menu
5468* Request and Macro Arguments::
5469@end menu
5470
5471@node Request and Macro Arguments, , Requests, Requests
5472@subsubsection Request and Macro Arguments
5473@cindex request arguments
5474@cindex macro arguments
5475@cindex arguments to requests and macros
5476
4d3e9548
JL
5477@cindex tabs, and macro arguments
5478@cindex macro arguments, and tabs
5479@cindex arguments to macros, and tabs
92d0a6a6
JR
5480Arguments to requests and macros are processed much like the shell:
5481The line is split into arguments according to
5482spaces.@footnote{Plan@tie{}9's @code{troff} implementation also allows
5483tabs for argument separation -- @code{gtroff} intentionally doesn't
5484support this.}
5485
5486@cindex spaces, in a macro argument
5487An argument to a macro which is intended to contain spaces can either be
5488enclosed in double quotes, or have the spaces @dfn{escaped} with
5489backslashes. This is @emph{not} true for requests.
5490
5491Here are a few examples for a hypothetical macro @code{uh}:
5492
5493@Example
5494.uh The Mouse Problem
5495.uh "The Mouse Problem"
5496.uh The\ Mouse\ Problem
5497@endExample
5498
5499@cindex @code{\~}, difference to @code{\@key{SP}}
5500@cindex @code{\@key{SP}}, difference to @code{\~}
5501@noindent
5502The first line is the @code{uh} macro being called with 3 arguments,
5503@samp{The}, @samp{Mouse}, and @samp{Problem}. The latter two have the
5504same effect of calling the @code{uh} macro with one argument, @samp{The
5505Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
5506is ``classical'' in the sense that it can be found in most @code{troff}
5507documents. Nevertheless, it is not optimal in all situations, since
5508@w{@samp{\ }} inserts a fixed-width, non-breaking space character which
5509can't stretch. @code{gtroff} provides a different command @code{\~} to
5510insert a stretchable, non-breaking space.}
5511
5512@cindex @code{"}, in a macro argument
5513@cindex double quote, in a macro argument
5514A double quote which isn't preceded by a space doesn't start a macro
5515argument. If not closing a string, it is printed literally.
5516
5517For example,
5518
5519@Example
5520.xxx a" "b c" "de"fg"
5521@endExample
5522
5523@noindent
5524has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
5525Don't rely on this obscure behaviour!
5526
5527There are two possibilities to get a double quote reliably.
5528
5529@itemize @bullet
5530@item
4d3e9548
JL
5531Enclose the whole argument with double quotes and use two consecutive
5532double quotes to represent a single one. This traditional solution has
5533the disadvantage that double quotes don't survive argument expansion
5534again if called in compatibility mode (using the @option{-C} option of
5535@code{groff}):
92d0a6a6
JR
5536
5537@Example
5538.de xx
5539. tm xx: `\\$1' `\\$2' `\\$3'
5540.
5541. yy "\\$1" "\\$2" "\\$3"
5542..
5543.de yy
5544. tm yy: `\\$1' `\\$2' `\\$3'
5545..
5546.xx A "test with ""quotes""" .
5547 @result{} xx: `A' `test with "quotes"' `.'
5548 @result{} yy: `A' `test with ' `quotes""'
5549@endExample
5550
5551@noindent
5552If not in compatibility mode, you get the expected result
5553
5554@Example
5555xx: `A' `test with "quotes"' `.'
5556yy: `A' `test with "quotes"' `.'
5557@endExample
5558
5559@noindent
5560since @code{gtroff} preserves the input level.
5561
5562@item
5563Use the double quote glyph @code{\(dq}. This works with and without
4d3e9548
JL
5564compatibility mode enabled since @code{gtroff} doesn't convert
5565@code{\(dq} back to a double quote input character.
92d0a6a6 5566
4d3e9548
JL
5567Note that this method won't work with @acronym{UNIX} @code{troff} in
5568general since the glyph `dq' isn't defined normally.
92d0a6a6
JR
5569@end itemize
5570
5571@cindex @code{ds} request, and double quotes
5572Double quotes in the @code{ds} request are handled differently.
5573@xref{Strings}, for more details.
5574
5575@c ---------------------------------------------------------------------
5576
5577@node Macros, Escapes, Requests, Embedded Commands
5578@subsection Macros
5579@cindex macros
5580
5581@code{gtroff} has a @dfn{macro} facility for defining a series of lines
5582which can be invoked by name. They are called in the same manner as
5583requests -- arguments also may be passed basically in the same manner.
5584
5585@xref{Writing Macros}, and @ref{Request and Macro Arguments}.
5586
5587@c ---------------------------------------------------------------------
5588
5589@node Escapes, , Macros, Embedded Commands
5590@subsection Escapes
5591@cindex escapes
5592
5593Escapes may occur anywhere in the input to @code{gtroff}. They usually
5594begin with a backslash and are followed by a single character which
5595indicates the function to be performed. The escape character can be
5596changed; see @ref{Character Translations}.
5597
5598Escape sequences which require an identifier as a parameter accept three
5599possible syntax forms.
5600
5601@itemize @bullet
5602@item
5603The next single character is the identifier.
5604
5605@cindex @code{(}, starting a two-character identifier
5606@item
5607If this single character is an opening parenthesis, take the following
5608two characters as the identifier. Note that there is no closing
5609parenthesis after the identifier.
5610
5611@cindex @code{[}, starting an identifier
5612@cindex @code{]}, ending an identifier
5613@item
5614If this single character is an opening bracket, take all characters
5615until a closing bracket as the identifier.
5616@end itemize
5617
5618@noindent
5619Examples:
5620
5621@Example
5622\fB
5623\n(XX
5624\*[TeX]
5625@endExample
5626
5627@cindex @code{'}, delimiting arguments
5628@cindex argument delimiting characters
5629@cindex characters, argument delimiting
5630@cindex delimiting characters for arguments
5631Other escapes may require several arguments and/or some special format.
5632In such cases the argument is traditionally enclosed in single quotes
5633(and quotes are always used in this manual for the definitions of escape
5634sequences). The enclosed text is then processed according to what that
5635escape expects. Example:
5636
5637@Example
5638\l'1.5i\(bu'
5639@endExample
5640
5641@cindex @code{\o}, possible quote characters
5642@cindex @code{\b}, possible quote characters
5643@cindex @code{\X}, possible quote characters
5644Note that the quote character can be replaced with any other character
5645which does not occur in the argument (even a newline or a space
5646character) in the following escapes: @code{\o}, @code{\b}, and
5647@code{\X}. This makes e.g.
5648
5649@Example
5650A caf
5651\o
5652e\'
5653
5654
5655in Paris
465b256c 5656 @result{} A café in Paris
92d0a6a6
JR
5657@endExample
5658
5659@noindent
5660possible, but it is better not to use this feature to avoid confusion.
5661
5662@cindex @code{\%}, used as delimiter
5663@cindex @code{\@key{SP}}, used as delimiter
5664@cindex @code{\|}, used as delimiter
5665@cindex @code{\^}, used as delimiter
5666@cindex @code{\@{}, used as delimiter
5667@cindex @code{\@}}, used as delimiter
5668@cindex @code{\'}, used as delimiter
5669@cindex @code{\`}, used as delimiter
5670@cindex @code{\-}, used as delimiter
5671@cindex @code{\_}, used as delimiter
5672@cindex @code{\!}, used as delimiter
5673@cindex @code{\?}, used as delimiter
92d0a6a6
JR
5674@cindex @code{\)}, used as delimiter
5675@cindex @code{\/}, used as delimiter
5676@cindex @code{\,}, used as delimiter
5677@cindex @code{\&}, used as delimiter
5678@ifnotinfo
5679@cindex @code{\:}, used as delimiter
5680@end ifnotinfo
5681@ifinfo
5682@cindex @code{\@r{<colon>}}, used as delimiter
5683@end ifinfo
5684@cindex @code{\~}, used as delimiter
5685@cindex @code{\0}, used as delimiter
5686@cindex @code{\a}, used as delimiter
5687@cindex @code{\c}, used as delimiter
5688@cindex @code{\d}, used as delimiter
5689@cindex @code{\e}, used as delimiter
5690@cindex @code{\E}, used as delimiter
5691@cindex @code{\p}, used as delimiter
5692@cindex @code{\r}, used as delimiter
5693@cindex @code{\t}, used as delimiter
5694@cindex @code{\u}, used as delimiter
5695The following escapes sequences (which are handled similarly to
5696characters since they don't take a parameter) are also allowed as
5697delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5698@code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
4d3e9548
JL
5699@code{\?}, @code{\)}, @code{\/}, @code{\,}, @code{\&}, @code{\:},
5700@code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
5701@code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}. Again, don't
5702use these if possible.
92d0a6a6
JR
5703
5704@cindex @code{\A}, allowed delimiters
5705@cindex @code{\B}, allowed delimiters
5706@cindex @code{\Z}, allowed delimiters
5707@cindex @code{\C}, allowed delimiters
5708@cindex @code{\w}, allowed delimiters
5709No newline characters as delimiters are allowed in the following
5710escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5711
5712@cindex @code{\D}, allowed delimiters
5713@cindex @code{\h}, allowed delimiters
5714@cindex @code{\H}, allowed delimiters
5715@cindex @code{\l}, allowed delimiters
5716@cindex @code{\L}, allowed delimiters
5717@cindex @code{\N}, allowed delimiters
5718@cindex @code{\R}, allowed delimiters
5719@cindex @code{\s}, allowed delimiters
5720@cindex @code{\S}, allowed delimiters
5721@cindex @code{\v}, allowed delimiters
5722@cindex @code{\x}, allowed delimiters
5723Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
4d3e9548
JL
5724@code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
5725@code{\x} can't use the following characters as delimiters:
92d0a6a6
JR
5726
5727@itemize @bullet
5728@item
5729@cindex numbers, and delimiters
5730@cindex digits, and delimiters
5731The digits @code{0}-@code{9}.
5732
5733@item
5734@cindex operators, as delimiters
5735@cindex @code{+}, as delimiter
5736@cindex @code{-}, as delimiter
5737@cindex @code{/}, as delimiter
5738@cindex @code{*}, as delimiter
5739@cindex @code{%}, as delimiter
5740@cindex @code{<}, as delimiter
5741@cindex @code{>}, as delimiter
5742@cindex @code{=}, as delimiter
5743@cindex @code{&}, as delimiter
5744@ifnotinfo
5745@cindex @code{:}, as delimiter
5746@end ifnotinfo
5747@ifinfo
5748@cindex <colon>, as delimiter
5749@end ifinfo
5750@cindex @code{(}, as delimiter
5751@cindex @code{)}, as delimiter
5752@cindex @code{.}, as delimiter
5753The (single-character) operators @samp{+-/*%<>=&:().}.
5754
5755@item
5756@cindex space character
5757@cindex character, space
5758@cindex tab character
5759@cindex character, tab
5760@cindex newline character
5761@cindex character, newline
5762The space, tab, and newline characters.
5763
5764@item
5765@cindex @code{\%}, used as delimiter
5766@ifnotinfo
5767@cindex @code{\:}, used as delimiter
5768@end ifnotinfo
5769@ifinfo
5770@cindex @code{\@r{<colon>}}, used as delimiter
5771@end ifinfo
5772@cindex @code{\@{}, used as delimiter
5773@cindex @code{\@}}, used as delimiter
5774@cindex @code{\'}, used as delimiter
5775@cindex @code{\`}, used as delimiter
5776@cindex @code{\-}, used as delimiter
5777@cindex @code{\_}, used as delimiter
5778@cindex @code{\!}, used as delimiter
92d0a6a6
JR
5779@cindex @code{\/}, used as delimiter
5780@cindex @code{\c}, used as delimiter
5781@cindex @code{\e}, used as delimiter
5782@cindex @code{\p}, used as delimiter
4d3e9548
JL
5783All escape sequences except @code{\%}, @code{\:}, @code{\@{},
5784@code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
92d0a6a6
JR
5785@code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5786@end itemize
5787
5788@cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5789@cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
4d3e9548
JL
5790To have a backslash (actually, the current escape character) appear in
5791the output several escapes are defined: @code{\\}, @code{\e} or
5792@code{\E}. These are very similar, and only differ with respect to
5793being used in macros or diversions. @xref{Character Translations}, for
5794an exact description of those escapes.
92d0a6a6 5795
4d3e9548
JL
5796@xref{Implementation Differences}, @ref{Copy-in Mode}, and
5797@ref{Diversions}, @ref{Identifiers}, for more information.
92d0a6a6
JR
5798
5799@menu
5800* Comments::
5801@end menu
5802
5803@node Comments, , Escapes, Escapes
5804@subsubsection Comments
5805@cindex comments
5806
5807Probably one of the most@footnote{Unfortunately, this is a lie. But
5808hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5809common forms of escapes is the comment.
5810
5811@Defesc {\\", , , }
5812Start a comment. Everything to the end of the input line is ignored.
5813
5814This may sound simple, but it can be tricky to keep the comments from
5815interfering with the appearance of the final output.
5816
5817@cindex @code{ds}, @code{ds1} requests, and comments
5818@cindex @code{as}, @code{as1} requests, and comments
4d3e9548
JL
5819If the escape is to the right of some text or a request, that portion of
5820the line is ignored, but the space leading up to it is noticed by
5821@code{gtroff}. This only affects the @code{ds} and @code{as} request
5822and its variants.
92d0a6a6
JR
5823
5824@cindex tabs, before comments
5825@cindex comments, lining up with tabs
5826One possibly irritating idiosyncracy is that tabs must not be used to
5827line up comments. Tabs are not treated as whitespace between the
5828request and macro arguments.
5829
5830@cindex undefined request
5831@cindex request, undefined
4d3e9548
JL
5832A comment on a line by itself is treated as a blank line, because after
5833eliminating the comment, that is all that remains:
92d0a6a6
JR
5834
5835@Example
5836Test
5837\" comment
5838Test
5839@endExample
5840
5841@noindent
5842produces
5843
5844@Example
5845Test
5846
5847Test
5848@endExample
5849
5850To avoid this, it is common to start the line with @code{.\"} which
5851causes the line to be treated as an undefined request and thus ignored
5852completely.
5853
5854@cindex @code{'}, as a comment
5855Another commenting scheme seen sometimes is three consecutive single
5856quotes (@code{'''}) at the beginning of a line. This works, but
5857@code{gtroff} gives a warning about an undefined macro (namely
5858@code{''}), which is harmless, but irritating.
5859@endDefesc
5860
5861@Defesc {\\#, , , }
5862To avoid all this, @code{gtroff} has a new comment mechanism using the
5863@code{\#} escape. This escape works the same as @code{\"} except that
5864the newline is also ignored:
5865
5866@Example
5867Test
5868\# comment
5869Test
5870@endExample
5871
5872@noindent
5873produces
5874
5875@Example
5876Test Test
5877@endExample
5878
5879@noindent
5880as expected.
5881@endDefesc
5882
5883@Defreq {ig, [@Var{end}]}
5884Ignore all input until @code{gtroff} encounters the macro named
5885@code{.}@var{end} on a line by itself (or @code{..} if @var{end} is not
5886specified). This is useful for commenting out large blocks of text:
5887
5888@Example
5889text text text...
5890.ig
5891This is part of a large block
5892of text that has been
5893temporarily(?) commented out.
5894
5895We can restore it simply by removing
5896the .ig request and the ".." at the
5897end of the block.
5898..
5899More text text text...
5900@endExample
5901
5902@noindent
5903produces
5904
5905@Example
5906text text text@dots{} More text text text@dots{}
5907@endExample
5908
5909@noindent
4d3e9548 5910Note that the commented-out block of text does not cause a break.
92d0a6a6 5911
4d3e9548
JL
5912@cindex @code{ig} request, and copy-in mode
5913@cindex copy-in mode, and @code{ig} request
5914@cindex mode, copy-in, and @code{ig} request
5915@cindex @code{ig} request, and auto-increment
5916@cindex auto-increment, and @code{ig} request
92d0a6a6
JR
5917The input is read in copy-mode; auto-incremented registers @emph{are}
5918affected (@pxref{Auto-increment}).
5919@endDefreq
5920
5921
5922@c =====================================================================
5923
5924@node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5925@section Registers
5926@cindex registers
5927
5928Numeric variables in @code{gtroff} are called @dfn{registers}. There
5929are a number of built-in registers, supplying anything from the date to
5930details of formatting parameters.
5931
5932@xref{Identifiers}, for details on register identifiers.
5933
5934@menu
5935* Setting Registers::
5936* Interpolating Registers::
5937* Auto-increment::
5938* Assigning Formats::
5939* Built-in Registers::
5940@end menu
5941
5942@c ---------------------------------------------------------------------
5943
5944@node Setting Registers, Interpolating Registers, Registers, Registers
5945@subsection Setting Registers
5946@cindex setting registers (@code{nr}, @code{\R})
5947@cindex registers, setting (@code{nr}, @code{\R})
5948
4d3e9548
JL
5949Define or set registers using the @code{nr} request or the @code{\R}
5950escape.
92d0a6a6
JR
5951
5952@DefreqList {nr, ident value}
5953@DefescListEnd {\\R, ', ident value, '}
4d3e9548
JL
5954Set number register @var{ident} to @var{value}. If @var{ident} doesn't
5955exist, @code{gtroff} creates it.
92d0a6a6
JR
5956
5957The argument to @code{\R} usually has to be enclosed in quotes.
5958@xref{Escapes}, for details on parameter delimiting characters.
5959
5960The @code{\R} escape doesn't produce an input token in @code{gtroff};
4d3e9548 5961in other words, it vanishes completely after @code{gtroff} has
92d0a6a6
JR
5962processed it.
5963@endDefreq
5964
5965For example, the following two lines are equivalent:
5966
5967@Example
5968.nr a (((17 + (3 * 4))) % 4)
5969\R'a (((17 + (3 * 4))) % 4)'
5970 @result{} 1
5971@endExample
5972
5973Both @code{nr} and @code{\R} have two additional special forms to
5974increment or decrement a register.
5975
5976@DefreqList {nr, ident @t{+}@Var{value}}
5977@DefreqItem {nr, ident @t{-}@Var{value}}
5978@DefescItem {\\R, ', ident @t{+}value, '}
5979@DefescListEnd {\\R, ', ident @t{-}value, '}
5980Increment (decrement) register @var{ident} by @var{value}.
5981
5982@Example
5983.nr a 1
5984.nr a +1
5985\na
5986 @result{} 2
5987@endExample
5988
5989@cindex negating register values
5990To assign the negated value of a register to another register, some care
5991must be taken to get the desired result:
5992
5993@Example
5994.nr a 7
5995.nr b 3
5996.nr a -\nb
5997\na
5998 @result{} 4
5999.nr a (-\nb)
6000\na
6001 @result{} -3
6002@endExample
6003
6004@noindent
6005The surrounding parentheses prevent the interpretation of the minus sign
6006as a decrementing operator. An alternative is to start the assignment
6007with a @samp{0}:
6008
6009@Example
6010.nr a 7
6011.nr b -3
6012.nr a \nb
6013\na
6014 @result{} 4
6015.nr a 0\nb
6016\na
6017 @result{} -3
6018@endExample
6019@endDefreq
6020
6021@Defreq {rr, ident}
6022@cindex removing number register (@code{rr})
6023@cindex number register, removing (@code{rr})
6024@cindex register, removing (@code{rr})
6025Remove number register @var{ident}. If @var{ident} doesn't exist, the
6026request is ignored.
6027@endDefreq
6028
6029@Defreq {rnn, ident1 ident2}
6030@cindex renaming number register (@code{rnn})
6031@cindex number register, renaming (@code{rnn})
6032@cindex register, renaming (@code{rnn})
6033Rename number register @var{ident1} to @var{ident2}. If either
6034@var{ident1} or @var{ident2} doesn't exist, the request is ignored.
6035@endDefreq
6036
6037@Defreq {aln, ident1 ident2}
6038@cindex alias, number register, creating (@code{aln})
6039@cindex creating alias, for number register (@code{aln})
6040@cindex number register, creating alias (@code{aln})
6041@cindex register, creating alias (@code{aln})
6042Create an alias @var{ident1} for a number register @var{ident2}. The
6043new name and the old name are exactly equivalent. If @var{ident1} is
4d3e9548
JL
6044undefined, a warning of type @samp{reg} is generated, and the request is
6045ignored. @xref{Debugging}, for information about warnings.
92d0a6a6
JR
6046@endDefreq
6047
6048@c ---------------------------------------------------------------------
6049
6050@node Interpolating Registers, Auto-increment, Setting Registers, Registers
6051@subsection Interpolating Registers
6052@cindex interpolating registers (@code{\n})
6053@cindex registers, interpolating (@code{\n})
6054
6055Numeric registers can be accessed via the @code{\n} escape.
6056
6057@DefescList {\\n, , i, }
465b256c
JR
6058@DefescItem {\\n, @Lparen{}, id, }
6059@DefescListEnd {\\n, @Lbrack{}, ident, @Rbrack{}}
92d0a6a6
JR
6060@cindex nested assignments
6061@cindex assignments, nested
6062@cindex indirect assignments
6063@cindex assignments, indirect
6064Interpolate number register with name @var{ident} (one-character
4d3e9548
JL
6065name@tie{}@var{i}, two-character name @var{id}). This means that the
6066value of the register is expanded in-place while @code{gtroff} is
6067parsing the input line. Nested assignments (also called indirect
6068assignments) are possible.
92d0a6a6
JR
6069
6070@Example
6071.nr a 5
6072.nr as \na+\na
6073\n(as
6074 @result{} 10
6075@endExample
6076
6077@Example
6078.nr a1 5
6079.nr ab 6
6080.ds str b
6081.ds num 1
6082\n[a\n[num]]
6083 @result{} 5
6084\n[a\*[str]]
6085 @result{} 6
6086@endExample
6087@endDefesc
6088
6089@c ---------------------------------------------------------------------
6090
6091@node Auto-increment, Assigning Formats, Interpolating Registers, Registers
6092@subsection Auto-increment
6093@cindex auto-increment
6094@cindex increment, automatic
6095
4d3e9548
JL
6096Number registers can also be auto-incremented and auto-decremented. The
6097increment or decrement value can be specified with a third argument to
6098the @code{nr} request or @code{\R} escape.
92d0a6a6
JR
6099
6100@Defreq {nr, ident value incr}
6101@cindex @code{\R}, difference to @code{nr}
6102Set number register @var{ident} to @var{value}; the increment for
4d3e9548
JL
6103auto-incrementing is set to @var{incr}. Note that the @code{\R} escape
6104doesn't support this notation.
92d0a6a6
JR
6105@endDefreq
6106
4d3e9548
JL
6107To activate auto-incrementing, the escape @code{\n} has a special syntax
6108form.
92d0a6a6
JR
6109
6110@DefescList {\\n, +, i, }
6111@DefescItem {\\n, -, i, }
465b256c
JR
6112@DefescItem {\\n, @Lparen{}+, id, }
6113@DefescItem {\\n, @Lparen{}-, id, }
6114@DefescItem {\\n, +@Lparen{}, id, }
6115@DefescItem {\\n, -@Lparen{}, id, }
6116@DefescItem {\\n, @Lbrack{}+, ident, @Rbrack{}}
6117@DefescItem {\\n, @Lbrack{}-, ident, @Rbrack{}}
6118@DefescItem {\\n, +@Lbrack{}, ident, @Rbrack{}}
6119@DefescListEnd {\\n, -@Lbrack{}, ident, @Rbrack{}}
4d3e9548
JL
6120Before interpolating, increment or decrement @var{ident} (one-character
6121name@tie{}@var{i}, two-character name @var{id}) by the auto-increment
6122value as specified with the @code{nr} request (or the @code{\R} escape).
6123If no auto-increment value has been specified, these syntax forms are
6124identical to @code{\n}.
92d0a6a6
JR
6125@endDefesc
6126
6127For example,
6128
6129@Example
6130.nr a 0 1
6131.nr xx 0 5
6132.nr foo 0 -2
6133\n+a, \n+a, \n+a, \n+a, \n+a
6134.br
6135\n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
6136.br
6137\n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
6138@endExample
6139
6140@noindent
6141produces
6142
6143@Example
61441, 2, 3, 4, 5
6145-5, -10, -15, -20, -25
6146-2, -4, -6, -8, -10
6147@endExample
6148
6149@cindex increment value without changing the register
6150@cindex value, incrementing without changing the register
6151To change the increment value without changing the value of a register
6152(@var{a} in the example), the following can be used:
6153
6154@Example
6155.nr a \na 10
6156@endExample
6157
6158@c ---------------------------------------------------------------------
6159
6160@node Assigning Formats, Built-in Registers, Auto-increment, Registers
6161@subsection Assigning Formats
6162@cindex assigning formats (@code{af})
6163@cindex formats, assigning (@code{af})
6164
4d3e9548
JL
6165When a register is used, it is always textually replaced (or
6166interpolated) with a representation of that number. This output format
6167can be changed to a variety of formats (numbers, Roman numerals, etc.).
6168This is done using the @code{af} request.
92d0a6a6
JR
6169
6170@Defreq {af, ident format}
6171Change the output format of a number register. The first argument
6172@var{ident} is the name of the number register to be changed, and the
4d3e9548
JL
6173second argument @var{format} is the output format. The following output
6174formats are available:
92d0a6a6
JR
6175
6176@table @code
6177@item 1
6178Decimal arabic numbers. This is the default format: 0, 1, 2,
61793,@tie{}@enddots{}
6180
6181@item 0@dots{}0
6182Decimal numbers with as many digits as specified. So, @samp{00} would
6183result in printing numbers as 01, 02, 03,@tie{}@enddots{}
6184
4d3e9548 6185In fact, any digit instead of zero does work; @code{gtroff} only counts
92d0a6a6
JR
6186how many digits are specified. As a consequence, @code{af}'s default
6187format @samp{1} could be specified as @samp{0} also (and exactly this is
6188returned by the @code{\g} escape, see below).
6189
6190@item I
6191@cindex Roman numerals
6192@cindex numerals, Roman
6193Upper-case Roman numerals: 0, I, II, III, IV,@tie{}@enddots{}
6194
6195@item i
6196Lower-case Roman numerals: 0, i, ii, iii, iv,@tie{}@enddots{}
6197
6198@item A
6199Upper-case letters: 0, A, B, C, @dots{},@tie{}Z, AA, AB,@tie{}@enddots{}
6200
6201@item a
6202Lower-case letters: 0, a, b, c, @dots{},@tie{}z, aa, ab,@tie{}@enddots{}
6203@end table
6204
6205Omitting the number register format causes a warning of type
6206@samp{missing}. @xref{Debugging}, for more details. Specifying a
6207nonexistent format causes an error.
6208
6209The following example produces @samp{10, X, j, 010}:
6210
6211@Example
6212.nr a 10
6213.af a 1 \" the default format
6214\na,
6215.af a I
6216\na,
6217.af a a
6218\na,
6219.af a 001
6220\na
6221@endExample
6222
6223@cindex Roman numerals, maximum and minimum
6224@cindex maximum values of Roman numerals
6225@cindex minimum values of Roman numerals
6226The largest number representable for the @samp{i} and @samp{I} formats
6227is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
6228and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
6229@code{gtroff}. Currently, the correct glyphs of Roman numeral five
6230thousand and Roman numeral ten thousand (Unicode code points
6231@code{U+2182} and @code{U+2181}, respectively) are not available.
6232
6233If @var{ident} doesn't exist, it is created.
6234
6235@cindex read-only register, changing format
6236@cindex changing format, and read-only registers
6237Changing the output format of a read-only register causes an error. It
6238is necessary to first copy the register's value to a writeable register,
6239then apply the @code{af} request to this other register.
6240@endDefreq
6241
6242@DefescList {\\g, , i, }
465b256c
JR
6243@DefescItem {\\g, @Lparen{}, id, }
6244@DefescListEnd {\\g, @Lbrack{}, ident, @Rbrack{}}
92d0a6a6
JR
6245@cindex format of register (@code{\g})
6246@cindex register, format (@code{\g})
6247Return the current format of the specified register @var{ident}
6248(one-character name@tie{}@var{i}, two-character name @var{id}). For
4d3e9548
JL
6249example, @samp{\ga} after the previous example would produce the string
6250@samp{000}. If the register hasn't been defined yet, nothing is
6251returned.
92d0a6a6
JR
6252@endDefesc
6253
6254@c ---------------------------------------------------------------------
6255
6256@node Built-in Registers, , Assigning Formats, Registers
6257@subsection Built-in Registers
6258@cindex built-in registers
6259@cindex registers, built-in
6260
6261The following lists some built-in registers which are not described
6262elsewhere in this manual. Any register which begins with a @samp{.} is
6263read-only. A complete listing of all built-in registers can be found in
6264@ref{Register Index}.
6265
6266@table @code
6267@item \n[.F]
6268@cindex current input file name register (@code{.F})
6269@cindex input file name, current, register (@code{.F})
465b256c 6270@vindex .F
92d0a6a6
JR
6271This string-valued register returns the current input file name.
6272
6273@item \n[.H]
6274@cindex horizontal resolution register (@code{.H})
6275@cindex resolution, horizontal, register (@code{.H})
6276@vindex .H
6277Horizontal resolution in basic units.
6278
6279@item \n[.U]
6280@cindex safer mode
6281@cindex mode, safer
6282@cindex unsafe mode
6283@cindex mode, unsafe
4d3e9548
JL
6284If @code{gtroff} is called with the @option{-U} command line option to
6285activate unsafe mode, the number register @code{.U} is set to@tie{}1,
6286and to zero otherwise. @xref{Groff Options}.
92d0a6a6
JR
6287
6288@item \n[.V]
6289@cindex vertical resolution register (@code{.V})
6290@cindex resolution, vertical, register (@code{.V})
6291@vindex .V
6292Vertical resolution in basic units.
6293
6294@item \n[seconds]
6295@cindex seconds, current time (@code{seconds})
6296@cindex time, current, seconds (@code{seconds})
6297@cindex current time, seconds (@code{seconds})
6298@vindex seconds
6299The number of seconds after the minute, normally in the range@tie{}0
4d3e9548
JL
6300to@tie{}59, but can be up to@tie{}61 to allow for leap seconds.
6301Initialized at start-up of @code{gtroff}.
92d0a6a6
JR
6302
6303@item \n[minutes]
6304@cindex minutes, current time (@code{minutes})
6305@cindex time, current, minutes (@code{minutes})
6306@cindex current time, minutes (@code{minutes})
6307@vindex minutes
6308The number of minutes after the hour, in the range@tie{}0 to@tie{}59.
6309Initialized at start-up of @code{gtroff}.
6310
6311@item \n[hours]
6312@cindex hours, current time (@code{hours})
6313@cindex time, current, hours (@code{hours})
6314@cindex current time, hours (@code{hours})
6315@vindex hours
6316The number of hours past midnight, in the range@tie{}0 to@tie{}23.
6317Initialized at start-up of @code{gtroff}.
6318
6319@item \n[dw]
6320@cindex day of the week register (@code{dw})
6321@cindex date, day of the week register (@code{dw})
6322@vindex dw
6323Day of the week (1-7).
6324
6325@item \n[dy]
6326@cindex day of the month register (@code{dy})
6327@cindex date, day of the month register (@code{dy})
6328@vindex dy
6329Day of the month (1-31).
6330
6331@item \n[mo]
6332@cindex month of the year register (@code{mo})
6333@cindex date, month of the year register (@code{mo})
6334@vindex mo
6335Current month (1-12).
6336
6337@item \n[year]
6338@cindex date, year register (@code{year}, @code{yr})
6339@cindex year, current, register (@code{year}, @code{yr})
6340@vindex year
6341The current year.
6342
6343@item \n[yr]
465b256c 6344@vindex yr
92d0a6a6 6345The current year minus@tie{}1900. Unfortunately, the documentation of
4d3e9548
JL
6346@acronym{UNIX} Version@tie{}7's @code{troff} had a year@tie{}2000 bug:
6347It incorrectly claimed that @code{yr} contains the last two digits of
6348the year. That claim has never been true of either @acronym{AT&T}
92d0a6a6
JR
6349@code{troff} or GNU @code{troff}. Old @code{troff} input that looks
6350like this:
6351
6352@Example
6353'\" The following line stopped working after 1999
6354This document was formatted in 19\n(yr.
6355@endExample
6356
6357@noindent
6358can be corrected as follows:
6359
6360@Example
6361This document was formatted in \n[year].
6362@endExample
6363
6364@noindent
6365or, to be portable to older @code{troff} versions, as follows:
6366
6367@Example
6368.nr y4 1900+\n(yr
6369This document was formatted in \n(y4.
6370@endExample
6371
6372@item \n[.c]
6373@vindex .c
6374@itemx \n[c.]
6375@vindex c.
6376@cindex input line number register (@code{.c}, @code{c.})
6377@cindex line number, input, register (@code{.c}, @code{c.})
6378The current @emph{input} line number. Register @samp{.c} is read-only,
6379whereas @samp{c.} (a @code{gtroff} extension) is writable also,
6380affecting both @samp{.c} and @samp{c.}.
6381
6382@item \n[ln]
6383@vindex ln
6384@cindex output line number register (@code{ln})
6385@cindex line number, output, register (@code{ln})
6386The current @emph{output} line number after a call to the @code{nm}
6387request to activate line numbering.
6388
6389@xref{Miscellaneous}, for more information about line numbering.
6390
6391@item \n[.x]
6392@vindex .x
6393@cindex major version number register (@code{.x})
6394@cindex version number, major, register (@code{.x})
4d3e9548
JL
6395The major version number. For example, if the version number is 1.03
6396then @code{.x} contains@tie{}@samp{1}.
92d0a6a6
JR
6397
6398@item \n[.y]
6399@vindex .y
6400@cindex minor version number register (@code{.y})
6401@cindex version number, minor, register (@code{.y})
4d3e9548
JL
6402The minor version number. For example, if the version number is 1.03
6403then @code{.y} contains@tie{}@samp{03}.
92d0a6a6
JR
6404
6405@item \n[.Y]
6406@vindex .Y
6407@cindex revision number register (@code{.Y})
6408The revision number of @code{groff}.
6409
6410@item \n[$$]
6411@vindex $$
6412@cindex process ID of @code{gtroff} register (@code{$$})
6413@cindex @code{gtroff}, process ID register (@code{$$})
6414The process ID of @code{gtroff}.
6415
6416@item \n[.g]
6417@vindex .g
6418@cindex @code{gtroff}, identification register (@code{.g})
6419@cindex GNU-specific register (@code{.g})
6420Always@tie{}1. Macros should use this to determine whether they are
6421running under GNU @code{troff}.
6422
6423@item \n[.A]
6424@vindex .A
6425@cindex @acronym{ASCII} approximation output register (@code{.A})
6426If the command line option @option{-a} is used to produce an
6427@acronym{ASCII} approximation of the output, this is set to@tie{}1, zero
6428otherwise. @xref{Groff Options}.
6429
4d3e9548
JL
6430@item \n[.O]
6431@vindex .O
6432This read-only register is set to the suppression nesting level (see
6433escapes @code{\O}). @xref{Suppressing output}.
6434
92d0a6a6
JR
6435@item \n[.P]
6436@vindex .P
6437This register is set to@tie{}1 (and to@tie{}0 otherwise) if the current
6438page is actually being printed, i.e., if the @option{-o} option is being
6439used to only print selected pages. @xref{Groff Options}, for more
6440information.
6441
6442@item \n[.T]
6443@vindex .T
6444If @code{gtroff} is called with the @option{-T} command line option, the
6445number register @code{.T} is set to@tie{}1, and zero otherwise.
6446@xref{Groff Options}.
6447
6448@item \*[.T]
6449@stindex .T
6450@cindex output device name string register (@code{.T})
6451A single read-write string register which contains the current output
6452device (for example, @samp{latin1} or @samp{ps}). This is the only
6453string register defined by @code{gtroff}.
6454@end table
6455
6456
6457@c =====================================================================
6458
6459@node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
6460@section Manipulating Filling and Adjusting
6461@cindex manipulating filling and adjusting
6462@cindex filling and adjusting, manipulating
6463@cindex adjusting and filling, manipulating
6464@cindex justifying text
6465@cindex text, justifying
6466
6467@cindex break
6468@cindex line break
6469@cindex @code{bp} request, causing implicit linebreak
6470@cindex @code{ce} request, causing implicit linebreak
6471@cindex @code{cf} request, causing implicit linebreak
6472@cindex @code{fi} request, causing implicit linebreak
6473@cindex @code{fl} request, causing implicit linebreak
6474@cindex @code{in} request, causing implicit linebreak
6475@cindex @code{nf} request, causing implicit linebreak
6476@cindex @code{rj} request, causing implicit linebreak
6477@cindex @code{sp} request, causing implicit linebreak
6478@cindex @code{ti} request, causing implicit linebreak
6479@cindex @code{trf} request, causing implicit linebreak
6480Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
4d3e9548
JL
6481Breaks}. The @code{br} request likewise causes a break. Several other
6482requests also cause breaks, but implicitly. These are @code{bp},
6483@code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in}, @code{nf},
6484@code{rj}, @code{sp}, @code{ti}, and @code{trf}.
92d0a6a6
JR
6485
6486@Defreq {br, }
6487Break the current line, i.e., the input collected so far is emitted
6488without adjustment.
6489
4d3e9548
JL
6490If the no-break control character is used, @code{gtroff} suppresses the
6491break:
92d0a6a6
JR
6492
6493@Example
6494a
6495'br
6496b
6497 @result{} a b
6498@endExample
6499@endDefreq
6500
6501Initially, @code{gtroff} fills and adjusts text to both margins.
6502Filling can be disabled via the @code{nf} request and re-enabled with
6503the @code{fi} request.
6504
6505@DefreqList {fi, }
6506@DefregListEnd {.u}
6507@cindex fill mode (@code{fi})
6508@cindex mode, fill (@code{fi})
6509Activate fill mode (which is the default). This request implicitly
6510enables adjusting; it also inserts a break in the text currently being
6511filled. The read-only number register @code{.u} is set to@tie{}1.
6512
6513The fill mode status is associated with the current environment
6514(@pxref{Environments}).
6515
6516See @ref{Line Control}, for interaction with the @code{\c} escape.
6517@endDefreq
6518
6519@Defreq {nf, }
6520@cindex no-fill mode (@code{nf})
6521@cindex mode, no-fill (@code{nf})
6522Activate no-fill mode. Input lines are output as-is, retaining line
6523breaks and ignoring the current line length. This command implicitly
6524disables adjusting; it also causes a break. The number register
6525@code{.u} is set to@tie{}0.
6526
6527The fill mode status is associated with the current environment
6528(@pxref{Environments}).
6529
6530See @ref{Line Control}, for interaction with the @code{\c} escape.
6531@endDefreq
6532
6533@DefreqList {ad, [@Var{mode}]}
6534@DefregListEnd {.j}
6535Set adjusting mode.
6536
4d3e9548
JL
6537Activation and deactivation of adjusting is done implicitly with calls
6538to the @code{fi} or @code{nf} requests.
92d0a6a6
JR
6539
6540@var{mode} can have one of the following values:
6541
6542@table @code
6543@item l
6544@cindex ragged-right
6545Adjust text to the left margin. This produces what is traditionally
6546called ragged-right text.
6547
6548@item r
6549@cindex ragged-left
6550Adjust text to the right margin, producing ragged-left text.
6551
6552@item c
6553@cindex centered text
6554@cindex @code{ce} request, difference to @samp{.ad@tie{}c}
6555Center filled text. This is different to the @code{ce} request which
6556only centers text without filling.
6557
6558@item b
6559@itemx n
6560Justify to both margins. This is the default used by @code{gtroff}.
6561@end table
6562
4d3e9548
JL
6563Finally, @var{mode} can be the numeric argument returned by the
6564@code{.j} register.
92d0a6a6
JR
6565
6566With no argument, @code{gtroff} adjusts lines in the same way it did
6567before adjusting was deactivated (with a call to @code{na}, for
6568example).
6569
6570@Example
6571text
6572.ad r
6573.nr ad \n[.j]
6574text
6575.ad c
6576text
6577.na
6578text
6579.ad \" back to centering
6580text
6581.ad \n[ad] \" back to right justifying
6582@endExample
6583
6584@cindex adjustment mode register (@code{.j})
6585The current adjustment mode is available in the read-only number
6586register @code{.j}; it can be stored and subsequently used to set
6587adjustment.
6588
6589The adjustment mode status is associated with the current environment
6590(@pxref{Environments}).
6591@endDefreq
6592
6593@Defreq {na, }
6594Disable adjusting. This request won't change the current adjustment
6595mode: A subsequent call to @code{ad} uses the previous adjustment
6596setting.
6597
6598The adjustment mode status is associated with the current environment
6599(@pxref{Environments}).
6600@endDefreq
6601
6602@DefreqList {brp, }
6603@DefescListEnd {\\p, , , }
6604Adjust the current line and cause a break.
6605
6606In most cases this produces very ugly results since @code{gtroff}
6607doesn't have a sophisticated paragraph building algorithm (as @TeX{}
6608have, for example); instead, @code{gtroff} fills and adjusts a paragraph
6609line by line:
6610
6611@Example
4d3e9548
JL
6612This is an uninteresting sentence.
6613This is an uninteresting sentence.\p
6614This is an uninteresting sentence.
92d0a6a6
JR
6615@endExample
6616
6617@noindent
6618is formatted as
6619
6620@Example
4d3e9548
JL
6621This is an uninteresting sentence. This is an
6622uninteresting sentence.
6623This is an uninteresting sentence.
92d0a6a6
JR
6624@endExample
6625@endDefreq
6626
6627@DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
6628@DefregItem {.ss}
6629@DefregListEnd {.sss}
6630@cindex word space size register (@code{.ss})
6631@cindex size of word space register (@code{.ss})
6632@cindex space between words register (@code{.ss})
6633@cindex sentence space size register (@code{.sss})
6634@cindex size of sentence space register (@code{.sss})
6635@cindex space between sentences register (@code{.sss})
6636Change the size of a space between words. It takes its units as one
4d3e9548
JL
6637twelfth of the space width parameter for the current font. Initially
6638both the @var{word_space_size} and @var{sentence_space_size}
92d0a6a6
JR
6639are@tie{}12. In fill mode, the values specify the minimum distance.
6640
6641@cindex fill mode
6642@cindex mode, fill
4d3e9548
JL
6643If two arguments are given to the @code{ss} request, the second argument
6644sets the sentence space size. If the second argument is not given,
6645sentence space size is set to @var{word_space_size}. The sentence space
6646size is used in two circumstances: If the end of a sentence occurs at
6647the end of a line in fill mode, then both an inter-word space and a
6648sentence space are added; if two spaces follow the end of a sentence in
6649the middle of a line, then the second space is a sentence space. If a
6650second argument is never given to the @code{ss} request, the behaviour
6651of @acronym{UNIX} @code{troff} is the same as that exhibited by GNU
6652@code{troff}. In GNU @code{troff}, as in @acronym{UNIX} @code{troff}, a
6653sentence should always be followed by either a newline or two spaces.
92d0a6a6
JR
6654
6655The read-only number registers @code{.ss} and @code{.sss} hold the
6656values of the parameters set by the first and second arguments of the
6657@code{ss} request.
6658
6659The word space and sentence space values are associated with the current
6660environment (@pxref{Environments}).
6661
6662Contrary to @acronym{AT&T} @code{troff}, this request is @emph{not}
6663ignored if a TTY output device is used; the given values are then
4d3e9548
JL
6664rounded down to a multiple of@tie{}12 (@pxref{Implementation
6665Differences}).
92d0a6a6
JR
6666
6667The request is ignored if there is no parameter.
6668
6669@cindex discardable horizontal space
6670@cindex space, discardable, horizontal
6671@cindex horizontal discardable space
6672Another useful application of the @code{ss} request is to insert
6673discardable horizontal space, i.e., space which is discarded at a line
6674break. For example, paragraph-style footnotes could be separated this
6675way:
6676
6677@Example
6678.ll 4.5i
66791.\ This is the first footnote.\c
6680.ss 48
6681.nop
6682.ss 12
66832.\ This is the second footnote.
6684@endExample
6685
6686@noindent
6687The result:
6688
6689@Example
66901. This is the first footnote. 2. This
6691is the second footnote.
6692@endExample
6693
6694@noindent
6695Note that the @code{\h} escape produces unbreakable space.
6696@endDefreq
6697
6698@DefreqList {ce, [@Var{nnn}]}
6699@DefregListEnd {.ce}
6700@cindex centering lines (@code{ce})
6701@cindex lines, centering (@code{ce})
4d3e9548
JL
6702Center text. While the @w{@samp{.ad c}} request also centers text, it
6703fills the text as well. @code{ce} does not fill the text it affects.
6704This request causes a break. The number of lines still to be centered
6705is associated with the current environment (@pxref{Environments}).
92d0a6a6 6706
4d3e9548 6707The following example demonstrates the differences. Here the input:
92d0a6a6
JR
6708
6709@Example
6710.ll 4i
6711.ce 1000
6712This is a small text fragment which shows the differences
6713between the `.ce' and the `.ad c' request.
6714.ce 0
6715
6716.ad c
6717This is a small text fragment which shows the differences
6718between the `.ce' and the `.ad c' request.
6719@endExample
6720
6721@noindent
6722And here the result:
6723
6724@Example
6725 This is a small text fragment which
6726 shows the differences
6727between the `.ce' and the `.ad c' request.
6728
6729 This is a small text fragment which
6730shows the differences between the `.ce'
6731 and the `.ad c' request.
6732@endExample
6733
6734With no arguments, @code{ce} centers the next line of text. @var{nnn}
6735specifies the number of lines to be centered. If the argument is zero
6736or negative, centering is disabled.
6737
6738The basic length for centering text is the line length (as set with the
6739@code{ll} request) minus the indentation (as set with the @code{in}
6740request). Temporary indentation is ignored.
6741
4d3e9548
JL
6742As can be seen in the previous example, it is a common idiom to turn on
6743centering for a large number of lines, and to turn off centering after
6744text to be centered. This is useful for any request which takes a
6745number of lines as an argument.
92d0a6a6
JR
6746
6747The @code{.ce} read-only number register contains the number of lines
6748remaining to be centered, as set by the @code{ce} request.
6749@endDefreq
6750
6751@DefreqList {rj, [@Var{nnn}]}
6752@DefregListEnd {.rj}
6753@cindex justifying text (@code{rj})
6754@cindex text, justifying (@code{rj})
6755@cindex right-justifying (@code{rj})
6756Justify unfilled text to the right margin. Arguments are identical to
4d3e9548
JL
6757the @code{ce} request. The @code{.rj} read-only number register is the
6758number of lines to be right-justified as set by the @code{rj} request.
6759This request causes a break. The number of lines still to be
92d0a6a6
JR
6760right-justified is associated with the current environment
6761(@pxref{Environments}).
6762@endDefreq
6763
6764
6765@c =====================================================================
6766
6767@node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6768@section Manipulating Hyphenation
6769@cindex manipulating hyphenation
6770@cindex hyphenation, manipulating
6771
465b256c 6772Here a description of requests which influence hyphenation.
92d0a6a6
JR
6773
6774@DefreqList {hy, [@Var{mode}]}
6775@DefregListEnd {.hy}
6776Enable hyphenation. The request has an optional numeric argument,
6777@var{mode}, to restrict hyphenation if necessary:
6778
6779@table @code
6780@item 1
6781The default argument if @var{mode} is omitted. Hyphenate without
6782restrictions. This is also the start-up value of @code{gtroff}.
6783
6784@item 2
6785Do not hyphenate the last word on a page or column.
6786
6787@item 4
6788Do not hyphenate the last two characters of a word.
6789
6790@item 8
6791Do not hyphenate the first two characters of a word.
6792@end table
6793
6794Values in the previous table are additive. For example, the
4d3e9548
JL
6795value@tie{}12 causes @code{gtroff} to neither hyphenate the last two nor
6796the first two characters of a word.
92d0a6a6
JR
6797
6798@cindex hyphenation restrictions register (@code{.hy})
6799The current hyphenation restrictions can be found in the read-only
6800number register @samp{.hy}.
6801
6802The hyphenation mode is associated with the current environment
6803(@pxref{Environments}).
6804@endDefreq
6805
6806@Defreq {nh, }
4d3e9548
JL
6807Disable hyphenation (i.e., set the hyphenation mode to zero). Note that
6808the hyphenation mode of the last call to @code{hy} is not remembered.
92d0a6a6
JR
6809
6810The hyphenation mode is associated with the current environment
6811(@pxref{Environments}).
6812@endDefreq
6813
6814@DefreqList {hlm, [@Var{nnn}]}
6815@DefregItem {.hlm}
6816@DefregListEnd {.hlc}
6817@cindex explicit hyphen (@code{\%})
6818@cindex hyphen, explicit (@code{\%})
6819@cindex consecutive hyphenated lines (@code{hlm})
6820@cindex lines, consecutive hyphenated (@code{hlm})
6821@cindex hyphenated lines, consecutive (@code{hlm})
4d3e9548
JL
6822Set the maximum number of consecutive hyphenated lines to @var{nnn}. If
6823this number is negative, there is no maximum. The default value
92d0a6a6 6824is@tie{}@minus{}1 if @var{nnn} is omitted. This value is associated
4d3e9548
JL
6825with the current environment (@pxref{Environments}). Only lines output
6826from a given environment count towards the maximum associated with that
6827environment. Hyphens resulting from @code{\%} are counted; explicit
6828hyphens are not.
92d0a6a6
JR
6829
6830The current setting of @code{hlm} is available in the @code{.hlm}
6831read-only number register. Also the number of immediately preceding
6832consecutive hyphenated lines are available in the read-only number
6833register @samp{.hlc}.
6834@endDefreq
6835
6836@Defreq {hw, word1 word2 @dots{}}
6837Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated. The
6838words must be given with hyphens at the hyphenation points. For
6839example:
6840
6841@Example
6842.hw in-sa-lub-rious
6843@endExample
6844
6845@noindent
6846Besides the space character, any character whose hyphenation code value
6847is zero can be used to separate the arguments of @code{hw} (see the
6848documentation for the @code{hcode} request below for more information).
6849In addition, this request can be used more than once.
6850
6851Hyphenation exceptions specified with the @code{hw} request are
4d3e9548
JL
6852associated with the current hyphenation language; it causes an error if
6853there is no current hyphenation language.
92d0a6a6
JR
6854
6855This request is ignored if there is no parameter.
6856
6857In old versions of @code{troff} there was a limited amount of space to
6858store such information; fortunately, with @code{gtroff}, this is no
6859longer a restriction.
6860@endDefreq
6861
6862@DefescList {\\%, , , }
6863@deffnx Escape @t{\:}
6864@ifnotinfo
6865@esindex \:
6866@end ifnotinfo
6867@ifinfo
6868@esindex \@r{<colon>}
6869@end ifinfo
6870@cindex hyphenation character (@code{\%})
6871@cindex character, hyphenation (@code{\%})
6872@cindex disabling hyphenation (@code{\%})
6873@cindex hyphenation, disabling (@code{\%})
6874To tell @code{gtroff} how to hyphenate words on the fly, use the
6875@code{\%} escape, also known as the @dfn{hyphenation character}.
6876Preceding a word with this character prevents it from being
6877hyphenated; putting it inside a word indicates to @code{gtroff} that
6878the word may be hyphenated at that point. Note that this mechanism
6879only affects that one occurrence of the word; to change the
6880hyphenation of a word for the entire document, use the @code{hw}
6881request.
6882
4d3e9548
JL
6883The @code{\:} escape inserts a zero-width break point (that is, the word
6884breaks but without adding a hyphen).
92d0a6a6
JR
6885
6886@Example
6887... check the /var/log/\:httpd/\:access_log file ...
6888@endExample
6889
6890@cindex @code{\X}, followed by @code{\%}
6891@cindex @code{\Y}, followed by @code{\%}
6892@cindex @code{\%}, following @code{\X} or @code{\Y}
6893Note that @code{\X} and @code{\Y} start a word, that is, the @code{\%}
6894escape in (say) @w{@samp{\X'...'\%foobar}} and
4d3e9548
JL
6895@w{@samp{\Y'...'\%foobar}} no longer prevents hyphenation but inserts a
6896hyphenation point at the beginning of @samp{foobar}; most likely this
6897isn't what you want to do.
92d0a6a6
JR
6898@endDefesc
6899
6900@Defreq {hc, [@Var{char}]}
6901Change the hyphenation character to @var{char}. This character then
6902works the same as the @code{\%} escape, and thus, no longer appears in
6903the output. Without an argument, @code{hc} resets the hyphenation
6904character to be @code{\%} (the default) only.
6905
6906The hyphenation character is associated with the current environment
6907(@pxref{Environments}).
6908@endDefreq
6909
6910@DefreqList {hpf, pattern_file}
6911@DefreqItem {hpfa, pattern_file}
6912@DefreqListEnd {hpfcode, a b [c d @dots{}]}
6913@cindex hyphenation patterns (@code{hpf})
6914@cindex patterns for hyphenation (@code{hpf})
6915Read in a file of hyphenation patterns. This file is searched for in
6916the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6917searched for if the @option{-m@var{name}} option is specified.
6918
4d3e9548
JL
6919It should have the same format as (simple) @TeX{} patterns files. More
6920specifically, the following scanning rules are implemented.
92d0a6a6
JR
6921
6922@itemize @bullet
6923@item
4d3e9548
JL
6924A percent sign starts a comment (up to the end of the line) even if
6925preceded by a backslash.
92d0a6a6
JR
6926
6927@item
6928No support for `digraphs' like @code{\$}.
6929
6930@item
4d3e9548
JL
6931@code{^^@var{xx}} (@var{x} is 0-9 or a-f) and @code{^^@var{x}}
6932(character code of @var{x} in the range 0-127) are recognized; other use
6933of @code{^} causes an error.
92d0a6a6
JR
6934
6935@item
6936No macro expansion.
6937
6938@item
6939@code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
4d3e9548
JL
6940(possibly with whitespace before and after the braces). Everything
6941between the braces is taken as hyphenation patterns. Consequently,
6942@code{@{} and @code{@}} are not allowed in patterns.
92d0a6a6
JR
6943
6944@item
6945Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6946exceptions.
6947
6948@item
6949@code{\endinput} is recognized also.
6950
6951@item
4d3e9548
JL
6952For backwards compatibility, if @code{\patterns} is missing, the whole
6953file is treated as a list of hyphenation patterns (only recognizing the
6954@code{%} character as the start of a comment).
92d0a6a6
JR
6955@end itemize
6956
6957If no @code{hpf} request is specified (either in the document or in a
6958macro package), @code{gtroff} won't hyphenate at all.
6959
6960The @code{hpfa} request appends a file of patterns to the current list.
6961
6962The @code{hpfcode} request defines mapping values for character codes in
6963hyphenation patterns. @code{hpf} or @code{hpfa} then apply the mapping
4d3e9548
JL
6964(after reading the patterns) before replacing or appending them to the
6965current list of patterns. Its arguments are pairs of character codes --
6966integers from 0 to@tie{}255. The request maps character
6967code@tie{}@var{a} to code@tie{}@var{b}, code@tie{}@var{c} to
6968code@tie{}@var{d}, and so on. You can use character codes which would
6969be invalid otherwise.
92d0a6a6
JR
6970
6971@pindex troffrc
6972@pindex troffrc-end
6973@pindex hyphen.us
6974@pindex hyphenex.us
6975The set of hyphenation patterns is associated with the current language
6976set by the @code{hla} request. The @code{hpf} request is usually
6977invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6978@file{troffrc} loads hyphenation patterns and exceptions for American
6979English (in files @file{hyphen.us} and @file{hyphenex.us}).
6980
4d3e9548 6981A second call to @code{hpf} (for the same language) replaces the
92d0a6a6
JR
6982hyphenation patterns with the new ones.
6983
6984Invoking @code{hpf} causes an error if there is no current hyphenation
6985language.
6986@endDefreq
6987
465b256c 6988@Defreq {hcode, c1 code1 [c2 code2 @dots{}]}
92d0a6a6
JR
6989@cindex hyphenation code (@code{hcode})
6990@cindex code, hyphenation (@code{hcode})
6991Set the hyphenation code of character @var{c1} to @var{code1}, that of
4d3e9548
JL
6992@var{c2} to @var{code2}, etc. A hyphenation code must be a single input
6993character (not a special character) other than a digit or a space.
465b256c
JR
6994
6995To make hyphenation work, hyphenation codes must be set up. At
6996start-up, groff only assigns hyphenation codes to the letters
6997@samp{a}-@samp{z} (mapped to themselves) and to the letters
6998@samp{A}-@samp{Z} (mapped to @samp{a}-@samp{z}); all other hyphenation
6999codes are set to zero. Normally, hyphenation patterns contain only
4d3e9548 7000lowercase letters which should be applied regardless of case. In
465b256c
JR
7001other words, the words `FOO' and `Foo' should be hyphenated exactly the
7002same way as the word `foo' is hyphenated, and this is what @code{hcode}
7003is good for. Words which contain other letters won't be hyphenated
7004properly if the corresponding hyphenation patterns actually do contain
7005them. For example, the following @code{hcode} requests are necessary to
7006assign hyphenation codes to the letters @samp{ÄäÖöÜüß} (this is needed
7007for German):
7008
7009@Example
7010.hcode ä ä Ä ä
7011.hcode ö ö Ö ö
7012.hcode ü ü Ü ü
7013.hcode ß ß
7014@endExample
7015
7016Without those assignments, groff treats German words like
4d3e9548
JL
7017@w{`Kindergärten'} (the plural form of `kindergarten') as two substrings
7018@w{`kinderg'} and @w{`rten'} because the hyphenation code of the
7019umlaut@tie{}a is zero by default. There is a German hyphenation pattern
7020which covers @w{`kinder'}, so groff finds the hyphenation `kin-der'.
7021The other two hyphenation points (`kin-der-gär-ten') are missed.
92d0a6a6
JR
7022
7023This request is ignored if it has no parameter.
7024@endDefreq
7025
7026@DefreqList {hym, [@Var{length}]}
7027@DefregListEnd {.hym}
7028@cindex hyphenation margin (@code{hym})
7029@cindex margin for hyphenation (@code{hym})
7030@cindex @code{ad} request, and hyphenation margin
7031Set the (right) hyphenation margin to @var{length}. If the current
4d3e9548
JL
7032adjustment mode is not @samp{b} or @samp{n}, the line is not hyphenated
7033if it is shorter than @var{length}. Without an argument, the
7034hyphenation margin is reset to its default value, which is@tie{}0. The
7035default scaling indicator for this request is @samp{m}. The hyphenation
7036margin is associated with the current environment
92d0a6a6
JR
7037(@pxref{Environments}).
7038
4d3e9548
JL
7039A negative argument resets the hyphenation margin to zero, emitting a
7040warning of type @samp{range}.
92d0a6a6
JR
7041
7042@cindex hyphenation margin register (@code{.hym})
7043The current hyphenation margin is available in the @code{.hym} read-only
7044number register.
7045@endDefreq
7046
7047@DefreqList {hys, [@Var{hyphenation_space}]}
7048@DefregListEnd {.hys}
7049@cindex hyphenation space (@code{hys})
7050@cindex @code{ad} request, and hyphenation space
7051Set the hyphenation space to @var{hyphenation_space}. If the current
4d3e9548
JL
7052adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line if it
7053can be justified by adding no more than @var{hyphenation_space} extra
7054space to each word space. Without argument, the hyphenation space is
7055set to its default value, which is@tie{}0. The default scaling
7056indicator for this request is @samp{m}. The hyphenation space is
7057associated with the current environment (@pxref{Environments}).
92d0a6a6
JR
7058
7059A negative argument resets the hyphenation space to zero, emitting a
7060warning of type @samp{range}.
7061
7062@cindex hyphenation space register (@code{.hys})
7063The current hyphenation space is available in the @code{.hys} read-only
7064number register.
7065@endDefreq
7066
7067@Defreq {shc, [@Var{glyph}]}
7068@cindex soft hyphen character, setting (@code{shc})
7069@cindex character, soft hyphen, setting (@code{shc})
7070@cindex glyph, soft hyphen (@code{hy})
7071@cindex soft hyphen glyph (@code{hy})
7072@cindex @code{char} request, and soft hyphen character
7073@cindex @code{tr} request, and soft hyphen character
7074Set the @dfn{soft hyphen character} to @var{glyph}.@footnote{@dfn{Soft
7075hyphen character} is a misnomer since it is an output glyph.} If the
7076argument is omitted, the soft hyphen character is set to the default
7077glyph @code{\(hy} (this is the start-up value of @code{gtroff} also).
7078The soft hyphen character is the glyph that is inserted when a word is
4d3e9548
JL
7079hyphenated at a line break. If the soft hyphen character does not exist
7080in the font of the character immediately preceding a potential break
7081point, then the line is not broken at that point. Neither definitions
7082(specified with the @code{char} request) nor translations (specified
7083with the @code{tr} request) are considered when finding the soft hyphen
7084character.
92d0a6a6
JR
7085@endDefreq
7086
7087@DefreqList {hla, language}
7088@DefregListEnd {.hla}
7089@cindex @code{hpf} request, and hyphenation language
7090@cindex @code{hw} request, and hyphenation language
7091@pindex troffrc
7092@pindex troffrc-end
7093Set the current hyphenation language to the string @var{language}.
7094Hyphenation exceptions specified with the @code{hw} request and
7095hyphenation patterns specified with the @code{hpf} and @code{hpfa}
4d3e9548
JL
7096requests are both associated with the current hyphenation language. The
7097@code{hla} request is usually invoked by the @file{troffrc} or the
92d0a6a6
JR
7098@file{troffrc-end} files; @file{troffrc} sets the default language to
7099@samp{us}.
7100
7101@cindex hyphenation language register (@code{.hla})
7102The current hyphenation language is available as a string in the
7103read-only number register @samp{.hla}.
7104
7105@Example
7106.ds curr_language \n[.hla]
7107\*[curr_language]
7108 @result{} us
7109@endExample
7110@endDefreq
7111
7112
7113@c =====================================================================
7114
7115@node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
7116@section Manipulating Spacing
7117@cindex manipulating spacing
7118@cindex spacing, manipulating
7119
7120@Defreq {sp, [@Var{distance}]}
7121Space downwards @var{distance}. With no argument it advances
4d3e9548
JL
71221@tie{}line. A negative argument causes @code{gtroff} to move up the
7123page the specified distance. If the argument is preceded by a @samp{|}
92d0a6a6 7124then @code{gtroff} moves that distance from the top of the page. This
4d3e9548
JL
7125request causes a line break, and that adds the current line spacing to
7126the space you have just specified. The default scaling indicator is
7127@samp{v}.
7128
7129For convenience you may wish to use the following macros to set the
7130height of the next line at a given distance from the top or the bottom
7131of the page:
7132
7133@Example
7134.de y-from-top-down
7135. sp |\\$1-\\n[.v]u
7136..
7137.
7138.de y-from-bot-up
7139. sp |\\n[.p]u-\\$1-\\n[.v]u
7140..
7141@endExample
7142
7143@noindent
7144A call to @samp{.y-from-bot-up 10c} means that the bottom of the next
7145line will be at 10@dmn{cm} from the paper edge at the bottom.
92d0a6a6 7146
4d3e9548
JL
7147If a vertical trap is sprung during execution of @code{sp}, the amount