* doc/groff.texinfo: Add documentation of remaining escapes.
[s-roff.git] / doc / groff.texinfo
blob038850ca76a660f10ecd0d61daf4b035b806a0b7
1 \input texinfo   @c -*-texinfo-*-
3 @c
4 @c Please convert this manual with `texi2dvi -e groff.texinfo' due to a bug
5 @c in texinfo regarding expansion of user-defined macros.
6 @c
7 @c You need texinfo 4.2 or newer to format this document!
8 @c
10 @c %**start of header (This is for running Texinfo on a region.)
11 @setfilename  groff
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.)
18 @c We use the following indices:
20 @c   cindex: concepts
21 @c   rqindex: requests
22 @c   esindex: escapes
23 @c   vindex: registers
24 @c   kindex: commands in font files
25 @c   pindex: programs and files
26 @c   tindex: environment variables
27 @c   maindex: macros
28 @c   stindex: strings
29 @c   opindex: operators
31 @c tindex and cindex are merged.
33 @defcodeindex rq
34 @defcodeindex es
35 @defcodeindex ma
36 @defcodeindex st
37 @defcodeindex op
38 @syncodeindex tp cp
41 @c to avoid uppercasing in @deffn while converting to info, we define
42 @c our special @Var{}
44 @c due to a (not officially documented) `feature' in makeinfo 4.0,
45 @c macros are not expanded in @deffn (but the macro definition is
46 @c properly removed), so we have to define @Var{} directly in TeX also
48 @macro Var{arg}
49 \arg\
50 @end macro
51 @tex
52 \gdef\Var#1{\var{#1}}
53 @end tex
56 @c To assure correct HTML translation, some ugly hacks are necessary.
57 @c While processing a @def... request, the HTML translator looks at the
58 @c next line to decide whether it should start indentation or not.  If
59 @c it is something starting with @def... (e.g. @deffnx), it doesn't.
60 @c So we must assure during macro expansion that a @def... is seen.
62 @c The following macros have to be used:
64 @c One item:
66 @c   @Def...
68 @c Two items:
70 @c   @Def...List
71 @c   @Def...ListEnd
73 @c More than two:
75 @c   @Def...List
76 @c   @Def...Item
77 @c   @Def...Item
78 @c   ...
79 @c   @Def...ListEnd
81 @c The definition block must end with
83 @c   @endDef...
85 @c The above is valid for texinfo 4.0f.
88 @c a dummy macro to assure the `@def...'
90 @macro defdummy
91 @end macro
94 @c definition of requests
96 @macro Defreq{name, arg}
97 @deffn Request @t{.\name\} \arg\
98 @rqindex \name\
99 @end macro
101 @macro DefreqList{name, arg}
102 @deffn Request @t{.\name\} \arg\
103 @defdummy
104 @rqindex \name\
105 @end macro
107 @macro DefreqItem{name, arg}
108 @deffnx Request @t{.\name\} \arg\
109 @defdummy
110 @rqindex \name\
111 @end macro
113 @macro DefreqListEnd{name, arg}
114 @deffnx Request @t{.\name\} \arg\
115 @rqindex \name\
116 @end macro
118 @macro endDefreq
119 @end deffn
120 @end macro
123 @c definition of escapes
125 @macro Defesc{name, delimI, arg, delimII}
126 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
127 @esindex \name\
128 @end macro
130 @macro DefescList{name, delimI, arg, delimII}
131 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
132 @defdummy
133 @esindex \name\
134 @end macro
136 @macro DefescItem{name, delimI, arg, delimII}
137 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
138 @defdummy
139 @esindex \name\
140 @end macro
142 @macro DefescListEnd{name, delimI, arg, delimII}
143 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
144 @esindex \name\
145 @end macro
147 @macro endDefesc
148 @end deffn
149 @end macro
152 @c definition of registers
154 @macro Defreg{name}
155 @deffn Register @t{\\n[\name\]}
156 @vindex \name\
157 @end macro
159 @macro DefregList{name}
160 @deffn Register @t{\\n[\name\]}
161 @defdummy
162 @vindex \name\
163 @end macro
165 @macro DefregItem{name}
166 @deffnx Register @t{\\n[\name\]}
167 @defdummy
168 @vindex \name\
169 @end macro
171 @macro DefregListEnd{name}
172 @deffnx Register @t{\\n[\name\]}
173 @vindex \name\
174 @end macro
176 @macro endDefreg
177 @end deffn
178 @end macro
181 @c definition of registers specific to macro packages, preprocessors, etc.
183 @macro Defmpreg{name, package}
184 @deffn Register @t{\\n[\name\]}
185 @vindex \name\ @r{[}\package\@r{]}
186 @end macro
188 @macro DefmpregList{name, package}
189 @deffn Register @t{\\n[\name\]}
190 @defdummy
191 @vindex \name\ @r{[}\package\@r{]}
192 @end macro
194 @macro DefmpregItem{name, package}
195 @deffnx Register @t{\\n[\name\]}
196 @defdummy
197 @vindex \name\ @r{[}\package\@r{]}
198 @end macro
200 @macro DefmpregListEnd{name, package}
201 @deffnx Register @t{\\n[\name\]}
202 @vindex \name\ @r{[}\package\@r{]}
203 @end macro
205 @macro endDefmpreg
206 @end deffn
207 @end macro
210 @c definition of macros
212 @macro Defmac{name, arg, package}
213 @defmac @t{.\name\} \arg\
214 @maindex \name\ @r{[}\package\@r{]}
215 @end macro
217 @macro DefmacList{name, arg, package}
218 @defmac @t{.\name\} \arg\
219 @defdummy
220 @maindex \name\ @r{[}\package\@r{]}
221 @end macro
223 @macro DefmacItem{name, arg, package}
224 @defmacx @t{.\name\} \arg\
225 @defdummy
226 @maindex \name\ @r{[}\package\@r{]}
227 @end macro
229 @macro DefmacListEnd{name, arg, package}
230 @defmacx @t{.\name\} \arg\
231 @maindex \name\ @r{[}\package\@r{]}
232 @end macro
234 @macro endDefmac
235 @end defmac
236 @end macro
239 @c definition of strings
241 @macro Defstr{name, package}
242 @deffn String @t{\\*[\name\]}
243 @stindex \name\ @r{[}\package\@r{]}
244 @end macro
246 @macro DefstrList{name, package}
247 @deffn String @t{\\*[\name\]}
248 @defdummy
249 @stindex \name\ @r{[}\package\@r{]}
250 @end macro
252 @macro DefstrItem{name, package}
253 @deffnx String @t{\\*[\name\]}
254 @defdummy
255 @stindex \name\ @r{[}\package\@r{]}
256 @end macro
258 @macro DefstrListEnd{name, package}
259 @deffnx String @t{\\*[\name\]}
260 @stindex \name\ @r{[}\package\@r{]}
261 @end macro
263 @macro endDefstr
264 @end deffn
265 @end macro
268 @c our example macro
270 @macro Example
271 @example
272 @group
273 @end macro
275 @macro endExample
276 @end group
277 @end example
278 @end macro
281 @c We need special parentheses and brackets:
283 @c . Real parentheses in @deffn produce an error while compiling with
284 @c   TeX
285 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
287 @c This is true for texinfo 4.0.
289 @ifnottex
290 @macro lparen
292 @end macro
293 @macro rparen
295 @end macro
296 @macro lbrack
298 @end macro
299 @macro rbrack
301 @end macro
302 @end ifnottex
304 @iftex
305 @macro lparen
306 @@lparen
307 @end macro
308 @macro rparen
309 @@rparen
310 @end macro
311 @macro lbrack
312 @@lbrack
313 @end macro
314 @macro rbrack
315 @@rbrack
316 @end macro
317 @end iftex
320 @c Note: We say `Roman numerals' but `roman font'.
323 @c XXX comment all examples
326 @dircategory Miscellaneous
327 @direntry
328 * Groff: (groff).  The GNU troff document formatting system.
329 @end direntry
332 @smallbook
335 @iftex
336 @finalout
337 @end iftex
340 @ifinfo
341 This Info file documents GNU troff version 1.18.
343 Published by the Free Software Foundation
344 59 Temple Place, Suite 330
345 Boston, MA  02111-1307  USA
347 Copyright (C) 1994-2000, 2001, 2002 Free Software Foundation, Inc.
349 Permission is granted to make and distribute verbatim copies of this
350 manual provided the copyright notice and this permission notice are
351 preserved on all copies.
353 @ignore
354 Permission is granted to process this file through TeX and print the
355 results, provided the printed document carries copying permission notice
356 identical to this one except for the removal of this paragraph (this
357 paragraph not being relevant to the printed manual).
359 @end ignore
360 Permission is granted to copy and distribute modified versions of this
361 manual under the conditions for verbatim copying, provided that the
362 entire resulting derived work is distributed under the terms of a
363 permission notice identical to this one.
365 Permission is granted to copy and distribute translations of this manual
366 into another language, under the above conditions for modified versions,
367 except that this permission notice may be stated in a translation
368 approved by the Foundation.
370 Permission is granted to copy and distribute modified versions of this
371 manual under the conditions for verbatim copying, provided also that the
372 section entitled ``GNU General Public License'' is included exactly as
373 in the original, and provided that the entire resulting derived work is
374 distributed under the terms of a permission notice identical to this
375 one.
377 Permission is granted to copy and distribute translations of this manual
378 into another language, under the above conditions for modified versions,
379 except that the section entitled ``GNU General Public License'' may be
380 included in a translation approved by the Free Software Foundation
381 instead of in the original English.
382 @end ifinfo
385 @titlepage
386 @title groff
387 @subtitle The GNU implementation of @code{troff}
388 @subtitle Edition 1.18
389 @subtitle Spring 2002
390 @author by Trent A.@w{ }Fisher
391 @author and Werner Lemberg
393 @c Include the Distribution inside the titlepage environment so
394 @c that headings are turned off.  Headings on and off do not work.
396 @page
397 @vskip 0pt plus 1filll
398 Copyright @copyright@w{ }1994-2000, 2001, 2002 Free Software
399 Foundation,@w{ }Inc.
400 @sp 2
401 Version 1.18 of @code{groff}, @*
402 Spring 2002
403 @sp 2
404 Published by the Free Software Foundation @*
405 59 Temple Place, Suite 330 @*
406 Boston, MA  02111-1307  USA
409 Permission is granted to make and distribute verbatim copies of this
410 manual provided the copyright notice and this permission notice are
411 preserved on all copies.
413 Permission is granted to copy and distribute modified versions of this
414 manual under the conditions for verbatim copying, provided also that the
415 section entitled ``GNU General Public License'' is included exactly as
416 in the original, and provided that the entire resulting derived work is
417 distributed under the terms of a permission notice identical to this
418 one.
420 Permission is granted to copy and distribute translations of this manual
421 into another language, under the above conditions for modified versions,
422 except that the section entitled ``GNU General Public License'' may be
423 included in a translation approved by the Free Software Foundation
424 instead of in the original English.
426 Cover art by Etienne Suvasa.
427 @end titlepage
428 @page
432 @node Top, Copying, (dir), (dir)
434 @ifinfo
435 This Info file documents groff version 1.18, the GNU implementation of
436 the troff typesetting system.
438 This is an in-progress document; contributions, comments, or
439 contributions are welcome.  Send them to bug-groff@@gnu.org.
440 @end ifinfo
442 @menu
443 * Copying::
444 * Introduction::
445 * Invoking groff::
446 * Tutorial for Macro Users::
447 * Macro Packages::
448 * gtroff Reference::
449 * Preprocessors::
450 * Output Devices::
451 * File formats::
452 * Installation::
453 * Request Index::
454 * Escape Index::
455 * Operator Index::
456 * Register Index::
457 * Macro Index::
458 * String Index::
459 * Glyph Name Index::
460 * Font File Keyword Index::
461 * Program and File Index::
462 * Concept Index::
463 @end menu
467 @node Copying, Introduction, Top, Top
468 @cindex copying
469 @unnumbered GNU GENERAL PUBLIC LICENSE
470 @center Version 2, June 1991
472 @display
473 Copyright @copyright{}@w{ }1989, 1991 Free Software Foundation, Inc.
474 59@w{ }Temple Place, Suite@w{ }330, Boston, MA@w{ }02111, USA
476 Everyone is permitted to copy and distribute verbatim copies of this
477 license document, but changing it is not allowed.
478 @end display
480 @unnumberedsec Preamble
482 The licenses for most software are designed to take away your freedom to
483 share and change it.  By contrast, the GNU General Public License is
484 intended to guarantee your freedom to share and change free software --
485 to make sure the software is free for all its users.  This General
486 Public License applies to most of the Free Software Foundation's
487 software and to any other program whose authors commit to using it.
488 (Some other Free Software Foundation software is covered by the GNU
489 Library General Public License instead.)  You can apply it to your
490 programs, too.
492 When we speak of free software, we are referring to freedom, not price.
493 Our General Public Licenses are designed to make sure that you have the
494 freedom to distribute copies of free software (and charge for this
495 service if you wish), that you receive source code or can get it if you
496 want it, that you can change the software or use pieces of it in new
497 free programs; and that you know you can do these things.
499 To protect your rights, we need to make restrictions that forbid anyone
500 to deny you these rights or to ask you to surrender the rights.  These
501 restrictions translate to certain responsibilities for you if you
502 distribute copies of the software, or if you modify it.
504 For example, if you distribute copies of such a program, whether gratis
505 or for a fee, you must give the recipients all the rights that you have.
506 You must make sure that they, too, receive or can get the source code.
507 And you must show them these terms so they know their rights.
509 We protect your rights with two steps: (1)@w{ }copyright the software,
510 and (2)@w{ }offer you this license which gives you legal permission to
511 copy, distribute and/or modify the software.
513 Also, for each author's protection and ours, we want to make certain
514 that everyone understands that there is no warranty for this free
515 software.  If the software is modified by someone else and passed on, we
516 want its recipients to know that what they have is not the original, so
517 that any problems introduced by others will not reflect on the original
518 authors' reputations.
520 Finally, any free program is threatened constantly by software patents.
521 We wish to avoid the danger that redistributors of a free program will
522 individually obtain patent licenses, in effect making the program
523 proprietary.  To prevent this, we have made it clear that any patent
524 must be licensed for everyone's free use or not licensed at all.
526 The precise terms and conditions for copying, distribution and
527 modification follow.
529 @iftex
530 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
531 @end iftex
532 @ifinfo
533 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
534 @end ifinfo
536 @enumerate 0
537 @item
538 This License applies to any program or other work which contains a
539 notice placed by the copyright holder saying it may be distributed under
540 the terms of this General Public License.  The ``Program'', below,
541 refers to any such program or work, and a ``work based on the Program''
542 means either the Program or any derivative work under copyright law:
543 that is to say, a work containing the Program or a portion of it, either
544 verbatim or with modifications and/or translated into another language.
545 (Hereinafter, translation is included without limitation in the term
546 ``modification''.)  Each licensee is addressed as ``you''.
548 Activities other than copying, distribution and modification are not
549 covered by this License; they are outside its scope.  The act of running
550 the Program is not restricted, and the output from the Program is
551 covered only if its contents constitute a work based on the Program
552 (independent of having been made by running the Program).  Whether that
553 is true depends on what the Program does.
555 @item
556 You may copy and distribute verbatim copies of the Program's source code
557 as you receive it, in any medium, provided that you conspicuously and
558 appropriately publish on each copy an appropriate copyright notice and
559 disclaimer of warranty; keep intact all the notices that refer to this
560 License and to the absence of any warranty; and give any other
561 recipients of the Program a copy of this License along with the Program.
563 You may charge a fee for the physical act of transferring a copy, and
564 you may at your option offer warranty protection in exchange for a fee.
566 @item
567 You may modify your copy or copies of the Program or any portion of it,
568 thus forming a work based on the Program, and copy and distribute such
569 modifications or work under the terms of Section@w{ }1 above, provided
570 that you also meet all of these conditions:
572 @enumerate a
573 @item
574 You must cause the modified files to carry prominent notices stating
575 that you changed the files and the date of any change.
577 @item
578 You must cause any work that you distribute or publish, that in whole or
579 in part contains or is derived from the Program or any part thereof, to
580 be licensed as a whole at no charge to all third parties under the terms
581 of this License.
583 @item
584 If the modified program normally reads commands interactively when run,
585 you must cause it, when started running for such interactive use in the
586 most ordinary way, to print or display an announcement including an
587 appropriate copyright notice and a notice that there is no warranty (or
588 else, saying that you provide a warranty) and that users may
589 redistribute the program under these conditions, and telling the user
590 how to view a copy of this License.  (Exception: if the Program itself
591 is interactive but does not normally print such an announcement, your
592 work based on the Program is not required to print an announcement.)
593 @end enumerate
595 These requirements apply to the modified work as a whole.  If
596 identifiable sections of that work are not derived from the Program, and
597 can be reasonably considered independent and separate works in
598 themselves, then this License, and its terms, do not apply to those
599 sections when you distribute them as separate works.  But when you
600 distribute the same sections as part of a whole which is a work based on
601 the Program, the distribution of the whole must be on the terms of this
602 License, whose permissions for other licensees extend to the entire
603 whole, and thus to each and every part regardless of who wrote it.
605 Thus, it is not the intent of this section to claim rights or contest
606 your rights to work written entirely by you; rather, the intent is to
607 exercise the right to control the distribution of derivative or
608 collective works based on the Program.
610 In addition, mere aggregation of another work not based on the Program
611 with the Program (or with a work based on the Program) on a volume of a
612 storage or distribution medium does not bring the other work under the
613 scope of this License.
615 @item
616 You may copy and distribute the Program (or a work based on it, under
617 Section@w{ }2) in object code or executable form under the terms of
618 Sections@w{ }1 and@w{ }2 above provided that you also do one of the
619 following:
621 @enumerate a
622 @item
623 Accompany it with the complete corresponding machine-readable source
624 code, which must be distributed under the terms of Sections@w{ }1 and@w{
625 }2 above on a medium customarily used for software interchange; or,
627 @item
628 Accompany it with a written offer, valid for at least three years, to
629 give any third party, for a charge no more than your cost of physically
630 performing source distribution, a complete machine-readable copy of the
631 corresponding source code, to be distributed under the terms of
632 Sections@w{ }1 and@w{ }2 above on a medium customarily used for software
633 interchange; or,
635 @item
636 Accompany it with the information you received as to the offer to
637 distribute corresponding source code.  (This alternative is allowed only
638 for noncommercial distribution and only if you received the program in
639 object code or executable form with such an offer, in accord with
640 Subsection@w{ }b above.)
641 @end enumerate
643 The source code for a work means the preferred form of the work for
644 making modifications to it.  For an executable work, complete source
645 code means all the source code for all modules it contains, plus any
646 associated interface definition files, plus the scripts used to control
647 compilation and installation of the executable.  However, as a special
648 exception, the source code distributed need not include anything that is
649 normally distributed (in either source or binary form) with the major
650 components (compiler, kernel, and so on) of the operating system on
651 which the executable runs, unless that component itself accompanies the
652 executable.
654 If distribution of executable or object code is made by offering access
655 to copy from a designated place, then offering equivalent access to copy
656 the source code from the same place counts as distribution of the source
657 code, even though third parties are not compelled to copy the source
658 along with the object code.
660 @item
661 You may not copy, modify, sublicense, or distribute the Program except
662 as expressly provided under this License.  Any attempt otherwise to
663 copy, modify, sublicense or distribute the Program is void, and will
664 automatically terminate your rights under this License.  However,
665 parties who have received copies, or rights, from you under this License
666 will not have their licenses terminated so long as such parties remain
667 in full compliance.
669 @item
670 You are not required to accept this License, since you have not signed
671 it.  However, nothing else grants you permission to modify or distribute
672 the Program or its derivative works.  These actions are prohibited by
673 law if you do not accept this License.  Therefore, by modifying or
674 distributing the Program (or any work based on the Program), you
675 indicate your acceptance of this License to do so, and all its terms and
676 conditions for copying, distributing or modifying the Program or works
677 based on it.
679 @item
680 Each time you redistribute the Program (or any work based on the
681 Program), the recipient automatically receives a license from the
682 original licensor to copy, distribute or modify the Program subject to
683 these terms and conditions.  You may not impose any further restrictions
684 on the recipients' exercise of the rights granted herein.  You are not
685 responsible for enforcing compliance by third parties to this License.
687 @item
688 If, as a consequence of a court judgment or allegation of patent
689 infringement or for any other reason (not limited to patent issues),
690 conditions are imposed on you (whether by court order, agreement or
691 otherwise) that contradict the conditions of this License, they do not
692 excuse you from the conditions of this License.  If you cannot
693 distribute so as to satisfy simultaneously your obligations under this
694 License and any other pertinent obligations, then as a consequence you
695 may not distribute the Program at all.  For example, if a patent license
696 would not permit royalty-free redistribution of the Program by all those
697 who receive copies directly or indirectly through you, then the only way
698 you could satisfy both it and this License would be to refrain entirely
699 from distribution of the Program.
701 If any portion of this section is held invalid or unenforceable under
702 any particular circumstance, the balance of the section is intended to
703 apply and the section as a whole is intended to apply in other
704 circumstances.
706 It is not the purpose of this section to induce you to infringe any
707 patents or other property right claims or to contest validity of any
708 such claims; this section has the sole purpose of protecting the
709 integrity of the free software distribution system, which is implemented
710 by public license practices.  Many people have made generous
711 contributions to the wide range of software distributed through that
712 system in reliance on consistent application of that system; it is up to
713 the author/donor to decide if he or she is willing to distribute
714 software through any other system and a licensee cannot impose that
715 choice.
717 This section is intended to make thoroughly clear what is believed to be
718 a consequence of the rest of this License.
720 @item
721 If the distribution and/or use of the Program is restricted in certain
722 countries either by patents or by copyrighted interfaces, the original
723 copyright holder who places the Program under this License may add an
724 explicit geographical distribution limitation excluding those countries,
725 so that distribution is permitted only in or among countries not thus
726 excluded.  In such case, this License incorporates the limitation as if
727 written in the body of this License.
729 @item
730 The Free Software Foundation may publish revised and/or new versions of
731 the General Public License from time to time.  Such new versions will be
732 similar in spirit to the present version, but may differ in detail to
733 address new problems or concerns.
735 Each version is given a distinguishing version number.  If the Program
736 specifies a version number of this License which applies to it and ``any
737 later version'', you have the option of following the terms and
738 conditions either of that version or of any later version published by
739 the Free Software Foundation.  If the Program does not specify a version
740 number of this License, you may choose any version ever published by the
741 Free Software Foundation.
743 @item
744 If you wish to incorporate parts of the Program into other free programs
745 whose distribution conditions are different, write to the author to ask
746 for permission.  For software which is copyrighted by the Free Software
747 Foundation, write to the Free Software Foundation; we sometimes make
748 exceptions for this.  Our decision will be guided by the two goals of
749 preserving the free status of all derivatives of our free software and
750 of promoting the sharing and reuse of software generally.
752 @iftex
753 @heading NO WARRANTY
754 @end iftex
755 @ifinfo
756 @center NO WARRANTY
757 @end ifinfo
759 @item
760 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
761 THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW@.  EXCEPT WHEN
762 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
763 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER
764 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
765 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE@.
766 THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
767 YOU@.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
768 NECESSARY SERVICING, REPAIR OR CORRECTION.
770 @item
771 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
772 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
773 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
774 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
775 DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
776 (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
777 INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
778 THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
779 OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
780 @end enumerate
782 @iftex
783 @heading END OF TERMS AND CONDITIONS
784 @end iftex
785 @ifinfo
786 @center END OF TERMS AND CONDITIONS
787 @end ifinfo
790 @page
791 @unnumberedsec How to Apply These Terms to Your New Programs
793 If you develop a new program, and you want it to be of the greatest
794 possible use to the public, the best way to achieve this is to make it
795 free software which everyone can redistribute and change under these
796 terms.
798 To do so, attach the following notices to the program.  It is safest to
799 attach them to the start of each source file to most effectively convey
800 the exclusion of warranty; and each file should have at least the
801 ``copyright'' line and a pointer to where the full notice is found.
803 @smallexample
804 @var{one line to give the program's name and an idea of what it does.}
805 Copyright (C) 19@var{yy} @var{name of author}
807 This program is free software; you can redistribute it and/or modify
808 it under the terms of the GNU General Public License as published by
809 the Free Software Foundation; either version 2 of the License, or (at
810 your option) any later version.
812 This program is distributed in the hope that it will be useful, but
813 WITHOUT ANY WARRANTY; without even the implied warranty of
814 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@.  See the GNU
815 General Public License for more details.
817 You should have received a copy of the GNU General Public License
818 along with this program; if not, write to the Free Software
819 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
820 @end smallexample
822 Also add information on how to contact you by electronic and paper mail.
824 If the program is interactive, make it output a short notice like this
825 when it starts in an interactive mode:
827 @smallexample
828 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
829 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type
830 `show w'.  This is free software, and you are welcome to redistribute
831 it under certain conditions; type `show c' for details.
832 @end smallexample
834 The hypothetical commands @samp{show@w{ }w} and @samp{show@w{ }c} should
835 show the appropriate parts of the General Public License.  Of course,
836 the commands you use may be called something other than @samp{show@w{
837 }w} and @samp{show@w{ }c}; they could even be mouse-clicks or menu items
838 -- whatever suits your program.
840 You should also get your employer (if you work as a programmer) or your
841 school, if any, to sign a ``copyright disclaimer'' for the program, if
842 necessary.  Here is a sample; alter the names:
844 @smallexample
845 @group
846 Yoyodyne, Inc., hereby disclaims all copyright interest
847 in the program `Gnomovision' (which makes passes at compilers)
848 written by James Hacker.
850 @var{signature of Ty Coon}, 1 April 1989
851 Ty Coon, President of Vice
852 @end group
853 @end smallexample
855 This General Public License does not permit incorporating your program
856 into proprietary programs.  If your program is a subroutine library, you
857 may consider it more useful to permit linking proprietary applications
858 with the library.  If this is what you want to do, use the GNU Library
859 General Public License instead of this License.
863 @c =====================================================================
864 @c =====================================================================
866 @node Introduction, Invoking groff, Copying, Top
867 @chapter Introduction
868 @cindex introduction
870 GNU @code{troff} (or @code{groff}) is a system for typesetting
871 documents.  @code{troff} is very flexible and has been in existence (and
872 use) for about 3@w{ }decades.  It is quite widespread and firmly
873 entrenched in the @acronym{UNIX} community.
875 @menu
876 * What Is groff?::
877 * History::
878 * groff Capabilities::
879 * Macro Package Intro::
880 * Preprocessor Intro::
881 * Output device intro::
882 * Credits::
883 @end menu
886 @c =====================================================================
888 @node What Is groff?, History, Introduction, Introduction
889 @section What Is @code{groff}?
890 @cindex what is @code{groff}?
891 @cindex @code{groff} -- what is it?
893 @code{groff} belongs to an older generation of document preparation
894 systems, which operate more like compilers than the more recent
895 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
896 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
897 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
898 normal text files with embedded formatting commands.  These files can
899 then be processed by @code{groff} to produce a typeset document on a
900 variety of devices.
902 Likewise, @code{groff} should not be confused with a @dfn{word
903 processor}, since that term connotes an integrated system that includes
904 an editor and a text formatter.  Also, many word processors follow the
905 @acronym{WYSIWYG} paradigm discussed earlier.
907 Although @acronym{WYSIWYG} systems may be easier to use, they have a
908 number of disadvantages compared to @code{troff}:
910 @itemize @bullet
911 @item
912 They must be used on a graphics display to work on a document.
914 @item
915 Most of the @acronym{WYSIWYG} systems are either non-free or are not
916 very portable.
918 @item
919 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
921 @item
922 It is difficult to have a wide range of capabilities available within
923 the confines of a GUI/window system.
925 @item
926 It is more difficult to make global changes to a document.
927 @end itemize
929 @quotation
930 ``GUIs normally make it simple to accomplish simple actions and
931 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
932 @code{comp.unix.wizards})
933 @end quotation
936 @c =====================================================================
938 @node History, groff Capabilities, What Is groff?, Introduction
939 @section History
940 @cindex history
942 @cindex @code{runoff}, the program
943 @cindex @code{rf}, the program
944 @code{troff} can trace its origins back to a formatting program called
945 @code{runoff}, written by J.@w{ }E.@w{ }Saltzer, which ran on MIT's CTSS
946 operating system in the mid-sixties.  This name came from the common
947 phrase of the time ``I'll run off a document.''  Bob Morris ported it to
948 the 635 architecture and called the program @code{roff} (an abbreviation
949 of @code{runoff}).  It was rewritten as @code{rf} for the @w{PDP-7}
950 (before having @acronym{UNIX}), and at the same time (1969), Doug
951 McIllroy rewrote an extended and simplified version of @code{roff} in
952 the @acronym{BCPL} programming language.
954 @cindex @code{roff}, the program
955 The first version of @acronym{UNIX} was developed on a @w{PDP-7} which
956 was sitting around Bell Labs.  In 1971 the developers wanted to get a
957 @w{PDP-11} for further work on the operating system.  In order to
958 justify the cost for this system, they proposed that they would
959 implement a document formatting system for the AT&T patents division.
960 This first formatting program was a reimplementation of McIllroy's
961 @code{roff}, written by J.@w{ }F.@w{ }Ossanna.
963 @cindex @code{nroff}, the program
964 When they needed a more flexible language, a new version of @code{roff}
965 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
966 more complicated syntax, but provided the basis for all future versions.
967 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
968 version of @code{nroff} that would drive it.  It was dubbed
969 @code{troff}, for ``typesetter @code{roff}'', although many people have
970 speculated that it actually means ``Times @code{roff}'' because of the
971 use of the Times font family in @code{troff} by default.  As such, the
972 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
974 With @code{troff} came @code{nroff} (they were actually the same program
975 except for some @samp{#ifdef}s), which was for producing output for line
976 printers and character terminals.  It understood everything @code{troff}
977 did, and ignored the commands which were not applicable (e.g.@: font
978 changes).
980 Since there are several things which cannot be done easily in
981 @code{troff}, work on several preprocessors began.  These programs would
982 transform certain parts of a document into @code{troff}, which made a
983 very natural use of pipes in @acronym{UNIX}.
985 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
986 specified in a much simpler and more intuitive manner.  @code{tbl} is a
987 preprocessor for formatting tables.  The @code{refer} preprocessor (and
988 the similar program, @code{bib}) processes citations in a document
989 according to a bibliographic database.
991 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
992 language and produced output specifically for the CAT phototypesetter.
993 He rewrote it in C, although it was now 7000@w{ }lines of uncommented
994 code and still dependent on the CAT.  As the CAT became less common, and
995 was no longer supported by the manufacturer, the need to make it support
996 other devices became a priority.  However, before this could be done,
997 Ossanna was killed in an auto accident.
999 @pindex ditroff
1000 @cindex @code{ditroff}, the program
1001 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
1002 newly rewritten version produced a device independent code which was
1003 very easy for postprocessors to read and translate to the appropriate
1004 printer codes.  Also, this new version of @code{troff} (called
1005 @code{ditroff} for ``device independent @code{troff}'') had several
1006 extensions, which included drawing functions.
1008 Due to the additional abilities of the new version of @code{troff},
1009 several new preprocessors appeared.  The @code{pic} preprocessor
1010 provides a wide range of drawing functions.  Likewise the @code{ideal}
1011 preprocessor did the same, although via a much different paradigm.  The
1012 @code{grap} preprocessor took specifications for graphs, but, unlike
1013 other preprocessors, produced @code{pic} code.
1015 James Clark began work on a GNU implementation of @code{ditroff} in
1016 early@w{ }1989.  The first version, @code{groff}@w{ }0.3.1, was released
1017 June@w{ }1990.  @code{groff} included:
1019 @itemize @bullet
1020 @item
1021 A replacement for @code{ditroff} with many extensions.
1023 @item
1024 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
1026 @item
1027 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
1028 X@w{ }windows.  GNU @code{troff} also eliminated the need for a
1029 separate @code{nroff} program with a postprocessor which would produce
1030 @acronym{ASCII} output.
1032 @item
1033 A version of the @file{me} macros and an implementation of the
1034 @file{man} macros.
1035 @end itemize
1037 Also, a front-end was included which could construct the, sometimes
1038 painfully long, pipelines required for all the post- and preprocessors.
1040 Development of GNU @code{troff} progressed rapidly, and saw the
1041 additions of a replacement for @code{refer}, an implementation of the
1042 @file{ms} and @file{mm} macros, and a program to deduce how to format a
1043 document (@code{grog}).
1045 It was declared a stable (i.e.@: non-beta) package with the release of
1046 version@w{ }1.04 around November@w{ }1991.
1048 Beginning in@w{ }1999, @code{groff} has new maintainers (the package was
1049 an orphan for a few years).  As a result, new features and programs like
1050 @code{grn}, a preprocessor for gremlin images, and an output device to
1051 produce @acronym{HTML} output have been added.
1054 @c =====================================================================
1056 @node groff Capabilities, Macro Package Intro, History, Introduction
1057 @section @code{groff} Capabilities
1058 @cindex @code{groff} capabilities
1059 @cindex capabilities of @code{groff}
1061 So what exactly is @code{groff} capable of doing?  @code{groff} provides
1062 a wide range of low-level text formatting operations.  Using these, it
1063 is possible to perform a wide range of formatting tasks, such as
1064 footnotes, table of contents, multiple columns, etc.  Here's a list of
1065 the most important operations supported by @code{groff}:
1067 @itemize @bullet
1068 @item
1069 text filling, adjusting, and centering
1071 @item
1072 hyphenation
1074 @item
1075 page control
1077 @item
1078 font and character size control
1080 @item
1081 vertical spacing (i.e.@: double spacing)
1083 @item
1084 line length and indenting
1086 @item
1087 macros, strings, diversions, and traps
1089 @item
1090 number registers
1092 @item
1093 tabs, leaders, and fields
1095 @item
1096 input and output conventions and character translation
1098 @item
1099 overstrike, bracket, line drawing, and zero-width functions
1101 @item
1102 local horizontal and vertical motions and the width function
1104 @item
1105 three-part titles
1107 @item
1108 output line numbering
1110 @item
1111 conditional acceptance of input
1113 @item
1114 environment switching
1116 @item
1117 insertions from the standard input
1119 @item
1120 input/output file switching
1122 @item
1123 output and error messages
1124 @end itemize
1127 @c =====================================================================
1129 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
1130 @section Macro Packages
1131 @cindex macro packages
1133 Since @code{groff} provides such low-level facilities, it can be quite
1134 difficult to use by itself.  However, @code{groff} provides a
1135 @dfn{macro} facility to specify how certain routine operations (e.g.@w{
1136 }starting paragraphs, printing headers and footers, etc.)@: should be
1137 done.  These macros can be collected together into a @dfn{macro
1138 package}.  There are a number of macro packages available; the most
1139 common (and the ones described in this manual) are @file{man},
1140 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
1143 @c =====================================================================
1145 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
1146 @section Preprocessors
1147 @cindex preprocessors
1149 Although @code{groff} provides most functions needed to format a
1150 document, some operations would be unwieldy (e.g.@: to draw pictures).
1151 Therefore, programs called @dfn{preprocessors} were written which
1152 understand their own language and produce the necessary @code{groff}
1153 operations.  These preprocessors are able to differentiate their own
1154 input from the rest of the document via markers.
1156 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
1157 from the preprocessor into @code{groff}.  Any number of preprocessors
1158 may be used on a given document; in this case, the preprocessors are
1159 linked together into one pipeline.  However, in @code{groff}, the user
1160 does not need to construct the pipe, but only tell @code{groff} what
1161 preprocessors to use.
1163 @code{groff} currently has preprocessors for producing tables
1164 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
1165 (@code{pic} and @code{grn}), and for processing bibliographies
1166 (@code{refer}).  An associated program which is useful when dealing with
1167 preprocessors is @code{soelim}.
1169 A free implementation of @code{grap}, a preprocessor for drawing graphs,
1170 can be obtained as an extra package; @code{groff} can use @code{grap}
1171 also.
1173 There are other preprocessors in existence, but, unfortunately, no free
1174 implementations are available.  Among them are preprocessors for drawing
1175 mathematical pictures (@code{ideal}) and chemical structures
1176 (@code{chem}).
1179 @c =====================================================================
1181 @node Output device intro, Credits, Preprocessor Intro, Introduction
1182 @section Output Devices
1183 @cindex postprocessors
1184 @cindex output devices
1185 @cindex devices for output
1187 @code{groff} actually produces device independent code which may be
1188 fed into a postprocessor to produce output for a particular device.
1189 Currently, @code{groff} has postprocessors for @sc{PostScript}
1190 devices, character terminals, X@w{ }Windows (for previewing), @TeX{}
1191 DVI format, HP LaserJet@w{ }4 and Canon LBP printers (which use
1192 @acronym{CAPSL}), and @acronym{HTML}.
1195 @c =====================================================================
1197 @node Credits,  , Output device intro, Introduction
1198 @section Credits
1199 @cindex credits
1201 Large portions of this manual were taken from existing documents, most
1202 notably, the manual pages for the @code{groff} package by James Clark,
1203 and Eric Allman's papers on the @file{me} macro package.
1205 The section on the @file{man} macro package is partly based on Susan@w{
1206 }G.@: Kleinmann's @file{groff_man} manual page written for the Debian
1207 GNU/Linux system.
1211 @c =====================================================================
1212 @c =====================================================================
1214 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
1215 @chapter Invoking @code{groff}
1216 @cindex invoking @code{groff}
1217 @cindex @code{groff} invocation
1219 This section focuses on how to invoke the @code{groff} front end.  This
1220 front end takes care of the details of constructing the pipeline among
1221 the preprocessors, @code{gtroff} and the postprocessor.
1223 It has become a tradition that GNU programs get the prefix @samp{g} to
1224 distinguish it from its original counterparts provided by the host (see
1225 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
1226 GNU @code{eqn}.  On operating systems like Linux or the Hurd, which
1227 don't contain proprietary software, and on MS-DOS/MS-Windows, where
1228 @code{troff} and associated programs are not available at all, this
1229 prefix is omitted since GNU @code{troff} is the only used incarnation of
1230 @code{troff}.  Exception: @code{groff} is never replaced by @code{roff}.
1232 @menu
1233 * Groff Options::
1234 * Environment::
1235 * Invocation Examples::
1236 @end menu
1239 @c =====================================================================
1241 @node Groff Options, Environment, Invoking groff, Invoking groff
1242 @section Options
1243 @cindex options
1245 @pindex groff
1246 @pindex gtroff
1247 @pindex gpic
1248 @pindex geqn
1249 @pindex ggrn
1250 @pindex grap
1251 @pindex gtbl
1252 @pindex grefer
1253 @pindex gsoelim
1254 @code{groff} normally runs the @code{gtroff} program and a postprocessor
1255 appropriate for the selected device.  The default device is @samp{ps}
1256 (but it can be changed when @code{groff} is configured and built).  It
1257 can optionally preprocess with any of @code{gpic}, @code{geqn},
1258 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
1260 This section only documents options to the @code{groff} front end.  Many
1261 of the arguments to @code{groff} are passed on to @code{gtroff},
1262 therefore those are also included.  Arguments to pre- or postprocessors
1263 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
1264 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
1265 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
1266 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
1267 grolbp}, and @ref{Invoking gxditview}.
1269 The command line format for @code{groff} is:
1271 @Example
1272 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
1273       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
1274       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
1275       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
1276       [ @var{files}@dots{} ]
1277 @endExample
1279 The command line format for @code{gtroff} is as follows.
1281 @Example
1282 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
1283        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
1284        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
1285        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
1286 @endExample
1288 @noindent
1289 Obviously, many of the options to @code{groff} are actually passed on to
1290 @code{gtroff}.
1292 Options without an argument can be grouped behind a single@w{ }@option{-}.
1293 A filename of@w{ }@file{-} denotes the standard input.  It is possible to
1294 have whitespace between an option and its parameter.
1296 The @code{grog} command can be used to guess the correct @code{groff}
1297 command to format a file.
1299 Here's the description of the command-line options:
1301 @cindex command-line options
1302 @table @samp
1303 @item -h
1304 Print a help message.
1306 @item -e
1307 Preprocess with @code{geqn}.
1309 @item -t
1310 Preprocess with @code{gtbl}.
1312 @item -g
1313 Preprocess with @code{ggrn}.
1315 @item -G
1316 Preprocess with @code{grap}.
1318 @item -p
1319 Preprocess with @code{gpic}.
1321 @item -s
1322 Preprocess with @code{gsoelim}.
1324 @item -c
1325 Suppress color output.
1327 @item -R
1328 Preprocess with @code{grefer}.  No mechanism is provided for passing
1329 arguments to @code{grefer} because most @code{grefer} options have
1330 equivalent commands which can be included in the file.  @xref{grefer},
1331 for more details.
1333 @pindex troffrc
1334 @pindex troffrc-end
1335 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1336 accessible via @code{groff}.  This option prevents the loading of the
1337 @file{troffrc} and @file{troffrc-end} files.
1339 @item -v
1340 Make programs run by @code{groff} print out their version number.
1342 @item -V
1343 Print the pipeline on @code{stdout} instead of executing it.
1345 @item -z
1346 Suppress output from @code{gtroff}.  Only error messages are printed.
1348 @item -Z
1349 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
1350 automatically runs the appropriate postprocessor.
1352 @item -P@var{arg}
1353 Pass @var{arg} to the postprocessor.  Each argument should be passed
1354 with a separate @option{-P} option.  Note that @code{groff} does not
1355 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1357 @item -l
1358 Send the output to a spooler for printing.  The command used for this is
1359 specified by the @code{print} command in the device description file
1360 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
1361 ignored.
1363 @item -L@var{arg}
1364 Pass @var{arg} to the spooler.  Each argument should be passed with a
1365 separate @option{-L} option.  Note that @code{groff} does not prepend
1366 a @samp{-} to @var{arg} before passing it to the postprocessor.
1367 If the @code{print} keyword in the device description file is missing,
1368 @option{-L} is ignored.
1370 @item -T@var{dev}
1371 Prepare output for device @var{dev}.  The default device is @samp{ps},
1372 unless changed when @code{groff} was configured and built.  The
1373 following are the output devices currently available:
1375 @table @code
1376 @item ps
1377 For @sc{PostScript} printers and previewers.
1379 @item dvi
1380 For @TeX{} DVI format.
1382 @item X75
1383 For a 75@dmn{dpi} X11 previewer.
1385 @item X75-12
1386 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font.
1388 @item X100
1389 For a 100@dmn{dpi} X11 previewer.
1391 @item X100-12
1392 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font.
1394 @item ascii
1395 For typewriter-like devices.
1397 @item latin1
1398 For typewriter-like devices that support the @w{Latin-1} (@w{ISO
1399 8859-1}) character set.
1401 @item utf8
1402 For typewriter-like devices which use the Unicode (@w{ISO 10646})
1403 character set with @w{UTF-8} encoding.
1405 @item cp1047
1406 @cindex @acronym{EBCDIC} encoding
1407 @cindex encoding, @acronym{EBCDIC}
1408 @cindex encoding, cp1047
1409 @cindex cp1047
1410 @cindex IBM cp1047
1411 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1412 cp1047.
1414 @item lj4
1415 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
1417 @item lbp
1418 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1419 printers).
1421 @pindex pre-grohtml
1422 @pindex post-grohtml
1423 @cindex @code{grohtml}, the program
1424 @item html
1425 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1426 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1427 postprocessor (@code{post-grohtml}).
1428 @end table
1430 @cindex output device name string register (@code{.T})
1431 @cindex output device usage number register (@code{.T})
1432 The predefined @code{gtroff} string register @code{.T} contains the
1433 current output device; the read-only number register @code{.T} is set
1434 to@w{ }1 if this option is used (which is always true if @code{groff} is
1435 used to call @code{gtroff}).  @xref{Built-in Registers}.
1437 The postprocessor to be used for a device is specified by the
1438 @code{postpro} command in the device description file.  (@xref{Font
1439 Files}, for more info.)  This can be overridden with the @option{-X}
1440 option.
1442 @item -X
1443 Preview with @code{gxditview} instead of using the usual postprocessor.
1444 This is unlikely to produce good results except with @option{-Tps}.
1446 Note that this is not the same as using @option{-TX75} or
1447 @option{-TX100} to view a document with @code{gxditview}: The former
1448 uses the metrics of the specified device, whereas the latter uses
1449 X-specific fonts and metrics.
1451 @item -N
1452 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1453 the @option{-N} option in @code{geqn}.
1455 @cindex @code{open} request, and safer mode
1456 @cindex @code{opena} request, and safer mode
1457 @cindex @code{pso} request, and safer mode
1458 @cindex @code{sy} request, and safer mode
1459 @cindex @code{pi} request, and safer mode
1460 @item -S
1461 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1462 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1463 requests.  For security reasons, this is enabled by default.
1465 @item -U
1466 Unsafe mode.  Reverts to the old unsafe behaviour.
1468 @item -a
1469 @cindex @acronym{ASCII} approximation output register (@code{.A})
1470 Generate an @acronym{ASCII} approximation of the typeset output.  The
1471 read-only register @code{.A} is then set to@w{ }1.  @xref{Built-in
1472 Registers}.  A typical example is
1474 @Example
1475 groff -a -man -Tdvi troff.man | less
1476 @endExample
1478 @noindent
1479 which shows how lines are broken for the DVI device.  Note that this
1480 option is rather useless today since graphic output devices are
1481 available virtually everywhere.
1483 @item -b
1484 Print a backtrace with each warning or error message.  This backtrace
1485 should help track down the cause of the error.  The line numbers given
1486 in the backtrace may not always be correct: @code{gtroff} can get
1487 confused by @code{as} or @code{am} requests while counting line numbers.
1489 @item -i
1490 Read the standard input after all the named input files have been
1491 processed.
1493 @item -w@var{name}
1494 Enable warning @var{name}.  Available warnings are described in
1495 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1497 @item -W@var{name}
1498 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1500 @item -E
1501 Inhibit all error messages.
1503 @item -C
1504 Enable compatibility mode.  @xref{Implementation Differences}, for the
1505 list of incompatibilities between @code{groff} and traditional Unix
1506 @code{troff}.
1508 @item -d@var{cs}
1509 @itemx -d@var{name}=s
1510 Define @var{c} or @var{name} to be a string@w{ }@var{s}.  @var{c}@w{ }must
1511 be a one-letter name; @var{name} can be of arbitrary length.  All string
1512 assignments happen before loading any macro file (including the start-up
1513 file).
1515 @item -f@var{fam}
1516 Use @var{fam} as the default font family.  @xref{Font Families}.
1518 @item -m@var{name}
1519 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1520 for this in its macro directories.  If it isn't found, it tries
1521 @file{tmac.@var{name}} (and searches in the same directories).
1523 @c XXX document local and system macro dirs
1525 @item -n@var{num}
1526 Number the first page @var{num}.
1528 @item -o@var{list}
1529 @cindex print current page register (@code{.P})
1530 Output only pages in @var{list}, which is a comma-separated list of page
1531 ranges; @samp{@var{n}} means print page@w{ }@var{n}, @samp{@var{m}-@var{n}}
1532 means print every page between @var{m} and@w{ }@var{n}, @samp{-@var{n}}
1533 means print every page up to@w{ }@var{n}, @samp{@var{n}-} means print every
1534 page beginning with@w{ }@var{n}.  @code{gtroff} exits after printing the
1535 last page in the list.  All the ranges are inclusive on both ends.
1537 Within @code{gtroff}, this information can be extracted with the
1538 @samp{.P} register.  @xref{Built-in Registers}.
1540 If your document restarts page numbering at the beginning of each
1541 chapter, then @code{gtroff} prints the specified page range for each
1542 chapter.
1544 @item -r@var{cn}
1545 @itemx -r@var{name}=@var{n}
1546 Set number register@w{ }@var{c} or @var{name} to the value@w{ }@var{n}.
1547 @var{c}@w{ }must be a one-letter name; @var{name} can be of arbitrary
1548 length.  @var{n}@w{ }can be any @code{gtroff} numeric expression.  All
1549 register  assignments happen before loading any macro file (including
1550 the start-up file).
1552 @item -F@var{dir}
1553 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1554 (@var{name} is the name of the device), for the @file{DESC} file, and
1555 for font files before looking in the standard directories.
1557 @item -M@var{dir}
1558 Search directory @file{@var{dir}} for macro files before the standard
1559 directories.
1561 @item -I@var{dir}
1562 This option is as described in @ref{gsoelim}.  It implies the
1563 @option{-s} option.
1564 @end table
1567 @c =====================================================================
1569 @node Environment, Invocation Examples, Groff Options, Invoking groff
1570 @section Environment
1571 @cindex environment variables
1572 @cindex variables in environment
1574 There are also several environment variables (of the operating system,
1575 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1577 @table @code
1578 @item GROFF_COMMAND_PREFIX
1579 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1580 If this is set to@w{ }@var{X}, then @code{groff} runs @code{@var{X}troff}
1581 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1582 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1583 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1584 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1586 @c XXX document default values
1588 @item GROFF_TMAC_PATH
1589 @tindex GROFF_TMAC_PATH@r{, environment variable}
1590 A colon-separated list of directories in which to search for macro files
1591 (before the default directories are tried).
1593 @c XXX document local and system macro dirs
1595 @item GROFF_TYPESETTER
1596 @tindex GROFF_TYPESETTER@r{, environment variable}
1597 The default output device.
1599 @item GROFF_FONT_PATH
1600 @tindex GROFF_FONT_PATH@r{, environment variable}
1601 A colon-separated list of directories in which to search for the
1602 @code{dev}@var{name} directory (before the default directories are
1603 tried).
1605 @item GROFF_BIN_PATH
1606 @tindex GROFF_BIN_PATH@r{, environment variable}
1607 This search path, followed by @code{PATH}, is used for commands executed
1608 by @code{groff}.
1610 @item GROFF_TMPDIR
1611 @tindex GROFF_TMPDIR@r{, environment variable}
1612 @tindex TMPDIR@r{, environment variable}
1613 The directory in which @code{groff} creates temporary files.  If this is
1614 not set and @env{TMPDIR} is set, temporary files are created in that
1615 directory.  Otherwise temporary files are created in a system-dependent
1616 default directory (on Unix and GNU/Linux systems, this is usually
1617 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1618 @code{post-grohtml} can create temporary files in this directory.
1619 @end table
1621 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1622 rather than colons, to separate the directories in the lists described
1623 above.
1626 @c =====================================================================
1628 @node Invocation Examples,  , Environment, Invoking groff
1629 @section Invocation Examples
1630 @cindex invocation examples
1631 @cindex examples of invocation
1633 This section lists several common uses of @code{groff} and the
1634 corresponding command lines.
1636 @Example
1637 groff file
1638 @endExample
1640 @noindent
1641 This command processes @file{file} without a macro package or a
1642 preprocessor.  The output device is the default, @samp{ps}, and the
1643 output is sent to @code{stdout}.
1645 @Example
1646 groff -t -mandoc -Tascii file | less
1647 @endExample
1649 @noindent
1650 This is basically what a call to the @code{man} program does.
1651 @code{gtroff} processes the manual page @file{file} with the
1652 @file{mandoc} macro file (which in turn either calls the @file{man} or
1653 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1654 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1655 displays the result.
1657 @Example
1658 groff -X -m me file
1659 @endExample
1661 @noindent
1662 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1663 package.  Since no @option{-T} option is specified, use the default
1664 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1665 @w{@samp{-me}}; the latter is an anachronism from the early days of
1666 @acronym{UNIX}.@footnote{The same is true for the other main macro
1667 packages that come with @code{groff}: @file{man}, @file{mdoc},
1668 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1669 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1670 @w{@samp{-m trace}} must be used.}
1672 @Example
1673 groff -man -rD1 -z file
1674 @endExample
1676 @noindent
1677 Check @file{file} with the @file{man} macro package, forcing
1678 double-sided printing -- don't produce any output.
1680 @menu
1681 * grog::
1682 @end menu
1684 @c ---------------------------------------------------------------------
1686 @node grog,  , Invocation Examples, Invocation Examples
1687 @subsection @code{grog}
1689 @pindex grog
1690 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1691 and/or macro packages are required for formatting them, and prints the
1692 @code{groff} command including those options on the standard output.  It
1693 generates one or more of the options @option{-e}, @option{-man},
1694 @option{-me}, @option{-mm}, @option{-ms}, @option{-mdoc},
1695 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1696 @option{-s}, and @option{-t}.
1698 A special file name@w{ }@file{-} refers to the standard input.  Specifying
1699 no files also means to read the standard input.  Any specified options
1700 are included in the printed command.  No space is allowed between
1701 options and their arguments.  The only options recognized are
1702 @option{-C} (which is also passed on) to enable compatibility mode, and
1703 @option{-v} (if it is the only parameter) to print the version number.
1705 For example,
1707 @Example
1708 grog -Tdvi paper.ms
1709 @endExample
1711 @noindent
1712 guesses the appropriate command to print @file{paper.ms} and then prints
1713 it to the command line after adding the @option{-Tdvi} option.  For
1714 direct execution, enclose the call to @code{grog} in backquotes at the
1715 @acronym{UNIX} shell prompt:
1717 @Example
1718 `grog -Tdvi paper.ms` > paper.dvi
1719 @endExample
1721 @noindent
1722 As seen in the example, it is still necessary to redirect the output to
1723 something meaningful (i.e.@: either a file or a pager program like
1724 @code{less}).
1728 @c =====================================================================
1729 @c =====================================================================
1731 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1732 @chapter Tutorial for Macro Users
1733 @cindex tutorial for macro users
1734 @cindex macros, tutorial for users
1735 @cindex user's tutorial for macros
1736 @cindex user's macro tutorial
1738 Most users tend to use a macro package to format their papers.  This
1739 means that the whole breadth of @code{groff} is not necessary for most
1740 people.  This chapter covers the material needed to efficiently use a
1741 macro package.
1743 @menu
1744 * Basics::
1745 * Common Features::
1746 @end menu
1749 @c =====================================================================
1751 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1752 @section Basics
1753 @cindex basics of macros
1754 @cindex macro basics
1756 This section covers some of the basic concepts necessary to understand
1757 how to use a macro package.@footnote{This section is derived from
1758 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1759 References are made throughout to more detailed information, if desired.
1761 @code{gtroff} reads an input file prepared by the user and outputs a
1762 formatted document suitable for publication or framing.  The input
1763 consists of text, or words to be printed, and embedded commands
1764 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1765 format the output.  For more detail on this, see @ref{Embedded
1766 Commands}.
1768 The word @dfn{argument} is used in this chapter to mean a word or number
1769 which appears on the same line as a request, and which modifies the
1770 meaning of that request.  For example, the request
1772 @Example
1774 @endExample
1776 @noindent
1777 spaces one line, but
1779 @Example
1780 .sp 4
1781 @endExample
1783 @noindent
1784 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1785 request which says to space four lines instead of one.  Arguments are
1786 separated from the request and from each other by spaces (@emph{no}
1787 tabs).  More details on this can be found in @ref{Request Arguments}.
1789 The primary function of @code{gtroff} is to collect words from input
1790 lines, fill output lines with those words, justify the right-hand margin
1791 by inserting extra spaces in the line, and output the result.  For
1792 example, the input:
1794 @Example
1795 Now is the time
1796 for all good men
1797 to come to the aid
1798 of their party.
1799 Four score and seven
1800 years ago,...
1801 @endExample
1803 @noindent
1804 is read, packed onto output lines, and justified to produce:
1806 @quotation
1807 Now is the time for all good men to come to the aid of their party.
1808 Four score and seven years ago,@dots{}
1809 @end quotation
1811 @cindex break
1812 @cindex line break
1813 Sometimes a new output line should be started even though the current
1814 line is not yet full; for example, at the end of a paragraph.  To do
1815 this it is possible to cause a @dfn{break}, which starts a new output
1816 line.  Some requests cause a break automatically, as normally do blank
1817 input lines and input lines beginning with a space.
1819 Not all input lines are text to be formatted.  Some input lines are
1820 requests which describe how to format the text.  Requests always have a
1821 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1822 the input line.
1824 The text formatter also does more complex things, such as automatically
1825 numbering pages, skipping over page boundaries, putting footnotes in the
1826 correct place, and so forth.
1828 Here are a few hints for preparing text for input to @code{gtroff}.
1830 @itemize @bullet
1831 @item
1832 First, keep the input lines short.  Short input lines are easier to
1833 edit, and @code{gtroff} packs words onto longer lines anyhow.
1835 @item
1836 In keeping with this, it is helpful to begin a new line after every
1837 comma or phrase, since common corrections are to add or delete sentences
1838 or phrases.
1840 @item
1841 End each sentence with two spaces -- or better, start each sentence on a
1842 new line.  @code{gtroff} recognizes characters that usually end a
1843 sentence, and inserts sentence space accordingly.
1845 @item
1846 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1847 enough to hyphenate words as needed, but is not smart enough to take
1848 hyphens out and join a word back together.  Also, words such as
1849 ``mother-in-law'' should not be broken over a line, since then a space
1850 can occur where not wanted, such as ``@w{mother- in}-law''.
1851 @end itemize
1853 @cindex double spacing (@code{ls})
1854 @cindex spacing
1855 @code{gtroff} double spaces output text automatically if you use the
1856 request @w{@samp{.ls 2}}.  Reactivate single spaced mode by typing
1857 @w{@samp{.ls 1}}.
1859 A number of requests allow to change the way the output looks,
1860 sometimes called the @dfn{layout} of the output page.  Most of these
1861 requests adjust the placing of @dfn{white space} (blank lines or
1862 spaces).
1864 @cindex new page (@code{bp})
1865 The @samp{.bp} request starts a new page, causing a line break.
1867 @cindex blank line (@code{sp})
1868 @cindex empty line (@code{sp})
1869 @cindex line, empty (@code{sp})
1870 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1871 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1872 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1873 @var{N}@w{ }centimeters).  For example, the input:
1875 @Example
1876 .sp 1.5i
1877 My thoughts on the subject
1879 @endExample
1881 @noindent
1882 leaves one and a half inches of space, followed by the line ``My
1883 thoughts on the subject'', followed by a single blank line (more
1884 measurement units are available, see @ref{Measurements}).
1886 @cindex centering lines (@code{ce})
1887 @cindex lines, centering (@code{ce})
1888 Text lines can be centered by using the @code{ce} request.  The line
1889 after @code{ce} is centered (horizontally) on the page.  To center more
1890 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1891 of lines to center), followed by the @var{N}@w{ }lines.  To center many
1892 lines without counting them, type:
1894 @Example
1895 .ce 1000
1896 lines to center
1897 .ce 0
1898 @endExample
1900 @noindent
1901 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1902 lines, in other words, stop centering.
1904 @cindex line break (@code{br})
1905 @cindex break (@code{br})
1906 All of these requests cause a break; that is, they always start a new
1907 line.  To start a new line without performing any other action, use
1908 @code{br}.
1911 @c =====================================================================
1913 @node Common Features,  , Basics, Tutorial for Macro Users
1914 @section Common Features
1915 @cindex common features
1916 @cindex features, common
1918 @code{gtroff} provides very low-level operations for formatting a
1919 document.  There are many common routine operations which are done in
1920 all documents.  These common operations are written into @dfn{macros}
1921 and collected into a @dfn{macro package}.
1923 All macro packages provide certain common capabilities which fall into
1924 the following categories.
1926 @menu
1927 * Paragraphs::
1928 * Sections and Chapters::
1929 * Headers and Footers::
1930 * Page Layout Adjustment::
1931 * Displays::
1932 * Footnotes and Annotations::
1933 * Table of Contents::
1934 * Indices::
1935 * Paper Formats::
1936 * Multiple Columns::
1937 * Font and Size Changes::
1938 * Predefined Strings::
1939 * Preprocessor Support::
1940 * Configuration and Customization::
1941 @end menu
1943 @c ---------------------------------------------------------------------
1945 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1946 @subsection Paragraphs
1947 @cindex paragraphs
1949 One of the most common and most used capability is starting a
1950 paragraph.  There are a number of different types of paragraphs, any
1951 of which can be initiated with macros supplied by the macro package.
1952 Normally, paragraphs start with a blank line and the first line
1953 indented, like the text in this manual.  There are also block style
1954 paragraphs, which omit the indentation:
1956 @Example
1957 Some   men  look   at  constitutions   with  sanctimonious
1958 reverence, and deem them like the ark of the covenant, too
1959 sacred to be touched.
1960 @endExample
1962 @noindent
1963 And there are also indented paragraphs which begin with a tag or label
1964 at the margin and the remaining text indented.
1966 @example
1967 @group
1968 one   This is  the first paragraph.  Notice  how the first
1969       line of  the resulting  paragraph lines up  with the
1970       other lines in the paragraph.
1971 @end group
1972 @group
1973 longlabel
1974       This  paragraph   had  a  long   label.   The  first
1975       character of text on the first line does not line up
1976       with  the  text  on  second  and  subsequent  lines,
1977       although they line up with each other.
1978 @end group
1979 @end example
1981 A variation of this is a bulleted list.
1983 @c XXX description
1985 @c ---------------------------------------------------------------------
1987 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1988 @subsection Sections and Chapters
1990 Most macro packages supply some form of section headers.  The simplest
1991 kind is simply the heading on a line by itself in bold type.  Others
1992 supply automatically numbered section heading or different heading
1993 styles at different levels.  Some, more sophisticated, macro packages
1994 supply macros for starting chapters and appendices.
1996 @c ---------------------------------------------------------------------
1998 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1999 @subsection Headers and Footers
2001 Every macro package gives some way to manipulate the headers and footers
2002 (or @dfn{titles}) on each page.  Some packages allow for different ones
2003 on the even and odd pages (for material printed in a book form).
2005 The titles are called three-part titles, that is, there is a
2006 left-justified part, a centered part, and a right-justified part.  An
2007 automatically generated page number may be put in any of these fields
2008 with the @samp{%} character (see @ref{Page Layout}, for more details).
2010 @c ---------------------------------------------------------------------
2012 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
2013 @subsection Page Layout
2015 Most macro packages let the user specify top and bottom margins and
2016 other details about the appearance of the printed pages.
2018 @c ---------------------------------------------------------------------
2020 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2021 @subsection Displays
2022 @cindex displays
2024 Displays are sections of text to be set off from the body of the paper.
2025 Major quotes, tables, and figures are types of displays, as are all the
2026 examples used in this document.
2028 @cindex quotes, major
2029 @cindex major quotes
2030 @dfn{Major quotes} are quotes which are several lines long, and hence
2031 are set in from the rest of the text without quote marks around them.
2033 @cindex list
2034 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
2035 should be used when the material to be printed should not be filled and
2036 justified like normal text, such as columns of figures or the examples
2037 used in this paper.
2039 @cindex keep
2040 A @dfn{keep} is a display of lines which are kept on a single page if
2041 possible.  An example for a keep might be a diagram.  Keeps differ from
2042 lists in that lists may be broken over a page boundary whereas keeps are
2043 not.
2045 @cindex keep, floating
2046 @cindex floating keep
2047 Floating keeps move relative to the text.  Hence, they are good for
2048 things which are referred to by name, such as ``See figure@w{ }3''.  A
2049 floating keep appears at the bottom of the current page if it fits;
2050 otherwise, it appears at the top of the next page.  Meanwhile, the
2051 surrounding text `flows' around the keep, thus leaving no blank areas.
2053 @c ---------------------------------------------------------------------
2055 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2056 @subsection Footnotes and Annotations
2057 @cindex footnotes
2058 @cindex annotations
2060 There are a number of requests to save text for later printing.
2062 @dfn{Footnotes} are printed at the bottom of the current page.
2064 @cindex delayed text
2065 @dfn{Delayed text} is very similar to a footnote except that it is
2066 printed when called for explicitly.  This allows a list of references to
2067 appear (for example) at the end of each chapter, as is the convention in
2068 some disciplines.
2070 Most macro packages which supply this functionality also supply a means
2071 of automatically numbering either type of annotation.
2073 @c ---------------------------------------------------------------------
2075 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2076 @subsection Table of Contents
2077 @cindex table of contents
2078 @cindex contents, table of
2080 @dfn{Tables of contents} are a type of delayed text having a tag
2081 (usually the page number) attached to each entry after a row of dots.
2082 The table accumulates throughout the paper until printed, usually after
2083 the paper has ended.  Many macro packages provide the ability to have
2084 several tables of contents (e.g.@: a standard table of contents, a list
2085 of tables, etc).
2087 @c ---------------------------------------------------------------------
2089 @node Indices, Paper Formats, Table of Contents, Common Features
2090 @subsection Indices
2091 @cindex index, in macro package
2093 While some macro packages use the term @dfn{index}, none actually
2094 provide that functionality.  The facilities they call indices are
2095 actually more appropriate for tables of contents.
2097 @c ---------------------------------------------------------------------
2099 @node Paper Formats, Multiple Columns, Indices, Common Features
2100 @subsection Paper Formats
2101 @cindex paper formats
2103 Some macro packages provide stock formats for various kinds of
2104 documents.  Many of them provide a common format for the title and
2105 opening pages of a technical paper.  The @file{mm} macros in particular
2106 provide formats for letters and memoranda.
2108 @c ---------------------------------------------------------------------
2110 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2111 @subsection Multiple Columns
2113 Some macro packages (but not @file{man}) provide the ability to have two
2114 or more columns on a page.
2116 @c ---------------------------------------------------------------------
2118 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2119 @subsection Font and Size Changes
2121 The built-in font and size functions are not always intuitive, so all
2122 macro packages provide macros to make these operations simpler.
2124 @c ---------------------------------------------------------------------
2126 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2127 @subsection Predefined Strings
2129 Most macro packages provide various predefined strings for a variety of
2130 uses; examples are sub- and superscripts, printable dates, quotes and
2131 various special characters.
2133 @c ---------------------------------------------------------------------
2135 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2136 @subsection Preprocessor Support
2138 All macro packages provide support for the various preprocessors and may
2139 extend their functionality.
2141 For example, all macro packages mark tables (which are processed with
2142 @code{gtbl}) by placing them between @code{.TS} and @code{.TE} macros.
2143 The @file{ms} macro package has an option, @code{.TS@w{}H}, that prints
2144 a caption at the top of a new page (when the table is too long to fit on
2145 a single page).
2147 @c ---------------------------------------------------------------------
2149 @node Configuration and Customization,  , Preprocessor Support, Common Features
2150 @subsection Configuration and Customization
2152 Some macro packages provide means of customizing many of the details of
2153 how the package behaves.  This ranges from setting the default type size
2154 to changing the appearance of section headers.
2158 @c =====================================================================
2159 @c =====================================================================
2161 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2162 @chapter Macro Packages
2163 @cindex macro packages
2164 @cindex packages, macros
2166 This chapter documents the main macro packages that come with
2167 @code{groff}.
2169 @menu
2170 * man::
2171 * mdoc::
2172 * ms::
2173 * me::
2174 * mm::
2175 @end menu
2178 @c =====================================================================
2180 @node man, mdoc, Macro Packages, Macro Packages
2181 @section @file{man}
2182 @cindex manual pages
2183 @pindex an.tmac
2184 @pindex man.tmac
2185 @pindex man-old.tmac
2187 This is the most popular and probably the most important macro package
2188 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2189 are based on it.
2191 @menu
2192 * Man options::
2193 * Man usage::
2194 * Man font macros::
2195 * Miscellaneous man macros::
2196 * Predefined man strings::
2197 * Preprocessors in man pages::
2198 @end menu
2200 @c ---------------------------------------------------------------------
2202 @node Man options, Man usage, man, man
2203 @subsection Options
2205 The command line format for using the @file{man} macros with
2206 @code{groff} is:
2208 @Example
2209 groff -m man [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
2210       [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
2211 @endExample
2213 @noindent
2214 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2216 @table @code
2217 @item -rcR=1
2218 This option (the default if a tty output device is used) creates a
2219 single, very long page instead of multiple pages.  Use @code{-rcR=0}
2220 to disable it.
2222 @item -rC1
2223 If more than one manual page is given on the command line, number the
2224 pages continuously, rather than starting each at@w{ }1.
2226 @item -rD1
2227 Double-sided printing.  Footers for even and odd pages are formatted
2228 differently.
2230 @item -rP@var{nnn}
2231 Page numbering starts with @var{nnn} rather than with@w{ }1.
2233 @item -rS@var{xx}
2234 Use @var{xx} (which can be 10, 11, or@w{ }12@dmn{pt}) as the base
2235 document font size instead of the default value of@w{ }10@dmn{pt}.
2237 @item -rX@var{nnn}
2238 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2239 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2240 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2241 @end table
2243 @c ---------------------------------------------------------------------
2245 @node Man usage, Man font macros, Man options, man
2246 @subsection Usage
2247 @cindex @code{man} macros
2248 @cindex macros for manual pages [@code{man}]
2250 @pindex man.local
2251 This section describes the available macros for manual pages.  For
2252 further customization, put additional macros and requests into the file
2253 @file{man.local} which is loaded immediately after the @file{man}
2254 package.
2256 @Defmac {TH, title section [@Var{extra1}] [@Var{extra2}] [@Var{extra3}], man}
2257 Set the title of the man page to @var{title} and the section to
2258 @var{section}, which must have a value between 1 and@w{ }8.  The value
2259 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
2260 to indicate a specific subsection of the man pages.
2262 Both @var{title} and @var{section} are positioned at the left and right
2263 in the header line (with @var{section} in parentheses immediately
2264 appended to @var{title}.  @var{extra1} is positioned in the middle of
2265 the footer line.  @var{extra2} is positioned at the left in the footer
2266 line (or at the left on even pages and at the right on odd pages if
2267 double-sided printing is active).  @var{extra3} is centered in the
2268 header line.
2270 For @acronym{HTML} output, headers and footers are completely suppressed.
2272 Additionally, this macro starts a new page; the new line number is@w{ }1
2273 again (except if the @option{-rC1} option is given on the command line)
2274 -- this feature is intended only for formatting multiple man pages; a
2275 single man page should contain exactly one @code{TH} macro at the
2276 beginning of the file.
2277 @endDefmac
2279 @Defmac {SH, [@Var{heading}], man}
2280 Set up an unnumbered section heading sticking out to the left.  Prints
2281 out all the text following @code{SH} up to the end of the line (or the
2282 text in the next line if there is no argument to @code{SH}) in bold
2283 face, one size larger than the base document size.  Additionally, the
2284 left margin for the following text is reset to its default value.
2285 @endDefmac
2287 @Defmac {SS, [@Var{heading}], man}
2288 Set up an unnumbered (sub)section heading.  Prints out all the text
2289 following @code{SS} up to the end of the line (or the text in the next
2290 line if there is no argument to @code{SS}) in bold face, at the same
2291 size as the base document size.  Additionally, the left margin for the
2292 following text is reset to its default value.
2293 @endDefmac
2295 @Defmac {TP, [@Var{nnn}], man}
2296 Set up an indented paragraph with label.  The indentation is set to
2297 @var{nnn} if that argument is supplied (the default unit is @samp{n}
2298 if omitted), otherwise it is set to the default indentation value.
2300 The first line of text following this macro is interpreted as a string
2301 to be printed flush-left, as it is appropriate for a label.  It is not
2302 interpreted as part of a paragraph, so there is no attempt to fill the
2303 first line with text from the following input lines.  Nevertheless, if
2304 the label is not as wide as the indentation, then the paragraph starts
2305 at the same line (but indented), continuing on the following lines.
2306 If the label is wider than the indentation, then the descriptive part
2307 of the paragraph begins on the line following the label, entirely
2308 indented.  Note that neither font shape nor font size of the label is
2309 set to a default value; on the other hand, the rest of the text has
2310 default font settings.
2311 @endDefmac
2313 @DefmacList {LP, , man}
2314 @DefmacItem {PP, , man}
2315 @DefmacListEnd {P, , man}
2316 These macros are mutual aliases.  Any of them causes a line break at
2317 the current position, followed by a vertical space downwards by the
2318 amount specified by the @code{PD} macro.  The font size and shape are
2319 reset to the default value (10@dmn{pt} roman).  Finally, the current
2320 left margin is restored.
2321 @endDefmac
2323 @Defmac {IP, [@Var{designator}] [@Var{nnn}], man}
2324 Set up an indented paragraph, using @var{designator} as a tag to mark
2325 its beginning.  The indentation is set to @var{nnn} if that argument
2326 is supplied (default unit is @samp{n}), otherwise the default
2327 indentation value is used.  Font size and face of the paragraph (but
2328 not the designator) are reset to their default values.  To start an
2329 indented paragraph with a particular indentation but without a
2330 designator, use @samp{""} (two double quotes) as the first argument of
2331 @code{IP}.
2333 For example, to start a paragraph with bullets as the designator and
2334 4@dmn{en} indentation, write
2336 @Example
2337 .IP \(bu 4
2338 @endExample
2339 @endDefmac
2341 @cindex hanging indentation [@code{man}]
2342 @cindex @code{man} macros, hanging indentation
2343 @Defmac {HP, [@Var{nnn}], man}
2344 Set up a paragraph with hanging left indentation.  The indentation is
2345 set to @var{nnn} if that argument is supplied (default unit is
2346 @samp{n}), otherwise the default indentation value is used.  Font size
2347 and face are reset to their default values.
2348 @endDefmac
2350 @cindex left margin, how to move [@code{man}]
2351 @cindex @code{man} macros, moving left margin
2352 @Defmac {RS, [@Var{nnn}], man}
2353 Move the left margin to the right by the value @var{nnn} if specified
2354 (default unit is @samp{n}); otherwise the default indentation value
2355 is used.  Calls to the @code{RS} macro can be nested.
2356 @endDefmac
2358 @Defmac {RE, [@Var{nnn}], man}
2359 Move the left margin back to level @var{nnn}; if no argument is given,
2360 it moves one level back.  The first level (i.e., no call to @code{RS}
2361 yet) has number@w{ }1, and each call to @code{RS} increases the level
2362 by@w{ }1.
2363 @endDefmac
2365 @cindex line breaks, with vertical space [@code{man}]
2366 @cindex @code{man} macros, line breaks with vertical space
2367 To summarize, the following macros cause a line break with the insertion
2368 of vertical space (which amount can be changed with the @code{PD}
2369 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2370 @code{P}), @code{IP}, and @code{HP}.
2372 @cindex line breaks, without vertical space [@code{man}]
2373 @cindex @code{man} macros, line breaks without vertical space
2374 The macros @code{RS} and @code{RE} also cause a break but do not insert
2375 vertical space.
2377 @c ---------------------------------------------------------------------
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
2384 The standard font is roman; the default text size is 10@w{ }point.
2386 @Defmac {SM, [@Var{text}], man}
2387 Set the text on the same line or the text on the next line in a font
2388 that is one point size smaller than the default font.
2389 @endDefmac
2391 @cindex boldface [@code{man}]
2392 @cindex @code{man} macros, boldface
2393 @Defmac {SB, [@Var{text}], man}
2394 Set the text on the same line or the text on the next line in boldface
2395 font, one point size smaller than the default font.
2396 @endDefmac
2398 @Defmac {BI, text, man}
2399 Set its arguments alternately in bold face and italic.  Thus,
2401 @Example
2402 .BI this "word and" that
2403 @endExample
2405 @noindent
2406 would set ``this'' and ``that'' in bold face, and ``word and'' in
2407 italics.
2408 @endDefmac
2410 @Defmac {IB, text, man}
2411 Set its arguments alternately in italic and bold face.
2412 @endDefmac
2414 @Defmac {RI, text, man}
2415 Set its arguments alternately in roman and italic.
2416 @endDefmac
2418 @Defmac {IR, text, man}
2419 Set its arguments alternately in italic and roman.
2420 @endDefmac
2422 @Defmac {BR, text, man}
2423 Set its arguments alternately in bold face and roman.
2424 @endDefmac
2426 @Defmac {RB, text, man}
2427 Set its arguments alternately in roman and bold face.
2428 @endDefmac
2430 @Defmac {B, [@Var{text}], man}
2431 Set @var{text} in bold face.  If no text is present on the line where
2432 the macro is called, then the text of the next line appears in bold
2433 face.
2434 @endDefmac
2436 @cindex italic fonts [@code{man}]
2437 @cindex @code{man} macros, italic fonts
2438 @Defmac {I, [@Var{text}], man}
2439 Set @var{text} in italic.  If no text is present on the line where the
2440 macro is called, then the text of the next line appears in italic.
2441 @endDefmac
2443 @c ---------------------------------------------------------------------
2445 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2446 @subsection Miscellaneous macros
2448 @pindex grohtml
2449 @cindex @code{man} macros, default indentation
2450 @cindex default indentation [@code{man}]
2451 The default indentation is 7.2@dmn{n} for all output devices except for
2452 @code{grohtml} which ignores indentation.
2454 @cindex tab stops [@code{man}]
2455 @cindex @code{man} macros, tab stops
2456 @Defmac {DT, , man}
2457 Set tabs every 0.5@w{ }inches.  Since this macro is always called
2458 during a @code{TH} request, it makes sense to call it only if the tab
2459 positions have been changed.
2460 @endDefmac
2462 @cindex empty space before a paragraph [@code{man}]
2463 @cindex @code{man} macros, empty space before a paragraph
2464 @Defmac {PD, [@Var{nnn}], man}
2465 Adjust the empty space before a new paragraph (or section).  The
2466 optional argument gives the amount of space (default unit is
2467 @samp{v}); without parameter, the value is reset to its default value
2468 (1@w{ }line for tty devices, 0.4@dmn{v}@w{ }otherwise).
2469 @endDefmac
2471 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2472 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2474 @c ---------------------------------------------------------------------
2476 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2477 @subsection Predefined strings
2479 The following strings are defined:
2481 @Defstr {S, man}
2482 Switch back to the default font size.
2483 @endDefstr
2485 @Defstr {R, man}
2486 The `registered' sign.
2487 @endDefstr
2489 @Defstr {Tm, man}
2490 The `trademark' sign.
2491 @endDefstr
2493 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2494 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2495 @DefstrList {lq, man}
2496 @DefstrListEnd {rq, man}
2497 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2498 respectively.
2499 @endDefstr
2501 @c ---------------------------------------------------------------------
2503 @node Preprocessors in man pages,  , Predefined man strings, man
2504 @subsection Preprocessors in @file{man} pages
2506 @cindex preprocessor, calling convention
2507 @cindex calling convention of preprocessors
2508 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2509 become common usage to make the first line of the man page look like
2510 this:
2512 @Example
2513 '\" @var{word}
2514 @endExample
2516 @pindex geqn@r{, invocation in manual pages}
2517 @pindex grefer@r{, invocation in manual pages}
2518 @pindex gtbl@r{, invocation in manual pages}
2519 @pindex man@r{, invocation of preprocessors}
2520 @noindent
2521 Note the single space character after the double quote.  @var{word}
2522 consists of letters for the needed preprocessors: @samp{e} for
2523 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2524 Modern implementations of the @code{man} program read this first line
2525 and automatically call the right preprocessor(s).
2528 @c =====================================================================
2530 @node mdoc, ms, man, Macro Packages
2531 @section @file{mdoc}
2532 @cindex @file{mdoc}
2534 @c XXX documentation
2535 @c XXX this is a placeholder until we get stuff knocked into shape
2536 See the @code{mdoc} manpage (type @command{man 7 groff_mdoc} at
2537 the command line).
2540 @c =====================================================================
2542 @node ms, me, mdoc, Macro Packages
2543 @section @file{ms}
2544 @cindex @file{ms}
2546 The @file{-ms}
2547 macros are suitable for reports, letters, books,
2548 user manuals, and so forth.
2549 The package provides macros for cover pages, section headings,
2550 paragraphs, lists, footnotes, pagination,
2551 and a table of contents.
2553 @menu
2554 * ms Intro::
2555 * General ms Structure::
2556 * ms Document Control Registers::
2557 * ms Cover Page Macros::
2558 * ms Body Text::
2559 * ms Page Layout::
2560 * Differences from AT&T ms::
2561 @end menu
2563 @c ---------------------------------------------------------------------
2565 @node ms Intro, General ms Structure, ms, ms
2566 @subsection Introduction to @file{ms}
2568 The original @file{-ms} macros were included with
2569 @acronym{AT&T} @code{troff} as well as the
2570 @file{man} macros.
2571 While the @file{man} package is intended for brief documents
2572 that can be read on-line as well as printed, the @file{ms}
2573 macros are suitable for longer documents that are meant to be
2574 printed rather than read on-line.
2576 The @file{ms} macro package included with @code{groff}
2577 is a complete, bottom-up re-implementation.
2578 Several macros (specific to @acronym{AT&T}
2579 or Berkeley) are not included, while several new commands are.
2580 @xref{Differences from AT&T ms}, for more information.
2582 @c ---------------------------------------------------------------------
2584 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2585 @subsection General structure of an @file{ms} document
2586 @cindex @file{ms}, general structure
2588 The @file{ms} macro package expects a certain amount of structure,
2589 but not as much as packages such as @file{man} or @file{mdoc}.
2591 The simplest documents can begin with a paragraph macro
2592 (such as @code{LP} or @code{PP}),
2593 and consist of text separated by paragraph macros
2594 or even blank lines.
2595 Longer documents have a structure as follows:
2597 @table @strong
2598 @item Document type
2599 If you invoke the @code{RP}
2600 (report) macro on the first line of the document,
2601 @code{groff} prints the cover page information on its own page;
2602 otherwise it prints the information on the
2603 first page with your document text immediately following.
2604 Other document formats found in @acronym{AT&T} @code{troff}
2605 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2606 @code{groff}.
2608 @item Format and layout
2609 By setting number registers,
2610 you can change your document's type (font and size),
2611 margins, spacing, headers and footers, and footnotes.
2612 @xref{ms Document Control Registers}, for more details.
2614 @item Cover page
2615 A cover page consists of a title, the author's name and institution,
2616 an abstract, and the date.
2617 @footnote{Actually, only the title is required.}
2618 @xref{ms Cover Page Macros}, for more details.
2620 @item Body
2621 Following the cover page is your document.
2622 You can use the @file{ms}
2623 macros to write reports, letters, books, and so forth.
2624 The package is designed for structured documents,
2625 consisting of paragraphs interspersed with headings
2626 and augmented by lists, footnotes, tables, and other
2627 common constructs.
2628 @xref{ms Body Text}, for more details.
2630 @item Table of contents
2631 Longer documents usually include a table of contents,
2632 which you can invoke by placing the
2633 @code{TC}
2634 macro at the end of your document.
2635 The @file{ms}
2636 macros have minimal indexing facilities, consisting of the
2637 @code{IX} macro, which prints an entry on standard error.
2638 Printing the table of contents at the end is necessary since
2639 @code{groff} is a single-pass text formatter,
2640 thus it cannot determine the page number of each section
2641 until that section has actually been set and printed.
2642 Since @file{ms} output is intended for hardcopy,
2643 you can manually relocate the pages containing
2644 the table of contents between the cover page and the
2645 body text after printing.
2646 @end table
2648 @c ---------------------------------------------------------------------
2650 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2651 @subsection Document control registers
2652 @cindex @file{ms}, document control registers
2654 The following is a list of document control number registers.
2655 For the sake of consistency,
2656 set registers related to margins at the beginning of your document,
2657 or just after the @code{RP} macro.
2658 You can set other registers later in your document,
2659 but you should keep them together at the beginning
2660 to make them easy to find and edit as necessary.
2662 @unnumberedsubsubsec Margin Settings
2664 @Defmpreg {PO, ms}
2665 Defines the page offset (i.e.@: the left margin).
2666 There is no explicit right margin setting; the combination of
2667 the @code{PO} and @code{LL} registers implicitly define the
2668 right margin width.
2670 Effective: next page.
2672 Default value: 1@dmn{i}.
2673 @endDefmpreg
2675 @Defmpreg {LL, ms}
2676 Defines the line length (i.e.@: the width of the body text).
2678 Effective: next paragraph.
2680 Default: 6@dmn{i}.
2681 @endDefmpreg
2683 @Defmpreg {LT, ms}
2684 Defines the title length (i.e.@: the header and footer width).
2685 This is usually the same as @code{LL}, but not necessarily.
2687 Effective: next paragraph.
2689 Default: 6@dmn{i}.
2690 @endDefmpreg
2692 @Defmpreg {HM, ms}
2693 Defines the header margin height at the top of the page.
2695 Effective: next page.
2697 Default: 1@dmn{i}.
2698 @endDefmpreg
2700 @Defmpreg {FM, ms}
2701 Defines the footer margin height at the bottom of the page.
2703 Effective: next page.
2705 Default: 1@dmn{i}.
2706 @endDefmpreg
2708 @unnumberedsubsubsec Text Settings
2710 @Defmpreg {PS, ms}
2711 Defines the point size of the body text.
2713 Effective: next paragraph.
2715 Default: 10@dmn{p}.
2716 @endDefmpreg
2718 @Defmpreg {VS, ms}
2719 Defines the space between lines (line height plus leading).
2721 Effective: next paragraph.
2723 Default: 12@dmn{p}.
2724 @endDefmpreg
2726 @unnumberedsubsubsec Paragraph Settings
2728 @Defmpreg {PI, ms}
2729 Defines the initial indent of a @code{.PP} paragraph.
2731 Effective: next paragraph.
2733 Default: 5@dmn{n}.
2734 @endDefmpreg
2736 @Defmpreg {PD, ms}
2737 Defines the space between paragraphs.
2739 Effective: next paragraph.
2741 Default: 0.3@dmn{v}.
2742 @endDefmpreg
2744 @Defmpreg {QI, ms}
2745 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2747 Effective: next paragraph.
2749 Default: 5@dmn{n}.
2750 @endDefmpreg
2752 @unnumberedsubsubsec Footnote Settings
2754 @Defmpreg {FL, ms}
2755 Defines the length of a footnote.
2757 Effective: next footnote.
2759 Default: @math{@code{@\n[LL]} * 5 / 6}.
2760 @endDefmpreg
2762 @Defmpreg {FI, ms}
2763 Defines the footnote indent.
2765 Effective: next footnote.
2767 Default: 2@dmn{n}.
2768 @endDefmpreg
2770 @Defmpreg {FF, ms}
2771 The footnote format:
2772 @table @code
2773 @item 0
2774 Prints the footnote number as a superscript; indents the footnote (default).
2776 @item 1
2777 Prints the number followed by a period (like 1.)
2778 and indents the footnote.
2780 @item 2
2781 Like 1, without an indent.
2783 @item 3
2784 Like 1, but prints the footnote number as a hanging paragraph.
2785 @end table
2787 Effective: next footnote.
2789 Default: 0.
2790 @endDefmpreg
2792 @unnumberedsubsubsec Miscellaneous Number Registers
2794 @Defmpreg {MINGW, ms}
2795 Defines the minimum width between columns in a multi-column document.
2797 Effective: next page.
2799 Default: 2@dmn{n}.
2800 @endDefmpreg
2802 @c ---------------------------------------------------------------------
2804 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2805 @subsection Cover page macros
2806 @cindex @file{ms}, cover page macros
2807 @cindex Cover page macros, @file{ms}
2809 Use the following macros to create a cover page for your document
2810 in the order shown.
2812 @Defmac {RP, [@code{no}], ms}
2813 Specifies the report format for your document.
2814 The report format creates a separate cover page.
2815 The default action (no @code{.RP}
2816 macro) is to print a subset of the
2817 cover page on page 1 of your document.
2819 If you use the word @code{no} as an optional argument,
2820 @code{groff} prints a title page but
2821 does not repeat any of the title page information
2822 (title, author, abstract, etc.)
2823 on page 1 of the document.
2824 @endDefmac
2826 @Defmac {DA, [@dots{}], ms}
2827 (optional) Print the current date, or the arguments to the macro if any,
2828 on the title page (if specified) and in the footers.
2829 This is the default for @code{nroff}.
2830 @endDefmac
2832 @Defmac {ND, [@dots{}], ms}
2833 (optional) Print the current date, or the arguments to the macro if any,
2834 on the title page (if specified) but not in the footers.
2835 This is the default for @code{troff}.
2836 @endDefmac
2838 @Defmac {TL, , ms}
2839 Specifies the document title.
2840 @code{groff} collects text following the @code{.TL}
2841 macro into the title, until reaching the author name or abstract.
2842 @endDefmac
2844 @Defmac {AU, , ms}
2845 Specifies the author's name, which appears on the
2846 line (or lines) immediately following.
2847 You can specify multiple authors as follows:
2849 @Example
2851 John Doe
2853 University of West Bumblefuzz
2855 Martha Buck
2857 Monolithic Corporation
2860 @endExample
2861 @endDefmac
2863 @Defmac {AI, , ms}
2864 Specifies the author's institution.
2865 You can specify multiple institutions in the same way
2866 that you specify multiple authors.
2867 @endDefmac
2869 @Defmac {AB, [@code{no}], ms}
2870 Begins the abstract.
2871 The default is to print the word @acronym{ABSTRACT},
2872 centered and in italics, above the text of the abstract.
2873 The word @code{no} as an optional argument suppresses this heading.
2874 @endDefmac
2876 @Defmac {AE, , ms}
2877 End the abstract.
2878 @endDefmac
2880 The following is example mark-up for a title page.
2881 @cindex Title page, example markup
2882 @cindex Example markup, title page
2884 @Example
2885 @cartouche
2888 The Inevitability of Code Bloat
2889 in Commercial and Free Software
2891 J. Random Luser
2893 University of West Bumblefuzz
2895 This report examines the long-term growth
2896 of the code bases in two large, popular software
2897 packages; the free Emacs and the commercial
2898 Microsoft Word.
2899 While differences appear in the type or order
2900 of features added, due to the different
2901 methodologies used, the results are the same
2902 in the end.
2904 The free software approach is shown to be
2905 superior in that while free software can
2906 become as bloated as commercial offerings,
2907 free software tends to have fewer serious
2908 bugs and the added features are in line with
2909 user demand.
2912 ... the rest of the paper follows ...
2913 @end cartouche
2914 @endExample
2916 @c ---------------------------------------------------------------------
2918 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2919 @subsection Body text
2920 @cindex @file{ms}, body text
2922 This section describes macros used to mark up the body of your document.
2923 Examples include paragraphs, sections, and other groups.
2925 @menu
2926 * Paragraphs in ms::
2927 * Headings in ms::
2928 * Highlighting in ms::
2929 * Lists in ms::
2930 * Indents in ms::
2931 * Tabstops in ms::
2932 * ms Displays and Keeps::
2933 * ms Insertions::
2934 * Example multi-page table::
2935 * ms Footnotes::
2936 @end menu
2938 @c ---------------------------------------------------------------------
2940 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2941 @subsubsection Paragraphs
2942 @cindex @file{ms}, paragraph macros
2944 The following paragraph types are available.
2946 @Defmac {PP, , ms}
2947 Sets a paragraph with an initial indent.
2948 @endDefmac
2950 @Defmac {LP, , ms}
2951 Sets a paragraph with no initial indent.
2952 @endDefmac
2954 @Defmac {QP, , ms}
2955 Sets a paragraph that is indented at both left and right margins.
2956 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2957 The next paragraph or heading returns margins to normal.
2958 @endDefmac
2960 @Defmac {XP, , ms}
2961 Sets a paragraph whose lines are indented,
2962 except for the first line.
2963 This is a Berkeley extension.
2964 @endDefmac
2966 The following markup uses all four paragraph macros.
2968 @Example
2969 @cartouche
2970 .NH 2
2971 Cases used in the study
2973 The following software and versions were
2974 considered for this report.
2976 For commercial software, we chose
2977 .B "Microsoft Word for Windows" ,
2978 starting with version 1.0 through the
2979 current version (Word 2000).
2981 For free software, we chose
2982 .B Emacs ,
2983 from its first appearance as a standalone
2984 editor through the current version (v20).
2985 See [Bloggs 2002] for details.
2987 Franklin's Law applied to software:
2988 software expands to outgrow both
2989 RAM and disk space over time.
2991 Bibliography:
2993 Bloggs, Joseph R.,
2994 .I "Everyone's a Critic" ,
2995 Underground Press, March 2002.
2996 A definitive work that answers all questions
2997 and criticisms about the quality and usability of
2998 free software.
3000 @end cartouche
3001 @endExample
3003 @c ---------------------------------------------------------------------
3005 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3006 @subsubsection Headings
3007 @cindex @file{ms}, heading macros
3009 Use headings to create a hierarchical structure for your document.
3010 The @file{ms} macros print headings in @strong{bold},
3011 using the same font family and point size as the body text.
3013 The following describes the heading macros:
3015 @DefmacList {NH, @Var{curr-level}, ms}
3016 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3017 Numbered heading.
3018 The argument is either a numeric argument to indicate the
3019 level of the heading, or the letter@w{ }@code{S} followed by numeric
3020 arguments to set the heading level explicitly.
3022 If you specify heading levels out of sequence, such as invoking
3023 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
3024 prints a warning on standard error.
3025 @endDefmac
3027 @Defmac {SH, , ms}
3028 Unnumbered subheading.
3029 @endDefmac
3031 @c ---------------------------------------------------------------------
3033 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3034 @subsubsection Highlighting
3035 @cindex @file{ms}, highlighting macros
3037 The @file{ms} macros provide a variety of methods to highlight
3038 or emphasize text:
3040 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3041 Sets its first argument in @strong{bold type}.
3042 If you specify a second argument, @code{groff} prints it in the
3043 previous font after the bold text, with no intervening space
3044 (this allows you to set punctuation after the highlighted text
3045 without highlighting the punctuation).
3046 Similarly, it prints the third argument (if any) in the previous
3047 font @strong{before} the first argument.
3048 For example,
3050 @Example
3051 .B foo ) (
3052 @endExample
3054 prints (@strong{foo}).
3056 If you give this macro no arguments, @code{groff}
3057 prints all text following in bold until
3058 the next highlighting, paragraph, or heading macro.
3059 @endDefmac
3061 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3062 Sets its first argument in roman (or regular) type.
3063 It operates similarly to the @code{B}@w{ }macro otherwise.
3064 @endDefmac
3066 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3067 Sets its first argument in @emph{italic type}.
3068 It operates similarly to the @code{B}@w{ }macro otherwise.
3069 @endDefmac
3071 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3072 Sets its first argument in a @code{constant width face}.
3073 It operates similarly to the @code{B}@w{ }macro otherwise.
3074 @endDefmac
3076 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3077 Sets its first argument in bold italic type.
3078 It operates similarly to the @code{B}@w{ }macro otherwise.
3079 @endDefmac
3081 @Defmac {BX, [@Var{txt}], ms}
3082 Prints its argument and draws a box around it.
3083 If you want to box a string that contains spaces,
3084 use a digit-width space (@code{\0}).
3085 @endDefmac
3087 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3088 Prints its first argument with an underline.
3089 If you specify a second argument, @code{groff}
3090 prints it in the previous font after
3091 the underlined text, with no intervening space.
3092 @endDefmac
3094 @Defmac {LG, , ms}
3095 Prints all text following in larger type
3096 (two points larger than the current point size) until
3097 the next font size, highlighting, paragraph, or heading macro.
3098 You can specify this macro multiple times
3099 to enlarge the point size as needed.
3100 @endDefmac
3102 @Defmac {SM, , ms}
3103 Prints all text following in smaller type
3104 (two points smaller than the current point size) until
3105 the next type size, highlighting, paragraph, or heading macro.
3106 You can specify this macro multiple times
3107 to reduce the point size as needed.
3108 @endDefmac
3110 @Defmac {NL, , ms}
3111 Prints all text following in the normal point size
3112 (that is, the value of the @code{PS} register).
3113 @endDefmac
3115 @c ---------------------------------------------------------------------
3117 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
3118 @subsubsection Lists
3119 @cindex @file{ms}, list macros
3121 The @code{.IP} macro handles duties for all lists.
3123 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3124 The @var{marker} is usually a bullet character (@code{\[bu]})
3125 for unordered lists, a number (or auto-incrementing number
3126 register) for numbered lists, or a word or phrase for indented
3127 (glossary-style) lists.
3129 The @var{width} specifies the indent for the body of each list item;
3130 its default unit is @samp{n}.
3131 Once specified, the indent remains the same for all
3132 list items in the document until specified again.
3133 @endDefmac
3135 The following is an example of a bulleted list.
3136 @cindex Example markup, bulleted list (ms)
3137 @cindex Bulleted list, example markup (ms)
3139 @Example
3140 A bulleted list:
3141 .IP \[bu] 2
3142 lawyers
3143 .IP \[bu]
3144 guns
3145 .IP \[bu]
3146 money
3147 @endExample
3149 Produces:
3151 @Example
3152 A bulleted list:
3154 o lawyers
3156 o guns
3158 o money
3159 @endExample
3161 @sp 1
3163 The following is an example of a numbered list.
3164 @cindex Example markup, numbered list (ms)
3165 @cindex Numbered list, example markup (ms)
3167 @Example
3168 .nr step 1 1
3169 A numbered list:
3170 .IP \n[step] 3
3171 lawyers
3172 .IP \n+[step]
3173 guns
3174 .IP \n+[step]
3175 money
3176 @endExample
3178 Produces:
3180 @Example
3181 A numbered list:
3183 1. lawyers
3185 2. guns
3187 3. money
3188 @endExample
3190 Note the use of the auto-incrementing number
3191 register in this example.
3193 @sp 1
3194 The following is an example of a glossary-style list.
3195 @cindex Example markup, glossary-style list (ms)
3196 @cindex Glossary-style list, example markup (ms)
3198 @Example
3199 A glossary-style list:
3200 .IP lawyers 0.4i
3201 Two or more attorneys.
3202 .IP guns
3203 Firearms, preferably
3204 large-caliber.
3205 .IP money
3206 Gotta pay for those
3207 lawyers and guns!
3208 @endExample
3210 Produces:
3212 @Example
3213 A glossary-style list:
3215 lawyers
3216       Two or more attorneys.
3218 guns  Firearms, preferably large-caliber.
3220 money
3221       Gotta pay for those lawyers and guns!
3222 @endExample
3224 In the last example, the @code{IP} macro places the definition
3225 on the same line as the term if it has enough space; otherwise,
3226 it breaks to the next line and starts the definition below the
3227 term.
3228 This may or may not be the effect you want, especially if some
3229 of the definitions break and some do not.
3230 The following examples show two possible ways to force a break.
3232 The first workaround uses the @code{.br}
3233 request to force a break after printing the term or label.
3235 @Example
3236 @cartouche
3237 A glossary-style list:
3238 .IP lawyers 0.4i
3239 Two or more attorneys.
3240 .IP guns
3242 Firearms, preferably large-caliber.
3243 .IP money
3244 Gotta pay for those lawyers and guns!
3245 @end cartouche
3246 @endExample
3248 @sp 1
3249 The second workaround uses the @code{\p} escape to force the break.
3250 Note the space following the escape; this is important.
3251 If you omit the space, @code{groff} prints the first word on
3252 the same line as the term or label (if it fits) @strong{then}
3253 breaks the line.
3255 @Example
3256 @cartouche
3257 A glossary-style list:
3258 .IP lawyers 0.4i
3259 Two or more attorneys.
3260 .IP guns
3261 \p Firearms, preferably large-caliber.
3262 .IP money
3263 Gotta pay for those lawyers and guns!
3264 @end cartouche
3265 @endExample
3267 @sp 1
3268 To set nested lists, use the @code{RS} and @code{RE} macros.
3269 @xref{Indents in ms}, for more information.
3270 @cindex @file{ms}, nested lists
3271 @cindex Nested lists (ms)
3273 For example:
3275 @Example
3276 @cartouche
3277 .IP \[bu] 2
3278 Lawyers:
3280 .IP \[bu]
3281 Dewey,
3282 .IP \[bu]
3283 Cheatham,
3284 .IP \[bu]
3285 and Howe.
3287 .IP \[bu]
3288 Guns
3289 @end cartouche
3290 @endExample
3292 Produces:
3294 @Example
3295 o Lawyers:
3297   o  Dewey,
3299   o  Cheatham,
3301   o  and Howe.
3303 o Guns
3304 @endExample
3306 @c ---------------------------------------------------------------------
3308 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3309 @subsubsection Indents
3311 In many situations,
3312 you may need to indent a section of text
3313 while still wrapping and filling.
3314 @xref{Lists in ms},
3315 for an example of nested lists.
3317 @DefmacList {RS, , ms}
3318 @DefmacListEnd {RE, , ms}
3319 These macros begin and end an indented section.
3320 The @code{PI} register controls the amount of indent,
3321 allowing the indented text to line up under hanging
3322 and indented paragraphs.
3323 @endDefmac
3325 @xref{ms Displays and Keeps},
3326 for macros to indent and turn off filling.
3328 @c ---------------------------------------------------------------------
3330 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3331 @subsubsection Tab Stops
3333 Use the @code{ta} request to define tab stops as needed.
3334 @xref{Tabs and Fields}.
3336 @Defmac{TA, , ms}
3337 Use this macro to reset the tab stops to the default for @file{ms}
3338 (every 5n).
3339 You can redefine the @code{TA} macro to create a different set
3340 of default tab stops.
3341 @endDefmac
3343 @c ---------------------------------------------------------------------
3345 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3346 @subsubsection Displays and keeps
3347 @cindex @file{ms}, displays
3348 @cindex @file{ms}, keeps
3349 @cindex Keeps (ms)
3350 @cindex Displays (ms)
3352 Use displays to show text-based examples or figures
3353 (such as code listings).
3355 Displays turn off filling, so lines of code are displayed
3356 as-is without inserting @code{br} requests in between each line.
3357 Displays can be @dfn{kept} on a single page, or allowed
3358 to break across pages.
3360 @DefmacList {DS, @t{L}, ms}
3361 @DefmacItem {LD, , ms}
3362 @DefmacListEnd {DE, , ms}
3363 Left-justified display.
3364 The @samp{.DS L} call generates a page break, if necessary,
3365 to keep the entire display on one page.
3366 The @code{LD} macro allows the display to break across pages.
3367 The @code{DE} macro ends the display.
3368 @endDefmac
3370 @DefmacList {DS, @t{I}, ms}
3371 @DefmacItem {ID, , ms}
3372 @DefmacListEnd {DE, , ms}
3373 Indents the display as defined by the @code{DI} register.
3374 The @samp{.DS I} call generates a page break, if necessary,
3375 to keep the entire display on one page.
3376 The @code{ID} macro allows the display to break across pages.
3377 The @code{DE} macro ends the display.
3378 @endDefmac
3380 @DefmacList {DS, @t{B}, ms}
3381 @DefmacItem {BD, , ms}
3382 @DefmacListEnd {DE, , ms}
3383 Sets a block-centered display: the entire display is left-justified,
3384 but indented so that the longest line in the display is centered
3385 on the page.
3386 The @samp{.DS B} call generates a page break, if necessary,
3387 to keep the entire display on one page.
3388 The @code{BD} macro allows the display to break across pages.
3389 The @code{DE} macro ends the display.
3390 @endDefmac
3392 @DefmacList {DS, @t{C}, ms}
3393 @DefmacItem {CD, , ms}
3394 @DefmacListEnd {DE, , ms}
3395 Sets a centered display: each line in the display is centered.
3396 The @samp{.DS C} call generates a page break, if necessary,
3397 to keep the entire display on one page.
3398 The @code{CD} macro allows the display to break across pages.
3399 The @code{DE} macro ends the display.
3400 @endDefmac
3402 @DefmacList {DS, @t{R}, ms}
3403 @DefmacItem {RD, , ms}
3404 @DefmacListEnd {DE, , ms}
3405 Right-justifies each line in the display.
3406 The @samp{.DS R} call generates a page break, if necessary,
3407 to keep the entire display on one page.
3408 The @code{RD} macro allows the display to break across pages.
3409 The @code{DE} macro ends the display.
3410 @endDefmac
3412 @sp 1
3413 On occasion, you may want to @dfn{keep} other text together on a page.
3414 For example, you may want to keep two paragraphs together, or
3415 a paragraph that refers to a table (or list, or other item)
3416 immediately following.
3417 The @file{ms} macros provide the @code{KS} and @code{KE}
3418 macros for this purpose.
3420 @DefmacList {KS, , ms}
3421 @DefmacListEnd {KE, , ms}
3422 The @code{KS} macro begins a block of text to be kept on a
3423 single page, and the @code{KE} macro ends the block.
3424 @endDefmac
3426 @DefmacList {KF, , ms}
3427 @DefmacListEnd {KE, , ms}
3428 Specifies a @dfn{floating keep};
3429 if the keep cannot fit on the current page, @code{groff}
3430 holds the contents of the keep and allows text following
3431 the keep (in the source file) to fill in the remainder of
3432 the current page.
3433 When the page breaks, whether by an explicit @code{bp}
3434 request or by reaching the end of the page, @code{groff}
3435 prints the floating keep at the top of the new page.
3436 This is useful for printing large graphics or tables
3437 that do not need to appear exactly where specified.
3438 @endDefmac
3440 You can also use the @code{ne} request to force a page break if
3441 there is not enough vertical space remaining on the page.
3443 @sp 1
3444 Use the following macros to draw a box around a section of
3445 text (such as a display).
3447 @DefmacList {B1, , ms}
3448 @DefmacListEnd {B2, , ms}
3449 Marks the beginning and ending of text that is to have a
3450 box drawn around it.
3451 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3452 Text in the box is automatically placed in a diversion (keep).
3453 @endDefmac
3455 @c ---------------------------------------------------------------------
3457 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3458 @subsubsection Tables, figures, equations, and references
3459 @cindex @file{ms}, tables
3460 @cindex @file{ms}, figures
3461 @cindex @file{ms}, equations
3462 @cindex @file{ms}, references
3463 @cindex Tables (ms)
3464 @cindex Figures (ms)
3465 @cindex Equations (ms)
3466 @cindex References (ms)
3468 The @file{ms} macros support the standard
3469 @code{groff} preprocessors:
3470 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3471 @pindex tbl
3472 @pindex pic
3473 @pindex eqn
3474 @pindex refer
3475 You mark text meant for preprocessors by enclosing it
3476 in pairs of tags as follows.
3478 @DefmacList {TS, [@code{H}], ms}
3479 @DefmacListEnd {TE, , ms}
3480 Denotes a table, to be processed by the @code{tbl} preprocessor.
3481 The optional argument@w{ }@code{H} to @code{TS} instructs @code{groff}
3482 to create a running header with the information
3483 up to the @code{TH} macro.
3484 @code{groff} prints the header at the beginning of the
3485 table; if the table runs onto another page, @code{groff}
3486 prints the header on the next page as well.
3487 @endDefmac
3489 @DefmacList {PS, , ms}
3490 @DefmacListEnd {PE, , ms}
3491 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3492 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3493 @code{pic} manual available on the Web as a reference, or by using
3494 a graphics program such as @code{xfig}.
3495 @endDefmac
3497 @DefmacList {EQ, [@Var{align}], ms}
3498 @DefmacListEnd {EN, , ms}
3499 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3500 The optional @var{align} argument can be @code{C}, @code{L}, or@w{
3501 }@code{I} to center (the default), left-justify, or indent the equation.
3502 @endDefmac
3504 @DefmacList {[, , ms}
3505 @DefmacListEnd {], , ms}
3506 Denotes a reference, to be processed by the @code{refer} preprocessor.
3507 The @acronym{GNU} @cite{refer(1)} manpage provides a comprehensive
3508 reference to the preprocessor and the format of the bibliographic
3509 database.
3510 @endDefmac
3512 @menu
3513 * Example multi-page table::
3514 @end menu
3516 @c ---------------------------------------------------------------------
3518 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3519 @subsubsection An example multi-page table
3520 @cindex Example markup, multi-page table (ms)
3521 @cindex Multi-page table, example markup (ms)
3523 The following is an example of how to set up a
3524 table that may print across two or more pages.
3526 @Example
3527 @cartouche
3528 .TS H
3529 allbox expand;
3530 cb | cb .
3531 Text      ...of heading...
3535 l | l .
3536 ... the rest of the table follows...
3539 @end cartouche
3540 @endExample
3542 @c ---------------------------------------------------------------------
3544 @node ms Footnotes,  , Example multi-page table, ms Body Text
3545 @subsubsection Footnotes
3546 @cindex @file{ms}, footnotes
3547 @cindex Footnotes (ms)
3549 The @file{ms} macro package has a flexible footnote system.
3550 You can specify either numbered footnotes or symbolic footnotes
3551 (that is, using a marker such as a dagger symbol).
3553 @Defstr {*, ms}
3554 Specifies the location of a numbered footnote marker in the text.
3555 @endDefesc
3557 @DefmacList {FS, , ms}
3558 @DefmacListEnd {FE, , ms}
3559 Specifies the text of the footnote.
3560 The default action is to create a numbered footnote;
3561 you can create a symbolic footnote by specifying
3562 a @dfn{mark} character
3563 (such as @code{\[dg]} for the dagger character)
3564 in the body text and as an argument to the @code{FS} macro,
3565 followed by the text of the footnote
3566 and the @code{FE} macro.
3567 @endDefmac
3569 You can control how @code{groff}
3570 prints footnote numbers by changing the value of the
3571 @code{FF} register.  @xref{ms Document Control Registers}.
3573 @c ---------------------------------------------------------------------
3575 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3576 @subsection Page layout
3577 @cindex @file{ms}, page layout
3578 @cindex Page layout (ms)
3580 The default output from the @file{ms}
3581 macros provides a minimalist page layout:
3582 it prints a single column, with the page number centered at the top
3583 of each page.
3584 It prints no footers.
3586 You can change the layout by setting
3587 the proper number registers and strings.
3589 @menu
3590 * ms Headers and Footers::
3591 * ms Margins::
3592 * ms Multiple Columns::
3593 * ms TOC::
3594 * ms Strings and Special Characters::
3595 @end menu
3597 @c ---------------------------------------------------------------------
3599 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3600 @subsubsection Headers and footers
3601 @cindex @file{ms}, headers
3602 @cindex @file{ms}, footers
3603 @cindex Headers (ms)
3604 @cindex Footers (ms)
3606 For documents that do not distinguish between odd and even pages,
3607 set the following strings:
3609 @DefstrList {LH, ms}
3610 @DefstrItem {CH, ms}
3611 @DefstrListEnd {RH, ms}
3612 Sets the left, center, and right headers.
3613 @endDefstr
3615 @DefstrList {LF, ms}
3616 @DefstrItem {CF, ms}
3617 @DefstrListEnd {RF, ms}
3618 Sets the left, center, and right footers.
3619 @endDefstr
3621 @sp 1
3622 For documents that need different information printed in the
3623 even and odd pages, use the following macros:
3625 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3626 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3627 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3628 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3629 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3630 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3631 This is more flexible than defining the individual strings.
3633 You can replace the quote (@code{'}) marks with any character not
3634 appearing in the header or footer text.
3635 @endDefmac
3637 @c ---------------------------------------------------------------------
3639 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3640 @subsubsection Margins
3641 @cindex @file{ms}, margins
3643 You control margins using a set of number registers.
3644 @xref{ms Document Control Registers}, for details.
3646 @c ---------------------------------------------------------------------
3648 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3649 @subsubsection Multiple columns
3650 @cindex @file{ms}, multiple columns
3651 @cindex Multiple columns (ms)
3653 The @file{ms} macros can set text in as many columns as will
3654 reasonably fit on the page.
3655 The following macros are available;
3656 all of them force a page break if a multi-column mode is already set.
3657 However, if the current mode is single-column, starting a multi-column
3658 mode does @strong{not} force a page break.
3660 @Defmac {1C, , ms}
3661 Single-column mode.
3662 @endDefmac
3664 @Defmac {2C, , ms}
3665 Two-column mode.
3666 @endDefmac
3668 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3669 Multi-column mode.
3670 If you specify no arguments, it is equivalent to the
3671 @code{.2C} macro.
3672 Otherwise, @var{width} is the width of each column and
3673 @var{gutter} is the space between columns.
3674 The @code{MINGW} number register controls the default gutter width.
3675 @endDefmac
3677 @c ---------------------------------------------------------------------
3679 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3680 @subsubsection Creating a table of contents
3681 @cindex @file{ms}, creating table of contents
3682 @cindex Table of contents, creating (ms)
3684 The facilities in the @file{ms} macro package for creating
3685 a table of contents are semi-automated at best.
3686 Assuming that you want the table of contents to consist of
3687 the document's headings, you need to repeat those headings
3688 wrapped in @code{XS} and @code{XE} macros.
3690 @DefmacList {XS, [@Var{page}], ms}
3691 @DefmacItem {XA, [@Var{page}], ms}
3692 @DefmacListEnd {XE, , ms}
3693 These macros define a table of contents
3694 or an individual entry in the table of contents,
3695 depending on their use.
3696 The macros are very simple; they cannot indent a heading based on its level.
3697 The easiest way to work around this is to add tabs
3698 to the table of contents string.
3699 The following is an example:
3701 @Example
3702 @cartouche
3703 .NH 1
3704 Introduction
3706 Introduction
3711 .NH 2
3712 Methodology
3714         Methodology
3718 @end cartouche
3719 @endExample
3721 You can manually create a table of contents
3722 by beginning with the @code{XS} macro for the first entry,
3723 specifying the page number for that entry as the argument to @code{XS}.
3724 Add subsequent entries using the @code{XA} macro,
3725 specifying the page number for that entry as the argument to @code{XA}.
3726 The following is an example:
3728 @Example
3729 @cartouche
3730 .XS 1
3731 Introduction
3732 .XA 2
3733 A Brief History of the Universe
3734 .XA 729
3735 Details of Galactic Formation
3738 @end cartouche
3739 @endExample
3740 @endDefmac
3742 @Defmac {TC, [@code{no}], ms}
3743 Prints the table of contents on a new page,
3744 setting the page number to@w{ }@strong{i} (Roman numeral one).
3745 You should usually place this macro at the end of the
3746 file, since @code{groff} is a single-pass formatter and
3747 can only print what has been collected up to the point
3748 that the @code{TC} macro appears.
3750 The optional argument @code{no} suppresses printing
3751 the title specified by the string register @code{TOC}.
3752 @endDefmac
3754 @Defmac{PX, [@code{no}], ms}
3755 Prints the table of contents on a new page,
3756 using the current page numbering sequence.
3757 Use this macro to print a manually-generated table of contents
3758 at the beginning of your document.
3760 The optional argument @code{no} suppresses printing
3761 the title specified by the string register @code{TOC}.
3762 @endDefmac
3764 The @cite{Groff and Friends HOWTO}
3765 includes a @code{sed} script that automatically inserts
3766 @code{XS} and @code{XE} macro entries after each heading in a document.
3768 Altering the @code{NH} macro to automatically build the table
3769 of contents is perhaps initially more difficult, but would save
3770 a great deal of time in the long run if you use @file{ms} regularly.
3772 @c ---------------------------------------------------------------------
3774 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3775 @subsubsection Strings and Special Characters
3776 @cindex @file{ms}, strings
3777 @cindex @file{ms}, special characters
3778 @cindex @file{ms}, accent marks
3779 @cindex Accent marks
3780 @cindex Special characters
3781 @cindex Strings in @file{ms}
3783 The @file{ms} macros provide the following predefined strings.
3784 You can change the string definitions to help in creating
3785 documents in languages other than English.
3787 @Defstr {REFERENCES, ms}
3788 Contains the string printed at the beginning of the
3789 references (bibliography) page.
3790 The default is @samp{References}.
3791 @endDefstr
3793 @Defstr {ABSTRACT, ms}
3794 Contains the string printed at the beginning of the abstract.
3795 The default is @samp{ABSTRACT}.
3796 @endDefstr
3798 @Defstr {TOC, ms}
3799 Contains the string printed at the beginning of the table of contents.
3800 @endDefstr
3802 @DefstrList {MONTH1, ms}
3803 @DefstrItem {MONTH2, ms}
3804 @DefstrItem {MONTH3, ms}
3805 @DefstrItem {MONTH4, ms}
3806 @DefstrItem {MONTH5, ms}
3807 @DefstrItem {MONTH6, ms}
3808 @DefstrItem {MONTH7, ms}
3809 @DefstrItem {MONTH8, ms}
3810 @DefstrItem {MONTH9, ms}
3811 @DefstrItem {MONTH10, ms}
3812 @DefstrItem {MONTH11, ms}
3813 @DefstrListEnd {MONTH12, ms}
3814 Prints the full name of the month in dates.
3815 The default is @samp{January}, @samp{February}, etc.
3816 @endDefstr
3818 The following special characters are available:
3820 @Defstr {-, ms}
3821 Prints an em dash.
3822 @endDefstr
3824 @DefstrList {*Q, ms}
3825 @DefstrListEnd {*U, ms}
3826 Prints typographer's quotes in troff,
3827 plain quotes in nroff.
3828 @code{*Q} is the left quote and @code{*U} is the right quote.
3829 @endDefstr
3831 Improved accent marks are available in the @file{ms} macros.
3833 @Defmac {AM, , ms}
3834 Specify this macro at the beginning of your document
3835 to enable extended accent marks and special characters.
3836 This is a Berkeley extension.
3838 To use the accent marks, place them @strong{after}
3839 the character being accented.
3840 @endDefmac
3842 The following accent marks are available
3843 after invoking the @code{AM} macro:
3845 @Defstr {\', ms}
3846 Acute accent.
3847 @endDefstr
3849 @Defstr {\`, ms}
3850 Grave accent.
3851 @endDefstr
3853 @Defstr {^, ms}
3854 Circumflex.
3855 @endDefstr
3857 @Defstr {\,, ms}
3858 Cedilla.
3859 @endDefstr
3861 @Defstr {~, ms}
3862 Tilde.
3863 @endDefstr
3865 @deffn String @t{\*[:]}
3866 @ifnotinfo
3867 @stindex : @r{[}ms@r{]}
3868 @end ifnotinfo
3869 @ifinfo
3870 @stindex @r{<colon>} @r{[}ms@r{]}
3871 @end ifinfo
3872 Umlaut.
3873 @end deffn
3875 @Defstr {v, ms}
3876 Hacek.
3877 @endDefstr
3879 @Defstr {_, ms}
3880 Macron (overbar).
3881 @endDefstr
3883 @Defstr {., ms}
3884 Underdot.
3885 @endDefstr
3887 @Defstr {o, ms}
3888 Ring above.
3889 @endDefstr
3891 The following are standalone characters
3892 available after invoking the @code{AM} macro:
3894 @Defstr {?, ms}
3895 Upside-down question mark.
3896 @endDefstr
3898 @Defstr {!, ms}
3899 Upside-down exclamation point.
3900 @endDefstr
3902 @Defstr {8, ms}
3903 German @ss{} ligature.
3904 @endDefstr
3906 @Defstr {3, ms}
3907 Yogh.
3908 @endDefstr
3910 @Defstr {Th, ms}
3911 Uppercase thorn.
3912 @endDefstr
3914 @Defstr {th, ms}
3915 Lowercase thorn.
3916 @endDefstr
3918 @Defstr {D-, ms}
3919 Uppercase eth.
3920 @endDefstr
3922 @Defstr {d-, ms}
3923 Lowercase eth.
3924 @endDefstr
3926 @Defstr {q, ms}
3927 Hooked o.
3928 @endDefstr
3930 @Defstr {ae, ms}
3931 Lowercase @ae{} ligature.
3932 @endDefstr
3934 @Defstr {Ae, ms}
3935 Uppercase @AE{} ligature.
3936 @endDefstr
3938 @c ---------------------------------------------------------------------
3940 @node Differences from AT&T ms,  , ms Page Layout, ms
3941 @subsection Differences from @acronym{AT&T} @file{ms}
3942 @cindex @file{ms}, differences from @acronym{AT&T}
3943 @cindex @acronym{AT&T}, @code{ms} differences
3945 This section lists the (minor) differences between the
3946 @code{groff -ms} macros and @acronym{AT&T}
3947 @code{troff -ms} macros.
3949 @menu
3950 * Missing ms Macros::
3951 * Additional ms Macros::
3952 @end menu
3954 @c ---------------------------------------------------------------------
3956 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3957 @subsubsection @code{troff} macros not appearing in @code{groff}
3959 Macros missing from @code{groff -ms}
3960 are cover page macros specific to Bell Labs.
3961 The macros known to be missing are:
3963 @table @code
3964 @item .TM
3965 Technical memorandum; a cover sheet style
3967 @item .IM
3968 Internal memorandum; a cover sheet style
3970 @item .MR
3971 Memo for record; a cover sheet style
3973 @item .MF
3974 Memo for file; a cover sheet style
3976 @item .EG
3977 Engineer's notes; a cover sheet style
3979 @item .TR
3980 Computing Science Tech Report; a cover sheet style
3982 @item .OK
3983 Other keywords
3985 @item .CS
3986 Cover sheet information
3988 @item .MH
3989 A cover sheet macro
3990 @end table
3992 @c ---------------------------------------------------------------------
3994 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
3995 @subsubsection @code{groff} macros not appearing in AT&T @code{troff}
3997 The @code{groff -ms} macros have a few minor extensions
3998 compared to the @acronym{AT&T} @code{troff -ms} macros.
4000 @Defmac {AM, , ms}
4001 Improved accent marks.
4002 @xref{ms Strings and Special Characters}, for details.
4003 @endDefmac
4005 @Defmac {DS, @t{I}, ms}
4006 Indented display.
4007 The default behavior of @acronym{AT&T} @code{troff -ms}
4008 was to indent; the @code{groff} default prints displays
4009 flush left with the body text.
4010 @endDefmac
4012 @Defmac {CW, , ms}
4013 Print text in @code{constant width} (Courier) font.
4014 @endDefmac
4016 @Defmac {IX, , ms}
4017 Indexing term (printed on standard error).
4018 You can write a script to capture and process an index
4019 generated in this manner.
4020 @endDefmac
4022 @sp 1
4023 The following additional number registers
4024 appear in @code{groff -ms}:
4026 @Defmpreg {MINGW, ms}
4027 Specifies a minimum space
4028 between columns (for multi-column output); this takes the
4029 place of the @code{GW} register that was documented but apparently
4030 not implemented in @acronym{AT&T} @code{troff}.
4031 @endDefmpreg
4033 @sp 1
4034 Several new string registers are available as well.
4035 You can change these to handle (for example) the local language.
4036 @xref{ms Strings and Special Characters}, for details.
4039 @c =====================================================================
4041 @node me, mm, ms, Macro Packages
4042 @section @file{me}
4043 @cindex @file{me}
4045 @c XXX documentation
4046 @c XXX this is a placeholder until we get stuff knocked into shape
4047 See the @file{meintro.me} and @file{meref.me} documents in
4048 groff's @file{doc} directory.
4051 @c =====================================================================
4053 @node mm,  , me, Macro Packages
4054 @section @file{mm}
4055 @cindex @file{mm}
4057 @c XXX documentation
4058 @c XXX this is a placeholder until we get stuff knocked into shape
4059 See the @code{mm} manpage (type @command{man 7 groff_mm} at
4060 the command line).
4063 @c =====================================================================
4064 @c =====================================================================
4066 @node gtroff Reference, Preprocessors, Macro Packages, Top
4067 @chapter @code{gtroff} Reference
4068 @cindex reference, @code{gtroff}
4069 @cindex @code{gtroff} reference
4071 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4072 Users of macro packages may skip it if not interested in details.
4075 @menu
4076 * Text::
4077 * Input Conventions::
4078 * Measurements::
4079 * Expressions::
4080 * Identifiers::
4081 * Embedded Commands::
4082 * Registers::
4083 * Manipulating Filling and Adjusting::
4084 * Manipulating Hyphenation::
4085 * Manipulating Spacing::
4086 * Tabs and Fields::
4087 * Character Translations::
4088 * Troff and Nroff Mode::
4089 * Line Layout::
4090 * Line Control::
4091 * Page Layout::
4092 * Page Control::
4093 * Fonts::
4094 * Sizes::
4095 * Strings::
4096 * Conditionals and Loops::
4097 * Writing Macros::
4098 * Page Motions::
4099 * Drawing Requests::
4100 * Traps::
4101 * Diversions::
4102 * Environments::
4103 * Suppressing output::
4104 * Colors::
4105 * I/O::
4106 * Postprocessor Access::
4107 * Miscellaneous::
4108 * Gtroff Internals::
4109 * Debugging::
4110 * Implementation Differences::
4111 * Summary::
4112 @end menu
4115 @c =====================================================================
4117 @node Text, Input Conventions, gtroff Reference, gtroff Reference
4118 @section Text
4119 @cindex text, @code{gtroff} processing
4121 @code{gtroff} input files contain text with control commands
4122 interspersed throughout.  But, even without control codes, @code{gtroff}
4123 still does several things with the input text:
4125 @itemize @bullet
4126 @item
4127 filling and adjusting
4129 @item
4130 adding additional space after sentences
4132 @item
4133 hyphenating
4135 @item
4136 inserting implicit line breaks
4137 @end itemize
4139 @menu
4140 * Filling and Adjusting::
4141 * Hyphenation::
4142 * Sentences::
4143 * Tab Stops::
4144 * Implicit Line Breaks::
4145 @end menu
4147 @c ---------------------------------------------------------------------
4149 @node Filling and Adjusting, Hyphenation, Text, Text
4150 @subsection Filling and Adjusting
4151 @cindex filling
4152 @cindex adjusting
4154 When @code{gtroff} reads text, it collects words from the input and fits
4155 as many of them together on one output line as it can.  This is known as
4156 @dfn{filling}.
4158 @cindex leading spaces
4159 @cindex spaces, leading and trailing
4160 @cindex extra spaces
4161 @cindex trailing spaces
4162 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
4163 it.  This means it widens the spacing between words until the text
4164 reaches the right margin (in the default adjustment mode).  Extra spaces
4165 between words are preserved, but spaces at the end of lines are ignored.
4166 Spaces at the front of a line cause a @dfn{break} (breaks are
4167 explained in @ref{Implicit Line Breaks}).
4169 @xref{Manipulating Filling and Adjusting}.
4171 @c ---------------------------------------------------------------------
4173 @node Hyphenation, Sentences, Filling and Adjusting, Text
4174 @subsection Hyphenation
4175 @cindex hyphenation
4177 Since the odds are not great for finding a set of words, for every
4178 output line, which fit nicely on a line without inserting excessive
4179 amounts of space between words, @code{gtroff} hyphenates words so
4180 that it can justify lines without inserting too much space between
4181 words.  It uses an internal hyphenation algorithm (a simplified version
4182 of the algorithm used within @TeX{}) to indicate which words can be
4183 hyphenated and how to do so.  When a word is hyphenated, the first part
4184 of the word is added to the current filled line being output (with
4185 an attached hyphen), and the other portion is added to the next
4186 line to be filled.
4188 @xref{Manipulating Hyphenation}.
4190 @c ---------------------------------------------------------------------
4192 @node Sentences, Tab Stops, Hyphenation, Text
4193 @subsection Sentences
4194 @cindex sentences
4196 Although it is often debated, some typesetting rules say there should be
4197 different amounts of space after various punctuation marks.  For
4198 example, the @cite{Chicago typsetting manual} says that a period at the
4199 end of a sentence should have twice as much space following it as would
4200 a comma or a period as part of an abbreviation.
4202 @c XXX exact citation of Chicago manual
4204 @cindex sentence space
4205 @cindex space between sentences
4206 @cindex french-spacing
4207 @code{gtroff} does this by flagging certain characters (normally
4208 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4209 When @code{gtroff} encounters one of these characters at the end of a
4210 line, it appends a normal space followed by a @dfn{sentence space} in
4211 the formatted output.  (This justifies one of the conventions mentioned
4212 in @ref{Input Conventions}.)
4214 @cindex transparent characters
4215 @cindex character, transparent
4216 @cindex @code{dg} glyph, at end of sentence
4217 @cindex @code{rq} glyph, at end of sentence
4218 @cindex @code{"}, at end of sentence
4219 @cindex @code{'}, at end of sentence
4220 @cindex @code{)}, at end of sentence
4221 @cindex @code{]}, at end of sentence
4222 @cindex @code{*}, at end of sentence
4223 In addition, the following characters or glyphs are treated
4224 transparently while handling end-of-sentence characters: @samp{"},
4225 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{dg}, and @code{rq}.
4227 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4229 @cindex @code{\&}, at end of sentence
4230 To prevent the insertion of extra space after an end-of-sentence
4231 character (at the end of a line), append @code{\&}.
4233 @c ---------------------------------------------------------------------
4235 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4236 @subsection Tab Stops
4237 @cindex tab stops
4238 @cindex stops, tabulator
4239 @cindex tab character
4240 @cindex character, tabulator
4242 @cindex @acronym{EBCDIC} encoding
4243 @cindex encoding, @acronym{EBCDIC}
4244 @code{gtroff} translates @dfn{tabulator characters}, also called
4245 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4246 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4247 tabulator stop.  These tab stops are initially located every half inch
4248 across the page.  Using this, simple tables can be made easily.
4249 However, it can often be deceptive as the appearance (and width) of the
4250 text on a terminal and the results from @code{gtroff} can vary greatly.
4252 Also, a possible sticking point is that lines beginning with tab
4253 characters are still filled, again producing unexpected results.
4254 For example, the following input
4256 @multitable {12345678} {12345678} {12345678} {12345678}
4257 @item
4258 @tab 1 @tab 2 @tab 3
4259 @item
4260 @tab   @tab 4 @tab 5
4261 @end multitable
4263 @noindent
4264 produces
4266 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4267 @item
4268 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4269 @end multitable
4271 @xref{Tabs and Fields}.
4273 @c ---------------------------------------------------------------------
4275 @node Implicit Line Breaks,  , Tab Stops, Text
4276 @subsection Implicit Line Breaks
4277 @cindex implicit line breaks
4278 @cindex implicit breaks of lines
4279 @cindex line, implicit breaks
4280 @cindex break, implicit
4281 @cindex line break
4283 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4284 occurs, @code{gtroff} outputs the partially filled line
4285 (unjustified), and resumes collecting and filling text on the next output
4286 line.
4288 @cindex blank line
4289 @cindex empty line
4290 @cindex line, blank
4291 @cindex blank line macro (@code{blm})
4292 There are several ways to cause a break in @code{gtroff}.  A blank
4293 line not only causes a break, but it also outputs a one-line vertical
4294 space (effectively a blank line).  Note that this behaviour can be
4295 modified with the blank line macro request @code{blm}.
4296 @xref{Blank Line Traps}.
4298 @cindex fill mode
4299 @cindex mode, fill
4300 A line that begins with a space causes a break and the space is
4301 output at the beginning of the next line.  Note that this space isn't
4302 adjusted, even in fill mode.
4304 The end of file also causes a break -- otherwise the last line of
4305 the document may vanish!
4307 Certain requests also cause breaks, implicitly or explicitly.  This is
4308 discussed in @ref{Manipulating Filling and Adjusting}.
4311 @c =====================================================================
4313 @node Input Conventions, Measurements, Text, gtroff Reference
4314 @section Input Conventions
4315 @cindex input conventions
4316 @cindex conventions for input
4318 Since @code{gtroff} does filling automatically, it is traditional in
4319 @code{groff} not to try and type things in as nicely formatted
4320 paragraphs.  These are some conventions commonly used when typing
4321 @code{gtroff} text:
4323 @itemize @bullet
4324 @item
4325 Break lines after punctuation, particularly at the end of a sentence
4326 and in other logical places.  Keep separate phrases on lines by
4327 themselves, as entire phrases are often added or deleted when editing.
4329 @item
4330 Try to keep lines less than 40-60@w{ }characters, to allow space for
4331 inserting more text.
4333 @item
4334 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4335 don't try using spaces to get proper indentation).
4336 @end itemize
4339 @c =====================================================================
4341 @node Measurements, Expressions, Input Conventions, gtroff Reference
4342 @section Measurements
4343 @cindex measurements
4345 @cindex units of measurement
4346 @cindex basic unit (@code{u})
4347 @cindex machine unit (@code{u})
4348 @cindex measurement unit
4349 @cindex @code{u} unit
4350 @cindex unit, @code{u}
4351 @code{gtroff} (like many other programs) requires numeric parameters to
4352 specify various measurements.  Most numeric parameters@footnote{those
4353 that specify vertical or horizontal motion or a type size} may have a
4354 @dfn{measurement unit} attached.  These units are specified as a single
4355 character which immediately follows the number or expression.  Each of
4356 these units are understood, by @code{gtroff}, to be a multiple of its
4357 @dfn{basic unit}.  So, whenever a different measurement unit is
4358 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4359 basic unit, represented by a @samp{u}, is a device dependent measurement
4360 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4361 inch.  The values may be given as fractional numbers; however,
4362 fractional basic units are always rounded to integers.
4364 Some of the measurement units are completely independent of any of the
4365 current settings (e.g.@: type size) of @code{gtroff}.
4367 @table @code
4368 @item i
4369 @cindex inch unit (@code{i})
4370 @cindex @code{i} unit
4371 @cindex unit, @code{i}
4372 Inches.  An antiquated measurement unit still in use in certain
4373 backwards countries with incredibly low-cost computer equipment.  One
4374 inch is equal to@w{ }2.54@dmn{cm}.
4376 @item c
4377 @cindex centimeter unit (@code{c})
4378 @cindex @code{c} unit
4379 @cindex unit, @code{c}
4380 Centimeters.  One centimeter is equal to@w{ }0.3937@dmn{in}.
4382 @item p
4383 @cindex point unit (@code{p})
4384 @cindex @code{p} unit
4385 @cindex unit, @code{p}
4386 Points.  This is a typesetter's measurement used for measure type size.
4387 It is 72@w{ }points to an inch.
4389 @item P
4390 @cindex pica unit (@code{P})
4391 @cindex @code{P} unit
4392 @cindex unit, @code{P}
4393 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
4394 12@w{ }points to a pica).
4396 @item s
4397 @itemx z
4398 @cindex @code{s} unit
4399 @cindex unit, @code{s}
4400 @cindex @code{z} unit
4401 @cindex unit, @code{z}
4402 @xref{Fractional Type Sizes}, for a discussion of these units.
4404 @item f
4405 @cindex @code{f} unit
4406 @cindex unit, @code{f}
4407 Fractions. Value is 65536.
4408 @xref{Colors}, for usage.
4409 @end table
4411 The other measurements understood by @code{gtroff} depend on
4412 settings currently in effect in @code{gtroff}.  These are very useful
4413 for specifying measurements which should look proper with any size of
4414 text.
4416 @table @code
4417 @item m
4418 @cindex em unit (@code{m})
4419 @cindex @code{m} unit
4420 @cindex unit, @code{m}
4421 Ems.  This unit is equal to the current font size in points.  So called
4422 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
4423 in the current font.
4425 @item n
4426 @cindex en unit (@code{n})
4427 @cindex @code{n} unit
4428 @cindex unit, @code{n}
4429 Ens.  In @code{groff}, this is half of an em.
4431 @item v
4432 @cindex vertical space unit (@code{v})
4433 @cindex space, vertical, unit (@code{v})
4434 @cindex @code{v} unit
4435 @cindex unit, @code{v}
4436 Vertical space.  This is equivalent to the current line spacing.
4437 @xref{Sizes}, for more information about this.
4439 @item M
4440 @cindex @code{M} unit
4441 @cindex unit, @code{M}
4442 100ths of an em.
4443 @end table
4445 @menu
4446 * Default Units::
4447 @end menu
4449 @c ---------------------------------------------------------------------
4451 @node Default Units,  , Measurements, Measurements
4452 @subsection Default Units
4453 @cindex default units
4454 @cindex units, default
4456 Many requests take a default unit.  While this can be helpful at times,
4457 it can cause strange errors in some expressions.  For example, the line
4458 length request expects em units.  Here are several attempts to get a
4459 line length of 3.5@w{ }inches and their results:
4461 @Example
4462 3.5i      @result{}   3.5i
4463 7/2       @result{}   0i
4464 7/2i      @result{}   0i
4465 (7 / 2)u  @result{}   0i
4466 7i/2      @result{}   0.1i
4467 7i/2u     @result{}   3.5i
4468 @endExample
4470 @noindent
4471 Everything is converted to basic units first.  In the above example it
4472 is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m} equals@w{
4473 }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}).  The value 7@dmn{i}/2
4474 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4475 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4476 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4477 parenthesis is simply ignored.
4479 @cindex measurements, specifying safely
4480 Thus, the safest way to specify measurements is to always
4481 attach a scaling indicator.  If you want to multiply or divide by a
4482 certain scalar value, use @samp{u} as the unit for that value.
4485 @c =====================================================================
4487 @node Expressions, Identifiers, Measurements, gtroff Reference
4488 @section Expressions
4489 @cindex expressions
4491 @code{gtroff} has most arithmetic operators common to other languages:
4493 @c XXX more details; examples
4495 @itemize @bullet
4496 @item
4497 @cindex arithmetic operators
4498 @cindex operators, arithmetic
4499 @opindex +
4500 @opindex -
4501 @opindex /
4502 @opindex *
4503 @opindex %
4504 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4505 (division), @samp{*} (multiplication), @samp{%} (modulo).
4507 @code{gtroff} only provides integer arithmetic.  The internal type used
4508 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4509 signed integer.
4511 @item
4512 @cindex comparison operators
4513 @cindex operators, comparison
4514 @opindex <
4515 @opindex >
4516 @opindex >=
4517 @opindex <=
4518 @opindex =
4519 @opindex ==
4520 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4521 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4522 (equal), @samp{==} (the same as @samp{=}).
4524 @item
4525 @cindex logical operators
4526 @cindex operators, logical
4527 @opindex &
4528 @ifnotinfo
4529 @opindex :
4530 @end ifnotinfo
4531 @ifinfo
4532 @opindex @r{<colon>}
4533 @end ifinfo
4534 Logical: @samp{&} (logical and), @samp{:} (logical or).
4536 @item
4537 @cindex unary operators
4538 @cindex operators, unary
4539 @opindex -
4540 @opindex +
4541 @opindex !
4542 @cindex @code{if} request, and the @samp{!} operator
4543 @cindex @code{while} request, and the @samp{!} operator
4544 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4545 (just for completeness; does nothing in expressions), @samp{!} (logical
4546 not; this works only within @code{if} and @code{while} requests).  See
4547 below for the use of unary operators in motion requests.
4549 @item
4550 @cindex extremum operators
4551 @cindex operators, extremum
4552 @opindex >?
4553 @opindex <?
4554 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).  For example,
4555 @samp{5>?3} yields@w{ }@samp{5}.
4557 @c XXX add examples
4559 @item
4560 @cindex scaling operator
4561 @cindex operator, scaling
4562 Scaling: @code{(@var{c};@var{e})}.  Evaluate@w{ }@var{e} using@w{ }@var{c}
4563 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4564 indicators in the evaluation of@w{ }@var{e}.
4565 @end itemize
4567 @cindex parentheses
4568 @cindex order of evaluation in expressions
4569 @cindex expression, order of evaluation
4570 @opindex (
4571 @opindex )
4572 Parentheses may be used as in any other language.  However, in
4573 @code{gtroff} they are necessary to ensure order of evaluation.
4574 @code{gtroff} has no operator precedence; expressions are evaluated left
4575 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4576 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4577 expected.
4579 @cindex @code{+}, and page motion
4580 @cindex @code{-}, and page motion
4581 @cindex motion operators
4582 @cindex operators, motion
4583 For many requests which cause a motion on the page, the unary operators
4584 @samp{+} and @samp{-} work differently if leading an expression.  They
4585 then indicate a motion relative to the current position (down or up,
4586 respectively).
4588 @cindex @code{|}, and page motion
4589 @cindex absolute position operator (@code{|})
4590 @cindex position, absolute, operator (@code{|})
4591 Similarly, a leading @samp{|} operator indicates an absolute position.
4592 For vertical movements, it specifies the distance from the top of the
4593 page; for horizontal movements, it gives the distance from the beginning
4594 of the @emph{input} line.
4596 @c XXX xref
4597 @samp{+} and @samp{-} are also treated differently by the following
4598 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4599 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4600 @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4601 Here, leading plus and minus signs indicate increments and decrements.
4603 @c XXX add more xref
4604 @xref{Setting Registers}.
4606 @cindex numeric expression, valid
4607 @cindex valid numeric expression
4608 @Defesc {\\B, ', anything, '}
4609 Return@w{ }1 if @var{anything} is a valid numeric expression;
4610 or@w{ }0 if @var{anything} is empty or not a valid numeric expression.
4611 @endDefesc
4613 @cindex space characters in expressions
4614 @cindex expressions and space characters
4615 Due to the way arguments are parsed, spaces are not allowed in
4616 expressions, unless the entire expression is surrounded by parentheses.
4618 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4621 @c =====================================================================
4623 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4624 @section Identifiers
4625 @cindex identifiers
4627 Like any other language, @code{gtroff} has rules for properly formed
4628 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4629 almost any printable character, with the exception of the following
4630 characters:
4632 @itemize @bullet
4633 @item
4634 @cindex whitespace characters
4635 @cindex newline character
4636 @cindex character, whitespace
4637 Whitespace characters (spaces, tabs, and newlines).
4639 @item
4640 @cindex character, backspace
4641 @cindex backspace character
4642 @cindex @acronym{EBCDIC} encoding of backspace
4643 Backspace (@acronym{ASCII}@w{ }@code{0x08} or @acronym{EBCDIC}@w{
4644 }@code{0x16}) and character code @code{0x01}.
4646 @item
4647 @cindex invalid input characters
4648 @cindex input characters, invalid
4649 @cindex characters, invalid input
4650 @cindex Unicode
4651 The following input characters are invalid and are ignored if
4652 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4653 warning message of type @samp{input} (see @ref{Debugging}, for more
4654 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4655 @code{0x80}-@code{0x9F}.
4657 And here are the invalid input characters if @code{groff} runs on an
4658 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4659 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4660 @code{0x30}-@code{0x3F}.
4662 Currently, some of these reserved codepoints are used internally, thus
4663 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4664 character sets and encodings which use characters of these ranges.
4666 Note that invalid characters are removed before parsing; an
4667 identifier @code{foo}, followed by an invalid character, followed by
4668 @code{bar} is treated as @code{foobar}.
4669 @end itemize
4671 For example, any of the following is valid.
4673 @Example
4677 end-list
4679 @endExample
4681 @cindex @code{]}, as part of an identifier
4682 @noindent
4683 Note that identifiers longer than two characters with a closing bracket
4684 (@samp{]}) in its name can't be accessed with escape sequences which
4685 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4686 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4687 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4689 @c XXX xref
4691 @Defesc {\\A, ', ident, '}
4692 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4693 expands to the character@w{ }1 or@w{ }0 according to whether its
4694 argument (usually delimited by quotes) is or is not acceptable as the
4695 name of a string, macro, diversion, number register, environment, or
4696 font.  It returns@w{ }0 if no argument is given.  This is useful for
4697 looking up user input in some sort of associative table.
4699 @Example
4700 \A'end-list'
4701     @result{} 1
4702 @endExample
4703 @endDefesc
4705 @xref{Escapes}, for details on parameter delimiting characters.
4707 @c XXX add xrefs above
4709 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4710 @code{gtroff} needs to be told where identifiers end and text begins
4711 (and in different ways depending on their length):
4713 @itemize @bullet
4714 @item
4715 Single character.
4717 @cindex @code{(}, starting a two-character identifier
4718 @item
4719 Two characters.  Must be prefixed with @samp{(} in some situations.
4721 @cindex @code{[}, starting an identifier
4722 @cindex @code{]}, ending an identifier
4723 @item
4724 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4725 and@w{ }@samp{]} in some situations.  Any length identifier can be put
4726 in brackets.
4727 @end itemize
4729 @cindex undefined identifiers
4730 @cindex identifiers, undefined
4731 Unlike many other programming languages, undefined identifiers are
4732 silently ignored or expanded to nothing.
4733 When @code{gtroff} finds an undefined identifier, it emits a
4734 warning then:
4736 @itemize @bullet
4737 @item
4738 If the identifier is a string, macro, or diversion,
4739 @code{gtroff} defines it as empty.
4741 @item
4742 If the identifier is a number register, @code{gtroff}
4743 defines it with a value of@w{ }0.
4744 @end itemize
4746 @xref{Warnings}.
4748 @c XXX info about common identifier pool for strings and macros.
4750 @xref{Interpolating Registers}, and @ref{Strings}.
4753 @c =====================================================================
4755 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4756 @section Embedded Commands
4757 @cindex embedded commands
4758 @cindex commands, embedded
4760 Most documents need more functionality beyond filling, adjusting and
4761 implicit line breaking.  In order to gain further functionality,
4762 @code{gtroff} allows commands to be embedded into the text, in two ways.
4764 The first is a @dfn{request} which takes up an entire line, and does
4765 some large-scale operation (e.g.@: break lines, start new pages).
4767 The other is an @dfn{escape} which can be embedded anywhere in the text,
4768 or even as an argument to a request.
4769 @c XXX (Not always?)
4770 Escapes generally do more minor operations like sub- and superscripts,
4771 print a symbol, etc.
4773 @menu
4774 * Requests::
4775 * Macros::
4776 * Escapes::
4777 @end menu
4779 @c ---------------------------------------------------------------------
4781 @node Requests, Macros, Embedded Commands, Embedded Commands
4782 @subsection Requests
4783 @cindex requests
4785 @cindex control character (@code{.})
4786 @cindex character, control (@code{.})
4787 @cindex no-break control character (@code{'})
4788 @cindex character, no-break control (@code{'})
4789 @cindex control character, no-break (@code{'})
4790 A request line begins with a control character, which is either a single
4791 quote (@samp{'}, the @dfn{no-break control character}) or a period
4792 (@samp{.}, the normal @dfn{control character}).  These can be changed;
4793 see @ref{Character Translations}, for details.  After this there may be
4794 optional tabs or spaces followed by an identifier which is the name of
4795 the request.  This may be followed by any number of space-separated
4796 arguments (@emph{no} tabs here).
4798 @cindex structuring source code of documents or macro packages
4799 @cindex documents, structuring the source code
4800 @cindex macro packages, strucuring the source code
4801 Since a control character followed by whitespace only is ignored, it
4802 is common practice to use this feature for structuring the source code
4803 of documents or macro packages.
4805 @Example
4806 .de foo
4807 .  tm This is foo.
4811 .de bar
4812 .  tm This is bar.
4814 @endExample
4816 @cindex blank line
4817 @cindex blank line macro (@code{blm})
4818 Another possibility is to use the blank line macro request @code{blm}
4819 by assigning an empty macro to it.
4821 @Example
4822 .de do-nothing
4824 .blm do-nothing  \" activate blank line macro
4826 .de foo
4827 .  tm This is foo.
4831 .de bar
4832 .  tm This is bar.
4835 .blm             \" deactivate blank line macro
4836 @endExample
4838 @xref{Blank Line Traps}.
4840 @cindex zero width space character (@code{\&})
4841 @cindex character, zero width space (@code{\&})
4842 @cindex space character, zero width (@code{\&})
4843 @cindex @code{\&}, escaping control characters
4844 To begin a line with a control character without it being interpreted,
4845 precede it with @code{\&}.  This represents a zero width space, which
4846 means it does not affect the output.
4848 In most cases the period is used as a control character.  Several
4849 requests cause a break implicitly; using the single quote control
4850 character prevents this.
4852 @menu
4853 * Request Arguments::
4854 @end menu
4856 @node Request Arguments,  , Requests, Requests
4857 @subsubsection Request Arguments
4858 @cindex request arguments
4859 @cindex arguments to requests
4861 Arguments to requests (and macros) are processed much like the shell:
4862 The line is split into arguments according to spaces.  An argument
4863 which is intended to contain spaces can either be enclosed in double
4864 quotes, or have the spaces @dfn{escaped} with backslashes.
4866 Here are a few examples:
4868 @Example
4869 .uh The Mouse Problem
4870 .uh "The Mouse Problem"
4871 .uh The\ Mouse\ Problem
4872 @endExample
4874 @cindex @code{\~}, difference to @code{\@key{SP}}
4875 @cindex @code{\@key{SP}}, difference to @code{\~}
4876 @noindent
4877 The first line is the @code{uh} macro being called with 3 arguments,
4878 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
4879 same effect of calling the @code{uh} macro with one argument, @samp{The
4880 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4881 is ``classical'' in the sense that it can be found in most @code{troff}
4882 documents.  Nevertheless, it is not optimal in all situations, since
4883 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4884 can't stretch.  @code{gtroff} provides a different command @code{\~} to
4885 insert a stretchable, non-breaking space.}
4887 @cindex @code{"}, in a macro argument
4888 @cindex double quote, in a macro argument
4889 A double quote which isn't preceded by a space doesn't start a macro
4890 argument.  If not closing a string, it is printed literally.
4892 For example,
4894 @Example
4895 .xxx a" "b c" "de"fg"
4896 @endExample
4898 @noindent
4899 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4900 Don't rely on this obscure behaviour!
4902 There are two possibilities to get a double quote reliably.
4904 @itemize @bullet
4905 @item
4906 Enclose the whole argument with double quotes and use two consecutive double
4907 quotes to represent a single one.  This traditional solution has the
4908 disadvantage that double quotes don't survive argument expansion again if
4909 called in compatibility mode (using the @option{-C} option of @code{groff}):
4911 @Example
4912 .de xx
4913 .  tm xx: `\\$1' `\\$2' `\\$3'
4915 .  yy "\\$1" "\\$2" "\\$3"
4917 .de yy
4918 .  tm yy: `\\$1' `\\$2' `\\$3'
4920 .xx A "test with ""quotes""" .
4921     @result{} xx: `A' `test with "quotes"' `.'
4922     @result{} yy: `A' `test with ' `quotes""'
4923 @endExample
4925 @noindent
4926 If not in compatibility mode, you get the expected result
4928 @Example
4929 xx: `A' `test with "quotes"' `.'
4930 yy: `A' `test with "quotes"' `.'
4931 @endExample
4933 @noindent
4934 since @code{gtroff} preserves the input level.
4936 @item
4937 Use the double quote glyph @code{\(dq}.  This works with and without
4938 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
4939 back to a double quote input character.
4941 Not that this method won't work with @acronym{UNIX} @code{troff} in general
4942 since the glyph `dq' isn't defined normally.
4943 @end itemize
4945 @cindex @code{ds} request, and double quotes
4946 Double quotes in the @code{ds} request are handled differently.
4947 @xref{Strings}, for more details.
4949 @c ---------------------------------------------------------------------
4951 @node Macros, Escapes, Requests, Embedded Commands
4952 @subsection Macros
4953 @cindex macros
4955 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
4956 which can be invoked by name.  They are called in the same manner as
4957 requests -- arguments also may be passed in the same manner.
4959 @xref{Writing Macros}, and @ref{Request Arguments}.
4961 @c ---------------------------------------------------------------------
4963 @node Escapes,  , Macros, Embedded Commands
4964 @subsection Escapes
4965 @cindex escapes
4967 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
4968 begin with a backslash and are followed by a single character which
4969 indicates the function to be performed.  The escape character can be
4970 changed; see @ref{Character Translations}.
4972 Escape sequences which require an identifier as a parameter accept three
4973 possible syntax forms.
4975 @itemize @bullet
4976 @item
4977 The next single character is the identifier.
4979 @cindex @code{(}, starting a two-character identifier
4980 @item
4981 If this single character is an opening parenthesis, take the following
4982 two characters as the identifier.  Note that there is no closing
4983 parenthesis after the identifier.
4985 @cindex @code{[}, starting an identifier
4986 @cindex @code{]}, ending an identifier
4987 @item
4988 If this single character is an opening bracket, take all characters
4989 until a closing bracket as the identifier.
4990 @end itemize
4992 @noindent
4993 Examples:
4995 @Example
4997 \n(XX
4998 \*[TeX]
4999 @endExample
5001 @cindex @code{'}, delimiting arguments
5002 @cindex argument delimiting characters
5003 @cindex characters, argument delimiting
5004 @cindex delimiting characters for arguments
5005 Other escapes may require several arguments and/or some special format.
5006 In such cases the argument is traditionally enclosed in single quotes
5007 (and quotes are always used in this manual for the definitions of escape
5008 sequences).  The enclosed text is then processed according to what that
5009 escape expects.  Example:
5011 @Example
5012 \l'1.5i\(bu'
5013 @endExample
5015 @cindex @code{\o}, possible quote characters
5016 @cindex @code{\b}, possible quote characters
5017 @cindex @code{\X}, possible quote characters
5018 Note that the quote character can be replaced with any other character
5019 which does not occur in the argument (even a newline or a space
5020 character) in the following escapes: @code{\o}, @code{\b}, and
5021 @code{\X}.  This makes e.g.
5023 @Example
5024 A caf
5029 in Paris
5030   @result{} A caf@'e in Paris
5031 @endExample
5033 @noindent
5034 possible, but it is better not to use this feature to avoid confusion.
5036 @cindex @code{\%}, used as delimiter
5037 @cindex @code{\@key{SP}}, used as delimiter
5038 @cindex @code{\|}, used as delimiter
5039 @cindex @code{\^}, used as delimiter
5040 @cindex @code{\@{}, used as delimiter
5041 @cindex @code{\@}}, used as delimiter
5042 @cindex @code{\'}, used as delimiter
5043 @cindex @code{\`}, used as delimiter
5044 @cindex @code{\-}, used as delimiter
5045 @cindex @code{\_}, used as delimiter
5046 @cindex @code{\!}, used as delimiter
5047 @cindex @code{\?}, used as delimiter
5048 @cindex @code{\@@}, used as delimiter
5049 @cindex @code{\)}, used as delimiter
5050 @cindex @code{\/}, used as delimiter
5051 @cindex @code{\,}, used as delimiter
5052 @cindex @code{\&}, used as delimiter
5053 @ifnotinfo
5054 @cindex @code{\:}, used as delimiter
5055 @end ifnotinfo
5056 @ifinfo
5057 @cindex @code{\@r{<colon>}}, used as delimiter
5058 @end ifinfo
5059 @cindex @code{\~}, used as delimiter
5060 @cindex @code{\0}, used as delimiter
5061 @cindex @code{\a}, used as delimiter
5062 @cindex @code{\c}, used as delimiter
5063 @cindex @code{\d}, used as delimiter
5064 @cindex @code{\e}, used as delimiter
5065 @cindex @code{\E}, used as delimiter
5066 @cindex @code{\p}, used as delimiter
5067 @cindex @code{\r}, used as delimiter
5068 @cindex @code{\t}, used as delimiter
5069 @cindex @code{\u}, used as delimiter
5070 The following escapes sequences (which are handled similarly to
5071 characters since they don't take a parameter) are also allowed as
5072 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5073 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5074 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
5075 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
5076 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
5077 Again, don't use these if possible.
5079 @cindex @code{\A}, allowed delimiters
5080 @cindex @code{\B}, allowed delimiters
5081 @cindex @code{\Z}, allowed delimiters
5082 @cindex @code{\C}, allowed delimiters
5083 @cindex @code{\w}, allowed delimiters
5084 No newline characters as delimiters are allowed in the following
5085 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5087 @cindex @code{\D}, allowed delimiters
5088 @cindex @code{\h}, allowed delimiters
5089 @cindex @code{\H}, allowed delimiters
5090 @cindex @code{\l}, allowed delimiters
5091 @cindex @code{\L}, allowed delimiters
5092 @cindex @code{\N}, allowed delimiters
5093 @cindex @code{\R}, allowed delimiters
5094 @cindex @code{\s}, allowed delimiters
5095 @cindex @code{\S}, allowed delimiters
5096 @cindex @code{\v}, allowed delimiters
5097 @cindex @code{\x}, allowed delimiters
5098 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5099 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
5100 and @code{\x} can't use the following characters as delimiters:
5102 @itemize @bullet
5103 @item
5104 @cindex numbers, and delimiters
5105 @cindex digits, and delimiters
5106 The digits @code{0}-@code{9}.
5108 @item
5109 @cindex operators, as delimiters
5110 @cindex @code{+}, as delimiter
5111 @cindex @code{-}, as delimiter
5112 @cindex @code{/}, as delimiter
5113 @cindex @code{*}, as delimiter
5114 @cindex @code{%}, as delimiter
5115 @cindex @code{<}, as delimiter
5116 @cindex @code{>}, as delimiter
5117 @cindex @code{=}, as delimiter
5118 @cindex @code{&}, as delimiter
5119 @ifnotinfo
5120 @cindex @code{:}, as delimiter
5121 @end ifnotinfo
5122 @ifinfo
5123 @cindex <colon>, as delimiter
5124 @end ifinfo
5125 @cindex @code{(}, as delimiter
5126 @cindex @code{)}, as delimiter
5127 @cindex @code{.}, as delimiter
5128 The (single-character) operators @samp{+-/*%<>=&:().}.
5130 @item
5131 @cindex space character
5132 @cindex character, space
5133 @cindex tab character
5134 @cindex character, tab
5135 @cindex newline character
5136 @cindex character, newline
5137 The space, tab, and newline characters.
5139 @item
5140 @cindex @code{\%}, used as delimiter
5141 @ifnotinfo
5142 @cindex @code{\:}, used as delimiter
5143 @end ifnotinfo
5144 @ifinfo
5145 @cindex @code{\@r{<colon>}}, used as delimiter
5146 @end ifinfo
5147 @cindex @code{\@{}, used as delimiter
5148 @cindex @code{\@}}, used as delimiter
5149 @cindex @code{\'}, used as delimiter
5150 @cindex @code{\`}, used as delimiter
5151 @cindex @code{\-}, used as delimiter
5152 @cindex @code{\_}, used as delimiter
5153 @cindex @code{\!}, used as delimiter
5154 @cindex @code{\@@}, used as delimiter
5155 @cindex @code{\/}, used as delimiter
5156 @cindex @code{\c}, used as delimiter
5157 @cindex @code{\e}, used as delimiter
5158 @cindex @code{\p}, used as delimiter
5159 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
5160 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
5161 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5162 @end itemize
5164 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
5165 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
5166 To have a backslash (actually, the current escape character) appear in the
5167 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
5168 These are very similar, and only differ with respect to being used in
5169 macros or diversions.  @xref{Character Translations}, for an exact
5170 description of those escapes.
5172 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
5173 @ref{Identifiers}, for more information.
5175 @menu
5176 * Comments::
5177 @end menu
5179 @node Comments,  , Escapes, Escapes
5180 @subsubsection Comments
5181 @cindex comments
5183 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5184 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5185 common forms of escapes is the comment.
5187 @Defesc {\\", , , }
5188 Start a comment.  Everything to the end of the input line is ignored.
5190 This may sound simple, but it can be tricky to keep the comments from
5191 interfering with the appearance of the final output.
5193 @cindex @code{ds} request, and comments
5194 @cindex @code{ds1} request, and comments
5195 @cindex @code{as} request, and comments
5196 @cindex @code{as1} request, and comments
5197 If the escape is to the right of some text or a request, that portion
5198 of the line is ignored, but the space leading up to it is noticed by
5199 @code{gtroff}.  This only affects the @code{.ds} and @code{.as}
5200 request and its variants.
5202 @cindex tabs before comments
5203 @cindex comments, lining up with tabs
5204 One possibly irritating idiosyncracy is that tabs must not be used to
5205 line up comments.  Tabs are not treated as white space between the
5206 request and macro arguments.
5208 @cindex undefined request
5209 @cindex request, undefined
5210 A comment on a line by itself is treated as a blank line, because
5211 after eliminating the comment, that is all that remains:
5213 @Example
5214 Test
5215 \" comment
5216 Test
5217 @endExample
5219 @noindent
5220 produces
5222 @Example
5223 Test
5225 Test
5226 @endExample
5228 To avoid this, it is common to start the line with @code{.\"} which
5229 causes the line to be treated as an undefined request and thus ignored
5230 completely.
5232 @cindex @code{'}, as a comment
5233 Another commenting scheme seen sometimes is three consecutive single
5234 quotes (@code{'''}) at the beginning of a line.  This works, but
5235 @code{gtroff} gives a warning about an undefined macro (namely
5236 @code{''}), which is harmless, but irritating.
5237 @endDefesc
5239 @Defesc {\\#, , , }
5240 To avoid all this, @code{gtroff} has a new comment mechanism using the
5241 @code{\#} escape.  This escape works the same as @code{\"} except that
5242 the newline is also ignored:
5244 @Example
5245 Test
5246 \# comment
5247 Test
5248 @endExample
5250 @noindent
5251 produces
5253 @Example
5254 Test Test
5255 @endExample
5257 @noindent
5258 as expected.
5259 @endDefesc
5261 @Defreq {ig, yy}
5262 Ignore all input until @code{gtroff} encounters the macro named
5263 @code{.}@var{yy} on a line by itself (or @code{..} if @var{yy} is not
5264 specified).  This is useful for commenting out large blocks of text:
5266 @Example
5267 text text text...
5269 This is part of a large block
5270 of text that has been
5271 temporarily(?) commented out.
5273 We can restore it simply by removing
5274 the .ig request and the ".." at the
5275 end of the block.
5277 More text text text...
5278 @endExample
5280 @noindent
5281 produces
5283 @Example
5284 text text text@dots{}  More text text text@dots{}
5285 @endExample
5287 @noindent
5288 Note that the commented-out block of text does not
5289 cause a break.
5291 The input is read in copy-mode; auto-incremented registers @emph{are}
5292 affected (@pxref{Auto-increment}).
5293 @endDefreq
5296 @c =====================================================================
5298 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5299 @section Registers
5300 @cindex registers
5302 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5303 are a number of built-in registers, supplying anything from the date to
5304 details of formatting parameters.
5306 @xref{Identifiers}, for details on register identifiers.
5308 @menu
5309 * Setting Registers::
5310 * Interpolating Registers::
5311 * Auto-increment::
5312 * Assigning Formats::
5313 * Built-in Registers::
5314 @end menu
5316 @c ---------------------------------------------------------------------
5318 @node Setting Registers, Interpolating Registers, Registers, Registers
5319 @subsection Setting Registers
5320 @cindex setting registers (@code{nr}, @code{\R})
5321 @cindex registers, setting (@code{nr}, @code{\R})
5323 Define or set registers using the @code{nr} request or the
5324 @code{\R} escape.
5326 @DefreqList {nr, ident value}
5327 @DefescListEnd {\\R, ', ident value, '}
5328 Set number register @var{ident} to @var{value}.  If @var{ident}
5329 doesn't exist, @code{gtroff} creates it.
5331 The argument to @code{\R} usually has to be enclosed in quotes.
5332 @xref{Escapes}, for details on parameter delimiting characters.
5334 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5335 with other words, it vanishes completely after @code{gtroff} has
5336 processed it.
5337 @endDefreq
5339 For example, the following two lines are equivalent:
5341 @Example
5342 .nr a 1
5343 \R'a 1'
5344 @endExample
5346 Both @code{nr} and @code{\R} have two additional special forms to
5347 increment or decrement a register.
5349 @DefreqList {nr, ident @t{+}@Var{value}}
5350 @DefreqItem {nr, ident @t{-}@Var{value}}
5351 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5352 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5353 Increment (decrement) register @var{ident} by @var{value}.
5355 @Example
5356 .nr a 1
5357 .nr a +1
5359     @result{} 2
5360 @endExample
5362 @cindex negating register values
5363 To assign the negated value of a register to another register, some care
5364 must be taken to get the desired result:
5366 @Example
5367 .nr a 7
5368 .nr b 3
5369 .nr a -\nb
5371     @result{} 4
5372 .nr a (-\nb)
5374     @result{} -3
5375 @endExample
5377 @noindent
5378 The surrounding parentheses prevent the interpretation of the minus sign
5379 as a decrementing operator.  An alternative is to start the assignment
5380 with a @samp{0}:
5382 @Example
5383 .nr a 7
5384 .nr b -3
5385 .nr a \nb
5387     @result{} 4
5388 .nr a 0\nb
5390     @result{} -3
5391 @endExample
5392 @endDefreq
5394 @Defreq {rr, ident}
5395 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5396 request is ignored.
5397 @endDefreq
5399 @Defreq {rnn, ident1 ident2}
5400 Rename number register @var{ident1} to @var{ident2}.  If either
5401 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5402 @endDefreq
5404 @Defreq {aln, ident1 ident2}
5405 Create an alias @var{ident1} for a number register @var{ident2}.  The
5406 new name and the old name are exactly equivalent.  If @var{ident1} is
5407 undefined, a warning of type @samp{reg} is generated, and the request
5408 is ignored.  @xref{Debugging}, for information about warnings.
5409 @endDefreq
5411 @c ---------------------------------------------------------------------
5413 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5414 @subsection Interpolating Registers
5415 @cindex interpolating registers (@code{\n})
5416 @cindex registers, interpolating (@code{\n})
5418 Numeric registers can be accessed via the @code{\n} escape.
5420 @cindex nested assignments
5421 @cindex assignments, nested
5422 @cindex indirect assignments
5423 @cindex assignments, indirect
5424 @DefescList {\\n, , i, }
5425 @DefescItem {\\n, @lparen{}, id, }
5426 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5427 Interpolate number register with name @var{ident} (one-character name@w{
5428 }@var{i}, two-character name @var{id}). This means that the value of the
5429 register is expanded in-place while @code{gtroff} is parsing the input line.
5430 Nested assignments (also called indirect assignments) are possible.
5432 @Example
5433 .nr a 5
5434 .nr as \na+\na
5435 \n(as
5436     @result{} 10
5437 @endExample
5439 @Example
5440 .nr a1 5
5441 .nr ab 6
5442 .ds str b
5443 .ds num 1
5444 \n[a\n[num]]
5445     @result{} 5
5446 \n[a\*[str]]
5447     @result{} 6
5448 @endExample
5449 @endDefesc
5451 @c ---------------------------------------------------------------------
5453 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5454 @subsection Auto-increment
5455 @cindex auto-increment
5456 @cindex increment, automatic
5458 Number registers can also be auto-incremented and auto-decremented.
5459 The increment or decrement value can be specified with a third
5460 argument to the @code{nr} request or @code{\R} escape.
5462 @cindex @code{\R}, difference to @code{nr}
5463 @Defreq {nr, ident value incr}
5464 Set number register @var{ident} to @var{value}; the increment for
5465 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5466 escape doesn't support this notation.
5467 @endDefreq
5469 To activate auto-incrementing, the escape @code{\n} has a special
5470 syntax form.
5472 @DefescList {\\n, +, i, }
5473 @DefescItem {\\n, -, i, }
5474 @DefescItem {\\n, @lparen{}+, id, }
5475 @DefescItem {\\n, @lparen{}-, id, }
5476 @DefescItem {\\n, +@lparen{}, id, }
5477 @DefescItem {\\n, -@lparen{}, id, }
5478 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5479 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5480 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5481 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5482 Before interpolating, increment or decrement @var{ident}
5483 (one-character name@w{ }@var{i}, two-character name @var{id}) by the
5484 auto-increment value as specified with the @code{nr} request (or the
5485 @code{\R} escape).  If no auto-increment value has been specified,
5486 these syntax forms are identical to @code{\n}.
5487 @endDefesc
5489 For example,
5491 @Example
5492 .nr a 0 1
5493 .nr xx 0 5
5494 .nr foo 0 -2
5495 \n+a, \n+a, \n+a, \n+a, \n+a
5497 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5499 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5500 @endExample
5502 @noindent
5503 produces
5505 @Example
5506 1, 2, 3, 4, 5
5507 -5, -10, -15, -20, -25
5508 -2, -4, -6, -8, -10
5509 @endExample
5511 @cindex increment value without changing the register
5512 @cindex value, incrementing without changing the register
5513 To change the increment value without changing the value of a register
5514 (@var{a} in the example), the following can be used:
5516 @Example
5517 .nr a \na 10
5518 @endExample
5520 @c ---------------------------------------------------------------------
5522 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5523 @subsection Assigning Formats
5524 @cindex assigning formats (@code{af})
5525 @cindex formats, assigning (@code{af})
5527 When a register is used in the text of an input file (as opposed to
5528 part of an expression), it is textually replaced (or interpolated)
5529 with a representation of that number.  This output format can be
5530 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5531 is done using the @code{af} request.
5533 @Defreq {af, ident format}
5534 Change the output format of a number register.  The first argument
5535 @var{ident} is the name of the number register to be changed, and the
5536 second argument @var{format} is the output format.  The following
5537 output formats are available:
5539 @table @code
5540 @item 1
5541 Decimal arabic numbers.  This is the default format: 0, 1, 2, 3,@w{
5542 }@enddots{}
5544 @item 0@dots{}0
5545 Decimal numbers with as many digits as specified.  So, @samp{00} would
5546 result in printing numbers as 01, 02, 03,@w{ }@enddots{}
5548 In fact, any digit instead of zero will do; @code{gtroff} only counts
5549 how many digits are specified.  As a consequence, @code{af}'s default
5550 format @samp{1} could be specified as @samp{0} also (and exactly this is
5551 returned by the @code{\g} escape, see below).
5553 @item I
5554 @cindex Roman numerals
5555 @cindex numerals, Roman
5556 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@enddots{}
5558 @item i
5559 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@enddots{}
5561 @item A
5562 Upper-case letters: 0, A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@enddots{}
5564 @item a
5565 Lower-case letters: 0, a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@enddots{}
5566 @end table
5568 Omitting the number register format causes a warning of type
5569 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5570 nonexistent format causes an error.
5572 The following example produces @samp{10, X, j, 010}:
5574 @Example
5575 .nr a 10
5576 .af a 1           \" the default format
5577 \na,
5578 .af a I
5579 \na,
5580 .af a a
5581 \na,
5582 .af a 001
5584 @endExample
5586 @cindex Roman numerals, maximum and minimum
5587 @cindex maximum values of Roman numerals
5588 @cindex minimum values of Roman numerals
5589 The largest number representable for the @samp{i} and @samp{I} formats
5590 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5591 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5592 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5593 thousand and Roman numeral ten thousand (Unicode code points
5594 @code{U+2182} and @code{U+2181}, respectively) are not available.
5596 If @var{ident} doesn't exist, it is created.
5598 @cindex read-only register, changing format
5599 @cindex changing format, read-only register
5600 Changing the output format of a read-only register causes an error.  It
5601 is necessary to first copy the register's value to a writeable register,
5602 then apply the @code{af} request to this other register.
5603 @endDefreq
5605 @cindex format of register (@code{\g})
5606 @cindex register, format (@code{\g})
5607 @DefescList {\\g, , i, }
5608 @DefescItem {\\g, @lparen{}, id, }
5609 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5610 Return the current format of the specified register @var{ident}
5611 (one-character name@w{ }@var{i}, two-character name @var{id}).  For
5612 example, @samp{\ga} after the previous example would produce the
5613 string @samp{000}.  If the register hasn't been defined yet, nothing
5614 is returned.
5615 @endDefesc
5617 @c ---------------------------------------------------------------------
5619 @node Built-in Registers,  , Assigning Formats, Registers
5620 @subsection Built-in Registers
5621 @cindex built-in registers
5622 @cindex registers, built-in
5624 The following lists some built-in registers which are not described
5625 elsewhere in this manual.  Any register which begins with a @samp{.} is
5626 read-only.  A complete listing of all built-in registers can be found in
5627 @ref{Register Index}.
5629 @table @code
5630 @item .H
5631 @cindex horizontal resolution register (@code{.H})
5632 @cindex resolution, horizontal, register (@code{.H})
5633 @vindex .H
5634 Horizontal resolution in basic units.
5636 @item .V
5637 @cindex vertical resolution register (@code{.V})
5638 @cindex resolution, vertical, register (@code{.V})
5639 @vindex .V
5640 Vertical resolution in basic units.
5642 @item dw
5643 @cindex day of the week register (@code{dw})
5644 @cindex date, day of the week register (@code{dw})
5645 @vindex dw
5646 Day of the week (1-7).
5648 @item dy
5649 @cindex day of the month register (@code{dy})
5650 @cindex date, day of the month register (@code{dy})
5651 @vindex dy
5652 Day of the month (1-31).
5654 @item mo
5655 @cindex month of the year register (@code{mo})
5656 @cindex date, month of the year register (@code{mo})
5657 @vindex mo
5658 Current month (1-12).
5660 @item year
5661 @cindex date, year register (@code{year}, @code{yr})
5662 @cindex year, current, register (@code{year}, @code{yr})
5663 @vindex year
5664 The current year.
5666 @item yr
5667 @vindex yr
5668 The current year minus@w{ }1900.  Unfortunately, the documentation of
5669 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5670 incorrectly claimed that @code{yr} contains the last two digits of the
5671 year.  That claim has never been true of either traditional @code{troff}
5672 or GNU @code{troff}.  Old @code{troff} input that looks like this:
5674 @Example
5675 '\" The following line stopped working after 1999
5676 This document was formatted in 19\n(yr.
5677 @endExample
5679 @noindent
5680 can be corrected as follows:
5682 @Example
5683 This document was formatted in \n[year].
5684 @endExample
5686 @noindent
5687 or, to be portable to older @code{troff} versions, as follows:
5689 @Example
5690 .nr y4 1900+\n(yr
5691 This document was formatted in \n(y4.
5692 @endExample
5694 @item .c
5695 @vindex .c
5696 @itemx c.
5697 @vindex c.
5698 @cindex input line number register (@code{.c}, @code{c.})
5699 @cindex line number, input, register (@code{.c}, @code{c.})
5700 The current @emph{input} line number.  Register @samp{.c} is read-only,
5701 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5702 affecting both @samp{.c} and @samp{c.}.
5704 @item ln
5705 @vindex ln
5706 @cindex output line number register (@code{ln})
5707 @cindex line number, output, register (@code{ln})
5708 The current @emph{output} line number after a call to the @code{nm}
5709 request to activate line numbering.
5711 @xref{Miscellaneous}, for more information about line numbering.
5713 @item .x
5714 @vindex .x
5715 @cindex major version number register (@code{.x})
5716 @cindex version number, major, register (@code{.x})
5717 The major version number.  For example, if the version number is@w{
5718 }1.03 then @code{.x} contains@w{ }@samp{1}.
5720 @item .y
5721 @vindex .y
5722 @cindex minor version number register (@code{.y})
5723 @cindex version number, minor, register (@code{.y})
5724 The minor version number.  For example, if the version number is@w{
5725 }1.03 then @code{.y} contains@w{ }@samp{03}.
5727 @item .Y
5728 @vindex .Y
5729 @cindex revision number register (@code{.Y})
5730 The revision number of @code{groff}.
5732 @item $$
5733 @vindex $$
5734 @cindex process ID of @code{gtroff} register (@code{$$})
5735 @cindex @code{gtroff}, process ID register (@code{$$})
5736 The process ID of @code{gtroff}.
5738 @item .g
5739 @vindex .g
5740 @cindex @code{gtroff} identification register (@code{.g})
5741 @cindex GNU-specific register (@code{.g})
5742 Always@w{ }1.  Macros should use this to determine whether they are
5743 running under GNU @code{troff}.
5745 @item .A
5746 @vindex .A
5747 @cindex @acronym{ASCII} approximation output register (@code{.A})
5748 If the command line option @option{-a} is used to produce an
5749 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5750 otherwise.  @xref{Groff Options}.
5752 @item .P
5753 @vindex .P
5754 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5755 page is actually being printed, i.e., if the @option{-o} option is being
5756 used to only print selected pages.  @xref{Groff Options}, for more
5757 information.
5759 @item .T
5760 @vindex .T
5761 If @code{gtroff} is called with the @option{-T} command line option, the
5762 number register @code{.T} is set to@w{ }1, and zero otherwise.
5763 @xref{Groff Options}.
5765 @stindex .T
5766 @cindex output device name string register (@code{.T})
5767 Additionally, @code{gtroff} predefines a single read-write string
5768 register @code{.T} which contains the current output device (for
5769 example, @samp{latin1} or @samp{ps}).
5770 @end table
5773 @c =====================================================================
5775 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5776 @section Manipulating Filling and Adjusting
5777 @cindex manipulating filling and adjusting
5778 @cindex filling and adjusting, manipulating
5779 @cindex adjusting and filling, manipulating
5780 @cindex justifying text
5781 @cindex text, justifying
5783 @cindex break
5784 @cindex line break
5785 @cindex @code{bp} request, causing implicit linebreak
5786 @cindex @code{ce} request, causing implicit linebreak
5787 @cindex @code{cf} request, causing implicit linebreak
5788 @cindex @code{fi} request, causing implicit linebreak
5789 @cindex @code{fl} request, causing implicit linebreak
5790 @cindex @code{in} request, causing implicit linebreak
5791 @cindex @code{nf} request, causing implicit linebreak
5792 @cindex @code{rj} request, causing implicit linebreak
5793 @cindex @code{sp} request, causing implicit linebreak
5794 @cindex @code{ti} request, causing implicit linebreak
5795 @cindex @code{trf} request, causing implicit linebreak
5796 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5797 Breaks}.  The @code{br} request likewise causes a break.  Several
5798 other requests also cause breaks, but implicitly.  These are
5799 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5800 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5802 @Defreq {br, }
5803 Break the current line, i.e., the input collected so far is emitted
5804 without adjustment.
5806 If the no-break control character is used, @code{gtroff} suppresses
5807 the break:
5809 @Example
5813     @result{} a b
5814 @endExample
5815 @endDefreq
5817 Initially, @code{gtroff} fills and adjusts text to both margins.
5818 Filling can be disabled via the @code{nf} request and re-enabled with
5819 the @code{fi} request.
5821 @cindex fill mode (@code{fi})
5822 @cindex mode, fill (@code{fi})
5823 @DefreqList {fi, }
5824 @DefregListEnd {.u}
5825 Activate fill mode (which is the default).  This request implicitly
5826 enables adjusting; it also inserts a break in the text currently being
5827 filled.  The read-only number register @code{.u} is set to@w{ }1.
5829 The fill mode status is associated with the current environment
5830 (@pxref{Environments}).
5832 See @ref{Line Control}, for interaction with the @code{\c} escape.
5833 @endDefreq
5835 @cindex no-fill mode (@code{nf})
5836 @cindex mode, no-fill (@code{nf})
5837 @Defreq {nf, }
5838 Activate no-fill mode.  Input lines are output as-is, retaining line
5839 breaks and ignoring the current line length.  This command implicitly
5840 disables adjusting; it also causes a break.  The number register
5841 @code{.u} is set to@w{ }0.
5843 The fill mode status is associated with the current environment
5844 (@pxref{Environments}).
5846 See @ref{Line Control}, for interaction with the @code{\c} escape.
5847 @endDefreq
5849 @DefreqList {ad, [@Var{mode}]}
5850 @DefregListEnd {.j}
5851 Set adjusting mode.
5853 Activation and deactivation of adjusting is done implicitly with
5854 calls to the @code{fi} or @code{nf} requests.
5856 @var{mode} can have one of the following values:
5858 @table @code
5859 @item l
5860 @cindex ragged-right
5861 Adjust text to the left margin.  This produces what is traditionally
5862 called ragged-right text.
5864 @item r
5865 @cindex ragged-left
5866 Adjust text to the right margin, producing ragged-left text.
5868 @item c
5869 @cindex centered text
5870 @cindex @code{ce} request, difference to @code{ad@w{ }c}
5871 Center filled text.  This is different to the @code{ce} request which
5872 only centers text without filling.
5874 @item b
5875 @itemx n
5876 Justify to both margins.  This is the default used by @code{gtroff}.
5877 @end table
5879 With no argument, @code{gtroff} adjusts lines in the same way it did
5880 before adjusting was deactivated (with a call to @code{na}, for
5881 example).
5883 @Example
5884 text
5885 .ad r
5886 text
5887 .ad c
5888 text
5890 text
5891 .ad  \" back to centering
5892 text
5893 @endExample
5895 @cindex adjustment mode register (@code{.j})
5896 The current adjustment mode is available in the read-only number
5897 register @code{.j}; it can be stored and subsequently used to set
5898 adjustment.
5900 The adjustment mode status is associated with the current environment
5901 (@pxref{Environments}).
5902 @endDefreq
5904 @Defreq {na, }
5905 Disable adjusting.  This request won't change the current adjustment
5906 mode: A subsequent call to @code{ad} uses the previous adjustment
5907 setting.
5909 The adjustment mode status is associated with the current environment
5910 (@pxref{Environments}).
5911 @endDefreq
5913 @DefreqList {brp, }
5914 @DefescListEnd {\\p, , , }
5915 Adjust the current line and cause a break.
5917 In most cases this produces very ugly results since @code{gtroff}
5918 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5919 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5920 line by line:
5922 @Example
5923   This is an uninteresting sentence.
5924   This is an uninteresting sentence.\p
5925   This is an uninteresting sentence.
5926 @endExample
5928 @noindent
5929 is formatted as
5931 @Example
5932   This is  an uninteresting  sentence.   This  is an
5933   uninteresting                            sentence.
5934   This is an uninteresting sentence.
5935 @endExample
5936 @endDefreq
5938 @cindex word space size register (@code{.ss})
5939 @cindex size of word space register (@code{.ss})
5940 @cindex space between words register (@code{.ss})
5941 @cindex sentence space size register (@code{.sss})
5942 @cindex size of sentence space register (@code{.sss})
5943 @cindex space between sentences register (@code{.sss})
5944 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5945 @DefregItem {.ss}
5946 @DefregListEnd {.sss}
5947 Change the minimum size of a space between filled words.  It takes its
5948 units as one twelfth of the space width parameter for the current
5949 font.  Initially both the @var{word_space_size} and
5950 @var{sentence_space_size} are@w{ }12.
5952 @cindex fill mode
5953 @cindex mode, fill
5954 If two arguments are given to the @code{ss} request, the second
5955 argument sets the sentence space size.  If the second argument is not
5956 given, sentence space size is set to @var{word_space_size}.  The
5957 sentence space size is used in two circumstances: If the end of a
5958 sentence occurs at the end of a line in fill mode, then both an
5959 inter-word space and a sentence space are added; if two spaces follow
5960 the end of a sentence in the middle of a line, then the second space
5961 is a sentence space.  If a second argument is never given to the
5962 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5963 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5964 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5965 by either a newline or two spaces.
5967 The read-only number registers @code{.ss} and @code{.sss} hold the
5968 values of the parameters set by the first and second arguments of the
5969 @code{ss} request.
5971 The word space and sentence space values are associated with the current
5972 environment (@pxref{Environments}).
5974 Contrary to traditional Unix @code{troff}, this request is @emph{not}
5975 ignored if a tty output device is used; the given values are then
5976 rounded down to a multiple of@w{ }12.
5978 @c XXX xref implementation differences
5980 The request is ignored if there is no parameter.
5981 @endDefreq
5983 @cindex centering lines (@code{ce})
5984 @cindex lines, centering (@code{ce})
5985 @DefreqList {ce, [@Var{nnn}]}
5986 @DefregListEnd {.ce}
5987 Center text.  While the @w{@samp{.ad c}} request also centers text,
5988 it fills the text as well.  @code{ce} does not fill the
5989 text it affects.  This request causes a break.  The number of lines
5990 still to be centered is associated with the current environment
5991 (@pxref{Environments}).
5993 The following example demonstrates the differences.
5994 Here the input:
5996 @Example
5997 .ll 4i
5998 .ce 1000
5999 This is a small text fragment which shows the differences
6000 between the `.ce' and the `.ad c' request.
6001 .ce 0
6003 .ad c
6004 This is a small text fragment which shows the differences
6005 between the `.ce' and the `.ad c' request.
6006 @endExample
6008 @noindent
6009 And here the result:
6011 @Example
6012   This is a small text fragment which
6013          shows the differences
6014 between the `.ce' and the `.ad c' request.
6016   This is a small text fragment which
6017 shows the differences between the `.ce'
6018         and the `.ad c' request.
6019 @endExample
6021 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
6022 specifies the number of lines to be centered.  If the argument is zero
6023 or negative, centering is disabled.
6025 The basic length for centering text is the line length (as set with the
6026 @code{ll} request) minus the indentation (as set with the @code{in}
6027 request).  Temporary indentation is ignored.
6029 As can be seen in the previous example, it is a common idiom to turn
6030 on centering for a large number of lines, and to turn off centering
6031 after text to be centered.  This is useful for any request which takes
6032 a number of lines as an argument.
6034 The @code{.ce} read-only number register contains the number of lines
6035 remaining to be centered, as set by the @code{ce} request.
6036 @endDefreq
6038 @cindex justifying text (@code{rj})
6039 @cindex text, justifying (@code{rj})
6040 @cindex right-justifying (@code{rj})
6041 @DefreqList {rj, [@Var{nnn}]}
6042 @DefregListEnd {.rj}
6043 Justify unfilled text to the right margin.  Arguments are identical to
6044 the @code{ce} request.  The @code{.rj} read-only number register is
6045 the number of lines to be right-justified as set by the @code{rj}
6046 request.  This request causes a break.  The number of lines still to be
6047 right-justified is associated with the current environment
6048 (@pxref{Environments}).
6049 @endDefreq
6052 @c =====================================================================
6054 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6055 @section Manipulating Hyphenation
6056 @cindex manipulating hyphenation
6057 @cindex hyphenation, manipulating
6059 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
6060 There are a number of ways to influence hyphenation.
6062 @DefreqList {hy, [@Var{mode}]}
6063 @DefregListEnd {.hy}
6064 Enable hyphenation.  The request has an optional numeric argument,
6065 @var{mode}, to restrict hyphenation if necessary:
6067 @table @code
6068 @item 1
6069 The default argument if @var{mode} is omitted.  Hyphenate without
6070 restrictions.  This is also the start-up value of @code{gtroff}.
6072 @item 2
6073 Do not hyphenate the last word on a page or column.
6075 @item 4
6076 Do not hyphenate the last two characters of a word.
6078 @item 8
6079 Do not hyphenate the first two characters of a word.
6080 @end table
6082 Values in the previous table are additive.  For example, the value@w{
6083 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
6084 two characters of a word.
6086 @cindex hyphenation restrictions register (@code{.hy})
6087 The current hyphenation restrictions can be found in the read-only
6088 number register @samp{.hy}.
6090 The hyphenation mode is associated with the current environment
6091 (@pxref{Environments}).
6092 @endDefreq
6094 @Defreq {nh, }
6095 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
6096 that the hyphenation mode of the last call to @code{hy} is not
6097 remembered.
6099 The hyphenation mode is associated with the current environment
6100 (@pxref{Environments}).
6101 @endDefreq
6103 @cindex explicit hyphen (@code{\%})
6104 @cindex hyphen, explicit (@code{\%})
6105 @cindex consecutive hyphenated lines (@code{hlm})
6106 @cindex lines, consecutive hyphenated (@code{hlm})
6107 @cindex hyphenated lines, consecutive (@code{hlm})
6108 @DefreqList {hlm, [@Var{nnn}]}
6109 @DefregItem {.hlm}
6110 @DefregListEnd {.hlc}
6111 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
6112 If this number is negative, there is no maximum.  The default value
6113 is@w{ }@minus{}1 if @var{nnn} is omitted.  This value is associated
6114 with the current environment (@pxref{Environments}).  Only lines
6115 output from a given environment count towards the maximum associated
6116 with that environment.  Hyphens resulting from @code{\%} are counted;
6117 explicit hyphens are not.
6119 The current setting of @code{hlm} is available in the @code{.hlm}
6120 read-only number register.  Also the number of immediately preceding
6121 consecutive hyphenated lines are available in the read-only number
6122 register @samp{.hlc}.
6123 @endDefreq
6125 @Defreq {hw, word1 word2 @dots{}}
6126 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
6127 words must be given with hyphens at the hyphenation points.  For
6128 example:
6130 @Example
6131 .hw in-sa-lub-rious
6132 @endExample
6134 @noindent
6135 Besides the space character, any character whose hyphenation code value
6136 is zero can be used to separate the arguments of @code{hw} (see the
6137 documentation for the @code{hcode} request below for more information).
6138 In addition, this request can be used more than once.
6140 Hyphenation exceptions specified with the @code{hw} request are
6141 associated with the current hyphenation language; it causes an error
6142 if there is no current hyphenation language.
6144 This request is ignored if there is no parameter.
6146 In old versions of @code{troff} there was a limited amount of space to
6147 store such information; fortunately, with @code{gtroff}, this is no
6148 longer a restriction.
6149 @endDefreq
6151 @cindex hyphenation character (@code{\%})
6152 @cindex character, hyphenation (@code{\%})
6153 @cindex disabling hyphenation (@code{\%})
6154 @cindex hyphenation, disabling (@code{\%})
6155 @DefescList {\\%, , , }
6156 @deffnx Escape @t{\:}
6157 @ifnotinfo
6158 @esindex \:
6159 @end ifnotinfo
6160 @ifinfo
6161 @esindex @r{<colon>}
6162 @end ifinfo
6163 To tell @code{gtroff} how to hyphenate words on the fly, use the
6164 @code{\%} escape, also known as the @dfn{hyphenation character}.
6165 Preceding a word with this character prevents it from being
6166 hyphenated; putting it inside a word indicates to @code{gtroff} that
6167 the word may be hyphenated at that point.  Note that this mechanism
6168 only affects that one occurrence of the word; to change the
6169 hyphenation of a word for the entire document, use the @code{hw}
6170 request.
6172 The @code{\:} escape inserts a zero-width break point
6173 (that is, the word breaks but without adding a hyphen).
6175 @Example
6176 ... check the /var/log/\:httpd/\:access_log file ...
6177 @endExample
6178 @endDefesc
6180 @Defreq {hc, [@Var{char}]}
6181 Change the hyphenation character to @var{char}.  This character then
6182 works the same as the @code{\%} escape, and thus, no longer appears in
6183 the output.  Without an argument, @code{hc} resets the hyphenation
6184 character to be @code{\%} (the default) only.
6186 The hyphenation character is associated with the current environment
6187 (@pxref{Environments}).
6188 @endDefreq
6190 @cindex hyphenation patterns (@code{hpf})
6191 @cindex patterns for hyphenation (@code{hpf})
6192 @DefreqList {hpf, pattern_file}
6193 @DefreqItem {hpfa, pattern_file}
6194 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6195 Read in a file of hyphenation patterns.  This file is searched for in
6196 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6197 searched for if the @option{-m@var{name}} option is specified.
6199 It should have the same format as (simple) @TeX{} patterns files.
6200 More specifically, the following scanning rules are implemented.
6202 @itemize @bullet
6203 @item
6204 A percent sign starts a comment (up to the end of the line)
6205 even if preceded by a backslash.
6207 @item
6208 No support for `digraphs' like @code{\$}.
6210 @item
6211 The only multi-character construction recognized is @code{^^@var{xx}}
6212 (@var{x} is 0-9 or a-f);  other use of @code{^} causes an error.
6214 @item
6215 No macro expansion.
6217 @item
6218 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6219 (possibly with whitespace before and after the braces).
6220 Everything between the braces is taken as hyphenation patterns.
6221 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6223 @item
6224 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6225 exceptions.
6227 @item
6228 @code{\endinput} is recognized also.
6230 @item
6231 For backwards compatibility, if @code{\patterns} is missing,
6232 the whole file is treated as a list of hyphenation patterns
6233 (only recognizing the @code{%} character as the start of a comment).
6234 @end itemize
6236 If no @code{hpf} request is specified (either in the document or in a
6237 macro package), @code{gtroff} won't hyphenate at all.
6239 The @code{hpfa} request appends a file of patterns to the current list.
6241 The @code{hpfcode} request defines mapping values for character codes in
6242 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6243 (after reading the patterns) before replacing or appending them to
6244 the current list of patterns.  Its arguments are pairs of character codes
6245 -- integers from 0 to@w{ }255.  The request maps character code@w{ }@var{a}
6246 to code@w{ }@var{b}, code@w{ }@var{c} to code@w{ }@var{d}, and so on.  You
6247 can use character codes which would be invalid otherwise.
6249 @pindex troffrc
6250 @pindex troffrc-end
6251 @pindex hyphen.us
6252 The set of hyphenation patterns is associated with the current language
6253 set by the @code{hla} request.  The @code{hpf} request is usually
6254 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6255 @file{troffrc} loads hyphenation patterns for American English (in file
6256 @file{hyphen.us}).
6258 A second call to @code{hpf} (for the same language) will replace the
6259 hyphenation patterns with the new ones.
6261 Invoking @code{hpf} causes an error if there is no current hyphenation
6262 language.
6263 @endDefreq
6265 @cindex hyphenation code (@code{hcode})
6266 @cindex code, hyphenation (@code{hcode})
6267 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6268 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6269 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6270 input character (not a special character) other than a digit or a
6271 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6272 hyphenation code set to itself, and each upper-case letter
6273 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6274 version of itself.
6276 This request is ignored if it has no parameter.
6277 @endDefreq
6279 @cindex hyphenation margin (@code{hym})
6280 @cindex margin for hyphenation (@code{hym})
6281 @cindex @code{ad} request, and hyphenation margin
6282 @DefreqList {hym, [@Var{length}]}
6283 @DefregListEnd {.hym}
6284 Set the (right) hyphenation margin to @var{length}.  If the current
6285 adjustment mode is not @samp{b} or @samp{n}, the line is not
6286 hyphenated if it is shorter than @var{length}.  Without an argument,
6287 the hyphenation margin is reset to its default value, which is@w{ }0.
6288 The default scaling indicator for this request is @samp{m}.  The
6289 hyphenation margin is associated with the current environment
6290 (@pxref{Environments}).
6292 A negative argument resets the hyphenation margin to zero, emitting
6293 a warning of type @samp{range}.
6295 @cindex hyphenation margin register (@code{.hym})
6296 The current hyphenation margin is available in the @code{.hym} read-only
6297 number register.
6298 @endDefreq
6300 @cindex hyphenation space (@code{hys})
6301 @cindex @code{ad} request, and hyphenation space
6302 @DefreqList {hys, [@Var{hyphenation_space}]}
6303 @DefregListEnd {.hys}
6304 Set the hyphenation space to @var{hyphenation_space}.  If the current
6305 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6306 if it can be justified by adding no more than @var{hyphenation_space}
6307 extra space to each word space.  Without argument, the hyphenation
6308 space is set to its default value, which is@w{ }0.  The default
6309 scaling indicator for this request is @samp{m}.  The hyphenation
6310 space is associated with the current environment
6311 (@pxref{Environments}).
6313 A negative argument resets the hyphenation space to zero, emitting a
6314 warning of type @samp{range}.
6316 @cindex hyphenation space register (@code{.hys})
6317 The current hyphenation space is available in the @code{.hys} read-only
6318 number register.
6319 @endDefreq
6321 @cindex soft hyphen character, setting (@code{shc})
6322 @cindex character, soft hyphen, setting (@code{shc})
6323 @cindex glyph, soft hyphen (@code{hy})
6324 @cindex soft hyphen glyph (@code{hy})
6325 @cindex @code{char} request, and soft hyphen character
6326 @cindex @code{tr} request, and soft hyphen character
6327 @Defreq {shc, [@Var{char}]}
6328 Set the soft hyphen character to @var{char}.  If the argument is
6329 omitted, the soft hyphen character is set to the default character
6330 @code{\(hy} (this is the start-up value of @code{gtroff} also).  The
6331 soft hyphen character is the character that is inserted when a word is
6332 hyphenated at a line break.  If the soft hyphen character does not
6333 exist in the font of the character immediately preceding a potential
6334 break point, then the line is not broken at that point.  Neither
6335 definitions (specified with the @code{char} request) nor translations
6336 (specified with the @code{tr} request) are considered when finding the
6337 soft hyphen character.
6338 @endDefreq
6340 @cindex @code{hpf} request, and hyphenation language
6341 @cindex @code{hw} request, and hyphenation language
6342 @pindex troffrc
6343 @pindex troffrc-end
6344 @DefreqList {hla, language}
6345 @DefregListEnd {.hla}
6346 Set the current hyphenation language to the string @var{language}.
6347 Hyphenation exceptions specified with the @code{hw} request and
6348 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6349 requests are both associated with the current hyphenation language.
6350 The @code{hla} request is usually invoked by the @file{troffrc} or the
6351 @file{troffrc-end} files; @file{troffrc} sets the default language to
6352 @samp{us}.
6354 @cindex hyphenation language register (@code{.hla})
6355 The current hyphenation language is available as a string in the
6356 read-only number register @samp{.hla}.
6358 @Example
6359 .ds curr_language \n[.hla]
6360 \*[curr_language]
6361     @result{} us
6362 @endExample
6363 @endDefreq
6366 @c =====================================================================
6368 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6369 @section Manipulating Spacing
6370 @cindex manipulating spacing
6371 @cindex spacing, manipulating
6373 @Defreq {sp, [@Var{distance}]}
6374 Space downwards @var{distance}.  With no argument it advances 1@w{
6375 }line.  A negative argument causes @code{gtroff} to move up the page
6376 the specified distance.  If the argument is preceded by a @samp{|}
6377 then @code{gtroff} moves that distance from the top of the page.  This
6378 request causes a line break.  The default scaling indicator is @samp{v}.
6379 @endDefreq
6381 @cindex double spacing (@code{ls})
6382 @DefreqList {ls, [@Var{nnn}]}
6383 @DefregListEnd {.L}
6384 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6385 With no argument, @code{gtroff} uses the previous value before the
6386 last @code{ls} call.
6388 @Example
6389 .ls 2    \" This causes double-spaced output
6390 .ls 3    \" This causes triple-spaced output
6391 .ls      \" Again double spaced
6392 @endExample
6394 The line spacing is associated with the current environment
6395 (@pxref{Environments}).
6397 @cindex line spacing register (@code{.L})
6398 The read-only number register @code{.L} contains the current line
6399 spacing setting.
6400 @endDefreq
6402 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6403 as alternatives to @code{ls}.
6405 @c XXX document \n[nl]
6406 @c XXX document \n[nl] == -1 if vertical position is zero
6408 @DefescList {\\x, ', spacing, '}
6409 @DefregListEnd {.a}
6410 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6411 to allow space for a tall construct (like an equation).  The @code{\x}
6412 escape does this.  The escape is given a numerical argument, usually
6413 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6414 is @samp{v}.  If this number is positive extra vertical space is
6415 inserted below the current line.  A negative number adds space above.
6416 If this escape is used multiple times on the same line, the maximum of
6417 the values is used.
6419 @xref{Escapes}, for details on parameter delimiting characters.
6421 @cindex extra post-vertical line space register (@code{.a})
6422 The @code{.a} read-only number register contains the most recent
6423 (nonnegative) extra vertical line space.
6425 @c XXX
6426 @ignore
6427 @Example
6428 ... example of inline equation ...
6429 @endExample
6430 @end ignore
6431 @endDefesc
6433 @cindex @code{sp} request, and no-space mode
6434 @cindex no-space mode (@code{ns})
6435 @cindex mode, no-space (@code{ns})
6436 @cindex blank lines, disabling
6437 @cindex lines, blank, disabling
6438 @DefreqList {ns, }
6439 @DefregListEnd {.ns}
6440 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6441 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6442 advance to the next page is also disabled, except if it is accompanied
6443 by a page number (see @ref{Page Control}, for more information).  This
6444 mode ends when actual text is output or the @code{rs} request is
6445 encountered.  The read-only number register @code{.ns} is set to@w{ }1.
6447 This request is useful for macros that conditionally
6448 insert vertical space before the text starts
6449 (for example, a paragraph macro could insert some space
6450 except when it is the first paragraph after a section header).
6452 @c XXX xref
6453 @endDefreq
6455 @Defreq {rs, }
6456 Disable no-space mode.
6458 @c XXX xref
6459 @endDefreq
6462 @c =====================================================================
6464 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6465 @section Tabs and Fields
6466 @cindex tabs and fields
6467 @cindex fields and tabs
6469 @cindex @acronym{EBCDIC} encoding of a tab
6470 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6471 }5) causes a horizontal movement to the next tab stop (much
6472 like it did on a typewriter).
6474 @cindex tab character, non-interpreted (@code{\t})
6475 @Defesc {\\t, , , }
6476 This escape is a non-interpreted tab character.  In copy mode
6477 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6478 @endDefesc
6480 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6481 @DefregListEnd {.tabs}
6482 Change tab stop positions.  This request takes a series of tab
6483 specifiers as arguments (optionally divided into two groups with the
6484 letter @samp{T}) which indicate where each tab stop is to be
6485 (overriding any previous settings).
6487 Tab stops can be specified absolutely, i.e., as the distance from the
6488 left margin.  For example, the following sets 6@w{ }tab stops every
6489 one inch.
6491 @Example
6492 .ta 1i 2i 3i 4i 5i 6i
6493 @endExample
6495 Tab stops can also be specified using a leading @samp{+}
6496 which means that the specified tab stop is set relative to
6497 the previous tab stop.  For example, the following is equivalent to the
6498 previous example.
6500 @Example
6501 .ta 1i +1i +1i +1i +1i +1i
6502 @endExample
6504 @code{gtroff} supports an extended syntax to specify repeat values after
6505 the @samp{T} mark (these values are always taken as relative) -- this is
6506 the usual way to specify tabs set at equal intervals.  The following is,
6507 yet again, the same as the previous examples.  It does even more since
6508 it defines an infinite number of tab stops separated by one inch.
6510 @Example
6511 .ta T 1i
6512 @endExample
6514 Now we are ready to interpret the full syntax given at the beginning:
6515 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6516 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6517 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6518 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6520 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6521 20c 23c 28c 30c @dots{}}.
6523 The material in each tab column (i.e., the column between two tab stops)
6524 may be justified to the right or left or centered in the column.  This
6525 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6526 specifier.  The default justification is @samp{L}.  Example:
6528 @Example
6529 .ta 1i 2iC 3iR
6530 @endExample
6532 Some notes:
6534 @itemize @bullet
6535 @item
6536 The default unit of the @code{ta} request is @samp{m}.
6538 @item
6539 A tab stop is converted into a non-breakable horizontal movement which
6540 can be neither stretched nor squeezed.  For example,
6542 @Example
6543 .ds foo a\tb\tc
6544 .ta T 5i
6545 \*[foo]
6546 @endExample
6548 @noindent
6549 creates a single line which is a bit longer than 10@w{ }inches (a string
6550 is used to show exactly where the tab characters are).  Now consider the
6551 following:
6553 @Example
6554 .ds bar a\tb b\tc
6555 .ta T 5i
6556 \*[bar]
6557 @endExample
6559 @noindent
6560 @code{gtroff} first converts the tab stops of the line into unbreakable
6561 horizontal movements, then splits the line after the second @samp{b}
6562 (assuming a sufficiently short line length).  Usually, this isn't what
6563 the user wants.
6565 @item
6566 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6567 stop) are ignored except the first one which delimits the characters
6568 belonging to the last tab stop for right-justifying or centering.
6569 Consider the following example
6571 @Example
6572 .ds Z   foo\tbar\tfoo
6573 .ds ZZ  foo\tbar\tfoobar
6574 .ds ZZZ foo\tbar\tfoo\tbar
6575 .ta 2i 4iR
6576 \*[Z]
6578 \*[ZZ]
6580 \*[ZZZ]
6582 @endExample
6584 @noindent
6585 which produces the following output:
6587 @Example
6588 foo                 bar              foo
6589 foo                 bar           foobar
6590 foo                 bar              foobar
6591 @endExample
6593 @noindent
6594 The first line right-justifies the second `foo' relative to the tab
6595 stop.  The second line right-justifies `foobar'.  The third line finally
6596 right-justifies only `foo' because of the additional tab character which
6597 marks the end of the string belonging to the last defined tab stop.
6599 @item
6600 Tab stops are associated with the current environment
6601 (@pxref{Environments}).
6603 @item
6604 Calling @code{ta} without an argument removes all tab stops.
6606 @item
6607 @cindex tab stops, for tty output devices
6608 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}}.  This value
6609 is used even for tty output devices (contrary to @acronym{UNIX}
6610 @code{nroff} which has tab stops preset every 0.8@dmn{i}).
6612 @c XXX xref implementation differences
6613 @end itemize
6615 @cindex tab settings register (@code{.tabs})
6616 The read-only number register @code{.tabs} contains a string
6617 representation of the current tab settings suitable for use as an
6618 argument to the @code{ta} request.
6620 @Example
6621 .ds tab-string \n[.tabs]
6622 \*[tab-string]
6623     @result{} T120u
6624 @endExample
6625 @endDefreq
6627 @cindex tab repetition character (@code{tc})
6628 @cindex character, tab repetition (@code{tc})
6629 @Defreq {tc, [@Var{fill-char}]}
6630 Normally @code{gtroff} fills the space to the next tab stop with
6631 whitespace.  This can be changed with the @code{tc} request.  With no
6632 argument @code{gtroff} reverts to using whitespace, which is the
6633 default.  The value of this @dfn{tab repetition} character is
6634 associated with the current environment (@pxref{Environments}).
6635 @endDefreq
6637 @cindex tab, line-tabs mode
6638 @cindex line-tabs mode
6639 @DefreqList {linetabs, n}
6640 @DefregListEnd {.linetabs}
6641 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6642 or disable it otherwise (the default).
6643 In line-tabs mode, @code{gtroff} computes tab distances
6644 relative to the (current) output line instead of the input line.
6646 For example, the following code:
6648 @Example
6649 .ds x a\t\c
6650 .ds y b\t\c
6651 .ds z c
6652 .ta 1i 3i
6656 @endExample
6658 @noindent
6659 in normal mode, results in the output
6661 @Example
6662 a         b         c
6663 @endExample
6665 @noindent
6666 in line-tabs mode, the same code outputs
6668 @Example
6669 a         b                   c
6670 @endExample
6672 Line-tabs mode is associated with the current environment.
6673 The read-only register @code{.linetabs} is set to@w{ }1 if in line-tabs
6674 mode, and 0 in normal mode.
6675 @endDefreq
6677 @menu
6678 * Leaders::
6679 * Fields::
6680 @end menu
6682 @c ---------------------------------------------------------------------
6684 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6685 @subsection Leaders
6686 @cindex leaders
6688 Sometimes it may may be desirable to use the @code{tc} request to fill a
6689 particular tab stop with a given character (for example dots in a table
6690 of contents), but also normal tab stops on the rest of the line.  For
6691 this @code{gtroff} provides an alternate tab mechanism, called
6692 @dfn{leaders} which does just that.
6694 @cindex leader character
6695 A leader character (character code@w{ }1) behaves similarly to a tab
6696 character: It moves to the next tab stop.  The only difference is that
6697 for this movement, the fill character defaults to a period character and
6698 not to space.
6700 @cindex leader character, non-interpreted (@code{\a})
6701 @Defesc {\\a, , , }
6702 This escape is a non-interpreted leader character.  In copy mode
6703 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6704 character.
6705 @endDefesc
6707 @cindex leader repetition character (@code{lc})
6708 @cindex character, leader repetition (@code{lc})
6709 @Defreq {lc, [@Var{fill-char}]}
6710 Declare the leader character.  Without an argument, leaders act the
6711 same as tabs (i.e., using whitespace for filling).  @code{gtroff}'s
6712 start-up value is @samp{.}.  The value of this @dfn{leader repetition}
6713 character is associated with the current environment
6714 (@pxref{Environments}).
6715 @endDefreq
6717 @cindex table of contents
6718 @cindex contents, table of
6719 For a table of contents, to name an example, tab stops may be defined so
6720 that the section number is one tab stop, the title is the second with
6721 the remaining space being filled with a line of dots, and then the page
6722 number slightly separated from the dots.
6724 @Example
6725 .ds entry 1.1\tFoo\a\t12
6726 .lc .
6727 .ta 1i 5i +.25i
6728 \*[entry]
6729 @endExample
6731 @noindent
6732 This produces
6734 @Example
6735 1.1  Foo..........................................  12
6736 @endExample
6738 @c ---------------------------------------------------------------------
6740 @node Fields,  , Leaders, Tabs and Fields
6741 @subsection Fields
6742 @cindex fields
6744 @cindex field delimiting character (@code{fc})
6745 @cindex delimiting character for fields (@code{fc})
6746 @cindex character, field delimiting (@code{fc})
6747 @cindex field padding character (@code{fc})
6748 @cindex padding character for fields (@code{fc})
6749 @cindex character, field padding (@code{fc})
6750 @dfn{Fields} are a more general way of laying out tabular data.  A field
6751 is defined as the data between a pair of @dfn{delimiting characters}.
6752 It contains substrings which are separated by @dfn{padding characters}.
6753 The width of a field is the distance on the @emph{input} line from the
6754 position where the field starts to the next tab stop.  A padding
6755 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6756 command (thus it can even be negative) to make the sum of all substring
6757 lengths plus the stretchable space equal to the field width.  If more
6758 than one padding character is inserted, the available space is evenly
6759 distributed among them.
6761 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6762 Define a delimiting and a padding character for fields.  If the latter
6763 is missing, the padding character defaults to a space character.  If
6764 there is no argument at all, the field mechanism is disabled (which is
6765 the default).  Note that contrary to e.g.@: the tab repetition
6766 character, delimiting and padding characters are not associated to the
6767 current environment (@pxref{Environments}).
6769 Example:
6771 @Example
6772 .fc # ^
6773 .ta T 3i
6774 #foo^bar^smurf#
6776 #foo^^bar^smurf#
6777 @endExample
6779 @noindent
6780 and here the result:
6782 @Example
6783 foo         bar          smurf
6784 foo            bar       smurf
6785 @endExample
6786 @endDefreq
6789 @c =====================================================================
6791 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6792 @section Character Translations
6793 @cindex character translations
6794 @cindex translations of characters
6796 @cindex control character, changing (@code{cc})
6797 @cindex character, control, changing (@code{cc})
6798 @cindex no-break control character, changing (@code{c2})
6799 @cindex character, no-break control, changing (@code{c2})
6800 @cindex control character, no-break, changing (@code{c2})
6801 The control character (@samp{.}) and the no-break control character
6802 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6803 respectively.
6805 @Defreq {cc, [@Var{c}]}
6806 Set the control character to@w{ }@var{c}.  With no argument the default
6807 control character @samp{.} is restored.  The value of the control
6808 character is associated with the current environment
6809 (@pxref{Environments}).
6810 @endDefreq
6812 @Defreq {c2, [@Var{c}]}
6813 Set the no-break control character to@w{ }@var{c}.  With no argument the
6814 default control character @samp{'} is restored.  The value of the
6815 no-break control character is associated with the current environment
6816 (@pxref{Environments}).
6817 @endDefreq
6819 @cindex disabling @code{\} (@code{eo})
6820 @cindex @code{\}, disabling (@code{eo})
6821 @Defreq {eo, }
6822 Disable the escape mechanism completely.  After executing this
6823 request, the backslash character @samp{\} no longer starts an escape
6824 sequence.
6826 This request can be very helpful in writing macros since it is not
6827 necessary then to double the escape character.  Here an example:
6829 @Example
6830 .\" This is a simplified version of the
6831 .\" .BR request from the man macro package
6833 .de BR
6834 .  ds result \&
6835 .  while (\n[.$] >= 2) \@{\
6836 .    as result \fB\$1\fR\$2
6837 .    shift 2
6838 .  \@}
6839 .  if \n[.$] .as result \fB\$1
6840 \*[result]
6841 .  ft R
6844 @endExample
6845 @endDefreq
6847 @cindex escape character, changing (@code{ec})
6848 @cindex character, escape, changing (@code{ec})
6849 @Defreq {ec, [@Var{c}]}
6850 Set the escape character to@w{ }@var{c}.  With no argument the default
6851 escape character @samp{\} is restored.  It can be also used to
6852 re-enable the escape mechanism after an @code{eo} request.
6854 Note that changing the escape character globally will likely break
6855 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6856 i.e., to convert a macro definition into an internal form which is
6857 independent of its representation (@TeX{} has this mechanism).
6858 If a macro is called, it is executed literally.
6859 @endDefreq
6861 @DefreqList {ecs, }
6862 @DefreqListEnd {ecr, }
6863 The @code{ecs} request saves the current escape character
6864 in an internal register.
6865 Use this request in combination with the @code{ec} request to
6866 temporarily change the escape character.
6868 The @code{ecr} request restores the escape character
6869 saved with @code{ecs}.
6870 Without a previous call to @code{ecs}, this request
6871 sets the escape character to @code{\}.
6872 @endDefreq
6874 @DefescList {\\\\, , , }
6875 @DefescItem {\\e, , , }
6876 @DefescListEnd {\\E, , , }
6877 Print the current escape character (which is the backslash character
6878 @samp{\} by default).
6880 @code{\\} is a `delayed' backslash; more precisely, it is the default
6881 escape character followed by a backslash, which no longer has special
6882 meaning due to the leading escape character.  It is @emph{not} an escape
6883 sequence in the usual sense!  In any unknown escape sequence
6884 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6885 But if @var{X} is equal to the current escape character, no warning is
6886 emitted.
6888 As a consequence, only at top-level or in a diversion a backslash glyph is
6889 printed; in copy-in mode, it expands to a single backslash which then
6890 combines with the following character to an escape sequence.
6892 The @code{\E} escape differs from @code{\e} by printing an escape
6893 character that is not interpreted in copy mode.
6894 Use this to define strings with escapes that work
6895 when used in copy mode (for example, as a macro argument).
6896 The following example defines strings to begin and end
6897 a superscript:
6899 @Example
6900 .ds @{ \v'-.3m'\s'\Es[.s]*60/100'
6901 .ds @} \s0\v'.3m'
6902 @endExample
6904 Another example to demonstrate the differences between the various escape
6905 sequences, using a strange escape character, @samp{-}.
6907 @Example
6908 .ec -
6909 .de xxx
6910 --A'123'
6912 .xxx
6913     @result{} -A'foo'
6914 @endExample
6916 @noindent
6917 The result is surprising for most users, expecting @samp{1} since
6918 @samp{foo} is a valid identifier.  What has happened?  As mentioned
6919 above, the leading escape character makes the following character
6920 ordinary.  Written with the default escape character the sequence
6921 @samp{--} becomes @samp{\-} -- this is the minus sign.
6923 If the escape character followed by itself is a valid escape sequence,
6924 only @code{\E} yields the expected result:
6926 @Example
6927 .ec -
6928 .de xxx
6929 -EA'123'
6931 .xxx
6932     @result{} 1
6933 @endExample
6934 @endDefesc
6936 @Defesc {\\., , , }
6937 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
6938 As before, a warning message is suppressed if the escape character is
6939 followed by a dot, and the dot itself is printed.
6941 @Example
6942 .de foo
6943 .  nop foo
6945 .  de bar
6946 .    nop bar
6947 \\..
6950 .foo
6951 .bar
6952     @result{} foo bar
6953 @endExample
6955 @noindent
6956 The first backslash is consumed while the macro is read, and the second
6957 is swallowed while exexuting macro @code{foo}.
6958 @endDefesc
6960 A @dfn{translation} is a mapping of an input character to an output
6961 character.  The default mappings are given in the font definition files
6962 for the specific output device (@pxref{Font Files}); all mappings (both
6963 with @code{tr} and in the font definition files) occur at output time,
6964 i.e., the input character gets assigned the metric information of the
6965 mapped output character.
6967 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6968 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6969 Translate character @var{a} to@w{ }@var{b}, character @var{c} to@w{
6970 }@var{d}, etc.  If there is an odd number of arguments, the last one is
6971 translated to the space character.
6973 The @code{trin} request is identical to @code{tr},
6974 but when you unformat a diversion with @code{asciify}
6975 it ignores the translation.
6976 @xref{Diversions}, for details about the @code{asciify} request.
6978 Some notes:
6980 @itemize @bullet
6981 @item
6982 @cindex @code{\(}, and translations
6983 @cindex @code{\[}, and translations
6984 @cindex @code{\'}, and translations
6985 @cindex @code{\`}, and translations
6986 @cindex @code{\-}, and translations
6987 @cindex @code{\_}, and translations
6988 @cindex @code{\C}, and translations
6989 @cindex @code{\N}, and translations
6990 @cindex @code{char} request, and translations
6991 @cindex special character
6992 @cindex character, special
6993 @cindex numbered character (@code{\N})
6994 @cindex character, numbered (@code{\N})
6995 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6996 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6997 characters defined with the @code{char} request, and numbered characters
6998 (@code{\N'@var{xxx}'}) can be translated also.
7000 @item
7001 @cindex @code{\e}, and translations
7002 The @code{\e} escape can be translated also.
7004 @item
7005 @cindex @code{\%}, and translations
7006 @cindex @code{\~}, and translations
7007 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
7008 @code{\%} and @code{\~} can't be mapped onto another character).
7010 @item
7011 @cindex backspace character and translations
7012 @cindex character, backspace, and translations
7013 @cindex leader character and translations
7014 @cindex character, leader, and translations
7015 @cindex newline character and translations
7016 @cindex character, newline, and translations
7017 @cindex tab character and translations
7018 @cindex character, tab, and translations
7019 @cindex @code{\a}, and translations
7020 @cindex @code{\t}, and translations
7021 The following characters can't be translated: space (with one exception,
7022 see below), backspace, newline, leader (and @code{\a}), tab (and
7023 @code{\t}).
7025 @item
7026 @cindex @code{shc} request, and translations
7027 Translations are not considered for finding the soft hyphen character
7028 set with the @code{shc} request.
7030 @item
7031 @cindex @code{\&}, and translations
7032 The character pair @samp{@var{c}\&} (this is an arbitrary character@w{
7033 }@var{c} followed by the zero width space character) maps this
7034 character to nothing.
7036 @Example
7037 .tr a\&
7038 foo bar
7039     @result{} foo br
7040 @endExample
7042 @noindent
7043 It is even possible to map the space character to nothing:
7045 @Example
7046 .tr aa \&
7047 foo bar
7048     @result{} foobar
7049 @endExample
7051 @noindent
7052 As shown in the example, the space character can't be the first
7053 character pair as an argument of @code{tr}.  Additionally, it is not
7054 possible to map the space character to any other character; requests
7055 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
7057 If justification is active, lines are justified in spite of the
7058 `empty' space character (but there is no minimal distance, i.e.@: the
7059 space character, between words).
7061 @item
7062 After an output character has been constructed (this happens at the
7063 moment immediately before the character is appended to an output
7064 character list, either by direct output, in a macro, diversion, or
7065 string), it is no longer affected by @code{tr}.
7067 @item
7068 Translating undefined characters is possible also; @code{tr} does not
7069 check whether the characters in its argument are defined.
7071 @c XXX xref
7073 @item
7074 Without an argument, the @code{tr} request is ignored.
7075 @end itemize
7076 @endDefreq
7078 @cindex @code{\!}, and @code{trnt}
7079 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7080 @code{trnt} is the same as the @code{tr} request except that the
7081 translations do not apply to text that is transparently throughput
7082 into a diversion with @code{\!}.  @xref{Diversions}, for more
7083 information.
7085 For example,
7087 @Example
7088 .tr ab
7089 .di x
7090 \!.tm a
7093 @endExample
7095 @noindent
7096 prints @samp{b} to the standard error stream; if @code{trnt} is used
7097 instead of @code{tr} it prints @samp{a}.
7098 @endDefreq
7101 @c =====================================================================
7103 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7104 @section Troff and Nroff Mode
7105 @cindex troff mode
7106 @cindex mode, troff
7107 @cindex nroff mode
7108 @cindex mode, nroff
7110 Originally, @code{nroff} and @code{troff} were two separate programs,
7111 the former for tty output, the latter for everything else.  With GNU
7112 @code{troff}, both programs are merged into one executable, sending
7113 its output to a device driver (@code{grotty} for tty devices,
7114 @code{grops} for @sc{PostScript}, etc.) which interprets the
7115 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
7116 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
7117 since the differences are hardcoded.  For GNU @code{troff}, this
7118 distinction is not appropriate because @code{gtroff} simply takes the
7119 information given in the font files for a particular device without
7120 handling requests specially if a tty output device is used.
7122 Usually, a macro package can be used with all output devices.
7123 Nevertheless, it is sometimes necessary to make a distinction between
7124 tty and non-tty devices: @code{gtroff} provides two built-in
7125 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
7126 @code{while} requests to decide whether @code{gtroff} shall behave
7127 like @code{nroff} or like @code{troff}.
7129 @pindex troffrc
7130 @pindex troffrc-end
7131 @Defreq {troff, }
7132 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7133 condition false) for @code{if}, @code{ie}, and @code{while}
7134 conditional requests.  This is the default if @code{gtroff}
7135 (@emph{not} @code{groff}) is started with the @option{-R} switch to
7136 avoid loading of the start-up files @file{troffrc} and
7137 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
7138 mode if the output device is not a tty (e.g.@: `ps').
7139 @endDefreq
7141 @pindex tty.tmac
7142 @Defreq {nroff, }
7143 Make the @samp{n} built-in condition true (and the @samp{t} built-in
7144 condition false) for @code{if}, @code{ie}, and @code{while}
7145 conditional requests.  This is the default if @code{gtroff} uses a tty
7146 output device; the code for switching to nroff mode is in the file
7147 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
7148 @endDefreq
7150 @xref{Conditionals and Loops}, for more details on built-in
7151 conditions.
7154 @c =====================================================================
7156 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
7157 @section Line Layout
7158 @cindex line layout
7159 @cindex layout, line
7161 @cindex dimensions, line
7162 @cindex line dimensions
7163 The following drawing shows the dimensions which @code{gtroff} uses for
7164 placing a line of output onto the page.  They are labeled with the
7165 request which manipulates each dimension.
7167 @Example
7168                 -->| in |<--
7169                    |<-----------ll------------>|
7170               +----+----+----------------------+----+
7171               |    :    :                      :    |
7172               +----+----+----------------------+----+
7173            -->| po |<--
7174               |<--------paper width---------------->|
7175 @endExample
7177 @noindent
7178 These dimensions are:
7180 @ftable @code
7181 @item po
7182 @cindex left margin (@code{po})
7183 @cindex margin, left (@code{po})
7184 @cindex page offset (@code{po})
7185 @cindex offset, page (@code{po})
7186 @dfn{Page offset} -- this is the leftmost position of text on the final
7187 output, defining the @dfn{left margin}.
7189 @item in
7190 @cindex indentation (@code{in})
7191 @cindex line indentation (@code{in})
7192 @dfn{Indentation} -- this is the distance from the left margin where
7193 text is printed.
7195 @item ll
7196 @cindex line length (@code{ll})
7197 @cindex length of line (@code{ll})
7198 @dfn{Line length} -- this is the distance from the left margin to right
7199 margin.
7200 @end ftable
7202 @c XXX improve example
7204 @Example
7205 .in +.5i
7206 .ll -.5i
7207 A bunch of really boring text which should
7208 be indented from both margins.
7209 Replace me with a better (and more) example!
7210 .in -.5i
7211 .ll +.5i
7212 @endExample
7214 @pindex troffrc
7215 @DefreqList {po, [@Var{offset}]}
7216 @DefreqItem {po, @t{+}@Var{offset}}
7217 @DefreqItem {po, @t{-}@Var{offset}}
7218 @DefregListEnd {.o}
7219 Set horizontal page offset to @var{offset} (or increment or decrement
7220 the current value by @var{offset}).  Note that this request does not
7221 cause a break, so changing the page offset in the middle of text being
7222 filled may not yield the expected result.  The initial value is
7223 1@dmn{i}.  For tty output devices, it is set to 0 in the startup file
7224 @file{troffrc}; the default scaling indicator is @samp{m} (and
7225 not @samp{v} as incorrectly documented in the original
7226 @acronym{UNIX} troff manual).
7228 The current page offset can be found in the read-only number register
7229 @samp{.o}.
7231 If @code{po} is called without an argument, the page offset is reset to
7232 the previous value before the last call to @code{po}.
7234 @Example
7235 .po 3i
7236 \n[.o]
7237     @result{} 720
7238 .po -1i
7239 \n[.o]
7240     @result{} 480
7242 \n[.o]
7243     @result{} 720
7244 @endExample
7245 @endDefreq
7247 @DefreqList {in, [@Var{indent}]}
7248 @DefreqItem {in, @t{+}@Var{indent}}
7249 @DefreqItem {in, @t{-}@Var{indent}}
7250 @DefregListEnd {.i}
7251 Set indentation to @var{indent} (or increment or decrement the
7252 current value by @var{indent}).  This request causes a break.
7253 Initially, there is no indentation.
7255 If @code{in} is called without an argument, the indentation is reset to
7256 the previous value before the last call to @code{in}.  The default
7257 scaling indicator is @samp{m}.
7259 The indentation is associated with the current environment
7260 (@pxref{Environments}).
7262 If a negative indentation value is specified (which is not allowed),
7263 @code{gtroff} emits a warning of type @samp{range} and sets the
7264 indentation to zero.
7266 The effect of @code{in} is delayed until a partially collected line (if
7267 it exists) is output.  A temporary indent value is reset to zero also.
7269 The current indentation (as set by @code{in}) can be found in the
7270 read-only number register @samp{.i}.
7271 @endDefreq
7273 @DefreqList {ti, offset}
7274 @DefreqItem {ti, @t{+}@Var{offset}}
7275 @DefreqItem {ti, @t{-}@Var{offset}}
7276 @DefregListEnd {.in}
7277 Temporarily indent the next output line by @var{offset}.  If an
7278 increment or decrement value is specified, adjust the temporary
7279 indentation relative to the value set by the @code{in} request.
7281 This request causes a break; its value is associated with the current
7282 environment (@pxref{Environments}).  The default scaling indicator
7283 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7285 If the total indentation value is negative (which is not allowed),
7286 @code{gtroff} emits a warning of type @samp{range} and sets the
7287 temporary indentation to zero.  `Total indentation' is either
7288 @var{offset} if specified as an absolute value, or the temporary plus
7289 normal indentation, if @var{offset} is given as a relative value.
7291 The effect of @code{ti} is delayed until a partially collected line (if
7292 it exists) is output.
7294 The read-only number register @code{.in} is the indentation that applies
7295 to the current output line.
7297 The difference between @code{.i} and @code{.in} is that the latter takes
7298 into account whether a partially collected line still uses the old
7299 indentation value or a temporary indentation value is active.
7300 @endDefreq
7302 @DefreqList {ll, [@Var{length}]}
7303 @DefreqItem {ll, @t{+}@Var{length}}
7304 @DefreqItem {ll, @t{-}@Var{length}}
7305 @DefregItem {.l}
7306 @DefregListEnd {.ll}
7307 Set the line length to @var{length} (or increment or decrement the
7308 current value by @var{length}).  Initially, the line length is set to
7309 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7310 collected line (if it exists) is output.  The default scaling
7311 indicator is @samp{m}.
7313 If @code{ll} is called without an argument, the line length is reset to
7314 the previous value before the last call to @code{ll}.  If a negative
7315 line length is specified (which is not allowed), @code{gtroff} emits a
7316 warning of type @samp{range} and sets the line length to zero.
7318 The line length is associated with the current environment
7319 (@pxref{Environments}).
7321 @cindex line length register (@code{.l})
7322 The current line length (as set by @code{ll}) can be found in the
7323 read-only number register @samp{.l}.  The read-only number register
7324 @code{.ll} is the line length that applies to the current output line.
7326 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7327 and @code{.ll} is that the latter takes into account whether a partially
7328 collected line still uses the old line length value.
7329 @endDefreq
7332 @c =====================================================================
7334 @node Line Control, Page Layout, Line Layout, gtroff Reference
7335 @section Line Control
7336 @cindex line control
7337 @cindex control, line
7339 It is important to understand how @code{gtroff} handles input and output
7340 lines.
7342 Many escapes use positioning relative to the input line.  For example,
7343 this
7345 @Example
7346 This is a \h'|1.2i'test.
7348 This is a
7349 \h'|1.2i'test.
7350 @endExample
7352 @noindent
7353 produces
7355 @Example
7356 This is a   test.
7358 This is a             test.
7359 @endExample
7361 The main usage of this feature is to define macros which act exactly
7362 at the place where called.
7364 @Example
7365 .\" A simple macro to underline a word
7366 .de underline
7367 .  nop \\$1\l'|0\[ul]'
7369 @endExample
7371 @noindent
7372 In the above example, @samp{|0} specifies a negative distance from the
7373 current position (at the end of the just emitted argument @code{\$1}) back
7374 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7375 line from right to left.
7377 @cindex input line continuation
7378 @cindex line, input, continuation
7379 @cindex continuation, input line
7380 @cindex output line continuation
7381 @cindex line, output, continuation
7382 @cindex continuation, output line
7383 @cindex interrupted line
7384 @cindex line, interrupted
7385 @code{gtroff} makes a difference between input and output line
7386 continuation; the latter is also called @dfn{interrupting} a line.
7388 @DefescList {\\@key{RET}, , ,}
7389 @DefescItem {\\c, , ,}
7390 @DefregListEnd{.int}
7391 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7392 of a line immediately followed by a newline) works on the input level,
7393 suppressing the effects of the following newline in the input.
7395 @Example
7396 This is a \
7397 .test
7398     @result{} This is a .test
7399 @endExample
7401 The @samp{|} operator is also affected.
7403 @cindex @code{\R} escape, after @code{\c}
7404 @code{\c} works on the output level.  Anything after this escape on the
7405 same line is ignored, except @code{\R} which works as usual.  Anything
7406 before @code{\c} on the same line will be appended to the current partial
7407 output line.  The next non-command line after an interrupted line counts
7408 as a new input line.
7410 The visual results depend on whether no-fill mode is active.
7412 @itemize @bullet
7413 @item
7414 @cindex @code{\c} escape, and no-fill mode
7415 @cindex no-fill mode, and @code{\c}
7416 @cindex mode, no-fill, and @code{\c}
7417 If no-fill mode is active (using the @code{nf} request), the next input
7418 text line after @code{\c} will be handled as a continuation of the same
7419 input text line.
7421 @Example
7423 This is a \c
7424 test.
7425     @result{} This is a test.
7426 @endExample
7428 @item
7429 @cindex @code{\c} escape, and fill mode
7430 @cindex fill mode, and @code{\c}
7431 @cindex mode, fill, and @code{\c}
7432 If fill mode is active (using the @code{fi} request), a word interrupted
7433 with @code{\c} will be continued with the text on the next input text line,
7434 without an intervening space.
7436 @Example
7437 This is a te\c
7439     @result{} This is a test.
7440 @endExample
7441 @end itemize
7443 Note that an intervening control line which causes a break is stronger
7444 than @code{\c}, flushing out the current partial line in the usual way.
7446 @cindex interrupted line register (@code{.int})
7447 The @code{.int} register contains a positive value
7448 if the last output line was interrupted with @code{\c}; this is
7449 associated with the current environment (@pxref{Environments}).
7451 @endDefesc
7453 @c =====================================================================
7455 @node Page Layout, Page Control, Line Control, gtroff Reference
7456 @section Page Layout
7457 @cindex page layout
7458 @cindex layout, page
7460 @code{gtroff} provides some very primitive operations for controlling
7461 page layout.
7463 @cindex page length (@code{pl})
7464 @cindex length of page (@code{pl})
7465 @DefreqList {pl, [@Var{length}]}
7466 @DefreqItem {pl, @t{+}@Var{length}}
7467 @DefreqItem {pl, @t{-}@Var{length}}
7468 @DefregListEnd {.p}
7469 Set the @dfn{page length} to @var{length} (or increment or decrement
7470 the current value by @var{length}).  This is the length of the
7471 physical output page.  The default scaling indicator is @samp{v}.
7473 @cindex page length register (@code{.p})
7474 The current setting can be found in the read-only number register
7475 @samp{.p}.
7477 @cindex top margin
7478 @cindex margin, top
7479 @cindex bottom margin
7480 @cindex margin, bottom
7481 Note that this only specifies the size of the page, not the top and
7482 bottom margins.  Those are not set by @code{gtroff} directly.
7483 @xref{Traps}, for further information on how to do this.
7485 Negative @code{pl} values are possible also, but not very useful: No
7486 trap is sprung, and each line is output on a single page (thus
7487 suppressing all vertical spacing).
7489 If no argument or an invalid argument is given, @code{pl} sets the page
7490 length to 11@dmn{i}.
7491 @endDefreq
7493 @cindex headers
7494 @cindex footers
7495 @cindex titles
7496 @code{gtroff} provides several operations which help in setting up top
7497 and bottom titles (or headers and footers).
7499 @cindex title line (@code{tl})
7500 @cindex three-part title (@code{tl})
7501 @cindex page number character (@code{%})
7502 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7503 Print a @dfn{title line}.  It consists of three parts: a left
7504 justified portion, a centered portion, and a right justified portion.
7505 The argument separator @samp{'} can be replaced with any character not
7506 occurring in the title line.  The @samp{%} character is replaced with
7507 the current page number.  This character can be changed with the
7508 @code{pc} request (see below).
7510 Without argument, @code{tl} is ignored.
7512 Some notes:
7514 @itemize @bullet
7515 @item
7516 A title line is not restricted to the top or bottom of a page.
7518 @item
7519 @code{tl} prints the title line immediately, ignoring a partially filled
7520 line (which stays untouched).
7522 @item
7523 It is not an error to omit closing delimiters.  For example,
7524 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7525 title line with the left justified word @samp{foo}; the centered and
7526 right justfied parts are empty.
7528 @item
7529 Any modifications to the current environment within @code{tl} (e.g.@:
7530 changing the font or font size) are undone after processing @code{tl}.
7532 @item
7533 @code{tl} accepts the same parameter delimiting characters as the
7534 @code{\A} escape; see @ref{Escapes}.
7535 @end itemize
7536 @endDefreq
7538 @cindex length of title line (@code{lt})
7539 @cindex title line, length (@code{lt})
7540 @cindex title line length register (@code{.lt})
7541 @DefreqList {lt, [@Var{length}]}
7542 @DefreqItem {lt, @t{+}@Var{length}}
7543 @DefreqItem {lt, @t{-}@Var{length}}
7544 @DefregListEnd {.lt}
7545 The title line is printed using its own line length, which is
7546 specified (or incremented or decremented) with the @code{lt} request.
7547 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7548 line length is specified (which is not allowed), @code{gtroff} emits a
7549 warning of type @samp{range} and sets the title line length to zero.
7550 The default scaling indicator is @samp{m}.  If @code{lt} is called
7551 without an argument, the title length is reset to the previous value
7552 before the last call to @code{lt}.
7554 The current setting of this is available in the @code{.lt} read-only
7555 number register; it is associated with the current environment
7556 (@pxref{Environments}).
7558 @endDefreq
7560 @cindex page number (@code{pn})
7561 @cindex number, page (@code{pn})
7562 @DefreqList {pn, page}
7563 @DefreqItem {pn, @t{+}@Var{page}}
7564 @DefreqItem {pn, @t{-}@Var{page}}
7565 @DefregListEnd {.pn}
7566 Change (increase or decrease) the page number of the @emph{next} page.
7567 The only argument is the page number; the request is ignored without a
7568 parameter.
7570 The read-only number register @code{.pn} contains the number of the next
7571 page: either the value set by a @code{pn} request, or the number of the
7572 current page plus@w{ }1.
7573 @endDefreq
7575 @cindex page number register (@code{%})
7576 @Defreg {%}
7577 A read-write register holding the current page number.
7578 @endDefreg
7580 @cindex changing the page number character (@code{pc})
7581 @cindex page number character, changing (@code{pc})
7582 @vindex %
7583 @Defreq {pc, [@Var{char}]}
7584 Change the page number character (used by the @code{tl} request) to a
7585 different character.  With no argument, this mechanism is disabled.
7586 Note that this doesn't affect the number register@w{ }@code{%}.
7587 @endDefreq
7589 @xref{Traps}.
7592 @c =====================================================================
7594 @node Page Control, Fonts, Page Layout, gtroff Reference
7595 @section Page Control
7596 @cindex page control
7597 @cindex control, page
7599 @cindex new page (@code{bp})
7600 @cindex page, new (@code{bp})
7601 @DefreqList {bp, [@Var{page}]}
7602 @DefreqItem {bp, @t{+}@Var{page}}
7603 @DefreqListEnd {bp, @t{-}@Var{page}}
7604 Stop processing the current page and move to the next page.  This
7605 request causes a break.  It can also take an argument to set
7606 (increase, decrease) the page number of the next page.  The only
7607 difference between @code{bp} and @code{pn} is that @code{pn} does not
7608 cause a break or actually eject a page.
7610 @Example
7611 .de newpage                         \" define macro
7612 'bp                                 \" begin page
7613 'sp .5i                             \" vertical space
7614 .tl 'left top'center top'right top' \" title
7615 'sp .3i                             \" vertical space
7616 ..                                  \" end macro
7617 @endExample
7619 @cindex @code{bp} request, and top-level diversion
7620 @cindex top-level diversion and @code{bp}
7621 @cindex diversion, top-level, and @code{bp}
7622 @code{bp} has no effect if not called within the top-level diversion
7623 (@pxref{Diversions}).
7624 @endDefreq
7626 @cindex orphan lines, preventing with @code{ne}
7627 @cindex conditional page break (@code{ne})
7628 @cindex page break, conditional (@code{ne})
7629 @Defreq {ne, [@Var{space}]}
7630 It is often necessary to force a certain amount of space before a new
7631 page occurs.  This is most useful to make sure that there is not a
7632 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7633 request ensures that there is a certain distance, specified by the
7634 first argument, before the next page is triggered (see @ref{Traps},
7635 for further information).  The default unit for @code{ne} is @samp{v};
7636 the default value of @var{space} is@w{ }1@dmn{v} if no argument is
7637 given.
7639 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7640 do the following before each paragraph:
7642 @Example
7643 .ne 2
7644 text text text
7645 @endExample
7647 @code{ne} will then automatically cause a page break if there is space
7648 for one line only.
7649 @endDefreq
7651 @cindex @code{ne} request, comparison with @code{sv}
7652 @Defreq {sv, [@Var{space}]}
7653 @code{sv} is similar to the @code{ne} request; it reserves the
7654 specified amount of vertical space.  If the desired amount of space
7655 exists before the next trap (or the bottom page boundary if no trap is
7656 set), the space is output immediately (ignoring a partially filled line
7657 which stays untouched).  If there is not enough space, it is stored for
7658 later output via the @code{os} request.  The default value is@w{ }1@dmn{v}
7659 if no argument is given; the default unit is @samp{v}.
7660 @endDefreq
7663 @c =====================================================================
7665 @node Fonts, Sizes, Page Control, gtroff Reference
7666 @section Fonts
7667 @cindex fonts
7669 @code{gtroff} can switch fonts at any point in the text.
7671 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7672 These are Times Roman, Italic, Bold, and Bold Italic.  For non-tty
7673 devices, there is also at least one symbol font which contains various
7674 special symbols (Greek, mathematics).
7676 @menu
7677 * Changing Fonts::
7678 * Font Families::
7679 * Font Positions::
7680 * Using Symbols::
7681 * Special Fonts::
7682 * Artificial Fonts::
7683 * Ligatures and Kerning::
7684 @end menu
7686 @c ---------------------------------------------------------------------
7688 @node Changing Fonts, Font Families, Fonts, Fonts
7689 @subsection Changing Fonts
7690 @cindex fonts
7692 @cindex changing fonts (@code{ft}, @code{\f})
7693 @cindex fonts, changing (@code{ft}, @code{\f})
7694 @cindex @code{sty} request, and changing fonts
7695 @cindex @code{fam} request, and changing fonts
7696 @cindex @code{\F} escape, and changing fonts
7697 @kindex styles
7698 @kindex family
7699 @pindex DESC
7700 @DefreqList {ft, [@Var{font}]}
7701 @DefescItem {\\f, , f, }
7702 @DefescItem {\\f, @lparen{}, fn, }
7703 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7704 The @code{ft} request and the @code{\f} escape change the current font
7705 to @var{font} (one-character name@w{ }@var{f}, two-character name
7706 @var{fn}).
7708 If @var{font} is a style name (as set with the @code{sty} request or
7709 with the @code{styles} command in the @file{DESC} file), use it within
7710 the current font family (as set with the @code{fam} request, @code{\F}
7711 escape, or with the @code{family} command in the @file{DESC} file).
7713 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7714 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7715 With no argument or using @samp{P} as an argument, @code{.ft} switches
7716 to the previous font.  Use @code{\f[]} to do this with the escape.  The
7717 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7719 Fonts are generally specified as upper-case strings, which are usually
7720 1@w{ }to 4 characters representing an abbreviation or acronym of the
7721 font name.  This is no limitation, just a convention.
7723 The example below produces two identical lines.
7725 @Example
7726 eggs, bacon,
7727 .ft B
7728 spam
7730 and sausage.
7732 eggs, bacon, \fBspam\fP and sausage.
7733 @endExample
7735 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7736 As a consequence, it can be used in requests like @code{mc} (which
7737 expects a single character as an argument) to change the font on
7738 the fly:
7740 @Example
7741 .mc \f[I]x\f[]
7742 @endExample
7744 @xref{Font Positions}, for an alternative syntax.
7745 @endDefreq
7747 @cindex @code{ft} request, and font translations
7748 @cindex @code{ul} request, and font translations
7749 @cindex @code{bd} request, and font translations
7750 @cindex @code{\f}, and font translations
7751 @cindex @code{cs} request, and font translations
7752 @cindex @code{tkf} request, and font translations
7753 @cindex @code{special} request, and font translations
7754 @cindex @code{fspecial} request, and font translations
7755 @cindex @code{fp} request, and font translations
7756 @cindex @code{sty} request, and font translations
7757 @Defreq {ftr, f [@Var{g}]}
7758 Translate font@w{ }@var{f} to font@w{ }@var{g}.  Whenever a font named@w{
7759 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7760 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7761 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7762 font@w{ }@var{g} is used.  If @var{g} is missing or equal to@w{ }@var{f}
7763 the translation is undone.
7764 @endDefreq
7766 @c ---------------------------------------------------------------------
7768 @node Font Families, Font Positions, Changing Fonts, Fonts
7769 @subsection Font Families
7770 @cindex font families
7771 @cindex families, font
7772 @cindex font styles
7773 @cindex styles, font
7775 Due to the variety of fonts available, @code{gtroff} has added the
7776 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7777 specified as the concatenation of the font family and style.  Specifying
7778 a font without the family part causes @code{gtroff} to use that style of
7779 the current family.
7781 @cindex postscript fonts
7782 @cindex fonts, postscript
7783 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7784 @option{-Tlbp} are set up to this mechanism.
7785 By default, @code{gtroff} uses the Times family with the four styles
7786 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7788 This way, it is possible to use the basic four fonts and to select a
7789 different font family on the command line (@pxref{Groff Options}).
7791 @cindex changing font family (@code{fam}, @code{\F})
7792 @cindex font family, changing (@code{fam}, @code{\F})
7793 @DefreqList {fam, [@Var{family}]}
7794 @DefregItem {.fam}
7795 @DefescItem {\\F, , f, }
7796 @DefescItem {\\F, @lparen{}, fm, }
7797 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7798 @DefregListEnd {.fn}
7799 Switch font family to @var{family} (one-character name@w{ }@var{f},
7800 two-character name @var{fm}).  If no argument is given, switch
7801 back to the previous font family.  Use @code{\F[]} to do this with the
7802 escape.  Note that @code{\FP} doesn't work; it selects font family
7803 @samp{P} instead.
7805 The value at start-up is @samp{T}.
7806 The current font family is available in the read-only number register
7807 @samp{.fam} (this is a string-valued register); it is associated with
7808 the current environment.
7810 @Example
7811 spam,
7812 .fam H    \" helvetica family
7813 spam,     \" used font is family H + style R = HR
7814 .ft B     \" family H + style B = font HB
7815 spam,
7816 .fam T    \" times family
7817 spam,     \" used font is family T + style B = TB
7818 .ft AR    \" font AR (not a style)
7819 baked beans,
7820 .ft R     \" family T + style R = font TR
7821 and spam.
7822 @endExample
7824 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7825 As a consequence, it can be used in requests like @code{mc} (which
7826 expects a single character as an argument) to change the font family on
7827 the fly:
7829 @Example
7830 .mc \F[P]x\F[]
7831 @endExample
7833 The @samp{.fn} register contains the current @dfn{real font name}
7834 of the current font.
7835 This is a string-valued register.
7836 If the current font is a style, the value of @code{\n[.fn]}
7837 is the proper concatenation of family and style name.
7838 @endDefreq
7840 @cindex changing font style (@code{sty})
7841 @cindex font style, changing (@code{sty})
7842 @cindex @code{cs} request, and font styles
7843 @cindex @code{bd} request, and font styles
7844 @cindex @code{tkf} request, and font styles
7845 @cindex @code{uf} request, and font styles
7846 @cindex @code{fspecial} request, and font styles
7847 @Defreq {sty, n style}
7848 Associate @var{style} with font position@w{ }@var{n}.  A font position
7849 can be associated either with a font or with a style.  The current
7850 font is the index of a font position and so is also either a font or a
7851 style.  If it is a style, the font that is actually used is the font
7852 which name is the concatenation of the name of the current
7853 family and the name of the current style.  For example, if the current
7854 font is@w{ }1 and font position@w{ }1 is associated with style
7855 @samp{R} and the current font family is @samp{T}, then font
7856 @samp{TR} will be used.  If the current font is not a style, then the
7857 current family is ignored.  If the requests @code{cs}, @code{bd},
7858 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7859 they will instead be applied to the member of the current family
7860 corresponding to that style.
7862 @var{n}@w{ }must be a non-negative integer value.
7864 @pindex DESC
7865 @kindex styles
7866 The default family can be set with the @option{-f} option
7867 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7868 file controls which font positions (if any) are initially associated
7869 with styles rather than fonts.  For example, the default setting for
7870 @sc{PostScript} fonts
7872 @Example
7873 styles R I B BI
7874 @endExample
7876 @noindent
7877 is equivalent to
7879 @Example
7880 .sty 1 R
7881 .sty 2 I
7882 .sty 3 B
7883 .sty 4 BI
7884 @endExample
7886 @code{fam} and @code{\F} always check whether the current font position
7887 is valid; this can give surprising results if the current font position is
7888 associated with a style.
7890 In the following example, we want to access the @sc{PostScript} font
7891 @code{FooBar} from the font family @code{Foo}:
7893 @Example
7894 .sty \n[.fp] Bar
7895 .fam Foo
7896     @result{} warning: can't find font `FooR'
7897 @endExample
7899 @noindent
7900 The default font position at start-up is@w{ }1; for the
7901 @sc{PostScript} device, this is associated with style @samp{R}, so
7902 @code{gtroff} tries to open @code{FooR}.
7904 A solution to this problem is to use a dummy font like the following:
7906 @Example
7907 .fp 0 dummy TR    \" set up dummy font at position 0
7908 .sty \n[.fp] Bar  \" register style `Bar'
7909 .ft 0             \" switch to font at position 0
7910 .fam Foo          \" activate family `Foo'
7911 .ft Bar           \" switch to font `FooBar'
7912 @endExample
7914 @xref{Font Positions}.
7915 @endDefreq
7917 @c ---------------------------------------------------------------------
7919 @node Font Positions, Using Symbols, Font Families, Fonts
7920 @subsection Font Positions
7921 @cindex font positions
7922 @cindex positions, font
7924 For the sake of old phototypesetters and compatibility with old versions
7925 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7926 on which various fonts are mounted.
7928 @cindex mounting font (@code{fp})
7929 @cindex font, mounting (@code{fp})
7930 @DefreqList {fp, pos font [@Var{external-name}]}
7931 @DefregItem {.f}
7932 @DefregListEnd {.fp}
7933 Mount font @var{font} at position @var{pos} (which must be a
7934 non-negative integer).  This numeric position can then be referred to
7935 with font changing commands.  When @code{gtroff} starts it is using
7936 font position@w{ }1 (which must exist; position@w{ }0 is unused
7937 usually at start-up).
7939 @cindex font position register (@code{.f})
7940 The current font in use, as a font position, is available in the
7941 read-only number register @samp{.f}.  This can be useful to remember the
7942 current font for later recall.  It is associated with the current
7943 environment (@pxref{Environments}).
7945 @Example
7946 .nr save-font \n[.f]
7947 .ft B
7948 ... text text text ...
7949 .ft \n[save-font]
7950 @endExample
7952 @cindex next free font position register (@code{.fp})
7953 The number of the next free font position is available in the read-only
7954 number register @samp{.fp}.  This is useful when mounting a new font,
7955 like so:
7957 @Example
7958 .fp \n[.fp] NEATOFONT
7959 @endExample
7961 @pindex DESC@r{, and font mounting}
7962 Fonts not listed in the @file{DESC} file are automatically mounted on
7963 the next available font position when they are referenced.  If a font
7964 is to be mounted explicitly with the @code{fp} request on an unused
7965 font position, it should be mounted on the first unused font position,
7966 which can be found in the @code{.fp} register.  Although @code{gtroff}
7967 does not enforce this strictly, it is not allowed to mount a font at a
7968 position whose number is much greater (approx.@: 1000 positions) than
7969 that of any currently used position.
7971 The @code{fp} request has an optional third argument.  This argument
7972 gives the external name of the font, which is used for finding the font
7973 description file.  The second argument gives the internal name of the
7974 font which is used to refer to the font in @code{gtroff} after it has
7975 been mounted.  If there is no third argument then the internal name is
7976 used as the external name.  This feature makes it possible to use
7977 fonts with long names in compatibility mode.
7978 @endDefreq
7980 Both the @code{ft} request and the @code{\f} escape have alternative
7981 syntax forms to access font positions.
7983 @cindex changing font position (@code{\f})
7984 @cindex font position, changing (@code{\f})
7985 @cindex @code{sty} request, and font positions
7986 @cindex @code{fam} request, and font positions
7987 @cindex @code{\F} escape, and font positions
7988 @kindex styles
7989 @kindex family
7990 @pindex DESC
7991 @DefreqList {ft, nnn}
7992 @DefescItem {\\f, , n, }
7993 @DefescItem {\\f, @lparen{}, nn, }
7994 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
7995 Change the current font position to @var{nnn} (one-digit position@w{
7996 }@var{n}, two-digit position @var{nn}), which must be a non-negative
7997 integer.
7999 If @var{nnn} is associated with a style (as set with the @code{sty}
8000 request or with the @code{styles} command in the @file{DESC} file), use
8001 it within the current font family (as set with the @code{fam} request,
8002 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
8003 file).
8005 @Example
8006 this is font 1
8007 .ft 2
8008 this is font 2
8009 .ft                   \" switch back to font 1
8010 .ft 3
8011 this is font 3
8013 this is font 1 again
8014 @endExample
8016 @xref{Changing Fonts}, for the standard syntax form.
8017 @endDefreq
8019 @c ---------------------------------------------------------------------
8021 @node Using Symbols, Special Fonts, Font Positions, Fonts
8022 @subsection Using Symbols
8023 @cindex using symbols
8024 @cindex symbols, using
8026 @cindex glyph
8027 @cindex character
8028 @cindex ligature
8029 A @dfn{glyph} is a graphical representation of a @dfn{character}.
8030 While a character is an abstract entity containing semantic
8031 information, a glyph is something which can be actually seen on screen
8032 or paper.  It is possible that a character has multiple glyph
8033 representation forms (for example, the character `A' can be either
8034 written in a roman or an italic font, yielding two different glyphs);
8035 sometimes more than one character maps to a single glyph (this is a
8036 @dfn{ligature} -- the most common is `fi').
8038 @c XXX
8040 Please note that currently the distinction between glyphs and
8041 characters in this reference is not clearly carried out.  This will be
8042 improved eventually in the next revision.
8044 @cindex symbol
8045 @cindex special fonts
8046 @kindex fonts
8047 @pindex DESC
8048 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
8049 glyph names of a particular font are defined in its font file.  If the
8050 user requests a glyph not available in this font, @code{gtroff} looks
8051 up an ordered list of @dfn{special fonts}.  By default, the
8052 @sc{PostScript} output device supports the two special fonts @samp{SS}
8053 (slanted symbols) and @samp{S} (symbols) (the former is looked up
8054 before the latter).  Other output devices use different names for
8055 special fonts.  Fonts mounted with the @code{fonts} keyword in the
8056 @file{DESC} file are globally available.  To install additional
8057 special fonts locally (i.e.@: for a particular font), use the
8058 @code{fspecial} request.
8060 In summary, @code{gtroff} tries the following to find a given symbol:
8062 @itemize @bullet
8063 @item
8064 If the symbol has been defined with the @code{char} request, use it.
8065 This hides a symbol with the same name in the current font.
8067 @item
8068 Check the current font.
8070 @item
8071 If the symbol has been defined with the @code{fchar} request, use it.
8073 @item
8074 Check all fonts given with the @code{fspecial} request, in the order
8075 of appearance in @code{fspecial} calls.
8077 @item
8078 Check all fonts given with the @code{special} request, in the order
8079 of appearance in @code{special} calls (inclusively the special fonts
8080 defined in the @file{DESC} file, which come first).
8082 @item
8083 As a last resort, consult all fonts loaded up to now (in the order they
8084 have been called the first time) for special fonts and check them.
8085 @end itemize
8087 @xref{Font Files}, and @ref{Special Fonts}, for more details.
8089 @DefescList {\\, @lparen{}, nm, }
8090 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
8091 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
8092 special syntax for one-character names -- the natural form
8093 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
8094 one-character symbol is not the same as an input character, i.e., the
8095 character @code{a} is not the same as @code{\[a]}.  By default,
8096 @code{groff} defines only a single one-character symbol, @code{\[-]};
8097 it is usually accessed as @code{\-}.  On the other hand, @code{gtroff}
8098 has the special feature that @code{\[char@var{XXX}]} is the same as the
8099 input character with character code @var{XXX}.  For example,
8100 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8101 encoding is active.}
8103 If @var{name} is undefined, a warning of type @samp{char} is generated,
8104 and the escape is ignored.  @xref{Debugging}, for information about
8105 warnings.
8107 The list of available symbols is device dependent; see @ref{Glyph Name
8108 Index} for some of them discussed in this reference.
8110 @c XXX list of common symbols
8111 @endDefesc
8113 @cindex named character (@code{\C})
8114 @cindex character, named (@code{\C})
8115 @Defesc {\\C, ', xxx, '}
8116 Typeset the character named @var{xxx}.  Normally it is more convenient
8117 to use @code{\[@var{xxx}]}, but @code{\C} has the advantage that it is
8118 compatible with newer versions of @code{ditroff} and is available in
8119 compatibility mode.
8120 @endDefesc
8122 @cindex numbered character (@code{\N})
8123 @cindex character, numbered (@code{\N})
8124 @cindex @code{char} request, used with @code{\N}
8125 @cindex Unicode
8126 @Defesc {\\N, ', n, '}
8127 Typeset the character with code@w{ }@var{n} in the current font (this
8128 is @strong{not} the input character code).  @var{n}@w{ }can be any
8129 integer.  Most devices only have characters with codes between 0
8130 and@w{ }255; the Unicode output device uses codes in the range
8131 0--65535.  If the current font does not contain a character with that
8132 code, special fonts are @emph{not} searched.  The @code{\N} escape
8133 sequence can be conveniently used in conjunction with the @code{char}
8134 request:
8136 @Example
8137 .char \[phone] \f[ZD]\N'37'
8138 @endExample
8140 @noindent
8141 @pindex DESC
8142 @cindex unnamed characters
8143 @cindex characters, unnamed
8144 The code of each character is given in the fourth column in the font
8145 description file after the @code{charset} command.  It is possible to
8146 include unnamed characters in the font description file by using a
8147 name of @samp{---}; the @code{\N} escape sequence is the only way to
8148 use these.
8149 @endDefesc
8151 Some escape sequences directly map onto special glyphs.
8153 @Defesc {\\', , , }
8154 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8155 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}).  The same
8156 as @code{\[aa]}, the acute accent.
8157 @endDefesc
8159 @Defesc {\\`, , , }
8160 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8161 (@acronym{EBCDIC} character @code{0x79} usually).  The same as
8162 @code{\[ga]}, the grave accent.
8163 @endDefesc
8165 @Defesc {\\-, , , }
8166 This is the same as @code{\[-]}, the minus sign in the current font.
8167 @endDefesc
8169 @c XXX should be `glyph', not `character'
8171 @cindex character properties (@code{cflags})
8172 @cindex properties of characters (@code{cflags})
8173 @Defreq {cflags, n c1 c2 @dots{}}
8174 Each character has certain properties associated with it.  These
8175 properties can be modified with the @code{cflags} request.  The first
8176 argument is the sum of the desired flags and the remaining
8177 arguments are the characters to have those properties.  It is possible
8178 to omit the spaces between the characters.
8180 @table @code
8181 @item 1
8182 @cindex end-of-sentence characters
8183 @cindex characters, end-of-sentence
8184 the character ends sentences (initially characters @samp{.?!} have this
8185 property)
8187 @item 2
8188 @cindex hyphenating characters
8189 @cindex characters, hyphenation
8190 lines can be broken before the character (initially no characters have
8191 this property)
8193 @item 4
8194 @cindex @code{hy} glyph, and @code{cflags}
8195 @cindex @code{em} glyph, and @code{cflags}
8196 lines can be broken after the character (initially the characters
8197 @samp{-\(hy\(em} have this property)
8199 @item 8
8200 @cindex overlapping characters
8201 @cindex characters, overlapping
8202 @cindex @code{ul} glyph, and @code{cflags}
8203 @cindex @code{rn} glyph, and @code{cflags}
8204 @cindex @code{ru} glyph, and @code{cflags}
8205 the character overlaps horizontally (initially the characters
8206 @samp{\(ul\(rn\(ru} have this property)
8208 @item 16
8209 @cindex @code{br} glyph, and @code{cflags}
8210 the character overlaps vertically (initially character @samp{\(br} has
8211 this property)
8213 @item 32
8214 @cindex transparent characters
8215 @cindex character, transparent
8216 @cindex @code{"}, at end of sentence
8217 @cindex @code{'}, at end of sentence
8218 @cindex @code{)}, at end of sentence
8219 @cindex @code{]}, at end of sentence
8220 @cindex @code{*}, at end of sentence
8221 @cindex @code{dg} glyph, at end of sentence
8222 @cindex @code{rq} glyph, at end of sentence
8223 an end-of-sentence character followed by any number of characters with
8224 this property is treated as the end of a sentence if followed by a
8225 newline or two spaces; in other words the character is
8226 @dfn{transparent} for the purposes of end-of-sentence recognition --
8227 this is the same as having a zero space factor in @TeX{} (initially
8228 characters @samp{"')]*\(dg\(rq} have this property).
8229 @end table
8230 @endDefreq
8232 @cindex defining character (@code{char})
8233 @cindex character, defining (@code{char})
8234 @cindex creating new characters (@code{char})
8235 @cindex escape character, while defining character
8236 @cindex character, escape, while defining character
8237 @cindex @code{tr} request, and character definitions
8238 @cindex @code{cp} request, and character definitions
8239 @cindex @code{rc} request, and character definitions
8240 @cindex @code{lc} request, and character definitions
8241 @cindex @code{\l}, and character definitions
8242 @cindex @code{\L}, and character definitions
8243 @cindex @code{\&}, and character definitions
8244 @cindex @code{\e}, and character definitions
8245 @cindex @code{hcode} request, and character definitions
8246 @DefreqList {char, c [@Var{string}]}
8247 @DefreqListEnd {fchar, c [@Var{string}]}
8248 Define a new character@w{ }@var{c} to be @var{string} (which can be
8249 empty).  Every time character@w{ }@var{c} needs to be printed,
8250 @var{string} is processed in a temporary environment and the result is
8251 wrapped up into a single object.  Compatibility mode is turned off and
8252 the escape character is set to @samp{\} while @var{string} is being
8253 processed.  Any emboldening, constant spacing or track kerning is
8254 applied to this object rather than to individual characters in
8255 @var{string}.
8257 A character defined by this request can be used just
8258 like a normal character provided by the output device.  In particular,
8259 other characters can be translated to it with the @code{tr} or
8260 @code{trin} requests; it can be made the leader character by the
8261 @code{lc} request; repeated patterns can be drawn with the character
8262 using the @code{\l} and @code{\L} escape sequences; words containing
8263 the character can be hyphenated correctly if the @code{hcode} request
8264 is used to give the character a hyphenation code.
8266 There is a special anti-recursion
8267 feature: Use of character within the character's definition is handled
8268 like normal characters not defined with @code{char}.
8270 Note that the @code{tr} and @code{trin} requests take precedence if
8271 @code{char} accesses the same character.
8273 @Example
8274 .tr XY
8276     @result{} Y
8277 .char X Z
8279     @result{} Y
8280 .tr XX
8282     @result{} Z
8283 @endExample
8285 The @code{fchar} request defines a fallback character:
8286 @code{gtroff} only checks for characters defined with @code{fchar}
8287 if it cannot find the glyph in the current font.
8288 @code{gtroff} carries out this test before checking special fonts.
8289 @endDefreq
8291 @cindex removing character definition (@code{rchar})
8292 @cindex character, removing definition (@code{rchar})
8293 @Defreq {rchar, c1 c2 @dots{}}
8294 Remove the definitions of characters @var{c1}, @var{c2},@w{
8295 }@enddots{} This undoes the effect of a @code{char} or @code{fchar}
8296 request.
8298 It is possible to omit the whitespace between arguments.
8299 @endDefreq
8301 @xref{Special Characters}.
8303 @c ---------------------------------------------------------------------
8305 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8306 @subsection Special Fonts
8307 @cindex special fonts
8308 @cindex fonts, special
8310 @c XXX Add some more wrapper text up here.
8311 Special fonts are those that @code{gtroff} searches
8312 when it cannot find the requested character in the current font.
8313 The Symbol font is usually a special font.
8315 @DefreqList {special, s1 s2 @dots{}}
8316 @DefreqListEnd {fspecial, f s1 s2 @dots{}}
8317 Use the @code{special} request to define special fonts.
8319 Use the @code{fspecial} request to designate special fonts
8320 only when font@w{ }@var{f} font is active.
8321 @endDefreq
8323 @c ---------------------------------------------------------------------
8325 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8326 @subsection Artificial Fonts
8327 @cindex artificial fonts
8328 @cindex fonts, artificial
8330 There are a number of requests and escapes for artificially creating
8331 fonts.  These are largely vestiges of the days when output devices
8332 did not have a wide variety of fonts, and when @code{nroff} and
8333 @code{troff} were separate programs.  Most of them are no longer
8334 necessary in GNU @code{troff}.  Nevertheless, they are supported.
8336 @cindex changing the font height (@code{\H})
8337 @cindex font height, changing (@code{\H})
8338 @cindex height, font, changing (@code{\H})
8339 @DefescList {\\H, ', height, '}
8340 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8341 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8342 Change (increment, decrement) the height of the current font, but not
8343 the width.  If @var{height} is zero, restore the original height.
8344 Default unit is @samp{z}.
8346 Currently, only the @option{-Tps} device supports this feature.
8348 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8349 As a consequence, it can be used in requests like @code{mc} (which
8350 expects a single character as an argument) to change the font on
8351 the fly:
8353 @Example
8354 .mc \H'+5z'x\H'0'
8355 @endExample
8357 In compatibility mode, @code{gtroff} behaves differently:  If an
8358 increment or decrement is used, it is always taken relative to the
8359 current point size and not relative to the previously selected font
8360 height.  Thus,
8362 @Example
8363 .cp 1
8364 \H'+5'test \H'+5'test
8365 @endExample
8367 @noindent
8368 prints the word @samp{test} twice with the same font height (five
8369 points larger than the current font size).
8370 @endDefesc
8372 @cindex changing the font slant (@code{\S})
8373 @cindex font slant, changing (@code{\S})
8374 @cindex slant, font, changing (@code{\S})
8375 @DefescList {\\S, ', slant, '}
8376 Slant the current font by @var{slant} degrees.  Positive values slant
8377 to the right.
8379 Currently, only the @option{-Tps} device supports this feature.
8381 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8382 As a consequence, it can be used in requests like @code{mc} (which
8383 expects a single character as an argument) to change the font on
8384 the fly:
8386 @Example
8387 .mc \S'20'x\S'0'
8388 @endExample
8390 This request is incorrectly documented in the original @acronym{UNIX}
8391 troff manual; the slant is always set to an absolute value.
8392 @endDefesc
8394 @cindex underlining (@code{ul})
8395 @Defreq {ul, [@Var{lines}]}
8396 The @code{ul} request normally underlines subsequent lines if a tty
8397 output device is used.  Otherwise, the lines are printed in italics
8398 (only the term `underlined' is used in the following).  The single
8399 argument is the number of input lines to be underlined; with no
8400 argument, the next line is underlined.  If @var{lines} is zero or
8401 negative, stop the effects of @code{ul} (if it was active).  Requests
8402 and empty lines do not count for computing the number of underlined
8403 input lines, even if they produce some output like @code{tl}.  Lines
8404 inserted by macros (e.g.@: invoked by a trap) do count.
8406 At the beginning of @code{ul}, the current font is stored and the
8407 underline font is activated.  Within the span of a @code{ul} request,
8408 it is possible to change fonts, but after the last line affected by
8409 @code{ul} the saved font is restored.
8411 This number of lines still to be underlined is associated with the
8412 current environment (@pxref{Environments}).  The underline font can be
8413 changed with the @code{uf} request.
8415 @c XXX @xref should be changed to grotty
8417 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8418 @c implemented in for tty output devices, and which problems can arise.
8420 The @code{ul} request does not underline spaces.
8421 @endDefreq
8423 @cindex continuous underlining (@code{cu})
8424 @cindex underlining, continuous (@code{cu})
8425 @Defreq {cu, [@Var{lines}]}
8426 The @code{cu} request is similar to @code{ul} but underlines spaces as
8427 well (if a tty output device is used).
8428 @endDefreq
8430 @cindex underline font (@code{uf})
8431 @cindex font for underlining (@code{uf})
8432 @Defreq {uf, font}
8433 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
8434 default, this is the font at position@w{ }2.  @var{font} can be either
8435 a non-negative font position or the name of a font.
8436 @endDefreq
8438 @cindex imitating bold face (@code{bd})
8439 @cindex bold face, imitating (@code{bd})
8440 @DefreqList {bd, font [@Var{offset}]}
8441 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8442 @DefregListEnd {.b}
8443 Artificially create a bold font by printing each character twice,
8444 slightly offset.
8446 Two syntax forms are available.
8448 @itemize @bullet
8449 @item
8450 Imitate a bold font unconditionally.  The first argument specifies the
8451 font to embolden, and the second is the number of basic units, minus
8452 one, by which the two characters is offset.  If the second argument is
8453 missing, emboldening is turned off.
8455 @var{font} can be either a non-negative font position or the name of a
8456 font.
8458 @var{offset} is available in the @code{.b} read-only register if a
8459 special font is active; in the @code{bd} request, its default unit is
8460 @samp{u}.
8462 @cindex @code{fspecial} request, and imitating bold
8463 @kindex special
8464 @cindex embolding of special fonts
8465 @cindex special fonts, emboldening
8466 @item
8467 Imitate a bold form conditionally.  Embolden @var{font1} by
8468 @var{offset} only if font @var{font2} is the current font.  This
8469 command can be issued repeatedly to set up different emboldening
8470 values for different current fonts.  If the second argument is
8471 missing, emboldening is turned off for this particular current font.
8473 This affects special fonts only (either set up with the @code{special}
8474 command in font files or with the @code{fspecial} request).
8475 @end itemize
8476 @endDefreq
8478 @cindex constant character space mode (@code{cs})
8479 @cindex mode for constant character space (@code{cs})
8480 @cindex character, constant space
8481 @cindex @code{ps} request, and constant character space mode
8482 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8483 Switch to and from constant character space mode.  If activated, the
8484 width of every character is @math{@var{width}/36} ems.  The em size is
8485 given absolutely by @var{em-size}; if this argument is missing, the em
8486 value is taken from the current font size (as set with the @code{ps}
8487 request) when the font is effectively in use.  Without second and
8488 third argument, constant character space mode is deactivated.
8490 Default unit for @var{em-size} is @samp{z}; @var{width} is an integer.
8491 @endDefreq
8493 @c ---------------------------------------------------------------------
8495 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
8496 @subsection Ligatures and Kerning
8497 @cindex ligatures and kerning
8498 @cindex kerning and ligatures
8500 Ligatures are groups of characters that are run together.  For
8501 example, the letters `f' and `i' can form a ligature `fi' as in the
8502 word `file'.  This produces a cleaner look (albeit subtle) to the
8503 printed output.  Usually, ligatures are not available in fonts for tty
8504 output devices.
8506 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
8507 typesetter that was the target of AT&T @code{troff} also supported
8508 `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or `expert'
8509 fonts may include ligatures for `ft' and `ct', although GNU
8510 @code{troff} does not support these (yet).
8512 @cindex activating ligatures (@code{lg})
8513 @cindex ligatures, activating (@code{lg})
8514 @cindex ligatures enabled register (@code{.lg})
8515 @DefreqList {lg, [@Var{flag}]}
8516 @DefregListEnd {.lg}
8517 Switch the ligature mechanism on or off; if the parameter is non-zero
8518 or missing, ligatures are enabled, otherwise disabled.  Default is on.
8519 The current ligature mode can be found in the read-only number register
8520 @code{.lg} (set to 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
8522 Setting the ligature mode to@w{ }2 enables the two-character ligatures
8523 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8524 ffl).
8525 @endDefreq
8527 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8528 modifies the distance between a character pair to improve readability.
8529 In most cases (but not always) the distance is decreased.
8530 @ifnotinfo
8531 For example, compare the combination of the letters `V' and `A'.  With
8532 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
8533 @end ifnotinfo
8534 Typewriter-like fonts and fonts for terminals where all characters
8535 have the same width don't use kerning.
8537 @cindex activating kerning (@code{kern})
8538 @cindex kerning, activating (@code{kern})
8539 @cindex kerning enabled register (@code{.kern})
8540 @DefreqList {kern, [@Var{flag}]}
8541 @DefregListEnd {.kern}
8542 Switch kerning on or off.  If the parameter is non-zero or missing,
8543 enable pairwise kerning, otherwise disable it.  The read-only number
8544 register @code{.kern} is set to@w{ }1 if pairwise kerning is enabled,
8545 0@w{ }otherwise.
8547 @cindex zero width space character (@code{\&})
8548 @cindex character, zero width space (@code{\&})
8549 @cindex space character, zero width (@code{\&})
8550 If the font description file contains pairwise kerning information,
8551 characters from that font are kerned.  Kerning between two characters
8552 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8554 @xref{Font File Format}.
8555 @endDefreq
8557 @cindex track kerning
8558 @cindex kerning, track
8559 @dfn{Track kerning} expands or reduces the space between characters.
8560 This can be handy, for example, if you need to squeeze a long word
8561 onto a single line or spread some text to fill a narrow column.  It
8562 must be used with great care since it is usually considered bad
8563 typography if the reader notices the effect.
8565 @cindex activating track kerning (@code{tkf})
8566 @cindex track kerning, activating (@code{tkf})
8567 @Defreq {tkf, f s1 n1 s2 n2}
8568 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
8569 }@var{f} the width of every character is increased by an amount
8570 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8571 the current point size is less than or equal to @var{s1} the width is
8572 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8573 width is increased by @var{n2}; if the point size is greater than or
8574 equal to @var{s1} and less than or equal to @var{s2} the increase in
8575 width is a linear function of the point size.
8577 The default unit is @samp{z} for @var{s1} and @var{s2}, @samp{p} for
8578 @var{n1} and @var{n2}.
8580 Note that the track kerning amount is added even to the rightmost character
8581 in a line; for large values it is thus recommended to increase the line
8582 length by the same amount to compensate it.
8583 @endDefreq
8585 Sometimes, when typesetting letters of different fonts, more or less
8586 space at such boundaries are needed.  There are two escapes to help
8587 with this.
8589 @cindex italic correction (@code{\/})
8590 @cindex correction, italic (@code{\/})
8591 @cindex correction between italic and roman character (@code{\/})
8592 @cindex roman character, correction after italic character (@code{\/})
8593 @cindex italic character, correction before roman character (@code{\/})
8594 @Defesc {\\/, , , }
8595 Increase the width of the preceding character so that the spacing
8596 between that character and the following character is correct if the
8597 following character is a roman character.  For example, if an
8598 italic@w{ }@code{f} is immediately followed by a roman right
8599 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8600 overlaps the top left of the right parenthesis.  Use this escape
8601 sequence whenever an italic character is immediately followed by a
8602 roman character without any intervening space.  This small amount of
8603 space is also called @dfn{italic correction}.
8605 @iftex
8606 @example
8607 @group
8608 \f[I]f\f[R])
8609     @result{} {@it f}@r{)}
8610 \f[I]f\/\f[R])
8611     @result{} @i{f}@r{)}
8612 @end group
8613 @end example
8614 @end iftex
8615 @endDefesc
8617 @cindex left italic correction (@code{\,})
8618 @cindex correction, left italic (@code{\,})
8619 @cindex roman character, correction before italic character (@code{\,})
8620 @cindex italic character, correction after roman character (@code{\,})
8621 @Defesc {\\\,, , , }
8622 Modify the spacing of the following character so that the spacing
8623 between that character and the preceding character is correct if the
8624 preceding character is a roman character.  Use this escape sequence
8625 whenever a roman character is immediately followed by an italic
8626 character without any intervening space.  In analogy to above, this
8627 space could be called @dfn{left italic correction}, but this term
8628 isn't used widely.
8630 @iftex
8631 @example
8632 @group
8633 q\f[I]f
8634     @result{} @r{q}@i{f}
8635 q\,\f[I]f
8636     @result{} @r{q}@math{@ptexcomma}@i{f}
8637 @end group
8638 @end example
8639 @end iftex
8640 @endDefesc
8642 @Defesc {\\&, , , }
8643 Insert a zero-width character, which is invisible.  Its intended use
8644 is to stop interaction of a character with its surrounding.
8646 @itemize @bullet
8647 @item
8648 It prevents the insertion of extra space after an end-of-sentence
8649 character.
8651 @Example
8652 Test.
8653 Test.
8654     @result{} Test.  Test.
8655 Test.\&
8656 Test.
8657     @result{} Test. Test.
8658 @endExample
8660 @item
8661 It prevents interpretation of a control character at the beginning of
8662 an input line.
8664 @Example
8665 .Test
8666     @result{} warning: `Test' not defined
8667 \&.Test
8668     @result{} .Test
8669 @endExample
8671 @item
8672 It prevents kerning between two characters.
8674 @ifnotinfo
8675 @example
8676 @group
8678     @result{} @r{VA}
8679 V\&A
8680     @result{} @r{V@w{}A}
8681 @end group
8682 @end example
8683 @end ifnotinfo
8685 @item
8686 It is needed to map an arbitrary character to nothing in the @code{tr}
8687 request (@pxref{Character Translations}).
8688 @end itemize
8689 @endDefesc
8691 @Defesc {\\), , , }
8692 This escape is similar to @code{\&} except that it behaves like a
8693 character declared with the @code{cflags} request to be transparent
8694 for the purposes of an end-of-sentence character.
8696 Its main usage is in macro definitions to protect against arguments
8697 starting with a control character.
8699 @Example
8700 .de xxx
8701 \)\\$1
8703 .de yyy
8704 \&\\$1
8706 This is a test.\c
8707 .xxx '
8708 This is a test.
8709     @result{}This is a test.'  This is a test.
8710 This is a test.\c
8711 .yyy '
8712 This is a test.
8713     @result{}This is a test.' This is a test.
8714 @endExample
8715 @endDefesc
8718 @c =====================================================================
8720 @node Sizes, Strings, Fonts, gtroff Reference
8721 @section Sizes
8722 @cindex sizes
8724 @cindex baseline
8725 @cindex type size
8726 @cindex size of type
8727 @cindex vertical spacing
8728 @cindex spacing, vertical
8729 @code{gtroff} uses two dimensions with each line of text, type size
8730 and vertical spacing.  The @dfn{type size} is approximately the height
8731 of the tallest character.@footnote{This is usually the parenthesis.
8732 Note that in most cases the real dimensions of the glyphs in a font
8733 are @emph{not} related to its type size!  For example, the standard
8734 @sc{PostScript} font families `Times Roman', `Helvetica', and
8735 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8736 output, the size of `Helvetica' has to be reduced by one point, and
8737 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8738 spacing} is the amount of space @code{gtroff} allows for a line of
8739 text; normally, this is about 20%@w{ }larger than the current type
8740 size.  Ratios smaller than this can result in hard-to-read text;
8741 larger than this, it spreads the text out more vertically (useful for
8742 term papers).  By default, @code{gtroff} uses 10@w{ }point type on
8743 12@w{ }point spacing.
8745 @cindex leading
8746 The difference between type size and vertical spacing is known, by
8747 typesetters, as @dfn{leading} (this is pronounced `ledding').
8749 @menu
8750 * Changing Type Sizes::
8751 * Fractional Type Sizes::
8752 @end menu
8754 @c ---------------------------------------------------------------------
8756 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8757 @subsection Changing Type Sizes
8759 @cindex changing type sizes (@code{ps}, @code{\s})
8760 @cindex type sizes, changing (@code{ps}, @code{\s})
8761 @cindex point sizes, changing (@code{ps}, @code{\s})
8762 @DefreqList {ps, [@Var{size}]}
8763 @DefreqItem {ps, @t{+}@Var{size}}
8764 @DefreqItem {ps, @t{-}@Var{size}}
8765 @DefescItem {\\s, , size, }
8766 @DefregListEnd {.s}
8767 Use the @code{ps} request or the @code{\s} escape to change (increase,
8768 decrease) the type size (in points).  Specify @var{size} as either an
8769 absolute point size, or as a relative change from the current size.
8770 The size@w{ }0, or no argument, goes back to the previous size.
8772 Default unit of @code{size} is @samp{z}.  If @code{size} is zero or
8773 negative, it is set to 1@dmn{u}.
8775 @cindex type size registers (@code{.s}, @code{.ps})
8776 @cindex point size registers (@code{.s}, @code{.ps})
8777 The read-only number register @code{.s} returns the point size in
8778 points as a decimal fraction.  This is a string.  To get the point
8779 size in scaled points, use the @code{.ps} register instead.
8781 @code{.s} is associated with the current environment
8782 (@pxref{Environments}).
8784 @Example
8785 snap, snap,
8786 .ps +2
8787 grin, grin,
8788 .ps +2
8789 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8790 .ps 10
8791 @endExample
8793 The @code{\s} escape may be called in a variety of ways.  Much like
8794 other escapes there must be a way to determine where the argument ends
8795 and the text begins.  Any of the following forms are valid:
8797 @table @code
8798 @item \s@var{n}
8799 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either
8800 0 or in the range 4 to@w{ }39.
8802 @item \s+@var{n}
8803 @itemx \s-@var{n}
8804 Increase or decrease the point size by @var{n}@w{ }points.  @var{n}@w{
8805 }must be exactly one digit.
8807 @item \s(@var{nn}
8808 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly
8809 two digits.
8811 @item \s+(@var{nn}
8812 @itemx \s-(@var{nn}
8813 @itemx \s(+@var{nn}
8814 @itemx \s(-@var{nn}
8815 Increase or decrease the point size by @var{nn}@w{ }points.  @var{nn}
8816 must be exactly two digits.
8817 @end table
8819 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8820 As a consequence, it can be used in requests like @code{mc} (which
8821 expects a single character as an argument) to change the font on
8822 the fly:
8824 @Example
8825 .mc \s[20]x\s[0]
8826 @endExample
8828 @xref{Fractional Type Sizes}, for yet another syntactical form of
8829 using the @code{\s} escape.
8830 @endDefreq
8832 @Defreq {sizes, s1 s2 @dots{} sn [0]}
8833 Some devices may only have certain permissible sizes, in which case
8834 @code{gtroff} rounds to the nearest permissible size.
8835 The @file{DESC} file specifies which sizes are permissible for the device.
8837 Use the @code{sizes} request to change the permissible sizes
8838 for the current output device.
8839 Arguments are in scaled points;
8840 the @code{sizescale} line in the
8841 @file{DESC} file for the output device
8842 provides the scaling factor.
8843 For example, if the scaling factor is 1000,
8844 then the value 12000 is 12@w{ }points.
8846 Each argument can be a single point size (such as 12000),
8847 or a range of sizes (such as 4000-72000).
8848 You can optionally end the list with a zero.
8849 @endDefreq
8851 @cindex changing vertical line spacing (@code{vs})
8852 @cindex vertical line spacing, changing (@code{vs})
8853 @cindex vertical line spacing register (@code{.v})
8854 @DefreqList {vs, [@Var{space}]}
8855 @DefreqItem {vs, @t{+}@Var{space}}
8856 @DefreqItem {vs, @t{-}@Var{space}}
8857 @DefregListEnd {.v}
8858 Change (increase, decrease) the vertical spacing by @var{space}.  The
8859 default unit is @samp{p}.
8861 If @code{vs} is called without an argument, the vertical spacing is
8862 reset to the previous value before the last call to @code{vs}.
8864 @cindex @code{.V} register, and @code{vs}
8865 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8866 zero or negative; the vertical spacing is then set to the vertical
8867 resolution (as given in the @code{.V} register).
8869 The read-only number register @code{.v} contains the current vertical
8870 spacing; it is associated with the current environment
8871 (@pxref{Environments}).
8872 @endDefreq
8874 @cindex vertical line spacing, effective value
8875 The effective vertical line spacing consists of four components.
8877 @itemize @bullet
8878 @item
8879 The vertical line spacing as set with the @code{vs} request.
8881 @cindex post-vertical line spacing
8882 @cindex line spacing, post-vertical (@code{pvs})
8883 @item
8884 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
8885 This is vertical space which will be added after a line has been
8886 output.
8888 @cindex extra pre-vertical line space (@code{\x})
8889 @cindex line space, extra pre-vertical (@code{\x})
8890 @item
8891 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
8892 using a negative value.  This is vertical space which will be added once
8893 before the current line has been output.
8895 @cindex extra post-vertical line space (@code{\x})
8896 @cindex line space, extra post-vertical (@code{\x})
8897 @item
8898 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
8899 using a positive value.  This is vertical space which will be added once
8900 after the current line has been output.
8901 @end itemize
8903 @cindex double spacing (@code{vs}, @code{pvs})
8904 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
8905 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
8906 granularity for the inserted vertical space compared to @code{ls};
8907 furthermore, certain preprocessors assume single spacing.
8909 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
8910 and the @code{ls} request.
8912 @cindex @code{ls} request, alternative to (@code{pvs})
8913 @cindex post-vertical line spacing, changing (@code{pvs})
8914 @cindex post-vertical line spacing register (@code{.pvs})
8915 @DefreqList {pvs, [@Var{space}]}
8916 @DefreqItem {pvs, @t{+}@Var{space}}
8917 @DefreqItem {pvs, @t{-}@Var{space}}
8918 @DefregListEnd {.pvs}
8919 Change (increase, decrease) the post-vertical spacing by
8920 @var{space}.  The default unit is @samp{p}.
8922 If @code{pvs} is called without an argument, the post-vertical spacing is
8923 reset to the previous value before the last call to @code{pvs}.
8925 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8926 zero or negative; the vertical spacing is then set to zero.
8928 The read-only number register @code{.pvs} contains the current
8929 post-vertical spacing; it is associated with the current environment
8930 (@pxref{Environments}).
8931 @endDefreq
8933 @c XXX example
8935 @ignore
8936 @Example
8937 ... .sz macro example?? ...
8938 @endExample
8939 @end ignore
8941 @c ---------------------------------------------------------------------
8943 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
8944 @subsection Fractional Type Sizes
8945 @cindex fractional type sizes
8946 @cindex type sizes, fractional
8948 @cindex @code{s} unit
8949 @cindex unit, @code{s}
8950 @cindex @code{z} unit
8951 @cindex unit, @code{z}
8952 @cindex @code{ps} request, with fractional type sizes
8953 @cindex @code{cs} request, with fractional type sizes
8954 @cindex @code{tkf} request, with fractional type sizes
8955 @cindex @code{\H}, with fractional type sizes
8956 @cindex @code{\s}, with fractional type sizes
8957 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
8958 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
8959 default).  There is a new scale indicator @samp{z} which has the
8960 effect of multiplying by @var{sizescale}.  Requests and escape
8961 sequences in @code{gtroff} interpret arguments that represent a point
8962 size as being in units of scaled points, but they evaluate each such
8963 argument using a default scale indicator of @samp{z}.  Arguments
8964 treated in this way are the argument to the @code{ps} request, the
8965 third argument to the @code{cs} request, the second and fourth
8966 arguments to the @code{tkf} request, the argument to the @code{\H}
8967 escape sequence, and those variants of the @code{\s} escape sequence
8968 that take a numeric expression as their argument (see below).
8970 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
8971 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
8972 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
8973 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
8975 @code{gtroff} disallows the use of the @samp{z} scale indicator in
8976 instances where it would make no sense, such as a numeric
8977 expression whose default scale indicator was neither @samp{u} nor
8978 @samp{z}.  Similarly it would make
8979 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
8980 numeric expression whose default scale indicator was @samp{z}, and so
8981 @code{gtroff} disallows this as well.
8983 There is also new scale indicator @samp{s} which multiplies by the
8984 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
8985 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
8986 scale indicators.
8988 @Defreg {.ps}
8989 A read-only number register returning the point size in scaled points.
8991 @code{.ps} is associated with the current environment
8992 (@pxref{Environments}).
8993 @endDefreg
8995 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
8996 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
8997 @cindex @code{.ps} register, in comparison with @code{.psr}
8998 @cindex @code{.s} register, in comparison with @code{.sr}
8999 @DefregList {.psr}
9000 @DefregListEnd {.sr}
9001 The last-requested point size in scaled points is contained in the
9002 @code{.psr} read-only number register.  The last requested point size
9003 in points as a decimal fraction can be found in @code{.sr}.  This is a
9004 string-valued read-only number register.
9006 Note that the requested point sizes are device-independent, whereas
9007 the values returned by the @code{.ps} and @code{.s} registers are not.
9008 For example, if a point size of 11@dmn{pt} is requested, and a
9009 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
9010 specifies 10.95@dmn{pt} instead, this value is actually used.
9012 Both registers are associated with the current environment
9013 (@pxref{Environments}).
9014 @endDefreg
9016 The @code{\s} escape has the following syntax for working with
9017 fractional type sizes:
9019 @table @code
9020 @item \s[@var{n}]
9021 @itemx \s'@var{n}'
9022 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
9023 expression with a default scale indicator of @samp{z}.
9025 @item \s[+@var{n}]
9026 @itemx \s[-@var{n}]
9027 @itemx \s+[@var{n}]
9028 @itemx \s-[@var{n}]
9029 @itemx \s'+@var{n}'
9030 @itemx \s'-@var{n}'
9031 @itemx \s+'@var{n}'
9032 @itemx \s-'@var{n}'
9033 Increase or or decrease the point size by @var{n}@w{ }scaled points;
9034 @var{n}@w{ }is a numeric expression with a default scale indicator of
9035 @samp{z}.
9036 @end table
9038 @xref{Font Files}.
9041 @c =====================================================================
9043 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
9044 @section Strings
9045 @cindex strings
9047 @code{gtroff} has string variables, which are entirely for user
9048 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
9049 even this is a read-write string variable).
9051 @cindex string interpolation (@code{\*})
9052 @cindex string expansion (@code{\*})
9053 @cindex interpolation of strings (@code{\*})
9054 @cindex expansion of strings (@code{\*})
9055 @DefreqList {ds, name [@Var{string}]}
9056 @DefreqItem {ds1, name [@Var{string}]}
9057 @DefescItem {\\*, , n, }
9058 @DefescItem {\\*, @lparen{}, nm, }
9059 @DefescListEnd {\\*, @lbrack{}, name, @rbrack{}}
9060 Define and access a string variable @var{name} (one-character name@w{
9061 }@var{n}, two-character name @var{nm}).  If @var{name} already exists,
9062 @code{ds} overwrites the previous definition.
9064 Example:
9066 @Example
9067 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
9069 The \*(UX Operating System
9070 @endExample
9072 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9073 previously-defined string variable.  To be more precise, the stored
9074 string is pushed onto the input stack which is then parsed by
9075 @code{gtroff}.  Similar to number registers, it is possible to nest
9076 strings, i.e. string variables can be called within string variables.
9078 If the string named by the @code{\*} escape does not exist, it is
9079 defined as empty, and a warning of type @samp{mac} is emitted (see
9080 @ref{Debugging}, for more details).
9082 @cindex comments, with @code{ds}
9083 @cindex @code{ds} request, and comments
9084 @strong{Caution:} Unlike other requests, the second argument to the
9085 @code{ds} request takes up the entire line including trailing spaces.
9086 This means that comments on a line with such a request can introduce
9087 unwanted space into a string.
9089 @Example
9090 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9091 @endExample
9093 @noindent
9094 Instead the comment should be put on another line or have the comment
9095 escape adjacent with the end of the string.
9097 @Example
9098 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9099 @endExample
9101 @cindex trailing quotes
9102 @cindex quotes, trailing
9103 @cindex leading spaces with @code{ds}
9104 @cindex spaces with @code{ds}
9105 @cindex @code{ds} request, and leading spaces
9106 To produce leading space the string can be started with a double
9107 quote.  No trailing quote is needed; in fact, any trailing quote is
9108 included in your string.
9110 @Example
9111 .ds sign "           Yours in a white wine sauce,
9112 @endExample
9114 @cindex multi-line strings
9115 @cindex strings, multi-line
9116 @cindex newline character in strings, escaping
9117 @cindex escaping newline characters in strings
9118 Strings are not limited to a single line of text.  A string can span
9119 several lines by escaping the newlines with a backslash.  The
9120 resulting string is stored @emph{without} the newlines.
9122 @Example
9123 .ds foo lots and lots \
9124 of text are on these \
9125 next several lines
9126 @endExample
9128 It is not possible to have real newlines in a string.  To put a single
9129 double quote character into a string, use two consecutive double quote
9130 characters.
9132 The @code{ds1} request turns off compatibility mode
9133 while interpreting a string.  To be more precise, a @dfn{compatibility
9134 save} input token is inserted at the beginning of  the string, and a
9135 @dfn{compatibility restore} input token at the end.
9137 @Example
9138 .nr xxx 12345
9139 .ds aa The value of xxx is \\n[xxx].
9140 .ds1 bb The value of xxx ix \\n[xxx].
9142 .cp 1
9144 \*(aa
9145     @result{} warning: number register `[' not defined
9146     @result{} The value of xxx is 0xxx].
9147 \*(bb
9148     @result{} The value of xxx ix 12345.
9149 @endExample
9151 @cindex name space of macros and strings
9152 @cindex macros, shared name space with strings
9153 @cindex strings, shared name space with macros
9154 Strings, macros, and diversions (and boxes) share the same name space.
9155 Internally, even the same mechanism is used to store them.  This has
9156 some interesting consequences.  For example, it is possible to call a
9157 macro with string syntax and vice versa.
9159 @Example
9160 .de xxx
9161 a funny test.
9163 This is \*[xxx]
9164     @result{} This is a funny test.
9166 .ds yyy a funny test
9167 This is
9168 .yyy
9169     @result{} This is a funny test.
9170 @endExample
9172 Diversions and boxes can be also called with string syntax.  It is not
9173 possible to pass arguments to a macro if called with @code{\*}.
9175 Another consequence is that you can copy one-line diversions or boxes
9176 to a string.
9178 @Example
9179 .di xxx
9180 a \fItest\fR
9183 .ds yyy This is \*[xxx]\c
9184 \*[yyy].
9185     @result{} @r{This is a }@i{test}.
9186 @endExample
9188 @noindent
9189 As the previous example shows, it is possible to store formatted
9190 output in strings.  The @code{\c} escape prevents the insertion of an
9191 additional blank line in the output.
9193 Copying diversions longer than a single output line produces
9194 unexpected results.
9196 @Example
9197 .di xxx
9198 a funny
9200 test
9203 .ds yyy This is \*[xxx]\c
9204 \*[yyy].
9205     @result{} test This is a funny.
9206 @endExample
9208 Usually, it is not predictable whether a diversion contains one or
9209 more output lines, so this mechanism should be avoided.  With
9210 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9211 final newline from a diversion.  Another disadvantage is that the
9212 spaces in the copied string are already formatted, making them
9213 unstretchable.  This can cause ugly results.
9215 @cindex stripping final newline in diversions
9216 @cindex diversions, stripping final newline
9217 @cindex final newline, stripping in diversions
9218 @cindex newline, final, stripping in diversions
9219 @cindex horizontal space, unformatting
9220 @cindex space, horizontal, unformatting
9221 @cindex unformatting horizontal space
9222 A clean solution to this problem is available in GNU @code{troff},
9223 using the requests @code{chop} to remove the final newline of a
9224 diversion, and @code{unformat} to make the horizontal spaces
9225 stretchable again.
9227 @Example
9228 .box xxx
9229 a funny
9231 test
9233 .box
9234 .chop xxx
9235 .unformat xxx
9236 This is \*[xxx].
9237     @result{} This is a funny test.
9238 @endExample
9240 @xref{Gtroff Internals}, for more information.
9241 @endDefreq
9243 @cindex appending to strings (@code{as})
9244 @cindex strings, appending (@code{as})
9245 @DefreqList {as, name [@Var{string}]}
9246 @DefreqListEnd {as1, name [@Var{string}]}
9247 The @code{as} request is similar to @code{ds} but appends @var{string}
9248 to the string stored as @var{name} instead of redefining it.  If
9249 @var{name} doesn't exist yet, it is created.
9251 @Example
9252 .as sign " with shallots, onions and garlic,
9253 @endExample
9255 The @code{as1} request is similar to @code{as}, but compatibility mode
9256 is switched off while the appended string is interpreted.  To be more
9257 precise, a @dfn{compatibility save} input token is inserted at the
9258 beginning of the appended string, and a @dfn{compatibility restore}
9259 input token at the end.
9260 @endDefreq
9262 Rudimentary string manipulation routines are given with the next two
9263 requests.
9265 @cindex substring (@code{substring})
9266 @Defreq {substring, str n1 [@Var{n2}]}
9267 Replace the string in register@w{ }@var{str} with the substring
9268 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
9269 in the string has index one.  If @var{n2} is omitted, it is taken to
9270 be equal to the string's length.  If the index value @var{n1} or
9271 @var{n2} is negative or zero, it is counted from the end of the
9272 string, going backwards: The last character has index@w{ }0, the
9273 character before the last character has index@w{ }@minus{}1, etc.
9275 @Example
9276 .ds xxx abcdefgh
9277 .substring xxx 2 -3
9278 \*[xxx]
9279     @result{} bcde
9280 @endExample
9281 @endDefreq
9283 @cindex length of a string (@code{length})
9284 @cindex string, length of (@code{length})
9285 @Defreq {length, reg str}
9286 Compute the length of @var{str} and returns it in the number
9287 register@w{ }@var{reg}.  If @var{reg} doesn't exist, it is created.
9289 @Example
9290 .ds xxx abcdefgh
9291 .length yyy xxx
9292 \n[yyy]
9293     @result{} 8
9294 @endExample
9295 @endDefreq
9297 @cindex rename request (@code{rn})
9298 @cindex rename macro (@code{rn})
9299 @cindex rename string (@code{rn})
9300 @Defreq {rn, xx yy}
9301 Rename the request, macro, or string @var{xx} to @var{yy}.
9302 @endDefreq
9304 @cindex remove request (@code{rm})
9305 @cindex remove macro (@code{rm})
9306 @cindex remove string (@code{rm})
9307 @Defreq {rm, xx}
9308 Remove the request, macro, or string @var{xx}.  @code{gtroff} treats
9309 subsequent invocations as if the object had never been defined.
9310 @endDefreq
9312 @cindex alias, creating (@code{als})
9313 @cindex creating alias (@code{als})
9314 @Defreq {als, new old}
9315 Create an alias named @var{new} for the request, string, macro, or
9316 diversion object named @var{old}.  The new name and the old name are
9317 exactly equivalent (it is similar to a hard rather than a soft
9318 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9319 type @samp{mac} and ignores the request.
9320 @endDefreq
9322 @Defreq {chop, xx}
9323 Remove (chop) the last character from the macro, string, or diversion
9324 named @var{xx}. This is useful for removing the newline from the end
9325 of diversions that are to be interpolated as strings.  This command
9326 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9327 nodes inserted by @code{gtroff} automatically.
9328 @endDefreq
9330 @xref{Identifiers}, and @ref{Comments}.
9333 @c =====================================================================
9335 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9336 @section Conditionals and Loops
9337 @cindex conditionals and loops
9338 @cindex loops and conditionals
9340 @c XXX Introductory text
9342 @menu
9343 * Operators in Conditionals::
9344 * if-else::
9345 * while::
9346 @end menu
9348 @c ---------------------------------------------------------------------
9350 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9351 @subsection Operators in Conditionals
9353 @cindex @code{if} request, operators to use with it
9354 @cindex @code{while} request, operators to use with it
9355 In @code{if} and @code{while} requests, there are several more
9356 operators available:
9358 @table @code
9359 @item e
9360 @itemx o
9361 True if the current page is even or odd numbered (respectively).
9363 @item n
9364 True if the document is being processed in nroff mode (i.e., the
9365 @code{.nroff} command has been issued).
9367 @item t
9368 True if the document is being processed in troff mode (i.e., the
9369 @code{.troff} command has been issued).
9371 @item v
9372 Always false.  This condition is for compatibility with other
9373 @code{troff} versions only.
9375 @item '@var{xxx}'@var{yyy}'
9376 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
9377 characters can be used in place of the single quotes; the same set of
9378 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9379 @code{gtroff} formats the strings before being compared:
9381 @Example
9382 .ie "|"\fR|\fP" \
9383 true
9384 .el \
9385 false
9386     @result{} true
9387 @endExample
9389 @noindent
9390 The resulting motions, character sizes, and fonts have to
9391 match,@footnote{The created output nodes must be identical.
9392 @xref{Gtroff Internals}.} and not the individual motion, size, and
9393 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
9394 both result in a roman @samp{|} character with the same point size and
9395 at the same location on the page, so the strings are equal.  If
9396 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
9397 would be ``false'' because (the first) @samp{|} produces an italic
9398 @samp{|} rather than a roman one.
9400 @item r @var{xxx}
9401 True if there is a number register named @var{xxx}.
9403 @item d @var{xxx}
9404 True if there is a string, macro, diversion, or request named @var{xxx}.
9406 @item m @var{xxx}
9407 True if there is a color named @var{xxx}.
9409 @item c @var{ch}
9410 True if there is a character @var{ch} available; @var{ch} is either an
9411 @acronym{ASCII} character or a special character (@code{\(@var{ch}} or
9412 @code{\[@var{ch}]}); the condition is also true if @var{ch} has been
9413 defined by the @code{char} request.
9414 @end table
9416 Note that these operators can't be combined with other operators like
9417 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9418 between the exclamation mark and the operator) can be used to negate
9419 the result.
9421 @Example
9422 .nr xxx 1
9423 .ie !r xxx \
9424 true
9425 .el \
9426 false
9427     @result{} false
9428 @endExample
9430 A whitespace after @samp{!} always evaluates to zero (this bizarre
9431 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9433 @Example
9434 .nr xxx 1
9435 .ie ! r xxx \
9436 true
9437 .el \
9438 false
9439     @result{} r xxx true
9440 @endExample
9442 It is possible to omit the whitespace before the argument to the
9443 @samp{r}, @samp{d}, and @samp{c} operators.
9445 @xref{Expressions}.
9447 @c ---------------------------------------------------------------------
9449 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9450 @subsection if-else
9451 @cindex if-else
9453 @code{gtroff} has if-then-else constructs like other languages, although
9454 the formatting can be painful.
9456 @Defreq {if, expr anything}
9457 Evaluate the expression @var{expr}, and executes @var{anything} (the
9458 remainder of the line) if @var{expr} evaluates to non-zero (true).
9459 @var{anything} is interpreted as though it was on a line by itself
9460 (except that leading spaces are swallowed).  @xref{Expressions}, for
9461 more info.
9463 @Example
9464 .nr xxx 1
9465 .nr yyy 2
9466 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9467     @result{} true
9468 @endExample
9469 @endDefreq
9471 @Defreq{nop, anything}
9472 Executes @var{anything}.
9473 This is similar to @code{.if@w{ }1}.
9474 @endDefreq
9476 @DefreqList {ie, expr anything}
9477 @DefreqListEnd {el, anything}
9478 Use the @code{ie} and @code{el} requests to write an if-then-else.
9479 The first request is the `if' part and the latter is the `else' part.
9481 @Example
9482 .ie n .ls 2 \" double spacing in nroff
9483 .el   .ls 1 \" single spacing in troff
9484 @endExample
9485 @endDefreq
9487 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9488 @c to @deffn
9490 @c and in 4.2 you still can't use @{ in macros.
9492 @cindex begin of conditional block (@code{\@{})
9493 @cindex end of conditional block (@code{\@}})
9494 @cindex conditional block, begin (@code{\@{})
9495 @cindex conditional block, end (@code{\@}})
9496 @cindex block, conditional, begin (@code{\@{})
9497 @cindex block, condititional, end (@code{\@}})
9498 @c @DefescList {\@{, , , }
9499 @c @DefescListEnd {\@}, , , }
9500 @deffn Escape @t{\@{}
9501 @deffnx Escape @t{\@}}
9502 @esindex \@{
9503 @esindex \@}
9504 In many cases, an if (or if-else) construct needs to execute more than
9505 one request.  This can be done using the @code{\@{} and @code{\@}}
9506 escapes.  The following example shows the possible ways to use these
9507 escapes (note the position of the opening and closing braces).
9509 @Example
9510 .ie t \@{\
9511 .    ds lq ``
9512 .    ds rq ''
9513 .\@}
9514 .el \
9515 .\@{\
9516 .    ds lq "
9517 .    ds rq "\@}
9518 @endExample
9519 @c @endDefesc
9520 @end deffn
9522 @xref{Expressions}.
9524 @c ---------------------------------------------------------------------
9526 @node while,  , if-else, Conditionals and Loops
9527 @subsection while
9528 @cindex while
9530 @code{gtroff} provides a looping construct using the @code{while}
9531 request, which is used much like the @code{if} (and related) requests.
9533 @Defreq {while, expr anything}
9534 Evaluate the expression @var{expr}, and repeatedly execute
9535 @var{anything} (the remainder of the line) until @var{expr} evaluates
9536 to@w{ }0.
9538 @Example
9539 .nr a 0 1
9540 .while (\na < 9) \@{\
9541 \n+a,
9542 .\@}
9543 \n+a
9544     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9545 @endExample
9547 Some remarks.
9549 @cindex @code{de} request, and @code{while}
9550 @itemize @bullet
9551 @item
9552 The body of a @code{while} request is treated like the body of a
9553 @code{de} request: @code{gtroff} temporarily stores it in a macro
9554 which is deleted after the loop has been exited.  It can considerably
9555 slow down a macro if the body of the @code{while} request (within the
9556 macro) is large.  Each time the macro is executed, the @code{while}
9557 body is parsed and stored again as a temporary macro.
9559 @Example
9560 .de xxx
9561 .  nr num 10
9562 .  while (\\n[num] > 0) \@{\
9563 .    \" many lines of code
9564 .    nr num -1
9565 .  \@}
9567 @endExample
9569 @cindex recursive macros
9570 @cindex macros, recursive
9571 @noindent
9572 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9573 doesn't have the @code{while} request) is to use a recursive macro
9574 instead which is parsed only once during its definition.
9576 @Example
9577 .de yyy
9578 .  if (\\n[num] > 0) \@{\
9579 .    \" many lines of code
9580 .    nr num -1
9581 .    yyy
9582 .  \@}
9585 .de xxx
9586 .  nr num 10
9587 .  yyy
9589 @endExample
9591 @noindent
9592 Note that the number of available recursion levels is set to@w{ }1000
9593 (this is a compile-time constant value of @code{gtroff}).
9595 @item
9596 The closing brace of a @code{while} body must end a line.
9598 @Example
9599 .if 1 \@{\
9600 .  nr a 0 1
9601 .  while (\n[a] < 10) \@{\
9602 .    nop \n+[a]
9603 .\@}\@}
9604     @result{} unbalanced \@{ \@}
9605 @endExample
9606 @end itemize
9607 @endDefreq
9609 @cindex @code{while} request, confusing with @code{br}
9610 @cindex @code{break} request, in a @code{while} loop
9611 @cindex @code{continue} request, in a @code{while} loop
9612 @Defreq {break, }
9613 Break out of a @code{while} loop.  Be sure not to confuse this with
9614 the @code{br} request (causing a line break).
9615 @endDefreq
9617 @Defreq {continue, }
9618 Finish the current iteration of a @code{while} loop, immediately
9619 restarting the next iteration.
9620 @endDefreq
9622 @xref{Expressions}.
9625 @c =====================================================================
9627 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9628 @section Writing Macros
9629 @cindex writing macros
9630 @cindex macros, writing
9632 A @dfn{macro} is a collection of text and embedded commands which can
9633 be invoked multiple times.  Use macros to define common operations.
9635 @DefreqList {de, name [@Var{end}]}
9636 @DefreqItem {de1, name [@Var{end}]}
9637 @DefreqListEnd {dei, name [@Var{end}]}
9638 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
9639 lines (starting with the next one) into an internal buffer until it
9640 encounters the line @samp{..} (two dots).  The optional second
9641 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9643 There can be whitespace after the first dot in the line containing the
9644 ending token (either @samp{.} or macro @samp{@var{end}}).
9646 Here a small example macro called @samp{P} which causes a break and
9647 inserts some vertical space.  It could be used to separate paragraphs.
9649 @Example
9650 .de P
9651 .  br
9652 .  sp .8v
9654 @endExample
9656 @c XXX add info about macro definitions in macros.
9658 @c XXX give example for end macro.
9660 The @code{de1} request turns off compatibility mode
9661 while executing the macro.  On entry, the current compatibility mode
9662 is saved and restored at exit.
9664 @Example
9665 .nr xxx 12345
9667 .de aa
9668 The value of xxx is \\n[xxx].
9670 .de1 bb
9671 The value of xxx ix \\n[xxx].
9674 .cp 1
9677     @result{} warning: number register \e' not defined
9678     @result{} The value of xxx is 0xxx].
9680     @result{} The value of xxx ix 12345.
9681 @endExample
9683 The @code{dei} request defines a macro indirectly.
9684 That is, it expands strings whose names
9685 are @var{name} or @var{end} before performing the append.
9687 This:
9689 @Example
9690 .ds xx aa
9691 .ds yy bb
9692 .dei xx yy
9693 @endExample
9695 @noindent
9696 is equivalent to:
9698 @Example
9699 .de aa bb
9700 @endExample
9702 @pindex trace.tmac
9703 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9705 @c XXX info about common identifier pool for strings, macros, and
9706 @c     diversions.
9707 @endDefreq
9709 @cindex appending, to a macro (@code{am})
9710 @cindex macro appending (@code{am})
9711 @DefreqList {am, xx}
9712 @DefreqItem {am1, xx}
9713 @DefreqListEnd {ami, xx yy}
9714 Works similarly to @code{de} except it appends onto the macro named
9715 @var{xx}.  So, to make the previously defined @samp{P} macro actually
9716 do indented instead of block paragraphs, add the necessary code to the
9717 existing macro like this:
9719 @Example
9720 .am P
9721 .ti +5n
9723 @endExample
9725 The @code{am1} request turns off compatibility mode
9726 while executing the appended macro piece.  To be more precise, a
9727 @dfn{compatibility save} input token is inserted at the beginning of
9728 the appended code, and a @dfn{compatibility restore} input token at
9729 the end.
9731 The @code{ami} request appends indirectly,
9732 meaning that @code{gtroff} expands strings whose names
9733 are @var{xx} or @var{yy} before performing the append.
9735 @pindex trace.tmac
9736 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9737 @endDefreq
9739 @cindex alias, creating (@code{als})
9740 @cindex creating alias (@code{als})
9741 @xref{Strings}, for the @code{als} request to rename a macro.
9743 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9744 @code{as} requests (together with its variants) only create a new object
9745 if the name of the macro, diversion or string diversion is currently
9746 undefined or if it is defined to be a request; normally they modify the
9747 value of an existing object.
9749 @Defreq {return, }
9750 Exit a macro, immediately returning to the caller.
9751 @endDefreq
9753 @menu
9754 * Copy-in Mode::
9755 * Parameters::
9756 @end menu
9758 @c ---------------------------------------------------------------------
9760 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9761 @subsection Copy-in Mode
9762 @cindex copy-in mode
9763 @cindex mode, copy-in
9765 @cindex @code{\n}, when reading text for a macro
9766 @cindex @code{\$}, when reading text for a macro
9767 @cindex @code{\*}, when reading text for a macro
9768 @cindex @code{\\}, when reading text for a macro
9769 @cindex \@key{RET}, when reading text for a macro
9770 When @code{gtroff} reads in the text for a macro or diversion, it copies
9771 the text (including request lines, but excluding escapes) into an
9772 internal buffer.  Escapes are converted into an internal form,
9773 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9774 @code{\@key{RET}} which are evaluated and inserted into the text where
9775 the escape was located.  This is known as @dfn{copy-in} mode or
9776 @dfn{copy} mode.
9778 What this means is that you can specify when these escapes are to be
9779 evaluated (either at copy-in time or at the time of use) by insulating
9780 the escapes with an extra backslash.  Compare this to the @code{\def}
9781 and @code{\edef} commands in @TeX{}.
9783 The following example prints the numbers 20 and@w{ }10:
9785 @Example
9786 .nr x 20
9787 .de y
9788 .nr x 10
9789 \&\nx
9790 \&\\nx
9793 @endExample
9795 @c ---------------------------------------------------------------------
9797 @node Parameters,  , Copy-in Mode, Writing Macros
9798 @subsection Parameters
9799 @cindex parameters
9801 The arguments to a macro can be examined using a variety of escapes.
9803 @cindex number of arguments register (@code{.$})
9804 @Defreg {.$}
9805 The number of arguments in a macro.  This is a read-only number register.
9806 @endDefreg
9808 Any individual argument can be retrieved with one of the following
9809 escapes:
9811 @cindex copy-in mode, and macro arguments
9812 @cindex macro arguments (@code{\$})
9813 @cindex arguments, macro (@code{\$})
9814 @DefescList {\\$, , n, }
9815 @DefescItem {\\$, @lparen{}, nn, }
9816 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
9817 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
9818 argument.  As usual, the first form only accepts a single number
9819 (larger than zero), the second a two-digit number (larger or equal
9820 to@w{ }10), and the third any positive integer value (larger
9821 than zero).  Macros can have an unlimited number of arguments.  Note
9822 that due to copy-in mode, use two backslashes on these in actual use to
9823 prevent interpolation until the macro is actually invoked.
9824 @endDefesc
9826 @Defreq {shift, [@Var{n}]}
9827 Shift the arguments 1@w{ }position, or as
9828 many positions as specified by its argument.  After executing this
9829 request, argument@w{ }@var{i} becomes argument @math{@var{i}-@var{n}};
9830 arguments 1 to@w{ }@var{n} are no longer available.  Shifting by
9831 negative amounts is currently undefined.
9832 @endDefreq
9834 @DefescList {\\$*, , , }
9835 @DefescListEnd {\\$@@, , , }
9836 In some cases it is convenient to use all of the arguments at once (for
9837 example, to pass the arguments along to another macro).  The @code{\$*}
9838 escape concatenates all the arguments separated by spaces.  A
9839 similar escape is @code{\$@@}, which concatenates all the
9840 arguments with each surrounded by double quotes, and separated by
9841 spaces.  If not in compatibility mode, the input level of double quotes
9842 is preserved (see @ref{Request Arguments}).
9843 @endDefesc
9845 @cindex macro name register (@code{\$0})
9846 @cindex @code{als} request, and @code{\$0}
9847 @cindex @code{als} request, use with @code{\$0}
9848 @Defesc {\\$0, , , }
9849 The name used to invoke the current macro.
9850 The @code{als} request can make a macro have more than one name.
9852 @Example
9853 .de generic-macro
9854 .  ...
9855 .  if \\n[error] \@{\
9856 .    tm \\$0: Houston, we have a problem.
9857 .    return
9858 .  \@}
9861 .als foo generic-macro
9862 .als bar generic-macro
9863 @endExample
9864 @endDefesc
9866 @xref{Request Arguments}.
9869 @c =====================================================================
9871 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
9872 @section Page Motions
9873 @cindex page motions
9874 @cindex motions, page
9876 @xref{Manipulating Spacing}, for a discussion of the main request for
9877 vertical motion, @code{sp}.
9879 @cindex marking vertical page location (@code{mk})
9880 @cindex page location, vertical, marking (@code{mk})
9881 @cindex location, vertical, page, marking (@code{mk})
9882 @cindex vertical page location, marking (@code{mk})
9883 @cindex returning to marked vertical page location (@code{rt})
9884 @cindex page location, vertical, returning to marked (@code{rt})
9885 @cindex location, vertical, page, returning to marked (@code{rt})
9886 @cindex vertical page location, returning to marked (@code{rt})
9887 @DefreqList {mk, [@Var{reg}]}
9888 @DefreqListEnd {rt, [@Var{dist}]}
9889 The request @code{mk} can be used to mark a location on a page, for
9890 movement to later.  This request takes a register name as an argument
9891 in which to store the current page location.  With no argument it
9892 stores the location in an internal register.  The results of this can
9893 be used later by the @code{rt} or the @code{sp} request (or the
9894 @code{\v} escape).
9896 The @code{rt} request returns @emph{upwards} to the location marked
9897 with the last @code{mk} request.  If used with an argument, return to
9898 a position which distance from the top of the page is @var{dist} (no
9899 previous call to @code{mk} is necessary in this case).
9901 @c XXX example
9902 @ignore
9903 @Example
9904 ... dual column example ...
9905 @endExample
9906 @end ignore
9907 @endDefreq
9909 The following escapes give fine control of movements about the page.
9911 @cindex vertical motion (@code{\v})
9912 @cindex motion, vertical (@code{\v})
9913 @Defesc {\\v, ', e, '}
9914 Move vertically, usually from the current location on the page (if no
9915 absolute position operator @samp{|} is used).  The
9916 argument@w{ }@var{e} specifies the distance to move; positive is
9917 downwards and negative upwards.  The default unit for this escape
9918 @samp{v}.  Beware, however, that @code{gtroff} continues text
9919 processing at the point where the motion ends, so you should always
9920 balance motions to avoid interference with text processing.
9922 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
9923 consider a page bottom trap macro which prints a marker in the margin to
9924 indicate continuation of a footnote or something similar.
9925 @endDefesc
9927 There are some special-case escapes for vertical motion.
9929 @Defesc {\\r, , , }
9930 Move upwards@w{ }1@dmn{v}.
9931 @endDefesc
9933 @Defesc {\\u, , , }
9934 Move upwards@w{ }.5@dmn{v}.
9935 @endDefesc
9937 @Defesc {\\d, , , }
9938 Move down@w{ }.5@dmn{v}.
9939 @endDefesc
9941 @cindex inserting horizontal space (@code{\h})
9942 @cindex horizontal space (@code{\h})
9943 @cindex space, horizontal (@code{\h})
9944 @Defesc {\\h, ', e, '}
9945 Move horizontally, usually from the current location (if no absolute
9946 position operator @samp{|} is used).  The
9947 expression@w{ }@var{e} indicates how far to move: positive is rightwards
9948 and negative leftwards.
9949 @c XXX Is there a default unit for this?
9950 @endDefesc
9952 There are a number of special-case escapes for horizontal motion.
9954 @cindex space, unbreakable
9955 @cindex unbreakable space
9956 @Defesc {\\@key{SP}, , , }
9957 An unbreakable and unpaddable (i.e.@: not expanded during filling)
9958 space.  (Note: This is a backslash followed by a space.)
9959 @endDefesc
9961 @Defesc {\\~, , , }
9962 An unbreakable space that stretches like a normal inter-word space
9963 when a line is adjusted.
9964 @endDefesc
9966 @Defesc {\\|, , , }
9967 A 1/6@dmn{th} em space.  Ignored for tty output devices (rounded to
9968 zero).
9969 @endDefesc
9971 @Defesc {\\^, , , }
9972 A 1/12@dmn{th} em space.  Ignored for tty output devices (rounded to
9973 zero).
9974 @endDefesc
9976 @cindex space, width of a digit
9977 @cindex digit width space
9978 @Defesc {\\0, , , }
9979 A space the size of a digit.
9980 @endDefesc
9982 The following string sets the @TeX{} logo:
9984 @Example
9985 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
9986 @endExample
9988 @cindex width escape (@code{\w})
9989 @cindex escape, width (@code{\w})
9990 @DefescList {\\w, ', text, '}
9991 @DefregItem {st}
9992 @DefregItem {sb}
9993 @DefregItem {rst}
9994 @DefregItem {rsb}
9995 @DefregItem {ct}
9996 @DefregItem {ssc}
9997 @DefregListEnd {skw}
9998 Return the width of the specified @var{text} in basic units.
9999 This allows horizontal movement based on the width of some
10000 arbitrary text (e.g.@: given as an argument to a macro).
10002 @c XXX example
10004 @ignore
10005 @Example
10006 ... strlen example ...
10007 @endExample
10008 @end ignore
10010 Font changes may occur in @var{text} which don't affect current
10011 settings.
10013 After use, @code{\w} sets several registers:
10015 @table @code
10016 @item st
10017 @itemx sb
10018 The highest and lowest point of the baseline, respectively, in @var{text}.
10020 @item rst
10021 @itemx rsb
10022 Like the @code{st} and @code{sb} registers, but takes account of the
10023 heights and depths of characters.  With other words, this gives the
10024 highest and lowest point of @var{text}.
10026 @item ct
10027 Defines the kinds of characters occurring in @var{text}:
10029 @table @asis
10030 @item 0
10031 only short characters, no descenders or tall characters.
10033 @item 1
10034 at least one descender.
10036 @item 2
10037 at least one tall character.
10039 @item 3
10040 at least one each of a descender and a tall character.
10041 @end table
10043 @item ssc
10044 The amount of horizontal space (possibly negative) that should be added
10045 to the last character before a subscript.
10047 @item skw
10048 How far to right of the center of the last character in the @code{\w}
10049 argument, the center of an accent from a roman font should be placed
10050 over that character.
10051 @end table
10052 @endDefesc
10054 @cindex saving horizontal input line position (@code{\k})
10055 @cindex horizontal input line position, saving (@code{\k})
10056 @cindex input line position, horizontal, saving (@code{\k})
10057 @cindex position, horizontal input line, saving (@code{\k})
10058 @cindex line, input, horizontal position, saving (@code{\k})
10059 @DefescList {\\k, , p, }
10060 @DefescItem {\\k, @lparen{}, ps, }
10061 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10062 Store the current horizontal position in the @emph{input} line in
10063 number register with name @var{position} (one-character name@w{ }@var{p},
10064 two-character name @var{ps}).  Use this, for example, to return to the
10065 beginning of a string for highlighting or other decoration.
10066 @endDefesc
10068 @cindex horizontal input line position register (@code{hp})
10069 @cindex input line, horizontal position, register (@code{hp})
10070 @cindex position, horizontal, in input line, register (@code{hp})
10071 @cindex line, input, horizontal position, register (@code{hp})
10072 @Defreg {hp}
10073 The current horizontal position at the input line.
10074 @endDefreg
10076 @cindex horizontal output line position register (@code{.k})
10077 @cindex output line, horizontal position, register (@code{.k})
10078 @cindex position, horizontal, in output line, register (@code{.k})
10079 @cindex line, output, horizontal position, register (@code{.k})
10080 @Defreg {.k}
10081 A read-only number register containing the current horizontal output
10082 position.
10083 @endDefreg
10085 @cindex overstriking characters (@code{\o})
10086 @cindex characters, overstriking (@code{\o})
10087 @Defesc {\\o, ', @Var{a}@Var{b}@Var{c}, '}
10088 Overstrike characters @var{a}, @var{b}, @var{c}, @dots{}; the characters
10089 are centered, and the resulting spacing is the largest width of the
10090 affected characters.
10091 @endDefesc
10093 @cindex zero-width printing (@code{\z}, @code{\Z})
10094 @cindex printing, zero-width (@code{\z}, @code{\Z})
10095 @Defesc {\\z, , c, , }
10096 Print character @var{c} with zero width, i.e., without spacing.  Use
10097 this to overstrike characters left-aligned.
10098 @endDefesc
10100 @cindex zero-width printing (@code{\z}, @code{\Z})
10101 @cindex printing, zero-width (@code{\z}, @code{\Z})
10102 @Defesc {\\Z, ', anything, '}
10103 Print @var{anything}, then restore the horizontal and vertical position.
10104 The argument may not contain tabs or leaders.
10106 The following is an example of a strike-through macro:
10108 @Example
10109 .de ST
10110 .nr ww \w'\\$1'
10111 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10114 This is
10115 .ST "a test"
10116 an actual emergency!
10117 @endExample
10118 @endDefesc
10120 @c XXX documentation
10123 @c =====================================================================
10125 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10126 @section Drawing Requests
10127 @cindex drawing requests
10128 @cindex requests for drawing
10130 @code{gtroff} provides a number of ways to draw lines and other figures
10131 on the page.  Used in combination with the page motion commands (see
10132 @ref{Page Motions}, for more info), a wide variety of figures can be
10133 drawn.  However, for complex drawings these operations can be quite
10134 cumbersome, and it may be wise to use graphic preprocessors like
10135 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
10136 information.
10138 All drawing is done via escapes.
10140 @cindex drawing horizontal lines (@code{\l})
10141 @cindex horizontal line, drawing (@code{\l})
10142 @cindex line, horizontal, drawing (@code{\l})
10143 @DefescList {\\l, ', @Var{l}, '}
10144 @DefescListEnd {\\l, ', @Var{l}@Var{c}, '}
10145 Draw a line rightwards from the current location.
10146 @var{l} is the length of the line to be drawn, starting at the
10147 current location; positive numbers draw to the right, and negative
10148 numbers draw towards the left.  This can also be specified absolutely
10149 (i.e.@: with a leading @samp{|}) which draws back to the beginning
10150 of the input line.
10152 @cindex underscore character
10153 @cindex character, underscore
10154 @cindex line drawing character
10155 @cindex character for line drawing
10156 The optional second parameter@w{ }@var{c} is a character to draw the line
10157 with.  If this second argument is not specified, @code{gtroff} uses
10158 the underscore character.
10160 @cindex zero width space character (@code{\&})
10161 @cindex character, zero width space (@code{\&})
10162 @cindex space character, zero width (@code{\&})
10163 To separate the two arguments (to prevent @code{gtroff} from
10164 interpreting a drawing character as a scaling indicator) use @code{\&}.
10166 Here a small useful example:
10168 @Example
10169 .de box
10170 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10172 @endExample
10174 @noindent
10175 Note that this works by outputting a box rule (a vertical line), then
10176 the text given as an argument and then another box rule.  Then the line
10177 drawing escapes both draw from the current location to the beginning of
10178 the @emph{input} line.
10179 @endDefesc
10181 @cindex drawing vertical lines (@code{\L})
10182 @cindex vertical line drawing (@code{\L})
10183 @cindex line, vertical, drawing (@code{\L})
10184 @cindex line drawing character
10185 @cindex character for line drawing
10186 @cindex box rule character
10187 @cindex character, box rule
10188 @DefescList {\\L, ', @Var{l}, '}
10189 @DefescListEnd {\\L, ', @Var{l}@Var{c}, '}
10190 Draw vertical lines.  Its parameters are
10191 similar to the @code{\l} escape.  The
10192 movement is downwards for positive values,
10193 and upwards for negative values.  The
10194 default character is the box rule character.  As with the vertical
10195 motion escapes, text processing blindly continues where the line
10196 ends.
10198 @c XXX example
10200 @ignore
10201 @Example
10202 ... box macro ...
10203 @endExample
10204 @end ignore
10205 @endDefesc
10207 @Defesc {\\D, ', command arg @dots{}, '}
10208 The @code{\D} escape provides a variety of drawing functions.
10209 Note that on character devices, only vertical and horizontal lines are
10210 supported within @code{grotty}; other devices may only support a subset
10211 of the available drawing functions.
10213 @table @code
10214 @item \D'l @var{dx} @var{dy}'
10215 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10216 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10217 Draw a line from the current location to the relative point specified by
10218 (@var{dx},@var{dy}).
10220 @c XXX example
10222 @ignore
10223 @Example
10224 ... revised box macro ...
10225 @endExample
10226 @end ignore
10228 @item \D'c @var{d}'
10229 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10230 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10231 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
10232 current position.
10234 @item \D'C @var{d}'
10235 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10236 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10237 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10238 Draw a solid circle with the same parameters as an outlined circle.
10240 @item \D'e @var{x} @var{y}'
10241 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10242 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10243 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10244 diameter of @var{y} with the leftmost point at the current position.
10246 @item \D'E @var{x} @var{y}'
10247 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10248 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10249 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10250 Draw a solid ellipse with the same parameters as an outlined ellipse.
10252 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10253 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10254 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10255 Draw an arc clockwise from the current location through the two
10256 specified relative locations (@var{dx1},@var{dy1}) and
10257 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
10258 to the current position, and the coordinates of the second point are
10259 relative to the first point.
10261 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10262 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10263 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10264 Draw a spline from the current location to the relative point
10265 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10267 @item \D'f @var{n}'
10268 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10269 @cindex shading (@w{@code{\D'f @dots{}'}})
10270 @cindex shades for filling objects (@w{@code{\D'f @dots{}'}})
10271 Set the shade of gray to be used for filling solid objects to@w{
10272 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
10273 corresponds solid white and 1000 to solid black, and values in between
10274 correspond to intermediate shades of gray.  This applies only to solid
10275 circles, solid ellipses, and solid polygons.  By default, a level of
10276 1000 is used.
10278 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10279 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10280 @cindex polygon, drawing (@w{@code{\D''p @dots{}}})
10281 Draw a polygon from the current location to the relative position
10282 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10283 When the specified data points are exhausted, a line is drawn back
10284 to the starting point.
10286 @c XXX example
10288 @ignore
10289 @Example
10290 ... box example (yes, again) ...
10291 @endExample
10292 @end ignore
10294 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10295 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10296 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10297 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10298 Draw a solid polygon with the same parameters as an outlined polygon.
10300 @c XXX example
10302 @ignore
10303 @Example
10304 ... shaded box example ...
10305 @endExample
10306 @end ignore
10308 @item \D't @var{n}'
10309 @cindex line thickness (@w{@code{\D't @dots{}'}})
10310 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10311 Set the current line thickness to @var{n}@w{ }machine units.  A value of
10312 zero selects the smallest available line thickness.  A negative value
10313 makes the line thickness proportional to the current point size (this is
10314 the default behaviour of @code{ditroff}).
10315 @end table
10316 @endDefesc
10318 @xref{Drawing Functions}.
10320 @cindex pile, character (@code{\b})
10321 @cindex character pile (@code{\b})
10322 @cindex stacking characters (@code{\b})
10323 @Defesc {\\b, ', string, '}
10324 @dfn{Pile} a sequence of characters vertically, and center it vertically
10325 on the current line.  Use it to build large brackets and braces.
10327 @Example
10328 \b'\(lt\(bv\(lk\(bv\(lb'
10329 @endExample
10330 @endDefesc
10333 @c =====================================================================
10335 @node Traps, Diversions, Drawing Requests, gtroff Reference
10336 @section Traps
10337 @cindex traps
10339 @dfn{Traps} are locations, which, when reached, call a specified
10340 macro.  These traps can occur at a given location on the page, at a
10341 given location in the current diversion,
10342 at a blank line,
10343 after a certain number of input lines,
10344 or at the end of input.
10346 @cindex trap, springing
10347 @cindex springing a trap
10348 It is also said that a trap is @dfn{sprung} if the associated macro
10349 is executed.
10351 @menu
10352 * Page Location Traps::
10353 * Diversion Traps::
10354 * Input Line Traps::
10355 * Blank Line Traps::
10356 * End-of-input Traps::
10357 @end menu
10359 @c ---------------------------------------------------------------------
10361 @node Page Location Traps, Diversion Traps, Traps, Traps
10362 @subsection Page Location Traps
10363 @cindex page location traps
10364 @cindex traps, page location
10366 @dfn{Page location traps} perform an action when @code{gtroff}
10367 reaches or passes a certain vertical location on the page.  Page
10368 location traps have a variety of purposes, including:
10370 @itemize
10371 @item
10372 setting headers and footers
10374 @item
10375 setting body text in multiple columns
10377 @item
10378 setting footnotes
10379 @end itemize
10381 @cindex enabling vertical position traps (@code{vpt})
10382 @cindex vertical position traps, enabling (@code{vpt})
10383 @cindex vertical position trap enable register (@code{.vpt})
10384 @DefreqList {vpt, flag}
10385 @DefregListEnd {.vpt}
10386 Enable vertical position traps if @var{flag} is non-zero, or disables
10387 them otherwise.  Vertical position traps are traps set by the @code{wh}
10388 or @code{dt} requests.  Traps set by the @code{it} request are not
10389 vertical position traps.  The parameter that controls whether vertical
10390 position traps are enabled is global.  Initially vertical position traps
10391 are enabled.  The current setting of this is available in the
10392 @code{.vpt} read-only number register.
10393 @endDefreq
10395 @Defreq {wh, dist macro}
10396 Set a page location trap.  Positive values for @var{dist} set
10397 the trap relative to the top of the page; negative values set
10398 the trap relative to the bottom of the page.
10400 @var{macro} is the name of the macro to execute when the
10401 trap is sprung.
10403 @cindex page headers
10404 @cindex page footers
10405 @cindex headers
10406 @cindex footers
10407 The following is a simple example of how many macro packages
10408 set headers and footers.
10410 @Example
10411 .de hd                \" Page header
10412 '  sp .5i
10413 .  tl 'Title''date'
10414 '  sp .3i
10417 .de fo                \" Page footer
10418 '  sp 1v
10419 .  tl ''%''
10420 '  bp
10423 .wh 0   hd            \" trap at top of the page
10424 .wh -1i fo            \" trap one inch from bottom
10425 @endExample
10427 A trap at or below the bottom of the page is ignored; it can be made
10428 active by either moving it up or increasing the page length so that the
10429 trap is on the page.
10431 It is possible to have more than one trap at the same location; to do so,
10432 the traps must be defined at different locations, then moved together with
10433 the @code{ch} request; otherwise the second trap would replace the first
10434 one.  Earlier defined traps hide later defined traps if moved to the same
10435 position (the many empty lines caused by the @code{bp} request are omitted):
10437 @Example
10438 .de a
10439 .  nop a
10441 .de b
10442 .  nop b
10444 .de c
10445 .  nop c
10448 .wh 1i a
10449 .wh 2i b
10450 .wh 3i c
10452     @result{} a b c
10453 @endExample
10454 @Example
10455 .ch b 1i
10456 .ch c 1i
10458     @result{} a
10459 @endExample
10460 @Example
10461 .ch a 0.5i
10463     @result{} a b
10464 @endExample
10465 @endDefreq
10467 @cindex distance to next trap register (@code{.t})
10468 @cindex trap, distance, register (@code{.t})
10469 @Defreg {.t}
10470 A read-only number register holding the distance to the next trap.
10472 If there are no traps between the current position and the bottom of the
10473 page, it contains the distance to the page bottom.  In a diversion, the
10474 distance to the page bottom is infinite (the returned value is the biggest
10475 integer which can be represented in @code{groff}) if there are no diversion
10476 traps.
10477 @endDefreg
10479 @cindex changing trap location (@code{ch})
10480 @cindex trap, changing location (@code{ch})
10481 @Defreq {ch, macro dist}
10482 Change the location of a trap.
10483 The first argument is the name of the macro to be invoked at
10484 the trap, and the second argument is the new location for the trap
10485 (note that the parameters are specified the opposite of the @code{wh}
10486 request).  This is useful for building up footnotes in a diversion to
10487 allow more space at the bottom of the page for them.
10489 @c XXX
10491 @ignore
10492 @Example
10493 ... (simplified) footnote example ...
10494 @endExample
10495 @end ignore
10496 @endDefreq
10498 @Defreg {.ne}
10499 The read-only number register @code{.ne} contains the amount of space
10500 that was needed in the last @code{ne} request that caused a trap to be
10501 sprung.  Useful in conjunction with the @code{.trunc} register.
10502 @xref{Page Control}, for more information.
10503 @endDefreg
10505 @cindex @code{ne} request, and the @code{.trunc} register
10506 @cindex truncated vertical space register (@code{.trunc})
10507 @Defreg {.trunc}
10508 A read-only register containing the amount of vertical space truncated
10509 by the most recently sprung vertical position trap, or, if the trap was
10510 sprung by an @code{ne} request, minus the amount of vertical motion
10511 produced by the @code{ne} request.  In other words, at the point a trap
10512 is sprung, it represents the difference of what the vertical position
10513 would have been but for the trap, and what the vertical position
10514 actually is.
10515 @endDefreg
10517 @c ---------------------------------------------------------------------
10519 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10520 @subsection Diversion Traps
10521 @cindex diversion traps
10522 @cindex traps, diversion
10524 @cindex @code{.t} register, and diversions
10525 @cindex setting diversion trap (@code{dt})
10526 @cindex diversion trap, setting (@code{dt})
10527 @cindex trap, diversion, setting (@code{dt})
10528 @Defreq {dt, dist macro}
10529 Set a trap @emph{within} a diversion.
10530 @var{dist} is the location of the trap
10531 (identical to the @code{.wh} request)
10532 and @var{macro} is the name of the macro to be invoked.  The
10533 number register @code{.t} still works within diversions.
10534 @xref{Diversions}, for more information.
10535 @endDefreq
10537 @c ---------------------------------------------------------------------
10539 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10540 @subsection Input Line Traps
10541 @cindex input line traps
10542 @cindex traps, input line
10544 @cindex setting input line trap (@code{it})
10545 @cindex input line trap, setting (@code{it})
10546 @cindex trap, input line, setting (@code{it})
10547 @DefreqList {it, n macro}
10548 @DefreqItem {itc, n macro}
10549 Set an input line trap.
10550 @var{n}@w{ }is the number of lines of input which may be read before
10551 springing the trap, @var{macro} is the macro to be invoked.
10552 Request lines are not counted as input lines.
10554 For example, one possible use is to have a macro which prints the
10555 next @var{n}@w{ }lines in a bold font.
10557 @Example
10558 .de B
10559 .  it \\$1 B-end
10560 .  ft B
10563 .de B-end
10564 .  ft R
10566 @endExample
10568 @cindex input line traps and interrupted lines (@code{itc})
10569 @cindex interrupted lines and input line traps (@code{itc})
10570 @cindex traps, input line, and interrupted lines (@code{itc})
10571 @cindex lines, interrupted, and input line traps (@code{itc})
10572 The @code{itc} request is identical,
10573 except that a line interrupted with @code{\c}
10574 counts as one input line.
10576 Both requests are associated with the current environment
10577 (@pxref{Environments}); switching to another environment disables the
10578 current input trap, and going back reactivates it, restoring the number
10579 of already processed lines.
10580 @endDefreq
10582 @c ---------------------------------------------------------------------
10584 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10585 @subsection Blank Line Traps
10586 @cindex blank line traps
10587 @cindex traps, blank line
10588 @cindex blank line macro (@code{blm})
10589 @Defreq {blm, macro}
10590 Set a blank line trap.
10591 @code{gtroff} executes @var{macro} when it encounters a blank line in
10592 the input file.
10593 @endDefreq
10595 @c ---------------------------------------------------------------------
10597 @node End-of-input Traps,  , Blank Line Traps, Traps
10598 @subsection End-of-input Traps
10599 @cindex end-of-input traps
10600 @cindex traps, end-of-input
10602 @cindex setting end-of-input trap (@code{em})
10603 @cindex end-of-input trap, setting (@code{em})
10604 @cindex trap, end-of-input, setting (@code{em})
10605 @cindex end-of-input macro (@code{em})
10606 @cindex macro, end-of-input (@code{em})
10607 @Defreq {em, macro}
10608 Set a trap at the end of input.  @var{macro} is executed after the
10609 last line of the input file has been processed.
10611 For example, if the document had to have a section at the bottom of the
10612 last page for someone to approve it, the @code{em} request could be
10613 used.
10615 @Example
10616 .de approval
10617 .  ne 5v
10618 .  sp |(\\n[.t] - 6v)
10619 .  in +4i
10620 .  lc _
10621 .  br
10622 Approved:\t\a
10623 .  sp
10624 Date:\t\t\a
10627 .em approval
10628 @endExample
10629 @endDefreq
10632 @c =====================================================================
10634 @node Diversions, Environments, Traps, gtroff Reference
10635 @section Diversions
10636 @cindex diversions
10638 In @code{gtroff} it is possible to @dfn{divert} text into a named
10639 storage area.  Due to the similarity to defining macros it is sometimes
10640 said to be stored in a macro.  This is used for saving text for output
10641 at a later time, which is useful for keeping blocks of text on the same
10642 page, footnotes, tables of contents, and indices.
10644 @cindex top-level diversion
10645 @cindex diversion, top-level
10646 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
10647 diversion} if no diversion is active (i.e., the data is diverted to the
10648 output device).
10650 @cindex beginning diversion (@code{di})
10651 @cindex diversion, beginning (@code{di})
10652 @cindex ending diversion (@code{di})
10653 @cindex diversion, ending (@code{di})
10654 @cindex appending to diversion (@code{da})
10655 @cindex diversion, appending (@code{da})
10656 @DefreqList {di, macro}
10657 @DefreqListEnd {da, macro}
10658 Begin a diversion.  Like the @code{de}
10659 request, it takes an argument of a macro name to divert subsequent text
10660 into.  The @code{da} macro appends to an existing diversion.
10662 @code{di} or @code{da} without an argument ends the diversion.
10663 @endDefreq
10665 @DefreqList {box, macro}
10666 @DefreqListEnd {boxa, macro}
10667 Begin (or appends to) a diversion like the
10668 @code{di} and @code{da} requests.
10669 The difference is that @code{box} and @code{boxa}
10670 do not include a partially-filled line in the diversion.
10672 Compare this:
10674 @Example
10675 Before the box.
10676 .box xxx
10677 In the box.
10679 .box
10680 After the box.
10682     @result{} Before the box.  After the box.
10683 .xxx
10684     @result{} In the box.
10685 @endExample
10687 @noindent
10688 with this:
10690 @Example
10691 Before the diversion.
10692 .di yyy
10693 In the diversion.
10696 After the diversion.
10698     @result{} After the diversion.
10699 .yyy
10700     @result{} Before the diversion.  In the diversion.
10701 @endExample
10703 @code{box} or @code{boxa} without an argument ends the diversion.
10704 @endDefreq
10706 @cindex @code{nl} register, and @code{.d}
10707 @cindex nested diversions
10708 @cindex diversion, nested
10709 @cindex diversion name register (@code{.z})
10710 @cindex vertical position in diversion register (@code{.d})
10711 @cindex position, vertical, in diversion, register (@code{.d})
10712 @cindex diversion, vertical position in, register (@code{.d})
10713 @DefregList {.z}
10714 @DefregListEnd {.d}
10715 Diversions may be nested.  The read-only number register @code{.z}
10716 contains the name of the current diversion (this is a string-valued
10717 register).  The read-only number register @code{.d} contains the current
10718 vertical place in the diversion.  If not in a diversion it is the same
10719 as the register @code{nl}.
10720 @endDefreg
10722 @cindex high-water mark register (@code{.h})
10723 @cindex mark, high-water, register (@code{.h})
10724 @cindex position of lowest text line (@code{.h})
10725 @cindex text line, position of lowest (@code{.h})
10726 @Defreg {.h}
10727 The @dfn{high-water mark} on the current page.  It corresponds to the
10728 text baseline of the lowest line on the page.  This is a read-only
10729 register.
10731 @Example
10732 .tm .h==\n[.h], nl==\n[nl]
10733     @result{} .h==0, nl==-1
10734 This is a test.
10736 .sp 2
10737 .tm .h==\n[.h], nl==\n[nl]
10738     @result{} .h==40, nl==120
10739 @endExample
10741 @cindex @code{.h} register, difference to @code{nl}
10742 @cindex @code{nl} register, difference to @code{.h}
10743 @noindent
10744 As can be seen in the previous example, empty lines are not considered
10745 in the return value of the @code{.h} register.
10746 @endDefreg
10748 @DefregList {dn}
10749 @DefregListEnd {dl}
10750 After completing a diversion, the read-write number registers @code{dn}
10751 and @code{dl} contain the vertical and horizontal size of the diversion.
10753 @example
10754 @group
10755 .\" Center text both horizontally & vertically
10757 .\" Enclose macro definitions in .eo and .ec
10758 .\" to avoid the doubling of the backslash
10760 .\" macro .(c starts centering mode
10761 .de (c
10762 .  br
10763 .  ev (c
10764 .  evc 0
10765 .  in 0
10766 .  nf
10767 .  di @@c
10769 @end group
10770 @group
10771 .\" macro .)c terminates centering mode
10772 .de )c
10773 .  br
10774 .  ev
10775 .  di
10776 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
10777 .  sp \n[@@s]u
10778 .  ce 1000
10779 .  @@c
10780 .  ce 0
10781 .  sp \n[@@s]u
10782 .  br
10783 .  fi
10784 .  rr @@s
10785 .  rm @@s
10786 .  rm @@c
10788 .\" End of macro definitions, restore escape mechanism
10790 @end group
10791 @end example
10792 @endDefreg
10794 @cindex transparent output (@code{\!}, @code{\?})
10795 @cindex output, transparent (@code{\!}, @code{\?})
10796 @DefescList {\\!, , , }
10797 @DefescListEnd {\\?, , @Var{anything}, \\?}
10798 Prevent requests, macros, and escapes from being
10799 interpreted when read into a diversion.  This takes the given text
10800 and @dfn{transparently} embeds it into the diversion.  This is useful for
10801 macros which shouldn't be invoked until the diverted text is actually
10802 output.
10804 @c XXX anything is read in copy mode. (what about \! ??)
10806 The @code{\!} escape transparently embeds text up to
10807 and including the end of the line.
10808 The @code{\?} escape transparently embeds text until the next
10809 occurrence of the @code{\?} escape.  For example:
10811 @Example
10812 \?@var{anything}\?
10813 @endExample
10815 @noindent
10816 @var{anything} may not contain newlines; use @code{\!}  to embed
10817 newlines in a diversion.  The escape sequence @code{\?} is also
10818 recognized in copy mode and turned into a single internal code; it is
10819 this code that terminates @var{anything}.  Thus the following example
10820 prints@w{ }4.
10822 @Example
10823 .nr x 1
10825 .di d
10826 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
10828 .nr x 2
10829 .di e
10832 .nr x 3
10833 .di f
10836 .nr x 4
10838 @endExample
10839 @endDefesc
10841 @cindex unformatting diversions (@code{asciify})
10842 @cindex diversion, unformatting (@code{asciify})
10843 @cindex @code{trin} and @code{asciify} request
10844 @Defreq {asciify, div}
10845 @dfn{Unformat} the diversion specified by @var{div}
10846 in such a way that @acronym{ASCII} characters, characters translated with
10847 the @code{trin} request, space characters, and some escape sequences that
10848 were formatted and diverted are treated like ordinary input
10849 characters when the diversion is reread.  It can be also used for gross
10850 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
10852 @Example
10853 .tr @@.
10854 .di x
10855 @@nr n 1
10858 .tr @@@@
10859 .asciify x
10861 @endExample
10863 @xref{Copy-in Mode}.
10864 @endDefreq
10866 @Defreq {unformat, div}
10867 Like @code{asciify}, unformat the specified diversion.
10868 However, @code{unformat} only unformats spaces and tabs
10869 between words.
10870 Unformatted tabs are treated as input tokens,
10871 and spaces are stretchable again.
10873 The vertical size of lines is not preserved; glyph information (font,
10874 font size, space width, etc.)@: is retained.
10875 @endDefreq
10878 @c =====================================================================
10880 @node Environments, Suppressing output, Diversions, gtroff Reference
10881 @section Environments
10882 @cindex environments
10884 It happens frequently that some text should be printed in a certain
10885 format regardless of what may be in effect at the time, for example, in
10886 a trap invoked macro to print headers and footers.  To solve this
10887 @code{gtroff} processes text in @dfn{environments}.  An
10888 environment contains most of the parameters that control text
10889 processing.  It is possible to switch amongst these environments; by
10890 default @code{gtroff} processes text in environment@w{ }0.  The
10891 following is the information kept in an environment.
10893 @itemize @bullet
10894 @item
10895 font parameters (size, family, style, character height and slant, space
10896 and sentence space size)
10898 @item
10899 page parameters (line length, title length, vertical spacing,
10900 line spacing, indentation, line numbering, centering, right-justifying,
10901 underlining, hyphenation data)
10903 @item
10904 fill and adjust mode
10906 @item
10907 tab stops, tab and leader characters, escape character,
10908 no-break and hyphen indicators, margin character data
10910 @item
10911 partially collected lines
10913 @item
10914 input traps
10916 @item
10917 drawing and fill colours
10918 @end itemize
10920 These environments may be given arbitrary names (see @ref{Identifiers},
10921 for more info).  Old versions of @code{troff} only had environments
10922 named @samp{0}, @samp{1}, and @samp{2}.
10924 @cindex switching environment (@code{ev})
10925 @cindex environment, switching (@code{ev})
10926 @cindex environment number/name register (@code{.ev})
10927 @DefreqList {ev, env}
10928 @DefregListEnd {.ev}
10929 Switch to another environment.  The argument @var{env} is the name of
10930 the environment to switch to.  With no argument, @code{gtroff} switches
10931 back to the previous environment.  There is no limit on the number of
10932 named environments; they are created the first time that they are
10933 referenced.  The @code{.ev} read-only register contains the name or
10934 number of the current environment.  This is a string-valued register.
10936 Note that a call to @code{ev} (with argument) pushes the previously
10937 active environment onto a stack.  If, say, environments @samp{foo},
10938 @samp{bar}, and @samp{zap} are called (in that order), the first
10939 @code{ev} request without parameter switches back to environment
10940 @samp{bar} (which is popped off the stack), and a second call
10941 switches back to environment @samp{foo}.
10943 @c XXX example
10945 @ignore
10946 @Example
10947 ... page break macro, revised ...
10948 @endExample
10949 @end ignore
10951 Here is an example:
10953 @Example
10954 .ev footnote-env
10955 .fam N
10956 .ps 6
10957 .vs 8
10958 .ll -.5i
10963 .ev footnote-env
10964 \(dg Note the large, friendly letters.
10966 @endExample
10967 @endDefreq
10969 @cindex copying environment (@code{evc})
10970 @cindex environment, copying (@code{evc})
10971 @Defreq {evc, env}
10972 Copy the environment @var{env} into the current environment.
10974 The following environment data is not copied:
10976 @itemize @bullet
10977 @item
10978 Partially filled lines.
10980 @item
10981 The status whether the previous line was interrupted.
10983 @item
10984 The number of lines still to center, or to right-justify, or to underline
10985 (with or without underlined spaces); they are set to zero.
10987 @item
10988 The status whether a temporary indent is active.
10990 @item
10991 Input traps and its associated data.
10993 @item
10994 Line numbering mode is disabled; it can be reactivated with
10995 @w{@samp{.nm +0}}.
10997 @item
10998 The number of consecutive hyphenated lines (set to zero).
10999 @end itemize
11000 @endDefreq
11002 @cindex environment, last character
11003 @DefregList {.cht}
11004 @DefregItem {.cdp}
11005 @DefregListEnd {.csk}
11006 The @code{\n[.cht]} register contains the
11007 maximum extent (above the baseline)
11008 of the last character added to the current environment.
11010 The @code{\n[.cdp]} register contains the
11011 maximum extent (below the baseline)
11012 of the last character added to the current environment.
11014 The @code{\n[.csk]} register contains the
11015 @dfn{skew} (how far to the right of the character's center
11016 that @code{gtroff} shold place an accent)
11017 of the last character added to the current environment.
11018 @endDefreg
11021 @c =====================================================================
11023 @node Suppressing output, Colors, Environments, gtroff Reference
11024 @section Suppressing output
11026 @cindex suppressing output (@code{\O})
11027 @cindex output, suppressing (@code{\O})
11028 @Defesc {\\O, , num, }
11029 Disable or enable output depending on the value of @var{num}:
11031 @table @samp
11032 @item \O0
11033 Disable any ditroff glyphs from being emitted to the device driver,
11034 provided that the escape occurs at the outer level (see @code{\O3} and
11035 @code{\O4}).
11037 @item \O1
11038 Enable output of glyphs, provided that the escape occurs at the outer
11039 level.
11040 @end table
11042 @vindex opminx
11043 @vindex opminy
11044 @vindex opmaxx
11045 @vindex opmaxy
11046 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11047 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11048 @xref{Register Index}.  These four registers mark the top left and
11049 bottom right hand corners of a box which encompasses all written glyphs.
11051 @table @samp
11052 @item \O2
11053 Provided that the escape occurs at the outer level, enable output of
11054 glyphs and also write out to @code{stderr} the page number and four
11055 registers encompassing the glyphs previously written since the last call
11056 to @code{\O}.
11058 @item \O3
11059 Begin a nesting level.  This is really an internal mechanism for
11060 @code{grohtml} while producing images.  They are generated by running
11061 the troff source through troff to the PostScript device and GhostScript
11062 to produce images in PNG format.  The @code{\O3} escape will start a new
11063 page if the device is not html (to reduce the possibility of images
11064 crossing a page boundary).
11066 @item \O4
11067 End a nesting level.
11069 @item \O[5Pfilename]
11070 This escape is @code{grohtml} specific.  Provided that this escape
11071 occurs at the outer nesting level write the @code{filename} to
11072 @code{stderr}.  The position of the image, @var{P}, must be specified
11073 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
11074 right, centered, inline).  @var{filename} will be associated with the
11075 production of the next inline image.
11076 @end table
11077 @endDefesc
11080 @c =====================================================================
11082 @node Colors, I/O, Suppressing output, gtroff Reference
11083 @section Colors
11085 @Defreq {defcolor, ident scheme color_components}
11086 Define color with name @var{ident}.  @var{scheme} can be one of  the
11087 following values: @code{rgb} (three components), @code{cym} (three
11088 components), @code{cmyk} (four components), and @code{gray} or
11089 @code{grey} (one component).
11091 @cindex default color
11092 @cindex color, default
11093 Color components can be given either as a hexadecimal string or as
11094 positive decimal integers in the range 0--65535.  A hexadecimal string
11095 contains all color components concatenated.  It must start with either
11096 @code{#} or @code{##}; the former specifies hex values in the range
11097 0--255 (which are internally multiplied by@w{ }257), the latter in the
11098 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11099 (magenta).  The default color name @c{default} can't be redefined; its
11100 value is device-specific (usually black).  It is possible that the
11101 default color for @code{\m} and @code{\M} is not identical.
11103 @cindex @code{f} unit, and colors
11104 @cindex unit, @code{f}, and colors
11105 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
11106 its value by 65536; this makes it convenient to specify color components
11107 as fractions in the range 0 to@w{ }1 (1f equals 65536u).  Example:
11109 @Example
11110 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11111 @endExample
11113 Note that @code{f} is the default scaling indicator for the
11114 @code{defcolor} request, thus the above statement is equivalent to
11116 @Example
11117 .defcolor darkgreen rgb 0.1 0.5 0.2
11118 @endExample
11119 @endDefreq
11121 @DefescList {\\m, , c, }
11122 @DefescItem {\\m, @lparen{}, co, }
11123 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11124 Set drawing color.  The following example shows how to turn the next four
11125 words red.
11127 @Example
11128 \m[red]these are in red\m[] and these words are in black.
11129 @endExample
11131 The escape @code{\m[]} returns to the previous color.
11133 The drawing color is associated with the current environment
11134 (@pxref{Environments}).
11135 @endDefesc
11137 @DefescList {\\M, , c, }
11138 @DefescItem {\\M, @lparen{}, co, }
11139 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11140 Set background color for filled objects drawn with the
11141 @code{\D'@dots{}'} commands.
11143 A red ellipse can be created with the following code:
11145 @Example
11146 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11147 @endExample
11149 The escape @code{\M[]} returns to the previous fill color.
11151 The fill color is associated with the current environment
11152 (@pxref{Environments}).
11153 @endDefesc
11156 @c =====================================================================
11158 @node I/O, Postprocessor Access, Colors, gtroff Reference
11159 @section I/O
11160 @cindex i/o
11161 @cindex input and output requests
11162 @cindex requests for input and output
11163 @cindex output and input requests
11165 @code{gtroff} has several requests for including files:
11167 @cindex including a file (@code{so})
11168 @cindex file inclusion (@code{so})
11169 @Defreq {so, file}
11170 Read in the specified @var{file} and
11171 includes it in place of the @code{so} request.  This is quite useful for
11172 large documents, e.g.@: keeping each chapter in a separate file.
11173 @xref{gsoelim}, for more information.
11174 @endDefreq
11176 @Defreq {pso, command}
11177 Read the standard output from the specified @var{command}
11178 and includes it in place of the @code{pso} request.
11180 This request causes an error if used in safer mode (which is the default).
11181 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11182 mode.
11183 @endDefreq
11185 @Defreq {mso, file}
11186 Identical to the @code{so} request except that @code{gtroff}
11187 searches for the specified
11188 @var{file} in the same directories as macro files for the
11189 the @option{-m} command line option.  If the file name to be included
11190 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11191 to include @file{tmac.@var{name}} and vice versa.
11192 @endDefreq
11194 @cindex transparent output (@code{cf}, @code{trf})
11195 @cindex output, transparent (@code{cf}, @code{trf})
11196 @DefreqList {trf, file}
11197 @DefreqListEnd {cf, file}
11198 Transparently output the contents of @var{file}.  Each line is output
11199 as if it were preceded by @code{\!}; however, the lines are not subject
11200 to copy mode interpretation.  If the file does not end with a newline,
11201 then a newline is added (@code{trf} only).  For example, to define a
11202 macro@w{ }@code{x} containing the contents of file@w{ }@file{f}, use
11204 @Example
11205 .di x
11206 .trf f
11208 @endExample
11210 Both @code{trf} and @code{cf}, when used in a diversion,
11211 embeds an object in the diversion which, when reread, causes the
11212 contents of @var{file} to be transparently copied through to the
11213 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
11214 is immediately copied through to the output regardless of whether there
11215 is a current diversion; this behaviour is so anomalous that it must be
11216 considered a bug.
11218 @cindex @code{trf} request, and invalid characters
11219 @cindex characters, invalid for @code{trf} request
11220 @cindex invalid characters for @code{trf} request
11221 While @code{cf} copies the contents of @var{file} completely unprocessed,
11222 @code{trf} disallows characters such as NUL that are not valid
11223 @code{gtroff} input characters (@pxref{Identifiers}).
11225 Both requests cause a line break.
11226 @endDefreq
11228 @cindex processing next file (@code{nx})
11229 @cindex file, processing next (@code{nx})
11230 @cindex next file, processing (@code{nx})
11231 @Defreq {nx, [@Var{file}]}
11232 Force @code{gtroff} to continue processing of
11233 the file specified as an argument.  If no argument is given, immediately
11234 jump to the end of file.
11235 @endDefreq
11237 @cindex reading from standard input (@code{rd})
11238 @cindex standard input, reading from (@code{rd})
11239 @cindex input, standard, reading from (@code{rd})
11240 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11241 Read from standard input, and include what is read as though it
11242 were part of the input file.  Text is read until a blank line
11243 is encountered.
11245 If standard input is a TTY input device (keyboard), write @var{prompt}
11246 to standard error, followed by a colon (or send BEL for a beep if no
11247 argument is given).
11249 Arguments after @var{prompt} are available for the input.  For example,
11250 the line
11252 @Example
11253 .rd data foo bar
11254 @endExample
11256 with the input @w{@samp{This is \$2.}} prints
11258 @Example
11259 This is bar.
11260 @endExample
11261 @endDefreq
11263 @cindex form letters
11264 @cindex letters, form
11265 Using the @code{nx} and @code{rd} requests,
11266 it is easy to set up form letters.  The form
11267 letter template is constructed like this, putting the following lines
11268 into a file called @file{repeat.let}:
11270 @Example
11272 \*(td
11273 .sp 2
11279 Body of letter.
11281 .nx repeat.let
11282 @endExample
11284 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11285 @noindent
11286 When this is run, a file containing the following lines should be
11287 redirected in.  Note that requests included in this file are executed
11288 as though they were part of the form letter.  The last block of input
11289 is the @code{ex} request which tells groff to stop processing.  If
11290 this was not there, groff would not know when to stop.
11292 @Example
11293 Trent A. Fisher
11294 708 NW 19th Av., #202
11295 Portland, OR  97209
11297 Dear Trent,
11299 Len Adollar
11300 4315 Sierra Vista
11301 San Diego, CA  92103
11303 Dear Mr. Adollar,
11306 @endExample
11308 @Defreq {pi, pipe}
11309 Pipe the output of @code{gtroff} to the shell command(s)
11310 specified by @var{pipe}.  This request must occur before
11311 @code{gtroff} has a chance to print anything.
11313 @code{pi} causes an error if used in safer mode (which is the default).
11314 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11315 mode.
11316 @endDefreq
11318 @DefreqList {sy, cmds}
11319 @DefregListEnd {systat}
11320 Execute the shell command(s) specified by @var{cmds}.  The output is not
11321 saved anyplace, so it is up to the user to do so.
11323 This request causes an error if used in safer mode (which is the default).
11324 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11325 mode.
11327 For example, the following example introduces the current time
11328 into a document:
11330 @cindex time, current
11331 @cindex current time
11332 @pindex perl
11333 @Example
11334 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11335              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11336 .so /tmp/x\n[$$]
11337 .sy rm /tmp/x\n[$$]
11338 \nH:\nM:\nS
11339 @endExample
11341 @noindent
11342 Note that this works by having the @code{perl} script (run by @code{sy})
11343 print out the @code{nr} requests which set the number registers
11344 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in with
11345 the @code{so} request.
11347 @cindex @code{system()} return value register (@code{systat})
11348 The @code{systat} read-write number register contains the return value
11349 of the @code{system()} function executed by the last @code{sy} request.
11350 @endDefreq
11352 @cindex opening file (@code{open})
11353 @cindex file, opening (@code{open})
11354 @cindex appending to file (@code{opena})
11355 @cindex file, appending to (@code{opena})
11356 @DefreqList {open, stream file}
11357 @DefreqListEnd {opena, stream file}
11358 Open the specified @var{file} for writing and
11359 associates the specified @var{stream} with it.
11361 The @code{opena} request is like @code{open}, but if the file exists,
11362 append to it instead of truncating it.
11364 Both @code{open} and @code{opena} cause an error if used in safer mode
11365 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
11366 option to activate unsafe mode.
11367 @endDefreq
11369 @cindex copy-in mode, and @code{write} requests
11370 @cindex mode, copy-in, and @code{write} requests
11371 @cindex writing to file (@code{write})
11372 @cindex file, writing to (@code{write})
11373 @DefreqList {write, stream data}
11374 @DefreqListEnd {writec, stream data}
11375 Write to the file associated with the specified @var{stream}.
11376 The stream must previously have
11377 been the subject of an open request.  The remainder of the line is
11378 interpreted as the @code{ds} request reads its second argument: A
11379 leading @samp{"} is stripped, and it is read in copy-in mode.
11381 The @code{writec} request is like @code{write}, but only
11382 @code{write} appends a newline to the data.
11383 @endDefreq
11385 @cindex @code{asciify} and @code{writem}
11386 @Defreq {writem, stream xx}
11387 Write the contents of the macro or string @var{xx}
11388 to the file associated with the specified @var{stream}.
11390 @var{xx} is read in copy mode, i.e., already formatted elements are
11391 ignored.  Consequently, diversions must be unformatted with the
11392 @code{asciify} request before calling @code{writem}.  Usually, this
11393 means a loss of information.
11394 @endDefreq
11396 @cindex closing file (@code{close})
11397 @cindex file, closing (@code{close})
11398 @Defreq {close, stream}
11399 Close the specified @var{stream};
11400 the stream is no longer an acceptable argument to the
11401 @code{write} request.
11403 @c XXX example
11405 @ignore
11406 @Example
11407 ... example of open write &c ...
11408 @endExample
11409 @end ignore
11410 @endDefreq
11412 @DefescList {\\V, , e, }
11413 @DefescItem {\\V, @lparen{}, ev, }
11414 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11415 Interpolate the contents of the specified environment variable
11416 @var{env} (one-character name@w{ }@var{e}, two-character name @var{ev})
11417 as returned by the function @code{getenv}.  @code{\V} is interpreted
11418 in copy-in mode.
11419 @endDefesc
11422 @c =====================================================================
11424 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11425 @section Postprocessor Access
11426 @cindex postprocessor access
11427 @cindex access of postprocessor
11429 There are two escapes which give information directly to the
11430 postprocessor.  This is particularly useful for embedding
11431 @sc{PostScript} into the final document.
11433 @Defesc {\\X, ', xxx, '}
11434 Embeds its argument into the @code{gtroff}
11435 output preceded with @w{@samp{x X}}.
11437 @cindex @code{\&}, in @code{\X}
11438 @cindex @code{\)}, in @code{\X}
11439 @cindex @code{\%}, in @code{\X}
11440 @ifnotinfo
11441 @cindex @code{\:}, in @code{\X}
11442 @end ifnotinfo
11443 @ifinfo
11444 @cindex @code{\@r{<colon>}}, in @code{\X}
11445 @end ifinfo
11446 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11447 within @code{\X}; all other escapes (except @code{\\} which produces a
11448 backslash) cause an error.
11450 @kindex use_charnames_in_special
11451 @pindex DESC@r{, and @code{use_charnames_in_special}}
11452 @cindex @code{\X} and special characters
11453 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11454 file, special characters no longer cause an error; the name @var{xx} is
11455 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11456 Additionally, the backslash is represented as @code{\\}.
11458 This mechanism is currently used by @code{grohtml} only.
11459 @endDefesc
11461 @DefescList {\\Y, , n, }
11462 @DefescItem {\\Y, @lparen{}, nm, }
11463 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11464 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11465 (one-character name@w{ }@var{n}, two-character name @var{nm}).
11466 However, the contents of the string or macro @var{name} are not
11467 interpreted; also it is permitted for @var{name} to have been defined
11468 as a macro and thus contain newlines (it is not permitted for the
11469 argument to @code{\X} to contain newlines).  The inclusion of
11470 newlines requires an extension to the @acronym{UNIX} @code{troff}
11471 output format, and confuses drivers that do not know about this
11472 extension (@pxref{Line Continuation}).
11473 @endDefesc
11475 @xref{Output Devices}.
11478 @c =====================================================================
11480 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11481 @section Miscellaneous
11482 @cindex miscellaneous
11484 This section documents parts of @code{gtroff} which cannot (yet) be
11485 categorized elsewhere in this manual.
11487 @cindex printing line numbers (@code{nm})
11488 @cindex line numbers, printing (@code{nm})
11489 @cindex numbers, line, printing (@code{nm})
11490 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11491 Print line numbers.
11492 @var{start} is the line number of the @emph{next}
11493 output line.  @var{inc} indicates which line numbers are printed.
11494 For example, the value@w{ }5 means to emit only line numbers which
11495 are multiples of@w{ }5; this defaults to@w{ }1.  @var{space} is the
11496 space to be left between the number and the text; this defaults to
11497 one digit space.  The fourth argument is the indentation of the line
11498 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
11499 given as multiples of digit spaces; they can be negative also.
11500 Without any arguments, line numbers are turned off.
11502 @code{gtroff} reserves three digit spaces for the line number (which is
11503 printed right-justified) plus the amount given by @var{indent}; the
11504 output lines are concatenated to the line numbers, separated by
11505 @var{space}, and @emph{without} reducing the line length.  Depending
11506 on the value of the horizontal page offset (as set with the
11507 @code{po} request), line numbers which are longer than the reserved
11508 space stick out to the left, or the whole line is moved to the right.
11510 Parameters corresponding to missing arguments are not changed; any
11511 non-digit argument (to be more precise, any argument starting with a
11512 character valid as a delimiter for identifiers) is also treated as
11513 missing.
11515 If line numbering has been disabled with a call to @code{nm} without
11516 an argument, it can be reactivated with @samp{.nm +0}, using the
11517 previously active line numbering parameters.
11519 The parameters of @code{nm} are associated with the current environment
11520 (@pxref{Environments}).
11522 @Example
11523 .po 1m
11524 .ll 2i
11525 This test shows how line numbering works with groff.
11526 .nm 999
11527 This test shows how line numbering works with groff.
11529 .nm xxx 3 2
11530 .ll -\w'0'u
11531 This test shows how line numbering works with groff.
11532 .nn 2
11533 This test shows how line numbering works with groff.
11534 @endExample
11536 @noindent
11537 And here the result:
11539 @Example
11540  This  test shows how
11541  line numbering works
11542  999 with   groff.   This
11543 1000 test shows how  line
11544 1001 numbering works with
11545 1002 groff.
11546       This test shows how
11547       line      numbering
11548  works  with  groff.
11549  This test shows how
11550 1005  line      numbering
11551       works with groff.
11552 @endExample
11553 @endDefreq
11555 @c XXX xref ln register
11557 @Defreq {nn, [@Var{skip}]}
11558 Temporarily turn off line numbering.  The argument is the number
11559 of lines not to be numbered; this defaults to@w{ }1.
11560 @endDefreq
11562 @cindex margin character (@code{mc})
11563 @cindex character, for margins (@code{mc})
11564 @Defreq {mc, char [@Var{dist}]}
11565 Print margin character to the right of the text.
11566 The first argument is the character to be
11567 printed.  The second argument is the distance away from the right
11568 margin.  If missing, the previously set value is used; default is
11569 10@dmn{pt}).  For text lines that are too long (that is, longer than
11570 the text length plus @var{dist}), the margin character is directly
11571 appended to the lines.
11573 With no arguments the margin character is turned off.
11574 If this occurs before a break, no margin character is printed.
11576 @cindex @code{tl} request, and @code{mc}
11577 For empty lines and lines produced by the @code{tl} request no margin
11578 character is emitted.
11580 The margin character is associated with the current environment
11581 (@pxref{Environments}).
11583 @pindex nrchbar
11584 @pindex changebar
11585 This is quite useful for indicating text that has changed, and, in fact,
11586 there are programs available for doing this (they are called
11587 @code{nrchbar} and @code{changebar} and can be found in any
11588 @samp{comp.sources.unix} archive.
11590 @c XXX example
11592 @ignore
11593 @Example
11594 ... margin char example ...
11595 @endExample
11596 @end ignore
11597 @endDefreq
11599 @cindex PostScript, bounding box
11600 @cindex bounding box
11601 @DefreqList {psbb, filename}
11602 @DefregItem {llx}
11603 @DefregItem {lly}
11604 @DefregItem {urx}
11605 @DefregListEnd {ury}
11606 Retrieve the bounding box of the PostScript image
11607 found in @var{filename}.
11608 The file must conform to
11609 Adobe's @dfn{Document Structuring Conventions} (DSC);
11610 the command searches for a @code{%%BoundingBox} comment
11611 and extracts the bounding box values into the number registers
11612 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
11613 If an error occurs (for example, @code{psbb} cannot find
11614 the @code{%%BoundingBox} comment),
11615 it sets the four number registers to zero.
11616 @endDefreq
11619 @c =====================================================================
11621 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
11622 @section @code{gtroff} Internals
11624 @cindex input token
11625 @cindex token, input
11626 @cindex output node
11627 @cindex node, output
11628 @code{gtroff} processes input in three steps.  One or more input
11629 characters are converted to an @dfn{input token}.@footnote{Except the
11630 escapes @code{\f}, @code{\F}, @code{\H}, @code{\R}, @code{\s}, and
11631 @code{\S} which are processed immediately if not in copy-in mode.}
11632 Then, one or more input tokens are converted to an @dfn{output node}.
11633 Finally, output nodes are converted to the intermediate output language
11634 understood by all output devices.
11636 Actually, before step one happens, @code{gtroff} converts certain
11637 escape sequences into reserved input characters (not accessible by
11638 the user); such reserved characters are used for other internal
11639 processing also -- this is the very reason why not all characters
11640 are valid input.  @xref{Identifiers}, for more on this topic.
11642 For example, the input string @samp{fi\[:u]} is converted into a
11643 character token @samp{f}, a character token @samp{i}, and a special
11644 token @samp{:u} (representing u@w{ }umlaut).  Later on, the character
11645 tokens @samp{f} and @samp{i} are merged to a single output node
11646 representing the ligature glyph @samp{fi} (provided the current font
11647 has a glyph for this ligature); the same happens with @samp{:u}.  All
11648 output glyph nodes are `processed' which means that they are invariably
11649 associated with a given font, font size, advance width, etc.  During
11650 the formatting process, @code{gtroff} itself adds various nodes to
11651 control the data flow.
11653 Macros, diversions, and strings collect elements in two chained lists:
11654 a list of input tokens which have been passed unprocessed, and a list
11655 of output nodes.  Consider the following the diversion.
11657 @Example
11658 .di xxx
11664 @endExample
11666 @noindent
11667 It contains these elements.
11669 @multitable {@i{vertical size node}} {token list} {element number}
11670 @item node list               @tab token list @tab element number
11672 @item @i{line start node}     @tab ---        @tab 1
11673 @item @i{glyph node @code{a}} @tab ---        @tab 2
11674 @item @i{word space node}     @tab ---        @tab 3
11675 @item ---                     @tab @code{b}   @tab 4
11676 @item ---                     @tab @code{\n}  @tab 5
11677 @item @i{glyph node @code{c}} @tab ---        @tab 6
11678 @item @i{vertical size node}  @tab ---        @tab 7
11679 @item @i{vertical size node}  @tab ---        @tab 8
11680 @item ---                     @tab @code{\n}  @tab 9
11681 @end multitable
11683 @cindex @code{\v}, internal representation
11684 @noindent
11685 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
11686 (which are always present) specify the vertical extent of the last
11687 line, possibly modified by @code{\x}.  The @code{br} request finishes
11688 the current partial line, inserting a newline input token which is
11689 subsequently converted to a space when the diversion is reread.  Note
11690 that the word space node has a fixed width which isn't stretchable
11691 anymore.  To convert horizontal space nodes back to input tokens, use
11692 the @code{unformat} request.
11694 Macros only contain elements in the token list (and the node list is
11695 empty); diversions and strings can contain elements in both lists.
11698 @c =====================================================================
11700 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
11701 @section Debugging
11702 @cindex debugging
11704 @code{gtroff} is not easy to debug, but there are some useful features
11705 and strategies for debugging.
11707 @pindex soelim
11708 @cindex multi-file documents
11709 @cindex documents, multi-file
11710 @cindex setting input line number (@code{lf})
11711 @cindex input line number, setting (@code{lf})
11712 @cindex number, input line, setting (@code{lf})
11713 @Defreq {lf, line filename}
11714 Change the line number and the file name @code{gtroff} shall use for
11715 error and warning messages.  @var{line} is the input line number of the
11716 @emph{next} line.
11718 Without argument, the request is ignored.
11720 This is a debugging aid for documents which are split into many files,
11721 then put together with @code{soelim} and other preprocessors.  Usually,
11722 it isn't invoked manually.
11724 @c XXX example
11726 @ignore
11727 @Example
11728 ... example of soelim'ed doc ...
11729 @endExample
11730 @end ignore
11731 @endDefreq
11733 @cindex printing to stderr (@code{tm})
11734 @cindex stderr, printing to (@code{tm})
11735 @DefreqList {tm, string}
11736 @DefreqItem {tm1, string}
11737 @DefreqListEnd {tmc, string}
11738 Send @var{string} to the standard error output;
11739 this is very useful for printing debugging messages among other things.
11741 @var{string} is read in copy mode.
11743 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
11744 handles its argument similar to the @code{ds} request: a leading double
11745 quote in @var{string} is stripped to allow initial blanks.
11747 The @code{tmc} request is similar to @code{tm1} but does
11748 not append a newline (as is done in @code{tm} and @code{tm1}).
11749 @endDefreq
11751 @cindex aborting (@code{ab})
11752 @Defreq {ab, [@Var{string}]}
11753 Similar to the @code{tm} request, except that
11754 it causes @code{gtroff} to stop processing.  With no argument it
11755 prints @samp{User Abort.} to standard error.
11756 @endDefreq
11758 @cindex @code{ex} request, use in debugging
11759 @cindex exiting (@code{ex})
11760 @Defreq {ex, }
11761 The @code{ex} request also causes @code{gtroff} to stop processing;
11762 see also @ref{I/O}.
11763 @endDefreq
11765 When doing something involved it is useful to leave the debugging
11766 statements in the code and have them turned on by a command line flag.
11768 @Example
11769 .if \n(DB .tm debugging output
11770 @endExample
11772 @noindent
11773 To activate these statements say
11775 @Example
11776 groff -rDB=1 file
11777 @endExample
11779 If it is known in advance that there will be many errors and no useful
11780 output, @code{gtroff} can be forced to suppress formatted output with
11781 the @option{-z} flag.
11783 @cindex dumping symbol table (@code{pm})
11784 @cindex symbol table, dumping (@code{pm})
11785 @Defreq {pm, }
11786 Print the entire symbol table on @code{stderr}.  Names of all defined
11787 macros, strings, and diversions are print together with their size in
11788 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
11789 returned size can be larger than expected.
11791 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
11792 reports the sizes of diversions, ignores an additional argument to
11793 print only the total of the sizes, and the size isn't returned in
11794 blocks of 128 characters.
11795 @endDefreq
11797 @cindex dumping number registers (@code{pnr})
11798 @cindex number registers, dumping (@code{pnr})
11799 @Defreq {pnr, }
11800 Print the names and contents of all
11801 currently defined number registers on @code{stderr}.
11802 @endDefreq
11804 @cindex dumping traps (@code{ptr})
11805 @cindex traps, dumping (@code{ptr})
11806 @Defreq {ptr, }
11807 Print the names and positions of all traps
11808 (not including input line traps and diversion traps) on @code{stderr}.
11809 Empty slots in the page trap list are printed as well, because they can
11810 affect the priority of subsequently planted traps.
11811 @endDefreq
11813 @cindex flush output (@code{fl})
11814 @cindex output, flush (@code{fl})
11815 @cindex interactive use of @code{gtroff}
11816 @cindex @code{gtroff}, interactive use
11817 @Defreq {fl, }
11818 Instruct @code{gtroff} to flush its output immediately.  The intent
11819 is for interactive use, but this behaviour is currently not
11820 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
11821 TTY output is sent to a device driver also (@code{grotty}), making it
11822 non-trivial to communicate interactively.
11824 This request causes a line break.
11825 @endDefreq
11827 @cindex backtrace of input stack (@code{backtrace})
11828 @cindex input stack, backtrace (@code{backtrace})
11829 @Defreq {backtrace, }
11830 Print a backtrace of the input stack to the standard error stream.
11832 Consider the following in file @file{test}:
11834 @Example
11835 .de xxx
11836 .  backtrace
11838 .de yyy
11839 .  xxx
11842 .yyy
11843 @endExample
11845 @noindent
11846 On execution, @code{gtroff} prints the following:
11848 @Example
11849 test:2: backtrace: macro `xxx'
11850 test:5: backtrace: macro `yyy'
11851 test:8: backtrace: file `test'
11852 @endExample
11854 The option @option{-b} of @code{gtroff} internally calls a variant of
11855 this request on each error and warning.
11856 @endDefreq
11858 @cindex input stack, setting limit
11859 @Defreg {slimit}
11860 Use the @code{slimit} number register
11861 to set the maximum number of objects on the input stack.
11862 If @code{slimit} is less than or equal to@w{ }0,
11863 there is no limit set.
11864 With no limit, a buggy recursive macro can exhaust virtual memory.
11865 @endDefreg
11867 @cindex warnings
11868 @code{gtroff} has command line options for printing out more warnings
11869 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
11870 or an error occurs.  The most verbose level of warnings is @option{-ww}.
11872 @cindex level of warnings (@code{warn})
11873 @cindex warnings, level (@code{warn})
11874 @DefreqList {warn, [@Var{flags}]}
11875 @DefregListEnd {.warn}
11876 Control the level of warnings checked for.  The @var{flags} are the sum
11877 of the numbers associated with each warning that is to be enabled; all
11878 other warnings are disabled.  The number associated with each warning is
11879 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
11880 and @w{@code{.warn 1}} disables all warnings except that about missing
11881 characters.  If no argument is given, all warnings are enabled.
11883 The read-only number register @code{.warn} contains the current warning
11884 level.
11885 @endDefreq
11887 @menu
11888 * Warnings::
11889 @end menu
11891 @c ---------------------------------------------------------------------
11893 @node Warnings,  , Debugging, Debugging
11894 @subsection Warnings
11895 @cindex warnings
11897 The warnings that can be given to @code{gtroff} are divided into the
11898 following categories.  The name associated with each warning is used by
11899 the @option{-w} and @option{-W} options; the number is used by the
11900 @code{warn} request and by the @code{.warn} register.
11902 @table @samp
11903 @item char
11904 @itemx 1
11905 Non-existent characters.  This is enabled by default.
11907 @item number
11908 @itemx 2
11909 Invalid numeric expressions.  This is enabled by default.
11910 @xref{Expressions}.
11912 @item break
11913 @itemx 4
11914 @cindex fill mode
11915 @cindex mode, fill
11916 In fill mode, lines which could not be broken so that their length was
11917 less than the line length.  This is enabled by default.
11919 @item delim
11920 @itemx 8
11921 Missing or mismatched closing delimiters.
11923 @item el
11924 @itemx 16
11925 @cindex @code{ie} request, and warnings
11926 @cindex @code{el} request, and warnings
11927 Use of the @code{el} request with no matching @code{ie} request.
11928 @xref{if-else}.
11930 @item scale
11931 @itemx 32
11932 Meaningless scaling indicators.
11934 @item range
11935 @itemx 64
11936 Out of range arguments.
11938 @item syntax
11939 @itemx 128
11940 Dubious syntax in numeric expressions.
11942 @item di
11943 @itemx 256
11944 @cindex @code{di} request, and warnings
11945 @cindex @code{da} request, and warnings
11946 Use of @code{di} or @code{da} without an argument when there is no
11947 current diversion.
11949 @item mac
11950 @itemx 512
11951 @cindex @code{de} request, and warnings
11952 @c XXX more index entries
11953 Use of undefined strings, macros and diversions.  When an undefined
11954 string, macro, or diversion is used, that string is automatically
11955 defined as empty.  So, in most cases, at most one warning is given
11956 for each name.
11958 @item reg
11959 @itemx 1024
11960 @cindex @code{nr} request, and warnings
11961 @c XXX more index entries
11962 Use of undefined number registers.  When an undefined number register is
11963 used, that register is automatically defined to have a value of@w{ }0.
11964 So, in most cases, at most one warning is given for use of a particular
11965 name.
11967 @item tab
11968 @itemx 2048
11969 Use of a tab character where a number was expected.
11971 @item right-brace
11972 @itemx 4096
11973 @cindex @code{\@}}, debugging
11974 Use of @code{\@}} where a number was expected.
11976 @item missing
11977 @itemx 8192
11978 Requests that are missing non-optional arguments.
11980 @item input
11981 @itemx 16384
11982 Invalid input characters.
11984 @item escape
11985 @itemx 32768
11986 Unrecognized escape sequences.  When an unrecognized escape sequence is
11987 encountered, the escape character is ignored.
11989 @item space
11990 @itemx 65536
11991 @cindex compatibility mode
11992 Missing space between a request or macro and its argument.  This warning
11993 is given when an undefined name longer than two characters is
11994 encountered, and the first two characters of the name make a defined
11995 name.  The request or macro is not invoked.  When this warning is
11996 given, no macro is automatically defined.  This is enabled by default.
11997 This warning never occurs in compatibility mode.
11999 @item font
12000 @itemx 131072
12001 Non-existent fonts.  This is enabled by default.
12003 @item ig
12004 @itemx 262144
12005 Invalid escapes in text ignored with the @code{ig} request.  These are
12006 conditions that are errors when they do not occur in ignored text.
12008 @item color
12009 @itemx 524288
12010 Color related warnings.
12012 @item all
12013 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
12014 intended that this covers all warnings that are useful with traditional
12015 macro packages.
12017 @item w
12018 All warnings.
12019 @end table
12022 @c =====================================================================
12024 @node Implementation Differences, Summary, Debugging, gtroff Reference
12025 @section Implementation Differences
12026 @cindex implementation differences
12027 @cindex differences in implementation
12028 @cindex incompatibilities with Unix @code{troff}
12029 @cindex compatibility mode
12030 @cindex mode, compatibility
12032 GNU @code{troff} has a number of features which cause incompatibilities
12033 with documents written with old versions of @code{troff}.
12035 @cindex long names
12036 @cindex names, long
12037 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
12038 interprets
12040 @Example
12041 .dsabcd
12042 @endExample
12044 @cindex @code{\*}, incompatibilities with Unix @code{troff}
12045 @cindex @code{\n}, incompatibilities with Unix @code{troff}
12046 @noindent
12047 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
12048 @code{troff} interprets this as a call of a macro named
12049 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
12050 @code{\*[} or @code{\n[} as references to a string or number register
12051 called @samp{[}.  In GNU @code{troff}, however, this is normally
12052 interpreted as the start of a long name.  In compatibility mode GNU
12053 @code{troff} interprets long names in the traditional way
12054 (which means that they are not recognized as names).
12056 @DefreqList {cp, [@Var{n}]}
12057 @DefreqItem {do, cmd}
12058 @DefregListEnd {.C}
12059 If @var{n} is missing or non-zero, turn on compatibility mode;
12060 otherwise, turn it off.
12062 The number
12063 register @code{.C} is@w{ }1 if compatibility mode is on, 0@w{
12064 }otherwise.
12066 Compatibility mode can be turned on with the
12067 @option{-C} command line option.
12069 The @code{do} request turns off compatibility mode
12070 while executing its arguments as a @code{gtroff} command.
12072 @Example
12073 .do fam T
12074 @endExample
12076 @noindent
12077 executes the @code{fam} request when compatibility mode
12078 is enabled.
12080 @code{gtroff} restores the previous compatibility setting
12081 before interpreting any files sourced by the @var{cmd}.
12082 @endDefreq
12084 @cindex input level in delimited arguments
12085 @cindex delimited arguments, incompatibilities with Unix @code{troff}
12086 Two other features are controlled by @option{-C}.  If not in
12087 compatibility mode, GNU @code{troff} preserves the input level in
12088 delimited arguments:
12090 @Example
12091 .ds xx '
12092 \w'abc\*(xxdef'
12093 @endExample
12095 @noindent
12096 In compatibility mode, the string @samp{72def'} is returned; without
12097 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12098 device).
12100 @cindex @code{\f}, incompatibilities with Unix @code{troff}
12101 @cindex @code{\H}, incompatibilities with Unix @code{troff}
12102 @cindex @code{\R}, incompatibilities with Unix @code{troff}
12103 @cindex @code{\s}, incompatibilities with Unix @code{troff}
12104 @cindex @code{\S}, incompatibilities with Unix @code{troff}
12105 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
12106 @code{\S} are transparent for recognizing the beginning of a line only
12107 in compatibility mode (this is a rather obscure feature).  For example,
12108 the code
12110 @Example
12111 .de xx
12112 Hallo!
12114 \fB.xx\fP
12115 @endExample
12117 prints @samp{Hallo!} in bold face if in compatibility mode, and
12118 @samp{.xx} in bold face otherwise.
12120 @cindex @code{\A}, incompatibilities with Unix @code{troff}
12121 @cindex @code{\|}, incompatibilities with Unix @code{troff}
12122 @cindex @code{\^}, incompatibilities with Unix @code{troff}
12123 @cindex @code{\&}, incompatibilities with Unix @code{troff}
12124 @cindex @code{\@{}, incompatibilities with Unix @code{troff}
12125 @cindex @code{\@}}, incompatibilities with Unix @code{troff}
12126 @cindex @code{\@key{SP}}, incompatibilities with Unix @code{troff}
12127 @cindex @code{\'}, incompatibilities with Unix @code{troff}
12128 @cindex @code{\`}, incompatibilities with Unix @code{troff}
12129 @cindex @code{\-}, incompatibilities with Unix @code{troff}
12130 @cindex @code{\_}, incompatibilities with Unix @code{troff}
12131 @cindex @code{\!}, incompatibilities with Unix @code{troff}
12132 @cindex @code{\%}, incompatibilities with Unix @code{troff}
12133 @cindex @code{\c}, incompatibilities with Unix @code{troff}
12134 GNU @code{troff} does not allow the use of the escape sequences
12135 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12136 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12137 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12138 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
12139 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12140 avoiding use of these escape sequences in names.
12142 @cindex fractional point sizes
12143 @cindex point sizes, fractional
12144 @cindex @code{ps} request, incompatibilities with Unix @code{troff}
12145 Fractional point sizes cause one noteworthy incompatibility.  In
12146 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12147 indicators and thus
12149 @Example
12150 .ps 10u
12151 @endExample
12153 @noindent
12154 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
12155 sets the point size to 10@w{ }scaled points.  @xref{Fractional Type
12156 Sizes}, for more information.
12158 @cindex @code{bd} request, incompatibilities with Unix @code{troff}
12159 @cindex @code{cs} request, incompatibilities with Unix @code{troff}
12160 @cindex @code{tkf} request, incompatibilities with Unix @code{troff}
12161 @cindex @code{tr} request, incompatibilities with Unix @code{troff}
12162 @cindex @code{fp} request, incompatibilities with Unix @code{troff}
12163 @cindex input and output characters, compatibility with Unix
12164 @cindex output characters, compatibility with Unix
12165 @cindex characters, input and output, compatibility with Unix
12166 In GNU @code{troff} there is a fundamental difference between
12167 unformatted, input characters, and formatted, output characters.
12168 Everything that affects how an output character is output is stored
12169 with the character; once an output character has been constructed it is
12170 unaffected by any subsequent requests that are executed, including
12171 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12172 Normally output characters are constructed from input characters at the
12173 moment immediately before the character is added to the current output
12174 line.  Macros, diversions and strings are all, in fact, the same type of
12175 object; they contain lists of input characters and output characters in
12176 any combination.  An output character does not behave like an input
12177 character for the purposes of macro processing; it does not inherit any
12178 of the special properties that the input character from which it was
12179 constructed might have had.  For example,
12181 @Example
12182 .di x
12183 \\\\
12187 @endExample
12189 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
12190 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
12191 @cindex @code{\e}, incompatibilities with Unix @code{troff}
12192 @cindex @code{\!}, incompatibilities with Unix @code{troff}
12193 @cindex @code{\?}, incompatibilities with Unix @code{troff}
12194 @cindex transparent output, incompatibilities with Unix @code{troff}
12195 @cindex output, transparent, incompatibilities with Unix @code{troff}
12196 @noindent
12197 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12198 is turned into one output backslash and the resulting output backslashes
12199 are not interpreted as escape characters when they are reread.
12200 @acronym{UNIX} @code{troff} would interpret them as escape characters
12201 when they were reread and would end up printing one @samp{\}.  The
12202 correct way to obtain a printable backslash is to use the @code{\e}
12203 escape sequence: This always prints a single instance of the current
12204 escape character, regardless of whether or not it is used in a
12205 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12206 @code{troff}.@footnote{To be completely independent of the current
12207 escape character, use @code{\(rs} which represents a reverse solidus
12208 (backslash) glyph.}  To store, for some reason, an escape sequence in a
12209 diversion that will be interpreted when the diversion is reread, either
12210 use the traditional @code{\!} transparent output facility, or, if this
12211 is unsuitable, the new @code{\?} escape sequence.
12213 @xref{Diversions}, for more information.
12216 @c =====================================================================
12218 @node Summary,  , Implementation Differences, gtroff Reference
12219 @section Summary
12220 @cindex summary
12222 @c XXX documentation
12226 @c =====================================================================
12227 @c =====================================================================
12229 @node Preprocessors, Output Devices, gtroff Reference, Top
12230 @chapter Preprocessors
12231 @cindex preprocessors
12233 This chapter describes all preprocessors that come with @code{groff} or
12234 which are freely available.
12236 @menu
12237 * geqn::
12238 * gtbl::
12239 * gpic::
12240 * ggrn::
12241 * grap::
12242 * grefer::
12243 * gsoelim::
12244 @end menu
12247 @c =====================================================================
12249 @node geqn, gtbl, Preprocessors, Preprocessors
12250 @section @code{geqn}
12251 @cindex @code{eqn}, the program
12252 @cindex @code{geqn}, the program
12254 @c XXX
12256 @menu
12257 * Invoking geqn::
12258 @end menu
12260 @c ---------------------------------------------------------------------
12262 @node Invoking geqn,  , geqn, geqn
12263 @subsection Invoking @code{geqn}
12264 @cindex invoking @code{geqn}
12265 @cindex @code{geqn}, invoking
12267 @c XXX
12270 @c =====================================================================
12272 @node gtbl, gpic, geqn, Preprocessors
12273 @section @code{gtbl}
12274 @cindex @code{tbl}, the program
12275 @cindex @code{gtbl}, the program
12277 @c XXX
12279 @menu
12280 * Invoking gtbl::
12281 @end menu
12283 @c ---------------------------------------------------------------------
12285 @node Invoking gtbl,  , gtbl, gtbl
12286 @subsection Invoking @code{gtbl}
12287 @cindex invoking @code{gtbl}
12288 @cindex @code{gtbl}, invoking
12290 @c XXX
12293 @c =====================================================================
12295 @node gpic, ggrn, gtbl, Preprocessors
12296 @section @code{gpic}
12297 @cindex @code{pic}, the program
12298 @cindex @code{gpic}, the program
12300 @c XXX
12302 @menu
12303 * Invoking gpic::
12304 @end menu
12306 @c ---------------------------------------------------------------------
12308 @node Invoking gpic,  , gpic, gpic
12309 @subsection Invoking @code{gpic}
12310 @cindex invoking @code{gpic}
12311 @cindex @code{gpic}, invoking
12313 @c XXX
12316 @c =====================================================================
12318 @node ggrn, grap, gpic, Preprocessors
12319 @section @code{ggrn}
12320 @cindex @code{grn}, the program
12321 @cindex @code{ggrn}, the program
12323 @c XXX
12325 @menu
12326 * Invoking ggrn::
12327 @end menu
12329 @c ---------------------------------------------------------------------
12331 @node Invoking ggrn,  , ggrn, ggrn
12332 @subsection Invoking @code{ggrn}
12333 @cindex invoking @code{ggrn}
12334 @cindex @code{ggrn}, invoking
12336 @c XXX
12339 @c =====================================================================
12341 @node grap, grefer, ggrn, Preprocessors
12342 @section @code{grap}
12343 @cindex @code{grap}, the program
12345 A free implementation of @code{grap}, written by Ted Faber,
12346 is available as an extra package from the following address:
12348 @display
12349 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12350 @end display
12353 @c =====================================================================
12355 @node grefer, gsoelim, grap, Preprocessors
12356 @section @code{grefer}
12357 @cindex @code{refer}, the program
12358 @cindex @code{grefer}, the program
12360 @c XXX
12362 @menu
12363 * Invoking grefer::
12364 @end menu
12366 @c ---------------------------------------------------------------------
12368 @node Invoking grefer,  , grefer, grefer
12369 @subsection Invoking @code{grefer}
12370 @cindex invoking @code{grefer}
12371 @cindex @code{grefer}, invoking
12373 @c XXX
12376 @c =====================================================================
12378 @node gsoelim,  , grefer, Preprocessors
12379 @section @code{gsoelim}
12380 @cindex @code{soelim}, the program
12381 @cindex @code{gsoelim}, the program
12383 @c XXX
12385 @menu
12386 * Invoking gsoelim::
12387 @end menu
12389 @c ---------------------------------------------------------------------
12391 @node Invoking gsoelim,  , gsoelim, gsoelim
12392 @subsection Invoking @code{gsoelim}
12393 @cindex invoking @code{gsoelim}
12394 @cindex @code{gsoelim}, invoking
12396 @c XXX
12400 @c =====================================================================
12401 @c =====================================================================
12403 @node Output Devices, File formats, Preprocessors, Top
12404 @chapter Output Devices
12405 @cindex output devices
12406 @cindex devices for output
12408 @c XXX
12410 @menu
12411 * Special Characters::
12412 * grotty::
12413 * grops::
12414 * grodvi::
12415 * grolj4::
12416 * grolbp::
12417 * grohtml::
12418 * gxditview::
12419 @end menu
12422 @c =====================================================================
12424 @node Special Characters, grotty, Output Devices, Output Devices
12425 @section Special Characters
12426 @cindex special characters
12427 @cindex characters, special
12429 @c XXX
12431 @xref{Font Files}.
12434 @c =====================================================================
12436 @node grotty, grops, Special Characters, Output Devices
12437 @section @code{grotty}
12438 @cindex @code{grotty}, the program
12440 @c XXX
12442 @menu
12443 * Invoking grotty::
12444 @end menu
12446 @c ---------------------------------------------------------------------
12448 @node Invoking grotty,  , grotty, grotty
12449 @subsection Invoking @code{grotty}
12450 @cindex invoking @code{grotty}
12451 @cindex @code{grotty}, invoking
12453 @c XXX
12455 @c The following is no longer true; fix and extend it.
12457 @c @pindex less
12458 @c @cindex Teletype
12459 @c @cindex ISO 6249 SGR
12460 @c @cindex terminal control sequences
12461 @c @cindex control sequences, for terminals
12462 @c For tty output devices, underlining is done by emitting sequences of
12463 @c @samp{_} and @samp{\b} (the backspace character) before the actual
12464 @c character.  Literally, this is printing an underline character, then
12465 @c moving back one character position, and printing the actual character
12466 @c at the same position as the underline character (similar to a
12467 @c typewriter).  Usually, a modern terminal can't interpret this (and the
12468 @c original Teletype machines for which this sequence was appropriate are
12469 @c no longer in use).  You need a pager program like @code{less} which
12470 @c translates this into ISO 6429 SGR sequences to control terminals.
12473 @c =====================================================================
12475 @node grops, grodvi, grotty, Output Devices
12476 @section @code{grops}
12477 @cindex @code{grops}, the program
12479 @c XXX
12481 @menu
12482 * Invoking grops::
12483 * Embedding PostScript::
12484 @end menu
12486 @c ---------------------------------------------------------------------
12488 @node Invoking grops, Embedding PostScript, grops, grops
12489 @subsection Invoking @code{grops}
12490 @cindex invoking @code{grops}
12491 @cindex @code{grops}, invoking
12493 @c XXX
12495 @c ---------------------------------------------------------------------
12497 @node Embedding PostScript,  , Invoking grops, grops
12498 @subsection Embedding @sc{PostScript}
12499 @cindex embedding postscript
12500 @cindex postscript, embedding
12502 @c XXX
12505 @c =====================================================================
12507 @node grodvi, grolj4, grops, Output Devices
12508 @section @code{grodvi}
12509 @cindex @code{grodvi}, the program
12511 @c XXX
12513 @menu
12514 * Invoking grodvi::
12515 @end menu
12517 @c ---------------------------------------------------------------------
12519 @node Invoking grodvi,  , grodvi, grodvi
12520 @subsection Invoking @code{grodvi}
12521 @cindex invoking @code{grodvi}
12522 @cindex @code{grodvi}, invoking
12524 @c XXX
12527 @c =====================================================================
12529 @node grolj4, grolbp, grodvi, Output Devices
12530 @section @code{grolj4}
12531 @cindex @code{grolj4}, the program
12533 @c XXX
12535 @menu
12536 * Invoking grolj4::
12537 @end menu
12539 @c ---------------------------------------------------------------------
12541 @node Invoking grolj4,  , grolj4, grolj4
12542 @subsection Invoking @code{grolj4}
12543 @cindex invoking @code{grolj4}
12544 @cindex @code{grolj4}, invoking
12546 @c XXX
12549 @c =====================================================================
12551 @node grolbp, grohtml, grolj4, Output Devices
12552 @section @code{grolbp}
12553 @cindex @code{grolbp}, the program
12555 @c XXX
12557 @menu
12558 * Invoking grolbp::
12559 @end menu
12561 @c ---------------------------------------------------------------------
12563 @node Invoking grolbp,  , grolbp, grolbp
12564 @subsection Invoking @code{grolbp}
12565 @cindex invoking @code{grolbp}
12566 @cindex @code{grolbp}, invoking
12568 @c XXX
12571 @c =====================================================================
12573 @node grohtml, gxditview, grolbp, Output Devices
12574 @section @code{grohtml}
12575 @cindex @code{grohtml}, the program
12577 @c XXX
12579 @menu
12580 * Invoking grohtml::
12581 * grohtml specific registers and strings::
12582 @end menu
12584 @c ---------------------------------------------------------------------
12586 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
12587 @subsection Invoking @code{grohtml}
12588 @cindex invoking @code{grohtml}
12589 @cindex @code{grohtml}, invoking
12591 @c XXX
12593 @c ---------------------------------------------------------------------
12595 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
12596 @subsection @code{grohtml} specific registers and strings
12597 @cindex registers specific to @code{grohtml}
12598 @cindex strings specific to @code{grohtml}
12599 @cindex @code{grohtml}, registers and strings
12601 @DefmpregList {ps4html, grohtml}
12602 @DefstrListEnd {www-image-template, grohtml}
12603 The registers @code{ps4html} and @code{www-image-template} are defined
12604 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
12605 the @code{troff} input, marks up the inline equations and passes the
12606 result firstly to
12608 @example
12609 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
12610 @end example
12612 @noindent
12613 and secondly to
12615 @example
12616 troff -Thtml
12617 @end example
12619 The postscript device is used to create all the image files, and the
12620 register @code{ps4html} enables the macro sets to ignore floating
12621 keeps, footers, and headings.
12623 The register @code{www-image-template} is set to the user specified
12624 template name or the default name.
12625 @endDefmpreg
12628 @c =====================================================================
12630 @node gxditview,  , grohtml, Output Devices
12631 @section @code{gxditview}
12632 @cindex @code{gxditview}, the program
12634 @c XXX
12636 @menu
12637 * Invoking gxditview::
12638 @end menu
12640 @c ---------------------------------------------------------------------
12642 @node Invoking gxditview,  , gxditview, gxditview
12643 @subsection Invoking @code{gxditview}
12644 @cindex invoking @code{gxditview}
12645 @cindex @code{gxditview}, invoking
12647 @c XXX
12648 @c X11's xditview
12652 @c =====================================================================
12653 @c =====================================================================
12655 @node File formats, Installation, Output Devices, Top
12656 @chapter File formats
12657 @cindex file formats
12658 @cindex formats, file
12660 @c XXX
12662 @menu
12663 * gtroff Output::
12664 * Font Files::
12665 @end menu
12668 @c =====================================================================
12670 @node gtroff Output, Font Files, File formats, File formats
12671 @section @code{gtroff} Output
12672 @cindex @code{gtroff} output
12673 @cindex output, @code{gtroff}
12675 This section describes the format output of GNU @code{troff}.  The
12676 output format used by GNU @code{troff} is very similar -- but
12677 not identical -- to that used by
12678 @acronym{UNIX} device-independent @code{troff} (@code{ditroff}).
12680 @menu
12681 * Output Format::
12682 * Device Control::
12683 * Drawing Functions::
12684 * Line Continuation::
12685 @end menu
12687 @c ---------------------------------------------------------------------
12689 @node Output Format, Device Control, gtroff Output, gtroff Output
12690 @subsection Output Format
12691 @cindex output format
12692 @cindex format of output
12694 @cindex 8-bit input
12695 @cindex input, 8-bit
12696 The output format is text based, as opposed to a binary format (like
12697 @TeX{} DVI).  The output format is @w{8-bit} clean, thus single
12698 characters can have the eighth bit set, as can the names of fonts and
12699 special characters.
12701 The output format consists of single command characters with attached
12702 parameters which are separated from subsequent text by whitespace or a
12703 newline.
12705 The names of characters and fonts can be of arbitrary length; drivers
12706 should not assume that they are only two characters long (as
12707 @code{ditroff} does).
12709 When a character is to be printed, that character is always in the
12710 current font.  Unlike @code{ditroff}, it is not necessary for drivers to
12711 search special fonts to find a character.
12713 @table @code
12714 @item H@var{n}
12715 @c XXX
12717 @item V@var{n}
12718 @c XXX
12720 @item h@var{n}
12721 @c XXX
12723 @item v@var{n}
12724 @c XXX
12726 @item c@var{n}
12727 @c XXX
12729 @item C@var{n}
12730 @c XXX
12732 @item @var{nn}@var{c}
12733 @c XXX
12735 @item t@var{xxx}
12736 @var{xxx} is any sequence of characters terminated by a space or a
12737 newline; the first character should be printed at the current position,
12738 the the current horizontal position should be increased by the width of
12739 the first character, and so on for each character.  The width of the
12740 character is that given in the font file, appropriately scaled for the
12741 current point size, and rounded so that it is a multiple of the
12742 horizontal resolution.  Special characters cannot be printed using this
12743 command.
12745 @kindex tcommand
12746 @pindex DESC@r{, and @code{tcommand}}
12747 This command is only allowed if the @samp{tcommand} line is present in
12748 the @file{DESC} file.
12750 @item u@var{n} @var{xxx}
12751 This is same as the @samp{t} command except that after printing each
12752 character, the current horizontal position is increased by the sum of
12753 the width of that character and@w{ }@var{n}.
12755 This command is only allowed if the @samp{tcommand} line is present in
12756 the @file{DESC} file.
12758 @item n@var{a}@var{b}
12759 @c XXX
12761 @item p@var{n}
12762 @c XXX
12764 @item s@var{n}
12765 @kindex sizescale
12766 @pindex DESC@r{, and @code{sizescale}}
12767 The argument to the @samp{s} command is in scaled points (units of
12768 points/@var{n}, where @var{n} is the argument to the @samp{sizescale}
12769 command in the @file{DESC} file).
12771 @item f@var{n}
12772 @item x @dots{} \n
12773 Device control.
12774 @c XXX more info
12776 @item D@var{c} @var{x}@dots{}\n
12777 @c XXX
12778 @end table
12780 @c ---------------------------------------------------------------------
12782 @node Device Control, Drawing Functions, Output Format, gtroff Output
12783 @subsection Device Control
12784 @cindex device control
12785 @cindex control of devices
12787 The @samp{x} command is normally followed by a letter or word indicating
12788 the function to perform, followed by white space separated arguments.
12790 The first argument can be abbreviated to the first letter.
12792 @table @code
12793 @item x init
12794 @c XXX
12796 @item x T
12797 @c XXX
12799 @item x res @var{n} @var{h} @var{v}
12800 @c XXX
12802 @item x H
12803 @c XXX more info
12804 The argument to the @w{@samp{x Height}} command is also in scaled
12805 points.
12806 @end table
12808 The first three output commands are guaranteed to be:
12810 @Example
12811 x T device
12812 x res n h v
12813 x init
12814 @endExample
12816 @noindent
12817 For example, the input
12819 @Example
12820 crunchy \fH\s+2frog\s0\fP!?
12821 @endExample
12823 @noindent
12824 produces
12826 @c XXX example
12828 @ignore
12829 @Example
12830 ... sample output here ...
12831 @endExample
12832 @end ignore
12834 @c ---------------------------------------------------------------------
12836 @node Drawing Functions, Line Continuation, Device Control, gtroff Output
12837 @subsection Drawing Functions
12838 @cindex drawing functions
12839 @cindex functions for drawing
12841 @pindex gpic
12842 The @samp{D} drawing command has been extended.  These extensions are
12843 used by GNU @code{pic} only if the @option{-x} option is given.
12845 @xref{Drawing Requests}.
12847 @table @code
12848 @c XXX ...
12849 @item Df @var{n}
12850 Set the shade of gray to be used for filling solid objects to@w{
12851 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
12852 corresponds solid white and 1000 to solid black, and values in between
12853 correspond to intermediate shades of gray.  This applies only to solid
12854 circles, solid ellipses and solid polygons.  By default, a level of@w{
12855 }1000 is used.  Whatever color a solid object has, it should
12856 completely obscure everything beneath it.  A value greater than@w{ }1000
12857 or less than@w{ }0 can also be used: this means fill with the shade of
12858 gray that is currently being used for lines and text.  Normally this
12859 is black, but some drivers may provide a way of changing this.
12861 @item DC @var{d}
12862 Draw a solid circle with a diameter of@w{ }@var{d} with the leftmost
12863 point at the current position.
12865 @item DE @var{dx} @var{dy}
12866 Draw a solid ellipse with a horizontal diameter of@w{ }@var{dx} and a
12867 vertical diameter of@w{ }@var{dy} with the leftmost point at the current
12868 position.
12870 @item Dp @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
12871 Draw a polygon with automatic closure.  The first vertex is at the
12872 current position, the second vertex at an offset (@var{dx1},@var{dy1})
12873 from the current position, the second vertex at an offset
12874 (@var{dx2},@var{dy2}) from the first vertex, and so on up to the
12875 @var{n}@dmn{th} vertex.  At the moment, GNU @code{pic} only uses this
12876 command to generate triangles and rectangles.
12878 @item DP @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
12879 Like @code{Dp} but draw a solid rather than outlined polygon.
12881 @item Dt @var{n}
12882 @cindex line thickness
12883 @cindex thickness of lines
12884 Set the current line thickness to @var{n}@w{ }machine units.
12885 Traditionally, @acronym{UNIX} @code{troff} drivers use a line thickness
12886 proportional to the current point size; drivers should continue to do
12887 this if no @code{Dt} command has been given, or if a @code{Dt} command
12888 has been given with a negative value of@w{ }@var{n}.  A zero value of@w{
12889 }@var{n} selects the smallest available line thickness.
12890 @end table
12892 A difficulty arises in how the current position should be changed after
12893 the execution of these commands.  This is not of great importance since
12894 the code generated by GNU @code{pic} does not depend on this.  Given a
12895 drawing command of the form
12897 @Example
12898 \D'@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}'
12899 @endExample
12901 @cindex @code{\w}, and drawing commands
12902 @cindex @code{st} register, and drawing commands
12903 @cindex @code{sb} register, and drawing commands
12904 @noindent
12905 where @var{c} is not one of @samp{c}, @samp{e}, @samp{l}, @samp{a} or
12906 @samp{~}, @acronym{UNIX} @code{troff} treats each x@w{ }value
12907 as a horizontal quantity, and each y@w{ }value as a vertical
12908 quantity; it assumes that the width of the drawn object is the sum of
12909 all x@w{ }values, and that the height is the sum of all y@w{ }values.
12910 (The assumption about the height can be seen by examining the @code{st}
12911 and @code{sb} registers after using such a @code{D}@w{ }command in a
12912 @code{\w} escape sequence.)  This rule also holds for all the original
12913 drawing commands with the exception of @code{De}.  For the sake of
12914 compatibility GNU @code{troff} also follows this rule, even though it
12915 produces an ugly result in the case of the @code{Df}, @code{Dt}, and, to
12916 a lesser extent, @code{DE}@w{ }commands.  Thus after executing a
12917 @code{D}@w{ }command of the form
12919 @Example
12920 D@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}
12921 @endExample
12923 @noindent
12924 the current position should be increased horizontally by the sum of all
12925 x@w{ }values and vertically by the sum of all y@w{ }values.
12927 @c ---------------------------------------------------------------------
12929 @node Line Continuation,  , Drawing Functions, gtroff Output
12930 @subsection Line Continuation
12931 @cindex line continuation in output commands
12932 @cindex output commands, line continuation
12934 There is a continuation convention which permits the argument to the
12935 @w{@samp{x X}} command to contain newlines: When outputting the argument
12936 to the @w{@samp{x X}} command, GNU @code{troff} follows each newline
12937 in the argument with a @samp{+} character (as usual, it terminates
12938 the entire argument with a newline); thus if the line after the line
12939 containing the @w{@samp{x X}} command starts with @samp{+}, then the
12940 newline ending the line containing the @w{@samp{x X}} command should be
12941 treated as part of the argument to the @w{@samp{x X}} command, the
12942 @samp{+} should be ignored, and the part of the line following the
12943 @samp{+} should be treated like the part of the line following the
12944 @w{@samp{x X}} command.
12947 @c =====================================================================
12949 @node Font Files,  , gtroff Output, File formats
12950 @section Font Files
12951 @cindex font files
12952 @cindex files, font
12954 The @code{gtroff} font format is roughly a superset of the
12955 @code{ditroff} font format.  Unlike the @code{ditroff} font format,
12956 there is no associated binary format; all files are text files.  The
12957 font files for device @var{name} are stored in a directory
12958 @file{dev@var{name}}.  There are two types of file: a device description
12959 file called @file{DESC} and for each font@w{ }@var{f} a font file
12960 called@w{ }@file{@var{f}}.
12962 @menu
12963 * DESC File Format::
12964 * Font File Format::
12965 @end menu
12967 @c ---------------------------------------------------------------------
12969 @node DESC File Format, Font File Format, Font Files, Font Files
12970 @subsection @file{DESC} File Format
12971 @cindex @file{DESC} file format
12972 @cindex font description file format
12973 @cindex format of font description file
12974 @pindex DESC@r{ file format}
12976 The @file{DESC} file can contain the following types of line:
12978 @table @code
12979 @item res @var{n}
12980 @kindex res
12981 There are @var{n}@w{ }machine units per inch.
12983 @item hor @var{n}
12984 @kindex hor
12985 The horizontal resolution is @var{n}@w{ }machine units.
12987 @item vert @var{n}
12988 @kindex vert
12989 The vertical resolution is @var{n}@w{ }machine units.
12991 @item sizescale @var{n}
12992 @kindex sizescale
12993 The scale factor for point sizes.  By default this has a value of@w{ }1.
12994 One scaled point is equal to one point/@var{n}.  The arguments to the
12995 @code{unitwidth} and @code{sizes} commands are given in scaled points.
12996 @xref{Fractional Type Sizes}, for more information.
12998 @item unitwidth @var{n}
12999 @kindex unitwidth
13000 Quantities in the font files are given in machine units for fonts whose
13001 point size is @var{n}@w{ }scaled points.
13003 @item tcommand
13004 @kindex tcommand
13005 This means that the postprocessor can handle the @samp{t} and @samp{u}
13006 output commands.
13008 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
13009 @kindex sizes
13010 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
13011 @var{sn} scaled points.  The list of sizes must be terminated by a@w{
13012 }0.  Each @var{si} can also be a range of sizes @var{m}-@var{n}.  The
13013 list can extend over more than one line.
13015 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
13016 @kindex styles
13017 The first @var{m}@w{ }font positions are associated with styles
13018 @var{S1} @dots{} @var{Sm}.
13020 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
13021 @kindex fonts
13022 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
13023 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
13024 styles.  This command may extend over more than one line.  A font name
13025 of@var{ }0 means no font is mounted on the corresponding font position.
13027 @item family @var{fam}
13028 @kindex family
13029 The default font family is @var{fam}.
13031 @item charset
13032 @kindex charset
13033 This line and everything following in the file are ignored.  It is
13034 allowed for the sake of backwards compatibility.
13035 @end table
13037 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
13038 are mandatory.  Other commands are ignored by @code{gtroff} but may be
13039 used by postprocessors to store arbitrary information about the device
13040 in the @file{DESC} file.
13042 @c XXX add other commands resp. xrefs to output devices
13043 @c XXX add obsolete commands
13045 @c ---------------------------------------------------------------------
13047 @node Font File Format,  , DESC File Format, Font Files
13048 @subsection Font File Format
13049 @cindex font file format
13050 @cindex format of font files
13052 A font file has two sections.  The first section is a sequence of lines
13053 each containing a sequence of blank delimited words; the first word in
13054 the line is a key, and subsequent words give a value for that key.
13056 @table @code
13057 @item name @var{f}
13058 @kindex name
13059 The name of the font is@w{ }@var{f}.
13061 @item spacewidth @var{n}
13062 @kindex spacewidth
13063 The normal width of a space is@w{ }@var{n}.
13065 @item slant @var{n}
13066 @kindex slant
13067 The characters of the font have a slant of @var{n}@w{ }degrees.
13068 (Positive means forward.)
13070 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
13071 @kindex ligatures
13072 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
13073 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
13074 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
13075 terminated with a@w{ }0.  The list of ligatures may not extend over more
13076 than one line.
13078 @item special
13079 @kindex special
13080 The font is special; this means that when a character is requested that
13081 is not present in the current font, it is searched for in any
13082 special fonts that are mounted.
13083 @end table
13085 Other commands are ignored by @code{gtroff} but may be used by
13086 postprocessors to store arbitrary information about the font in the font
13087 file.
13089 @cindex comments in font files
13090 @cindex font files, comments
13091 @kindex #
13092 The first section can contain comments which start with the @samp{#}
13093 character and extend to the end of a line.
13095 The second section contains one or two subsections.  It must contain a
13096 @code{charset} subsection and it may also contain a @code{kernpairs}
13097 subsection.  These subsections can appear in any order.  Each
13098 subsection starts with a word on a line by itself.
13100 @kindex charset
13101 The word @code{charset} starts the character set subsection.  The
13102 @code{charset} line is followed by a sequence of lines.  Each line gives
13103 information for one character.  A line comprises a number of fields
13104 separated by blanks or tabs.  The format is
13106 @c XXX fix it for new HTML additions
13108 @Example
13109 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
13110 @endExample
13112 @cindex 8-bit input
13113 @cindex input, 8-bit
13114 @cindex accessing unnamed characters with @code{\N}
13115 @cindex unnamed characters, accessing with @code{\N}
13116 @cindex characters, unnamed, accessing with @code{\N}
13117 @kindex ---
13118 @noindent
13119 @var{name} identifies the character: If @var{name} is a single
13120 character@w{ }@var{c} then it corresponds to the @code{gtroff} input
13121 character@w{ }@var{c}; if it is of the form @samp{\@var{c}} where @var{c}
13122 is a single character, then it corresponds to the @code{gtroff} input
13123 character@w{ }\@var{c}; otherwise it corresponds to the groff input
13124 character @samp{\[@var{name}]}.  (If it is exactly two characters
13125 @var{xx} it can be entered as @samp{\(@var{xx}}.)  @code{gtroff}
13126 supports 8-bit characters; however some utilities have difficulties with
13127 eight-bit characters.  For this reason, there is a convention that the
13128 name @samp{char@var{n}} is equivalent to the single character whose code
13129 is@w{ }@var{n}.  For example, @samp{char163} would be equivalent to the
13130 character with code@w{ }163 which is the pounds sterling sign in @w{ISO
13131 Latin-1} character set.  The name @samp{---} is special and indicates
13132 that the character is unnamed; such characters can only be used by means
13133 of the @code{\N} escape sequence in @code{gtroff}.
13135 @c XXX input encodings vs. output encodings
13137 The @var{type} field gives the character type:
13139 @table @code
13140 @item 1
13141 the character has an descender, for example, `p';
13143 @item 2
13144 the character has an ascender, for example, `b';
13146 @item 3
13147 the character has both an ascender and a descender, for example, `('.
13148 @end table
13150 The @var{code} field gives the code which the postprocessor uses to
13151 print the character.  The character can also be input to @code{gtroff}
13152 using this code by means of the @code{\N} escape sequence.  The code can
13153 be any integer.  If it starts with @samp{0} it is interpreted as
13154 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
13155 hexadecimal.
13157 Anything on the line after the @var{code} field is ignored.
13159 The @var{metrics} field has the form:
13161 @Example
13162 @var{width}[,@var{height}[,@var{depth}[,@var{italic_correction}
13163   [,@var{left_italic_correction}[,@var{subscript_correction}]]]]]
13164 @endExample
13166 @noindent
13167 There must not be any spaces between these subfields (it has been split
13168 here into two lines for better legibility only).  Missing subfields are
13169 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
13170 there is no associated binary format, these values are not required to
13171 fit into a variable of type @samp{char} as they are in @code{ditroff}.
13172 The @var{width} subfield gives the width of the character.  The
13173 @var{height} subfield gives the height of the character (upwards is
13174 positive); if a character does not extend above the baseline, it should
13175 be given a zero height, rather than a negative height.  The @var{depth}
13176 subfield gives the depth of the character, that is, the distance below
13177 the lowest point below the baseline to which the character extends
13178 (downwards is positive); if a character does not extend below above the
13179 baseline, it should be given a zero depth, rather than a negative depth.
13180 The @var{italic_correction} subfield gives the amount of space that
13181 should be added after the character when it is immediately to be
13182 followed by a character from a roman font.  The
13183 @var{left_italic_correction} subfield gives the amount of space that
13184 should be added before the character when it is immediately to be
13185 preceded by a character from a roman font.  The
13186 @var{subscript_correction} gives the amount of space that should be
13187 added after a character before adding a subscript.  This should be less
13188 than the italic correction.
13190 A line in the @code{charset} section can also have the format
13192 @Example
13193 @var{name} "
13194 @endExample
13196 @noindent
13197 This indicates that @var{name} is just another name for the character
13198 mentioned in the preceding line.
13200 @kindex kernpairs
13201 The word @code{kernpairs} starts the kernpairs section.  This contains a
13202 sequence of lines of the form:
13204 @Example
13205 @var{c1} @var{c2} @var{n}
13206 @endExample
13208 @noindent
13209 This means that when character @var{c1} appears next to character
13210 @var{c2} the space between them should be increased by@w{ }@var{n}.
13211 Most entries in the kernpairs section have a negative value for@w{
13212 }@var{n}.
13216 @c =====================================================================
13217 @c =====================================================================
13219 @node Installation, Request Index, File formats, Top
13220 @chapter Installation
13221 @cindex installation
13223 @c XXX
13227 @c =====================================================================
13228 @c =====================================================================
13230 @node Request Index, Escape Index, Installation, Top
13231 @chapter Request Index
13233 Requests appear without the leading control character (normally either
13234 @samp{.} or @samp{'}).
13236 @printindex rq
13240 @c =====================================================================
13241 @c =====================================================================
13243 @node Escape Index, Operator Index, Request Index, Top
13244 @chapter Escape Index
13246 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
13247 emits a warning, printing character @var{X}.
13249 @printindex es
13253 @c =====================================================================
13254 @c =====================================================================
13256 @node Operator Index, Register Index, Escape Index, Top
13257 @chapter Operator Index
13259 @printindex op
13263 @c =====================================================================
13264 @c =====================================================================
13266 @node Register Index, Macro Index, Operator Index, Top
13267 @chapter Register Index
13269 The macro package or program a specific register belongs to is appended in
13270 brackets.
13272 A register name@w{ }@code{x} consisting of exactly one character can be
13273 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
13274 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
13275 of any length can be accessed as @samp{\n[xxx]}.
13277 @printindex vr
13281 @c =====================================================================
13282 @c =====================================================================
13284 @node Macro Index, String Index, Register Index, Top
13285 @chapter Macro Index
13287 The macro package a specific macro belongs to is appended in brackets.
13288 They appear without the leading control character (normally @samp{.}).
13290 @printindex ma
13294 @c =====================================================================
13295 @c =====================================================================
13297 @node String Index, Glyph Name Index, Macro Index, Top
13298 @chapter String Index
13300 The macro package or program a specific string belongs to is appended in
13301 brackets.
13303 A string name@w{ }@code{x} consisting of exactly one character can be
13304 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
13305 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
13306 of any length can be accessed as @samp{\*[xxx]}.
13309 @printindex st
13313 @c =====================================================================
13314 @c =====================================================================
13316 @node Glyph Name Index, Font File Keyword Index, String Index, Top
13317 @chapter Glyph Name Index
13319 A glyph name @code{xx} consisting of exactly two characters can be
13320 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
13321 accessed as @samp{\[xxx]}.
13323 @c XXX
13327 @c =====================================================================
13328 @c =====================================================================
13330 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
13331 @chapter Font File Keyword Index
13333 @printindex ky
13337 @c =====================================================================
13338 @c =====================================================================
13340 @node Program and File Index, Concept Index, Font File Keyword Index, Top
13341 @chapter Program  and File Index
13343 @printindex pg
13347 @c =====================================================================
13348 @c =====================================================================
13350 @node Concept Index,  , Program and File Index, Top
13351 @chapter Concept Index
13353 @printindex cp
13357 @summarycontents
13358 @contents
13359 @bye