Added request `hpfa' to append hyphenation patterns.
[s-roff.git] / doc / groff.texinfo
blobcb72218c4a032d9fa0f5810a092f6aee30fd52d8
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.1 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 [ -abeghilpstvzCEGNRSUVXZ ] [ -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 [ -abivzCERU ] [ -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 -R
1325 Preprocess with @code{grefer}.  No mechanism is provided for passing
1326 arguments to @code{grefer} because most @code{grefer} options have
1327 equivalent commands which can be included in the file.  @xref{grefer},
1328 for more details.
1330 @pindex troffrc
1331 @pindex troffrc-end
1332 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1333 accessible via @code{groff}.  This option prevents the loading of the
1334 @file{troffrc} and @file{troffrc-end} files.
1336 @item -v
1337 Make programs run by @code{groff} print out their version number.
1339 @item -V
1340 Print the pipeline on @code{stdout} instead of executing it.
1342 @item -z
1343 Suppress output from @code{gtroff}.  Only error messages are printed.
1345 @item -Z
1346 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
1347 automatically runs the appropriate postprocessor.
1349 @item -P@var{arg}
1350 Pass @var{arg} to the postprocessor.  Each argument should be passed
1351 with a separate @option{-P} option.  Note that @code{groff} does not
1352 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1354 @item -l
1355 Send the output to a spooler for printing.  The command used for this is
1356 specified by the @code{print} command in the device description file
1357 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
1358 ignored.
1360 @item -L@var{arg}
1361 Pass @var{arg} to the spooler.  Each argument should be passed with a
1362 separate @option{-L} option.  Note that @code{groff} does not prepend
1363 a @samp{-} to @var{arg} before passing it to the postprocessor.
1364 If the @code{print} keyword in the device description file is missing,
1365 @option{-L} is ignored.
1367 @item -T@var{dev}
1368 Prepare output for device @var{dev}.  The default device is @samp{ps},
1369 unless changed when @code{groff} was configured and built.  The
1370 following are the output devices currently available:
1372 @table @code
1373 @item ps
1374 For @sc{PostScript} printers and previewers.
1376 @item dvi
1377 For @TeX{} DVI format.
1379 @item X75
1380 For a 75@dmn{dpi} X11 previewer.
1382 @item X100
1383 For a 100@dmn{dpi} X11 previewer.
1385 @item ascii
1386 For typewriter-like devices.
1388 @item latin1
1389 For typewriter-like devices that support the @w{Latin-1} (@w{ISO
1390 8859-1}) character set.
1392 @item utf8
1393 For typewriter-like devices which use the Unicode (@w{ISO 10646})
1394 character set with @w{UTF-8} encoding.
1396 @item cp1047
1397 @cindex @acronym{EBCDIC} encoding
1398 @cindex encoding, @acronym{EBCDIC}
1399 @cindex encoding, cp1047
1400 @cindex cp1047
1401 @cindex IBM cp1047
1402 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1403 cp1047.
1405 @item lj4
1406 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
1408 @item lbp
1409 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1410 printers).
1412 @pindex pre-grohtml
1413 @pindex post-grohtml
1414 @cindex @code{grohtml}, the program
1415 @item html
1416 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1417 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1418 postprocessor (@code{post-grohtml}).
1419 @end table
1421 @cindex output device name string register (@code{.T})
1422 @cindex output device usage number register (@code{.T})
1423 The predefined @code{gtroff} string register @code{.T} contains the
1424 current output device; the read-only number register @code{.T} is set
1425 to@w{ }1 if this option is used (which is always true if @code{groff} is
1426 used to call @code{gtroff}).  @xref{Built-in Registers}.
1428 The postprocessor to be used for a device is specified by the
1429 @code{postpro} command in the device description file.  (@xref{Font
1430 Files}, for more info.)  This can be overridden with the @option{-X}
1431 option.
1433 @item -X
1434 Preview with @code{gxditview} instead of using the usual postprocessor.
1435 This is unlikely to produce good results except with @option{-Tps}.
1437 Note that this is not the same as using @option{-TX75} or
1438 @option{-TX100} to view a document with @code{gxditview}: The former
1439 uses the metrics of the specified device, whereas the latter uses
1440 X-specific fonts and metrics.
1442 @item -N
1443 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1444 the @option{-N} option in @code{geqn}.
1446 @item -S
1447 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1448 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1449 requests.  For security reasons, this is enabled by default.
1451 @item -U
1452 Unsafe mode.  Reverts to the old unsafe behaviour.
1454 @item -a
1455 @cindex @acronym{ASCII} approximation output register (@code{.A})
1456 Generate an @acronym{ASCII} approximation of the typeset output.  The
1457 read-only register @code{.A} is then set to@w{ }1.  @xref{Built-in
1458 Registers}.  A typical example is
1460 @Example
1461 groff -a -man -Tdvi troff.man | less
1462 @endExample
1464 @noindent
1465 which shows how lines are broken for the DVI device.  Note that this
1466 option is rather useless today since graphic output devices are
1467 available virtually everywhere.
1469 @item -b
1470 Print a backtrace with each warning or error message.  This backtrace
1471 should help track down the cause of the error.  The line numbers given
1472 in the backtrace may not always be correct: @code{gtroff} can get
1473 confused by @code{as} or @code{am} requests while counting line numbers.
1475 @item -i
1476 Read the standard input after all the named input files have been
1477 processed.
1479 @item -w@var{name}
1480 Enable warning @var{name}.  Available warnings are described in
1481 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1483 @item -W@var{name}
1484 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1486 @item -E
1487 Inhibit all error messages.
1489 @item -C
1490 Enable compatibility mode.  @xref{Implementation Differences}, for the
1491 list of incompatibilities between @code{groff} and traditional Unix
1492 @code{troff}.
1494 @item -d@var{cs}
1495 @itemx -d@var{name}=s
1496 Define @var{c} or @var{name} to be a string@w{ }@var{s}.  @var{c}@w{ }must
1497 be a one-letter name; @var{name} can be of arbitrary length.  All string
1498 assignments happen before loading any macro file (including the start-up
1499 file).
1501 @item -f@var{fam}
1502 Use @var{fam} as the default font family.  @xref{Font Families}.
1504 @item -m@var{name}
1505 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1506 for this in its macro directories.  If it isn't found, it tries
1507 @file{tmac.@var{name}} (and searches in the same directories).
1509 @c XXX document local and system macro dirs
1511 @item -n@var{num}
1512 Number the first page @var{num}.
1514 @item -o@var{list}
1515 @cindex print current page register (@code{.P})
1516 Output only pages in @var{list}, which is a comma-separated list of page
1517 ranges; @samp{@var{n}} means print page@w{ }@var{n}, @samp{@var{m}-@var{n}}
1518 means print every page between @var{m} and@w{ }@var{n}, @samp{-@var{n}}
1519 means print every page up to@w{ }@var{n}, @samp{@var{n}-} means print every
1520 page beginning with@w{ }@var{n}.  @code{gtroff} exits after printing the
1521 last page in the list.  All the ranges are inclusive on both ends.
1523 Within @code{gtroff}, this information can be extracted with the
1524 @samp{.P} register.  @xref{Built-in Registers}.
1526 If your document restarts page numbering at the beginning of each
1527 chapter, then @code{gtroff} prints the specified page range for each
1528 chapter.
1530 @item -r@var{cn}
1531 @itemx -r@var{name}=@var{n}
1532 Set number register@w{ }@var{c} or @var{name} to the value@w{ }@var{n}.
1533 @var{c}@w{ }must be a one-letter name; @var{name} can be of arbitrary
1534 length.  @var{n}@w{ }can be any @code{gtroff} numeric expression.  All
1535 register  assignments happen before loading any macro file (including
1536 the start-up file).
1538 @item -F@var{dir}
1539 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1540 (@var{name} is the name of the device), for the @file{DESC} file, and
1541 for font files before looking in the standard directories.
1543 @item -M@var{dir}
1544 Search directory @file{@var{dir}} for macro files before the standard
1545 directories.
1547 @item -I@var{dir}
1548 This option is as described in @ref{gsoelim}.  It implies the
1549 @option{-s} option.
1550 @end table
1553 @c =====================================================================
1555 @node Environment, Invocation Examples, Groff Options, Invoking groff
1556 @section Environment
1557 @cindex environment variables
1558 @cindex variables in environment
1560 There are also several environment variables (of the operating system,
1561 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1563 @table @code
1564 @item GROFF_COMMAND_PREFIX
1565 @tindex GROFF_COMMAND_PREFIX, environment variable
1566 If this is set to@w{ }@var{X}, then @code{groff} runs @code{@var{X}troff}
1567 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1568 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1569 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1570 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1572 @c XXX document default values
1574 @item GROFF_TMAC_PATH
1575 @tindex GROFF_TMAC_PATH@r{, environment variable}
1576 A colon-separated list of directories in which to search for macro files
1577 (before the default directories are tried).
1579 @c XXX document local and system macro dirs
1581 @item GROFF_TYPESETTER
1582 @tindex GROFF_TYPESETTER@r{, environment variable}
1583 The default output device.
1585 @item GROFF_FONT_PATH
1586 @tindex GROFF_FONT_PATH@r{, environment variable}
1587 A colon-separated list of directories in which to search for the
1588 @code{dev}@var{name} directory (before the default directories are
1589 tried).
1591 @item GROFF_BIN_PATH
1592 @tindex GROFF_BIN_PATH@r{, environment variable}
1593 This search path, followed by @code{PATH}, is used for commands executed
1594 by @code{groff}.
1596 @item GROFF_TMPDIR
1597 @tindex GROFF_TMPDIR@r{, environment variable}
1598 @tindex TMPDIR@r{, environment variable}
1599 The directory in which @code{groff} creates temporary files.  If this is
1600 not set and @env{TMPDIR} is set, temporary files are created in that
1601 directory.  Otherwise temporary files are created in a system-dependent
1602 default directory (on Unix and GNU/Linux systems, this is usually
1603 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1604 @code{post-grohtml} can create temporary files in this directory.
1605 @end table
1607 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1608 rather than colons, to separate the directories in the lists described
1609 above.
1612 @c =====================================================================
1614 @node Invocation Examples,  , Environment, Invoking groff
1615 @section Invocation Examples
1616 @cindex invocation examples
1617 @cindex examples of invocation
1619 This section lists several common uses of @code{groff} and the
1620 corresponding command lines.
1622 @Example
1623 groff file
1624 @endExample
1626 @noindent
1627 This command processes @file{file} without a macro package or a
1628 preprocessor.  The output device is the default, @samp{ps}, and the
1629 output is sent to @code{stdout}.
1631 @Example
1632 groff -t -mandoc -Tascii file | less
1633 @endExample
1635 @noindent
1636 This is basically what a call to the @code{man} program does.
1637 @code{gtroff} processes the manual page @file{file} with the
1638 @file{mandoc} macro file (which in turn either calls the @file{man} or
1639 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1640 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1641 displays the result.
1643 @Example
1644 groff -X -m me file
1645 @endExample
1647 @noindent
1648 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1649 package.  Since no @option{-T} option is specified, use the default
1650 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1651 @w{@samp{-me}}; the latter is an anachronism from the early days of
1652 @acronym{UNIX}.@footnote{The same is true for the other main macro
1653 packages that come with @code{groff}: @file{man}, @file{mdoc},
1654 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1655 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1656 @w{@samp{-m trace}} must be used.}
1658 @Example
1659 groff -man -rD1 -z file
1660 @endExample
1662 @noindent
1663 Check @file{file} with the @file{man} macro package, forcing
1664 double-sided printing -- don't produce any output.
1666 @menu
1667 * grog::
1668 @end menu
1670 @c ---------------------------------------------------------------------
1672 @node grog,  , Invocation Examples, Invocation Examples
1673 @subsection @code{grog}
1675 @pindex grog
1676 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1677 and/or macro packages are required for formatting them, and prints the
1678 @code{groff} command including those options on the standard output.  It
1679 generates one or more of the options @option{-e}, @option{-man},
1680 @option{-me}, @option{-mm}, @option{-ms}, @option{-mdoc},
1681 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1682 @option{-s}, and @option{-t}.
1684 A special file name@w{ }@file{-} refers to the standard input.  Specifying
1685 no files also means to read the standard input.  Any specified options
1686 are included in the printed command.  No space is allowed between
1687 options and their arguments.  The only options recognized are
1688 @option{-C} (which is also passed on) to enable compatibility mode, and
1689 @option{-v} (if it is the only parameter) to print the version number.
1691 For example,
1693 @Example
1694 grog -Tdvi paper.ms
1695 @endExample
1697 @noindent
1698 guesses the appropriate command to print @file{paper.ms} and then prints
1699 it to the command line after adding the @option{-Tdvi} option.  For
1700 direct execution, enclose the call to @code{grog} in backquotes at the
1701 @acronym{UNIX} shell prompt:
1703 @Example
1704 `grog -Tdvi paper.ms` > paper.dvi
1705 @endExample
1707 @noindent
1708 As seen in the example, it is still necessary to redirect the output to
1709 something meaningful (i.e.@: either a file or a pager program like
1710 @code{less}).
1714 @c =====================================================================
1715 @c =====================================================================
1717 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1718 @chapter Tutorial for Macro Users
1719 @cindex tutorial for macro users
1720 @cindex macros, tutorial for users
1721 @cindex user's tutorial for macros
1722 @cindex user's macro tutorial
1724 Most users tend to use a macro package to format their papers.  This
1725 means that the whole breadth of @code{groff} is not necessary for most
1726 people.  This chapter covers the material needed to efficiently use a
1727 macro package.
1729 @menu
1730 * Basics::
1731 * Common Features::
1732 @end menu
1735 @c =====================================================================
1737 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1738 @section Basics
1739 @cindex basics of macros
1740 @cindex macro basics
1742 This section covers some of the basic concepts necessary to understand
1743 how to use a macro package.@footnote{This section is derived from
1744 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1745 References are made throughout to more detailed information, if desired.
1747 @code{gtroff} reads an input file prepared by the user and outputs a
1748 formatted document suitable for publication or framing.  The input
1749 consists of text, or words to be printed, and embedded commands
1750 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1751 format the output.  For more detail on this, see @ref{Embedded
1752 Commands}.
1754 The word @dfn{argument} is used in this chapter to mean a word or number
1755 which appears on the same line as a request, and which modifies the
1756 meaning of that request.  For example, the request
1758 @Example
1760 @endExample
1762 @noindent
1763 spaces one line, but
1765 @Example
1766 .sp 4
1767 @endExample
1769 @noindent
1770 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1771 request which says to space four lines instead of one.  Arguments are
1772 separated from the request and from each other by spaces (@emph{no}
1773 tabs).  More details on this can be found in @ref{Request Arguments}.
1775 The primary function of @code{gtroff} is to collect words from input
1776 lines, fill output lines with those words, justify the right-hand margin
1777 by inserting extra spaces in the line, and output the result.  For
1778 example, the input:
1780 @Example
1781 Now is the time
1782 for all good men
1783 to come to the aid
1784 of their party.
1785 Four score and seven
1786 years ago,...
1787 @endExample
1789 @noindent
1790 is read, packed onto output lines, and justified to produce:
1792 @quotation
1793 Now is the time for all good men to come to the aid of their party.
1794 Four score and seven years ago,...
1795 @end quotation
1797 @cindex break
1798 @cindex line break
1799 Sometimes a new output line should be started even though the current
1800 line is not yet full; for example, at the end of a paragraph.  To do
1801 this it is possible to cause a @dfn{break}, which starts a new output
1802 line.  Some requests cause a break automatically, as normally do blank
1803 input lines and input lines beginning with a space.
1805 Not all input lines are text to be formatted.  Some input lines are
1806 requests which describe how to format the text.  Requests always have a
1807 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1808 the input line.
1810 The text formatter also does more complex things, such as automatically
1811 numbering pages, skipping over page boundaries, putting footnotes in the
1812 correct place, and so forth.
1814 Here are a few hints for preparing text for input to @code{gtroff}.
1816 @itemize @bullet
1817 @item
1818 First, keep the input lines short.  Short input lines are easier to
1819 edit, and @code{gtroff} packs words onto longer lines anyhow.
1821 @item
1822 In keeping with this, it is helpful to begin a new line after every
1823 comma or phrase, since common corrections are to add or delete sentences
1824 or phrases.
1826 @item
1827 End each sentence with two spaces -- or better, start each sentence on a
1828 new line.  @code{gtroff} recognizes characters that usually end a
1829 sentence, and inserts sentence space accordingly.
1831 @item
1832 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1833 enough to hyphenate words as needed, but is not smart enough to take
1834 hyphens out and join a word back together.  Also, words such as
1835 ``mother-in-law'' should not be broken over a line, since then a space
1836 can occur where not wanted, such as ``@w{mother- in}-law''.
1837 @end itemize
1839 @cindex double spacing (@code{ls})
1840 @cindex spacing
1841 @code{gtroff} double spaces output text automatically if you use the
1842 request @w{@samp{.ls 2}}.  Reactivate single spaced mode by typing
1843 @w{@samp{.ls 1}}.
1845 A number of requests allow to change the way the output looks,
1846 sometimes called the @dfn{layout} of the output page.  Most of these
1847 requests adjust the placing of @dfn{white space} (blank lines or
1848 spaces).
1850 @cindex new page (@code{bp})
1851 The @samp{.bp} request starts a new page, causing a line break.
1853 @cindex blank line (@code{sp})
1854 @cindex empty line (@code{sp})
1855 @cindex line, empty (@code{sp})
1856 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1857 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1858 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1859 @var{N}@w{ }centimeters).  For example, the input:
1861 @Example
1862 .sp 1.5i
1863 My thoughts on the subject
1865 @endExample
1867 @noindent
1868 leaves one and a half inches of space, followed by the line ``My
1869 thoughts on the subject'', followed by a single blank line (more
1870 measurement units are available, see @ref{Measurements}).
1872 @cindex centering lines (@code{ce})
1873 @cindex lines, centering (@code{ce})
1874 Text lines can be centered by using the @code{ce} request.  The line
1875 after @code{ce} is centered (horizontally) on the page.  To center more
1876 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1877 of lines to center), followed by the @var{N}@w{ }lines.  To center many
1878 lines without counting them, type:
1880 @Example
1881 .ce 1000
1882 lines to center
1883 .ce 0
1884 @endExample
1886 @noindent
1887 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1888 lines, in other words, stop centering.
1890 @cindex line break (@code{br})
1891 @cindex break (@code{br})
1892 All of these requests cause a break; that is, they always start a new
1893 line.  To start a new line without performing any other action, use
1894 @code{br}.
1897 @c =====================================================================
1899 @node Common Features,  , Basics, Tutorial for Macro Users
1900 @section Common Features
1901 @cindex common features
1902 @cindex features, common
1904 @code{gtroff} provides very low-level operations for formatting a
1905 document.  There are many common routine operations which are done in
1906 all documents.  These common operations are written into @dfn{macros}
1907 and collected into a @dfn{macro package}.
1909 All macro packages provide certain common capabilities which fall into
1910 the following categories.
1912 @menu
1913 * Paragraphs::
1914 * Sections and Chapters::
1915 * Headers and Footers::
1916 * Page Layout Adjustment::
1917 * Displays::
1918 * Footnotes and Annotations::
1919 * Table of Contents::
1920 * Indices::
1921 * Paper Formats::
1922 * Multiple Columns::
1923 * Font and Size Changes::
1924 * Predefined Strings::
1925 * Preprocessor Support::
1926 * Configuration and Customization::
1927 @end menu
1929 @c ---------------------------------------------------------------------
1931 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1932 @subsection Paragraphs
1933 @cindex paragraphs
1935 One of the most common and most used capability is starting a
1936 paragraph.  There are a number of different types of paragraphs, any
1937 of which can be initiated with macros supplied by the macro package.
1938 Normally, paragraphs start with a blank line and the first line
1939 indented, like the text in this manual.  There are also block style
1940 paragraphs, which omit the indentation:
1942 @Example
1943 Some   men  look   at  constitutions   with  sanctimonious
1944 reverence, and deem them like the ark of the covenant, too
1945 sacred to be touched.
1946 @endExample
1948 @noindent
1949 And there are also indented paragraphs which begin with a tag or label
1950 at the margin and the remaining text indented.
1952 @example
1953 @group
1954 one   This is  the first paragraph.  Notice  how the first
1955       line of  the resulting  paragraph lines up  with the
1956       other lines in the paragraph.
1957 @end group
1958 @group
1959 longlabel
1960       This  paragraph   had  a  long   label.   The  first
1961       character of text on the first line does not line up
1962       with  the  text  on  second  and  subsequent  lines,
1963       although they line up with each other.
1964 @end group
1965 @end example
1967 A variation of this is a bulleted list.
1969 @c XXX description
1971 @c ---------------------------------------------------------------------
1973 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1974 @subsection Sections and Chapters
1976 Most macro packages supply some form of section headers.  The simplest
1977 kind is simply the heading on a line by itself in bold type.  Others
1978 supply automatically numbered section heading or different heading
1979 styles at different levels.  Some, more sophisticated, macro packages
1980 supply macros for starting chapters and appendices.
1982 @c ---------------------------------------------------------------------
1984 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1985 @subsection Headers and Footers
1987 Every macro package gives some way to manipulate the headers and footers
1988 (or @dfn{titles}) on each page.  Some packages allow for different ones
1989 on the even and odd pages (for material printed in a book form).
1991 The titles are called three-part titles, that is, there is a
1992 left-justified part, a centered part, and a right-justified part.  An
1993 automatically generated page number may be put in any of these fields
1994 with the @samp{%} character (see @ref{Page Layout}, for more details).
1996 @c ---------------------------------------------------------------------
1998 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
1999 @subsection Page Layout
2001 Most macro packages let the user specify top and bottom margins and
2002 other details about the appearance of the printed pages.
2004 @c ---------------------------------------------------------------------
2006 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2007 @subsection Displays
2008 @cindex displays
2010 Displays are sections of text to be set off from the body of the paper.
2011 Major quotes, tables, and figures are types of displays, as are all the
2012 examples used in this document.
2014 @cindex quotes, major
2015 @cindex major quotes
2016 @dfn{Major quotes} are quotes which are several lines long, and hence
2017 are set in from the rest of the text without quote marks around them.
2019 @cindex list
2020 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
2021 should be used when the material to be printed should not be filled and
2022 justified like normal text, such as columns of figures or the examples
2023 used in this paper.
2025 @cindex keep
2026 A @dfn{keep} is a display of lines which are kept on a single page if
2027 possible.  An example for a keep might be a diagram.  Keeps differ from
2028 lists in that lists may be broken over a page boundary whereas keeps are
2029 not.
2031 @cindex keep, floating
2032 @cindex floating keep
2033 Floating keeps move relative to the text.  Hence, they are good for
2034 things which are referred to by name, such as ``See figure@w{ }3''.  A
2035 floating keep appears at the bottom of the current page if it fits;
2036 otherwise, it appears at the top of the next page.  Meanwhile, the
2037 surrounding text `flows' around the keep, thus leaving no blank areas.
2039 @c ---------------------------------------------------------------------
2041 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2042 @subsection Footnotes and Annotations
2043 @cindex footnotes
2044 @cindex annotations
2046 There are a number of requests to save text for later printing.
2048 @dfn{Footnotes} are printed at the bottom of the current page.
2050 @cindex delayed text
2051 @dfn{Delayed text} is very similar to a footnote except that it is
2052 printed when called for explicitly.  This allows a list of references to
2053 appear (for example) at the end of each chapter, as is the convention in
2054 some disciplines.
2056 Most macro packages which supply this functionality also supply a means
2057 of automatically numbering either type of annotation.
2059 @c ---------------------------------------------------------------------
2061 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2062 @subsection Table of Contents
2063 @cindex table of contents
2064 @cindex contents, table of
2066 @dfn{Tables of contents} are a type of delayed text having a tag
2067 (usually the page number) attached to each entry after a row of dots.
2068 The table accumulates throughout the paper until printed, usually after
2069 the paper has ended.  Many macro packages provide the ability to have
2070 several tables of contents (e.g.@: a standard table of contents, a list
2071 of tables, etc).
2073 @c ---------------------------------------------------------------------
2075 @node Indices, Paper Formats, Table of Contents, Common Features
2076 @subsection Indices
2077 @cindex index, in macro package
2079 While some macro packages use the term @dfn{index}, none actually
2080 provide that functionality.  The facilities they call indices are
2081 actually more appropriate for tables of contents.
2083 @c ---------------------------------------------------------------------
2085 @node Paper Formats, Multiple Columns, Indices, Common Features
2086 @subsection Paper Formats
2087 @cindex paper formats
2089 Some macro packages provide stock formats for various kinds of
2090 documents.  Many of them provide a common format for the title and
2091 opening pages of a technical paper.  The @file{mm} macros in particular
2092 provide formats for letters and memoranda.
2094 @c ---------------------------------------------------------------------
2096 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2097 @subsection Multiple Columns
2099 Some macro packages (but not @file{man}) provide the ability to have two
2100 or more columns on a page.
2102 @c ---------------------------------------------------------------------
2104 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2105 @subsection Font and Size Changes
2107 The built-in font and size functions are not always intuitive, so all
2108 macro packages provide macros to make these operations simpler.
2110 @c ---------------------------------------------------------------------
2112 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2113 @subsection Predefined Strings
2115 Most macro packages provide various predefined strings for a variety of
2116 uses; examples are sub- and superscripts, printable dates, quotes and
2117 various special characters.
2119 @c ---------------------------------------------------------------------
2121 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2122 @subsection Preprocessor Support
2124 All macro packages provide support for the various preprocessors and may
2125 extend their functionality.
2127 For example, all macro packages mark tables (which are processed with
2128 @code{gtbl}) by placing them between @code{.TS} and @code{.TE} macros.
2129 The @file{ms} macro package has an option, @code{.TS@w{}H}, that prints
2130 a caption at the top of a new page (when the table is too long to fit on
2131 a single page).
2133 @c ---------------------------------------------------------------------
2135 @node Configuration and Customization,  , Preprocessor Support, Common Features
2136 @subsection Configuration and Customization
2138 Some macro packages provide means of customizing many of the details of
2139 how the package behaves.  This ranges from setting the default type size
2140 to changing the appearance of section headers.
2144 @c =====================================================================
2145 @c =====================================================================
2147 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2148 @chapter Macro Packages
2149 @cindex macro packages
2150 @cindex packages, macros
2152 This chapter documents the main macro packages that come with
2153 @code{groff}.
2155 @menu
2156 * man::
2157 * mdoc::
2158 * ms::
2159 * me::
2160 * mm::
2161 @end menu
2164 @c =====================================================================
2166 @node man, mdoc, Macro Packages, Macro Packages
2167 @section @file{man}
2168 @cindex manual pages
2169 @pindex an.tmac
2170 @pindex man.tmac
2171 @pindex man-old.tmac
2173 This is the most popular and probably the most important macro package
2174 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2175 are based on it.
2177 @menu
2178 * Man options::
2179 * Man usage::
2180 * Man font macros::
2181 * Miscellaneous man macros::
2182 * Predefined man strings::
2183 * Preprocessors in man pages::
2184 @end menu
2186 @c ---------------------------------------------------------------------
2188 @node Man options, Man usage, man, man
2189 @subsection Options
2191 The command line format for using the @file{man} macros with
2192 @code{groff} is:
2194 @Example
2195 groff -m man [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
2196       [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
2197 @endExample
2199 @noindent
2200 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2202 @table @code
2203 @item -rcR=1
2204 This option (the default if a tty output device is used) creates a
2205 single, very long page instead of multiple pages.  Use @code{-rcR=0}
2206 to disable it.
2208 @item -rC1
2209 If more than one manual page is given on the command line, number the
2210 pages continuously, rather than starting each at@w{ }1.
2212 @item -rD1
2213 Double-sided printing.  Footers for even and odd pages are formatted
2214 differently.
2216 @item -rP@var{nnn}
2217 Page numbering starts with @var{nnn} rather than with@w{ }1.
2219 @item -rS@var{xx}
2220 Use @var{xx} (which can be 10, 11, or@w{ }12@dmn{pt}) as the base
2221 document font size instead of the default value of@w{ }10@dmn{pt}.
2223 @item -rX@var{nnn}
2224 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2225 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2226 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2227 @end table
2229 @c ---------------------------------------------------------------------
2231 @node Man usage, Man font macros, Man options, man
2232 @subsection Usage
2233 @cindex @code{man} macros
2234 @cindex macros for manual pages [@code{man}]
2236 @pindex man.local
2237 This section describes the available macros for manual pages.  For
2238 further customization, put additional macros and requests into the file
2239 @file{man.local} which is loaded immediately after the @file{man}
2240 package.
2242 @Defmac {TH, title section [@Var{extra1}] [@Var{extra2}] [@Var{extra3}], man}
2243 Set the title of the man page to @var{title} and the section to
2244 @var{section}, which must have a value between 1 and@w{ }8.  The value
2245 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
2246 to indicate a specific subsection of the man pages.
2248 Both @var{title} and @var{section} are positioned at the left and right
2249 in the header line (with @var{section} in parentheses immediately
2250 appended to @var{title}.  @var{extra1} is positioned in the middle of
2251 the footer line.  @var{extra2} is positioned at the left in the footer
2252 line (or at the left on even pages and at the right on odd pages if
2253 double-sided printing is active).  @var{extra3} is centered in the
2254 header line.
2256 For @acronym{HTML} output, headers and footers are completely suppressed.
2258 Additionally, this macro starts a new page; the new line number is@w{ }1
2259 again (except if the @option{-rC1} option is given on the command line)
2260 -- this feature is intended only for formatting multiple man pages; a
2261 single man page should contain exactly one @code{TH} macro at the
2262 beginning of the file.
2263 @endDefmac
2265 @Defmac {SH, [@Var{heading}], man}
2266 Set up an unnumbered section heading sticking out to the left.  Prints
2267 out all the text following @code{SH} up to the end of the line (or the
2268 text in the next line if there is no argument to @code{SH}) in bold
2269 face, one size larger than the base document size.  Additionally, the
2270 left margin for the following text is reset to its default value.
2271 @endDefmac
2273 @Defmac {SS, [@Var{heading}], man}
2274 Set up an unnumbered (sub)section heading.  Prints out all the text
2275 following @code{SS} up to the end of the line (or the text in the next
2276 line if there is no argument to @code{SS}) in bold face, at the same
2277 size as the base document size.  Additionally, the left margin for the
2278 following text is reset to its default value.
2279 @endDefmac
2281 @Defmac {TP, [@Var{nnn}], man}
2282 Set up an indented paragraph with label.  The indentation is set to
2283 @var{nnn} if that argument is supplied (the default unit is @samp{n}
2284 if omitted), otherwise it is set to the default indentation value.
2286 The first line of text following this macro is interpreted as a string
2287 to be printed flush-left, as it is appropriate for a label.  It is not
2288 interpreted as part of a paragraph, so there is no attempt to fill the
2289 first line with text from the following input lines.  Nevertheless, if
2290 the label is not as wide as the indentation, then the paragraph starts
2291 at the same line (but indented), continuing on the following lines.
2292 If the label is wider than the indentation, then the descriptive part
2293 of the paragraph begins on the line following the label, entirely
2294 indented.  Note that neither font shape nor font size of the label is
2295 set to a default value; on the other hand, the rest of the text has
2296 default font settings.
2297 @endDefmac
2299 @DefmacList {LP, , man}
2300 @DefmacItem {PP, , man}
2301 @DefmacListEnd {P, , man}
2302 These macros are mutual aliases.  Any of them causes a line break at
2303 the current position, followed by a vertical space downwards by the
2304 amount specified by the @code{PD} macro.  The font size and shape are
2305 reset to the default value (10@dmn{pt} roman).  Finally, the current
2306 left margin is restored.
2307 @endDefmac
2309 @Defmac {IP, [@Var{designator}] [@Var{nnn}], man}
2310 Set up an indented paragraph, using @var{designator} as a tag to mark
2311 its beginning.  The indentation is set to @var{nnn} if that argument
2312 is supplied (default unit is @samp{n}), otherwise the default
2313 indentation value is used.  Font size and face of the paragraph (but
2314 not the designator) are reset to their default values.  To start an
2315 indented paragraph with a particular indentation but without a
2316 designator, use @samp{""} (two double quotes) as the first argument of
2317 @code{IP}.
2319 For example, to start a paragraph with bullets as the designator and
2320 4@dmn{en} indentation, write
2322 @Example
2323 .IP \(bu 4
2324 @endExample
2325 @endDefmac
2327 @cindex hanging indentation [@code{man}]
2328 @cindex @code{man} macros, hanging indentation
2329 @Defmac {HP, [@Var{nnn}], man}
2330 Set up a paragraph with hanging left indentation.  The indentation is
2331 set to @var{nnn} if that argument is supplied (default unit is
2332 @samp{n}), otherwise the default indentation value is used.  Font size
2333 and face are reset to their default values.
2334 @endDefmac
2336 @cindex left margin, how to move [@code{man}]
2337 @cindex @code{man} macros, moving left margin
2338 @Defmac {RS, [@Var{nnn}], man}
2339 Move the left margin to the right by the value @var{nnn} if specified
2340 (default unit is @samp{n}); otherwise the default indentation value
2341 is used.  Calls to the @code{RS} macro can be nested.
2342 @endDefmac
2344 @Defmac {RE, [@Var{nnn}], man}
2345 Move the left margin back to level @var{nnn}; if no argument is given,
2346 it moves one level back.  The first level (i.e., no call to @code{RS}
2347 yet) has number@w{ }1, and each call to @code{RS} increases the level
2348 by@w{ }1.
2349 @endDefmac
2351 @cindex line breaks, with vertical space [@code{man}]
2352 @cindex @code{man} macros, line breaks with vertical space
2353 To summarize, the following macros cause a line break with the insertion
2354 of vertical space (which amount can be changed with the @code{PD}
2355 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2356 @code{P}), @code{IP}, and @code{HP}.
2358 @cindex line breaks, without vertical space [@code{man}]
2359 @cindex @code{man} macros, line breaks without vertical space
2360 The macros @code{RS} and @code{RE} also cause a break but do not insert
2361 vertical space.
2363 @c ---------------------------------------------------------------------
2365 @node Man font macros, Miscellaneous man macros, Man usage, man
2366 @subsection Macros to set fonts
2367 @cindex font selection [@code{man}]
2368 @cindex @code{man} macros, how to set fonts
2370 The standard font is roman; the default text size is 10@w{ }point.
2372 @Defmac {SM, [@Var{text}], man}
2373 Set the text on the same line or the text on the next line in a font
2374 that is one point size smaller than the default font.
2375 @endDefmac
2377 @cindex boldface [@code{man}]
2378 @cindex @code{man} macros, boldface
2379 @Defmac {SB, [@Var{text}], man}
2380 Set the text on the same line or the text on the next line in boldface
2381 font, one point size smaller than the default font.
2382 @endDefmac
2384 @Defmac {BI, text, man}
2385 Set its arguments alternately in bold face and italic.  Thus,
2387 @Example
2388 .BI this "word and" that
2389 @endExample
2391 @noindent
2392 would set ``this'' and ``that'' in bold face, and ``word and'' in
2393 italics.
2394 @endDefmac
2396 @Defmac {IB, text, man}
2397 Set its arguments alternately in italic and bold face.
2398 @endDefmac
2400 @Defmac {RI, text, man}
2401 Set its arguments alternately in roman and italic.
2402 @endDefmac
2404 @Defmac {IR, text, man}
2405 Set its arguments alternately in italic and roman.
2406 @endDefmac
2408 @Defmac {BR, text, man}
2409 Set its arguments alternately in bold face and roman.
2410 @endDefmac
2412 @Defmac {RB, text, man}
2413 Set its arguments alternately in roman and bold face.
2414 @endDefmac
2416 @Defmac {B, [@Var{text}], man}
2417 Set @var{text} in bold face.  If no text is present on the line where
2418 the macro is called, then the text of the next line appears in bold
2419 face.
2420 @endDefmac
2422 @cindex italic fonts [@code{man}]
2423 @cindex @code{man} macros, italic fonts
2424 @Defmac {I, [@Var{text}], man}
2425 Set @var{text} in italic.  If no text is present on the line where the
2426 macro is called, then the text of the next line appears in italic.
2427 @endDefmac
2429 @c ---------------------------------------------------------------------
2431 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2432 @subsection Miscellaneous macros
2434 @pindex grohtml
2435 @cindex @code{man} macros, default indentation
2436 @cindex default indentation [@code{man}]
2437 The default indentation is 7.2@dmn{n} for all output devices except for
2438 @code{grohtml} which ignores indentation.
2440 @cindex tab stops [@code{man}]
2441 @cindex @code{man} macros, tab stops
2442 @Defmac {DT, , man}
2443 Set tabs every 0.5@w{ }inches.  Since this macro is always called
2444 during a @code{TH} request, it makes sense to call it only if the tab
2445 positions have been changed.
2446 @endDefmac
2448 @cindex empty space before a paragraph [@code{man}]
2449 @cindex @code{man} macros, empty space before a paragraph
2450 @Defmac {PD, [@Var{nnn}], man}
2451 Adjust the empty space before a new paragraph (or section).  The
2452 optional argument gives the amount of space (default unit is
2453 @samp{v}); without parameter, the value is reset to its default value
2454 (1@w{ }line for tty devices, 0.4@dmn{v}@w{ }otherwise).
2455 @endDefmac
2457 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2458 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2460 @c ---------------------------------------------------------------------
2462 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2463 @subsection Predefined strings
2465 The following strings are defined:
2467 @Defstr {*S, man}
2468 Switch back to the default font size.
2469 @endDefstr
2471 @Defstr {*R, man}
2472 The `registered' sign.
2473 @endDefstr
2475 @Defstr {Tm, man}
2476 The `trademark' sign.
2477 @endDefstr
2479 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2480 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2481 @DefstrList {lq, man}
2482 @DefstrListEnd {rq, man}
2483 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2484 respectively.
2485 @endDefstr
2487 @c ---------------------------------------------------------------------
2489 @node Preprocessors in man pages,  , Predefined man strings, man
2490 @subsection Preprocessors in @file{man} pages
2492 @cindex preprocessor, calling convention
2493 @cindex calling convention of preprocessors
2494 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2495 become common usage to make the first line of the man page look like
2496 this:
2498 @Example
2499 '\" @var{word}
2500 @endExample
2502 @pindex geqn@r{, invocation in manual pages}
2503 @pindex grefer@r{, invocation in manual pages}
2504 @pindex gtbl@r{, invocation in manual pages}
2505 @pindex man@r{, invocation of preprocessors}
2506 @noindent
2507 Note the single space character after the double quote.  @var{word}
2508 consists of letters for the needed preprocessors: @samp{e} for
2509 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2510 Modern implementations of the @code{man} program read this first line
2511 and automatically call the right preprocessor(s).
2514 @c =====================================================================
2516 @node mdoc, ms, man, Macro Packages
2517 @section @file{mdoc}
2518 @cindex @file{mdoc}
2520 @c XXX documentation
2523 @c =====================================================================
2525 @node ms, me, mdoc, Macro Packages
2526 @section @file{ms}
2527 @cindex @file{ms}
2529 The @file{-ms}
2530 macros are suitable for reports, letters, books,
2531 user manuals, and so forth.
2532 The package provides macros for cover pages, section headings,
2533 paragraphs, lists, footnotes, pagination,
2534 and a table of contents.
2536 @menu
2537 * ms Intro::
2538 * General ms Structure::
2539 * ms Document Control Registers::
2540 * ms Cover Page Macros::
2541 * ms Body Text::
2542 * ms Page Layout::
2543 * Differences from AT&T ms::
2544 @end menu
2546 @c ---------------------------------------------------------------------
2548 @node ms Intro, General ms Structure, ms, ms
2549 @subsection Introduction to @file{ms}
2551 The original @file{-ms} macros were included with
2552 @acronym{AT&T} @code{troff} as well as the
2553 @file{man} macros.
2554 While the @file{man} package is intended for brief documents
2555 that can be read on-line as well as printed, the @file{ms}
2556 macros are suitable for longer documents that are meant to be
2557 printed rather than read on-line.
2559 The @file{ms} macro package included with @code{groff}
2560 is a complete, bottom-up re-implementation.
2561 Several macros (specific to @acronym{AT&T}
2562 or Berkeley) are not included, while several new commands are.
2563 @xref{Differences from AT&T ms}, for more information.
2565 @c ---------------------------------------------------------------------
2567 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2568 @subsection General structure of an @file{ms} document
2569 @cindex @file{ms}, general structure
2571 The @file{ms} macro package expects a certain amount of structure,
2572 but not as much as packages such as @file{man} or @file{mdoc}.
2574 The simplest documents can begin with a paragraph macro
2575 (such as @code{LP} or @code{PP}),
2576 and consist of text separated by paragraph macros
2577 or even blank lines.
2578 Longer documents have a structure as follows:
2580 @table @strong
2581 @item Document type
2582 If you invoke the @code{RP}
2583 (report) macro on the first line of the document,
2584 @code{groff} prints the cover page information on its own page;
2585 otherwise it prints the information on the
2586 first page with your document text immediately following.
2587 Other document formats found in @acronym{AT&T} @code{troff}
2588 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2589 @code{groff}.
2591 @item Format and layout
2592 By setting number registers,
2593 you can change your document's type (font and size),
2594 margins, spacing, headers and footers, and footnotes.
2595 @xref{ms Document Control Registers}, for more details.
2597 @item Cover page
2598 A cover page consists of a title, the author's name and institution,
2599 an abstract, and the date.
2600 @footnote{Actually, only the title is required.}
2601 @xref{ms Cover Page Macros}, for more details.
2603 @item Body
2604 Following the cover page is your document.
2605 You can use the @file{ms}
2606 macros to write reports, letters, books, and so forth.
2607 The package is designed for structured documents,
2608 consisting of paragraphs interspersed with headings
2609 and augmented by lists, footnotes, tables, and other
2610 common constructs.
2611 @xref{ms Body Text}, for more details.
2613 @item Table of contents
2614 Longer documents usually include a table of contents,
2615 which you can invoke by placing the
2616 @code{TC}
2617 macro at the end of your document.
2618 The @file{ms}
2619 macros have minimal indexing facilities, consisting of the
2620 @code{IX} macro, which prints an entry on standard error.
2621 Printing the table of contents at the end is necessary since
2622 @code{groff} is a single-pass text formatter,
2623 thus it cannot determine the page number of each section
2624 until that section has actually been set and printed.
2625 Since @file{ms} output is intended for hardcopy,
2626 you can manually relocate the pages containing
2627 the table of contents between the cover page and the
2628 body text after printing.
2629 @end table
2631 @c ---------------------------------------------------------------------
2633 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2634 @subsection Document control registers
2635 @cindex @file{ms}, document control registers
2637 The following is a list of document control number registers.
2638 For the sake of consistency,
2639 set registers related to margins at the beginning of your document,
2640 or just after the @code{RP} macro.
2641 You can set other registers later in your document,
2642 but you should keep them together at the beginning
2643 to make them easy to find and edit as necessary.
2645 @unnumberedsubsubsec Margin Settings
2647 @Defmpreg {PO, ms}
2648 Defines the page offset (i.e.@: the left margin).
2649 There is no explicit right margin setting; the combination of
2650 the @code{PO} and @code{LL} registers implicitly define the
2651 right margin width.
2653 Effective: next page.
2655 Default value: 1@dmn{i}.
2656 @endDefmpreg
2658 @Defmpreg {LL, ms}
2659 Defines the line length (i.e.@: the width of the body text).
2661 Effective: next paragraph.
2663 Default: 6@dmn{i}.
2664 @endDefmpreg
2666 @Defmpreg {LT, ms}
2667 Defines the title length (i.e.@: the header and footer width).
2668 This is usually the same as @code{LL}, but not necessarily.
2670 Effective: next paragraph.
2672 Default: 6@dmn{i}.
2673 @endDefmpreg
2675 @Defmpreg {HM, ms}
2676 Defines the header margin height at the top of the page.
2678 Effective: next page.
2680 Default: 1@dmn{i}.
2681 @endDefmpreg
2683 @Defmpreg {FM, ms}
2684 Defines the footer margin height at the bottom of the page.
2686 Effective: next page.
2688 Default: 1@dmn{i}.
2689 @endDefmpreg
2691 @unnumberedsubsubsec Text Settings
2693 @Defmpreg {PS, ms}
2694 Defines the point size of the body text.
2696 Effective: next paragraph.
2698 Default: 10@dmn{p}.
2699 @endDefmpreg
2701 @Defmpreg {VS, ms}
2702 Defines the space between lines (line height plus leading).
2704 Effective: next paragraph.
2706 Default: 12@dmn{p}.
2707 @endDefmpreg
2709 @unnumberedsubsubsec Paragraph Settings
2711 @Defmpreg {PI, ms}
2712 Defines the initial indent of a @code{.PP} paragraph.
2714 Effective: next paragraph.
2716 Default: 5@dmn{n}.
2717 @endDefmpreg
2719 @Defmpreg {PD, ms}
2720 Defines the space between paragraphs.
2722 Effective: next paragraph.
2724 Default: 0.3@dmn{v}.
2725 @endDefmpreg
2727 @Defmpreg {QI, ms}
2728 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2730 Effective: next paragraph.
2732 Default: 5@dmn{n}.
2733 @endDefmpreg
2735 @unnumberedsubsubsec Footnote Settings
2737 @Defmpreg {FL, ms}
2738 Defines the length of a footnote.
2740 Effective: next footnote.
2742 Default: @math{@code{@\n[LL]} * 5 / 6}.
2743 @endDefmpreg
2745 @Defmpreg {FI, ms}
2746 Defines the footnote indent.
2748 Effective: next footnote.
2750 Default: 2@dmn{n}.
2751 @endDefmpreg
2753 @Defmpreg {FF, ms}
2754 The footnote format:
2755 @table @code
2756 @item 0
2757 Prints the footnote number as a superscript; indents the footnote (default).
2759 @item 1
2760 Prints the number followed by a period (like 1.)
2761 and indents the footnote.
2763 @item 2
2764 Like 1, without an indent.
2766 @item 3
2767 Like 1, but prints the footnote number as a hanging paragraph.
2768 @end table
2770 Effective: next footnote.
2772 Default: 0.
2773 @endDefmpreg
2775 @unnumberedsubsubsec Miscellaneous Number Registers
2777 @Defmpreg {MINGW, ms}
2778 Defines the minimum width between columns in a multi-column document.
2780 Effective: next page.
2782 Default: 2@dmn{n}.
2783 @endDefmpreg
2785 @c ---------------------------------------------------------------------
2787 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2788 @subsection Cover page macros
2789 @cindex @file{ms}, cover page macros
2790 @cindex Cover page macros, @file{ms}
2792 Use the following macros to create a cover page for your document
2793 in the order shown.
2795 @Defmac {RP, [@code{no}], ms}
2796 Specifies the report format for your document.
2797 The report format creates a separate cover page.
2798 The default action (no @code{.RP}
2799 macro) is to print a subset of the
2800 cover page on page 1 of your document.
2802 If you use the word @code{no} as an optional argument,
2803 @code{groff} prints a title page but
2804 does not repeat any of the title page information
2805 (title, author, abstract, etc.)
2806 on page 1 of the document.
2807 @endDefmac
2809 @Defmac {DA, [@dots{}], ms}
2810 (optional) Print the current date, or the arguments to the macro if any,
2811 on the title page (if specified) and in the footers.
2812 This is the default for @code{nroff}.
2813 @endDefmac
2815 @Defmac {ND, [@dots{}], ms}
2816 (optional) Print the current date, or the arguments to the macro if any,
2817 on the title page (if specified) but not in the footers.
2818 This is the default for @code{troff}.
2819 @endDefmac
2821 @Defmac {TL, , ms}
2822 Specifies the document title.
2823 @code{groff} collects text following the @code{.TL}
2824 macro into the title, until reaching the author name or abstract.
2825 @endDefmac
2827 @Defmac {AU, , ms}
2828 Specifies the author's name, which appears on the
2829 line (or lines) immediately following.
2830 You can specify multiple authors as follows:
2832 @Example
2834 John Doe
2836 University of West Bumblefuzz
2838 Martha Buck
2840 Monolithic Corporation
2843 @endExample
2844 @endDefmac
2846 @Defmac {AI, , ms}
2847 Specifies the author's institution.
2848 You can specify multiple institutions in the same way
2849 that you specify multiple authors.
2850 @endDefmac
2852 @Defmac {AB, [@code{no}], ms}
2853 Begins the abstract.
2854 The default is to print the word @acronym{ABSTRACT},
2855 centered and in italics, above the text of the abstract.
2856 The word @code{no} as an optional argument suppresses this heading.
2857 @endDefmac
2859 @Defmac {AE, , ms}
2860 End the abstract.
2861 @endDefmac
2863 The following is example mark-up for a title page.
2864 @cindex Title page, example markup
2865 @cindex Example markup, title page
2867 @Example
2868 @cartouche
2871 The Inevitability of Code Bloat
2872 in Commercial and Free Software
2874 J. Random Luser
2876 University of West Bumblefuzz
2878 This report examines the long-term growth
2879 of the code bases in two large, popular software
2880 packages; the free Emacs and the commercial
2881 Microsoft Word.
2882 While differences appear in the type or order
2883 of features added, due to the different
2884 methodologies used, the results are the same
2885 in the end.
2887 The free software approach is shown to be
2888 superior in that while free software can
2889 become as bloated as commercial offerings,
2890 free software tends to have fewer serious
2891 bugs and the added features are in line with
2892 user demand.
2895 ... the rest of the paper follows ...
2896 @end cartouche
2897 @endExample
2899 @c ---------------------------------------------------------------------
2901 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2902 @subsection Body text
2903 @cindex @file{ms}, body text
2905 This section describes macros used to mark up the body of your document.
2906 Examples include paragraphs, sections, and other groups.
2908 @menu
2909 * Paragraphs in ms::
2910 * Headings in ms::
2911 * Highlighting in ms::
2912 * Lists in ms::
2913 * Indents in ms::
2914 * Tabstops in ms::
2915 * ms Displays and Keeps::
2916 * ms Insertions::
2917 * Example multi-page table::
2918 * ms Footnotes::
2919 @end menu
2921 @c ---------------------------------------------------------------------
2923 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2924 @subsubsection Paragraphs
2925 @cindex @file{ms}, paragraph macros
2927 The following paragraph types are available.
2929 @Defmac {PP, , ms}
2930 Sets a paragraph with an initial indent.
2931 @endDefmac
2933 @Defmac {LP, , ms}
2934 Sets a paragraph with no initial indent.
2935 @endDefmac
2937 @Defmac {QP, , ms}
2938 Sets a paragraph that is indented at both left and right margins.
2939 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2940 The next paragraph or heading returns margins to normal.
2941 @endDefmac
2943 @Defmac {XP, , ms}
2944 Sets a paragraph whose lines are indented,
2945 except for the first line.
2946 This is a Berkeley extension.
2947 @endDefmac
2949 The following markup uses all four paragraph macros.
2951 @Example
2952 @cartouche
2953 .NH 2
2954 Cases used in the study
2956 The following software and versions were
2957 considered for this report.
2959 For commercial software, we chose
2960 .B "Microsoft Word for Windows" ,
2961 starting with version 1.0 through the
2962 current version (Word 2000).
2964 For free software, we chose
2965 .B Emacs ,
2966 from its first appearance as a standalone
2967 editor through the current version (v20).
2968 See [Bloggs 2002] for details.
2970 Franklin's Law applied to software:
2971 software expands to outgrow both
2972 RAM and disk space over time.
2974 Bibliography:
2976 Bloggs, Joseph R.,
2977 .I "Everyone's a Critic" ,
2978 Underground Press, March 2002.
2979 A definitive work that answers all questions
2980 and criticisms about the quality and usability of
2981 free software.
2983 @end cartouche
2984 @endExample
2986 @c ---------------------------------------------------------------------
2988 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
2989 @subsubsection Headings
2990 @cindex @file{ms}, heading macros
2992 Use headings to create a hierarchical structure for your document.
2993 The @file{ms} macros print headings in @strong{bold},
2994 using the same font family and point size as the body text.
2996 The following describes the heading macros:
2998 @DefmacList {NH, @Var{curr-level}, ms}
2999 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3000 Numbered heading.
3001 The argument is either a numeric argument to indicate the
3002 level of the heading, or the letter@w{ }@code{S} followed by numeric
3003 arguments to set the heading level explicitly.
3005 If you specify heading levels out of sequence, such as invoking
3006 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
3007 prints a warning on standard error.
3008 @endDefmac
3010 @Defmac {SH, , ms}
3011 Unnumbered subheading.
3012 @endDefmac
3014 @c ---------------------------------------------------------------------
3016 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3017 @subsubsection Highlighting
3018 @cindex @file{ms}, highlighting macros
3020 The @file{ms} macros provide a variety of methods to highlight
3021 or emphasize text:
3023 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3024 Sets its first argument in @strong{bold type}.
3025 If you specify a second argument, @code{groff} prints it in the
3026 previous font after the bold text, with no intervening space
3027 (this allows you to set punctuation after the highlighted text
3028 without highlighting the punctuation).
3029 Similarly, it prints the third argument (if any) in the previous
3030 font @strong{before} the first argument.
3031 For example,
3033 @Example
3034 .B foo ) (
3035 @endExample
3037 prints (@strong{foo}).
3039 If you give this macro no arguments, @code{groff}
3040 prints all text following in bold until
3041 the next highlighting, paragraph, or heading macro.
3042 @endDefmac
3044 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3045 Sets its first argument in roman (or regular) type.
3046 It operates similarly to the @code{B}@w{ }macro otherwise.
3047 @endDefmac
3049 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3050 Sets its first argument in @emph{italic type}.
3051 It operates similarly to the @code{B}@w{ }macro otherwise.
3052 @endDefmac
3054 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3055 Sets its first argument in a @code{constant width face}.
3056 It operates similarly to the @code{B}@w{ }macro otherwise.
3057 @endDefmac
3059 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3060 Sets its first argument in bold italic type.
3061 It operates similarly to the @code{B}@w{ }macro otherwise.
3062 @endDefmac
3064 @Defmac {BX, [@Var{txt}], ms}
3065 Prints its argument and draws a box around it.
3066 If you want to box a string that contains spaces,
3067 use a digit-width space (@code{\0}).
3068 @endDefmac
3070 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3071 Prints its first argument with an underline.
3072 If you specify a second argument, @code{groff}
3073 prints it in the previous font after
3074 the underlined text, with no intervening space.
3075 @endDefmac
3077 @Defmac {LG, , ms}
3078 Prints all text following in larger type
3079 (two points larger than the current point size) until
3080 the next font size, highlighting, paragraph, or heading macro.
3081 You can specify this macro multiple times
3082 to enlarge the point size as needed.
3083 @endDefmac
3085 @Defmac {SM, , ms}
3086 Prints all text following in smaller type
3087 (two points smaller than the current point size) until
3088 the next type size, highlighting, paragraph, or heading macro.
3089 You can specify this macro multiple times
3090 to reduce the point size as needed.
3091 @endDefmac
3093 @Defmac {NL, , ms}
3094 Prints all text following in the normal point size
3095 (that is, the value of the @code{PS} register).
3096 @endDefmac
3098 @c ---------------------------------------------------------------------
3100 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
3101 @subsubsection Lists
3102 @cindex @file{ms}, list macros
3104 The @code{.IP} macro handles duties for all lists.
3106 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3107 The @var{marker} is usually a bullet character (@code{\[bu]})
3108 for unordered lists, a number (or auto-incrementing number
3109 register) for numbered lists, or a word or phrase for indented
3110 (glossary-style) lists.
3112 The @var{width} specifies the indent for the body of each list item;
3113 its default unit is @samp{n}.
3114 Once specified, the indent remains the same for all
3115 list items in the document until specified again.
3116 @endDefmac
3118 The following is an example of a bulleted list.
3119 @cindex Example markup, bulleted list (ms)
3120 @cindex Bulleted list, example markup (ms)
3122 @Example
3123 A bulleted list:
3124 .IP \[bu] 2
3125 lawyers
3126 .IP \[bu]
3127 guns
3128 .IP \[bu]
3129 money
3130 @endExample
3132 Produces:
3134 @Example
3135 A bulleted list:
3137 o lawyers
3139 o guns
3141 o money
3142 @endExample
3144 @sp 1
3146 The following is an example of a numbered list.
3147 @cindex Example markup, numbered list (ms)
3148 @cindex Numbered list, example markup (ms)
3150 @Example
3151 .nr step 1 1
3152 A numbered list:
3153 .IP \\n[step] 3
3154 lawyers
3155 .IP \\n+[step]
3156 guns
3157 .IP \\n+[step]
3158 money
3159 @endExample
3161 Produces:
3163 @Example
3164 A numbered list:
3166 1. lawyers
3168 2. guns
3170 3. money
3171 @endExample
3173 Note the use of the auto-incrementing number
3174 register in this example.
3176 @sp 1
3177 The following is an example of a glossary-style list.
3178 @cindex Example markup, glossary-style list (ms)
3179 @cindex Glossary-style list, example markup (ms)
3181 @Example
3182 A glossary-style list:
3183 .IP lawyers 0.4i
3184 Two or more attorneys.
3185 .IP guns
3186 Firearms, preferably
3187 large-caliber.
3188 .IP money
3189 Gotta pay for those
3190 lawyers and guns!
3191 @endExample
3193 Produces:
3195 @Example
3196 A glossary-style list:
3198 lawyers
3199       Two or more attorneys.
3201 guns  Firearms, preferably large-caliber.
3203 money
3204       Gotta pay for those lawyers and guns!
3205 @endExample
3207 In the last example, the @code{IP} macro places the definition
3208 on the same line as the term if it has enough space; otherwise,
3209 it breaks to the next line and starts the definition below the
3210 term.
3211 This may or may not be the effect you want, especially if some
3212 of the definitions break and some do not.
3213 The following examples show two possible ways to force a break.
3215 The first workaround uses the @code{.br}
3216 request to force a break after printing the term or label.
3218 @Example
3219 @cartouche
3220 A glossary-style list:
3221 .IP lawyers 0.4i
3222 Two or more attorneys.
3223 .IP guns
3225 Firearms, preferably large-caliber.
3226 .IP money
3227 Gotta pay for those lawyers and guns!
3228 @end cartouche
3229 @endExample
3231 @sp 1
3232 The second workaround uses the @code{\p} escape to force the break.
3233 Note the space following the escape; this is important.
3234 If you omit the space, @code{groff} prints the first word on
3235 the same line as the term or label (if it fits) @strong{then}
3236 breaks the line.
3238 @Example
3239 @cartouche
3240 A glossary-style list:
3241 .IP lawyers 0.4i
3242 Two or more attorneys.
3243 .IP guns
3244 \p Firearms, preferably large-caliber.
3245 .IP money
3246 Gotta pay for those lawyers and guns!
3247 @end cartouche
3248 @endExample
3250 @sp 1
3251 To set nested lists, use the @code{RS} and @code{RE} macros.
3252 @xref{Indents in ms}, for more information.
3253 @cindex @file{ms}, nested lists
3254 @cindex Nested lists (ms)
3256 For example:
3258 @Example
3259 @cartouche
3260 .IP \[bu] 2
3261 Lawyers:
3263 .IP \[bu]
3264 Dewey,
3265 .IP \[bu]
3266 Cheatham,
3267 .IP \[bu]
3268 and Howe.
3270 .IP \[bu]
3271 Guns
3272 @end cartouche
3273 @endExample
3275 Produces:
3277 @Example
3278 o Lawyers:
3280   o  Dewey,
3282   o  Cheatham,
3284   o  and Howe.
3286 o Guns
3287 @endExample
3289 @c ---------------------------------------------------------------------
3291 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3292 @subsubsection Indents
3294 In many situations,
3295 you may need to indent a section of text
3296 while still wrapping and filling.
3297 @xref{Lists in ms},
3298 for an example of nested lists.
3300 @DefmacList {RS, , ms}
3301 @DefmacListEnd {RE, , ms}
3302 These macros begin and end an indented section.
3303 The @code{PI} register controls the amount of indent,
3304 allowing the indented text to line up under hanging
3305 and indented paragraphs.
3306 @endDefmac
3308 @xref{ms Displays and Keeps},
3309 for macros to indent and turn off filling.
3311 @c ---------------------------------------------------------------------
3313 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3314 @subsubsection Tab Stops
3316 Use the @code{ta} request to define tab stops as needed.
3317 @xref{Tabs and Fields}.
3319 @Defmac{TA, , ms}
3320 Use this macro to reset the tab stops to the default for @file{ms}
3321 (every 5n).
3322 You can redefine the @code{TA} macro to create a different set
3323 of default tab stops.
3324 @endDefmac
3326 @c ---------------------------------------------------------------------
3328 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3329 @subsubsection Displays and keeps
3330 @cindex @file{ms}, displays
3331 @cindex @file{ms}, keeps
3332 @cindex Keeps (ms)
3333 @cindex Displays (ms)
3335 Use displays to show text-based examples or figures
3336 (such as code listings).
3338 Displays turn off filling, so lines of code are displayed
3339 as-is without inserting @code{br} requests in between each line.
3340 Displays can be @dfn{kept} on a single page, or allowed
3341 to break across pages.
3343 @DefmacList {DS, @t{L}, ms}
3344 @DefmacItem {LD, , ms}
3345 @DefmacListEnd {DE, , ms}
3346 Left-justified display.
3347 The @samp{.DS L} call generates a page break, if necessary,
3348 to keep the entire display on one page.
3349 The @code{LD} macro allows the display to break across pages.
3350 The @code{DE} macro ends the display.
3351 @endDefmac
3353 @DefmacList {DS, @t{I}, ms}
3354 @DefmacItem {ID, , ms}
3355 @DefmacListEnd {DE, , ms}
3356 Indents the display as defined by the @code{DI} register.
3357 The @samp{.DS I} call generates a page break, if necessary,
3358 to keep the entire display on one page.
3359 The @code{ID} macro allows the display to break across pages.
3360 The @code{DE} macro ends the display.
3361 @endDefmac
3363 @DefmacList {DS, @t{B}, ms}
3364 @DefmacItem {BD, , ms}
3365 @DefmacListEnd {DE, , ms}
3366 Sets a block-centered display: the entire display is left-justified,
3367 but indented so that the longest line in the display is centered
3368 on the page.
3369 The @samp{.DS B} call generates a page break, if necessary,
3370 to keep the entire display on one page.
3371 The @code{BD} macro allows the display to break across pages.
3372 The @code{DE} macro ends the display.
3373 @endDefmac
3375 @DefmacList {DS, @t{C}, ms}
3376 @DefmacItem {CD, , ms}
3377 @DefmacListEnd {DE, , ms}
3378 Sets a centered display: each line in the display is centered.
3379 The @samp{.DS C} call generates a page break, if necessary,
3380 to keep the entire display on one page.
3381 The @code{CD} macro allows the display to break across pages.
3382 The @code{DE} macro ends the display.
3383 @endDefmac
3385 @DefmacList {DS, @t{R}, ms}
3386 @DefmacItem {RD, , ms}
3387 @DefmacListEnd {DE, , ms}
3388 Right-justifies each line in the display.
3389 The @samp{.DS R} call generates a page break, if necessary,
3390 to keep the entire display on one page.
3391 The @code{RD} macro allows the display to break across pages.
3392 The @code{DE} macro ends the display.
3393 @endDefmac
3395 @sp 1
3396 On occasion, you may want to @dfn{keep} other text together on a page.
3397 For example, you may want to keep two paragraphs together, or
3398 a paragraph that refers to a table (or list, or other item)
3399 immediately following.
3400 The @file{ms} macros provide the @code{KS} and @code{KE}
3401 macros for this purpose.
3403 @DefmacList {KS, , ms}
3404 @DefmacListEnd {KE, , ms}
3405 The @code{KS} macro begins a block of text to be kept on a
3406 single page, and the @code{KE} macro ends the block.
3407 @endDefmac
3409 @DefmacList {KF, , ms}
3410 @DefmacListEnd {KE, , ms}
3411 Specifies a @dfn{floating keep};
3412 if the keep cannot fit on the current page, @code{groff}
3413 holds the contents of the keep and allows text following
3414 the keep (in the source file) to fill in the remainder of
3415 the current page.
3416 When the page breaks, whether by an explicit @code{bp}
3417 request or by reaching the end of the page, @code{groff}
3418 prints the floating keep at the top of the new page.
3419 This is useful for printing large graphics or tables
3420 that do not need to appear exactly where specified.
3421 @endDefmac
3423 You can also use the @code{ne} request to force a page break if
3424 there is not enough vertical space remaining on the page.
3426 @sp 1
3427 Use the following macros to draw a box around a section of
3428 text (such as a display).
3430 @DefmacList {B1, , ms}
3431 @DefmacListEnd {B2, , ms}
3432 Marks the beginning and ending of text that is to have a
3433 box drawn around it.
3434 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3435 Text in the box is automatically placed in a diversion (keep).
3436 @endDefmac
3438 @c ---------------------------------------------------------------------
3440 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3441 @subsubsection Tables, figures, equations, and references
3442 @cindex @file{ms}, tables
3443 @cindex @file{ms}, figures
3444 @cindex @file{ms}, equations
3445 @cindex @file{ms}, references
3446 @cindex Tables (ms)
3447 @cindex Figures (ms)
3448 @cindex Equations (ms)
3449 @cindex References (ms)
3451 The @file{ms} macros support the standard
3452 @code{groff} preprocessors:
3453 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3454 @pindex tbl
3455 @pindex pic
3456 @pindex eqn
3457 @pindex refer
3458 You mark text meant for preprocessors by enclosing it
3459 in pairs of tags as follows.
3461 @DefmacList {TS, [@code{H}], ms}
3462 @DefmacListEnd {TE, , ms}
3463 Denotes a table, to be processed by the @code{tbl} preprocessor.
3464 The optional argument@w{ }@code{H} to @code{TS} instructs @code{groff}
3465 to create a running header with the information
3466 up to the @code{TH} macro.
3467 @code{groff} prints the header at the beginning of the
3468 table; if the table runs onto another page, @code{groff}
3469 prints the header on the next page as well.
3470 @endDefmac
3472 @DefmacList {PS, , ms}
3473 @DefmacListEnd {PE, , ms}
3474 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3475 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3476 @code{pic} manual available on the Web as a reference, or by using
3477 a graphics program such as @code{xfig}.
3478 @endDefmac
3480 @DefmacList {EQ, [@Var{align}], ms}
3481 @DefmacListEnd {EN, , ms}
3482 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3483 The optional @var{align} argument can be @code{C}, @code{L}, or@w{
3484 }@code{I} to center (the default), left-justify, or indent the equation.
3485 @endDefmac
3487 @DefmacList {[, , ms}
3488 @DefmacListEnd {], , ms}
3489 Denotes a reference, to be processed by the @code{refer} preprocessor.
3490 The @acronym{GNU} @cite{refer(1)} manpage provides a comprehensive
3491 reference to the preprocessor and the format of the bibliographic
3492 database.
3493 @endDefmac
3495 @menu
3496 * Example multi-page table::
3497 @end menu
3499 @c ---------------------------------------------------------------------
3501 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3502 @subsubsection An example multi-page table
3503 @cindex Example markup, multi-page table (ms)
3504 @cindex Multi-page table, example markup (ms)
3506 The following is an example of how to set up a
3507 table that may print across two or more pages.
3509 @Example
3510 @cartouche
3511 .TS H
3512 allbox expand;
3513 cb | cb .
3514 Text      ...of heading...
3518 l | l .
3519 ... the rest of the table follows...
3522 @end cartouche
3523 @endExample
3525 @c ---------------------------------------------------------------------
3527 @node ms Footnotes,  , Example multi-page table, ms Body Text
3528 @subsubsection Footnotes
3529 @cindex @file{ms}, footnotes
3530 @cindex Footnotes (ms)
3532 The @file{ms} macro package has a flexible footnote system.
3533 You can specify either numbered footnotes or symbolic footnotes
3534 (that is, using a marker such as a dagger symbol).
3536 @Defstr {*, ms}
3537 Specifies the location of a numbered footnote marker in the text.
3538 @endDefesc
3540 @DefmacList {FS, , ms}
3541 @DefmacListEnd {FE, , ms}
3542 Specifies the text of the footnote.
3543 The default action is to create a numbered footnote;
3544 you can create a symbolic footnote by specifying
3545 a @dfn{mark} character
3546 (such as @code{\[dg]} for the dagger character)
3547 in the body text and as an argument to the @code{FS} macro,
3548 followed by the text of the footnote
3549 and the @code{FE} macro.
3550 @endDefmac
3552 You can control how @code{groff}
3553 prints footnote numbers by changing the value of the
3554 @code{FF} register.  @xref{ms Document Control Registers}.
3556 @c ---------------------------------------------------------------------
3558 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3559 @subsection Page layout
3560 @cindex @file{ms}, page layout
3561 @cindex Page layout (ms)
3563 The default output from the @file{ms}
3564 macros provides a minimalist page layout:
3565 it prints a single column, with the page number centered at the top
3566 of each page.
3567 It prints no footers.
3569 You can change the layout by setting
3570 the proper number registers and strings.
3572 @menu
3573 * ms Headers and Footers::
3574 * ms Margins::
3575 * ms Multiple Columns::
3576 * ms TOC::
3577 * ms Strings and Special Characters::
3578 @end menu
3580 @c ---------------------------------------------------------------------
3582 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3583 @subsubsection Headers and footers
3584 @cindex @file{ms}, headers
3585 @cindex @file{ms}, footers
3586 @cindex Headers (ms)
3587 @cindex Footers (ms)
3589 For documents that do not distinguish between odd and even pages,
3590 set the following strings:
3592 @DefstrList {LH, ms}
3593 @DefstrItem {CH, ms}
3594 @DefstrListEnd {RH, ms}
3595 Sets the left, center, and right headers.
3596 @endDefstr
3598 @DefstrList {LF, ms}
3599 @DefstrItem {CF, ms}
3600 @DefstrListEnd {RF, ms}
3601 Sets the left, center, and right footers.
3602 @endDefstr
3604 @sp 1
3605 For documents that need different information printed in the
3606 even and odd pages, use the following macros:
3608 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3609 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3610 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3611 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3612 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3613 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3614 This is more flexible than defining the individual strings.
3616 You can replace the quote (@code{'}) marks with any character not
3617 appearing in the header or footer text.
3618 @endDefmac
3620 @c ---------------------------------------------------------------------
3622 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3623 @subsubsection Margins
3624 @cindex @file{ms}, margins
3626 You control margins using a set of number registers.
3627 @xref{ms Document Control Registers}, for details.
3629 @c ---------------------------------------------------------------------
3631 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3632 @subsubsection Multiple columns
3633 @cindex @file{ms}, multiple columns
3634 @cindex Multiple columns (ms)
3636 The @file{ms} macros can set text in as many columns as will
3637 reasonably fit on the page.
3638 The following macros are available;
3639 all of them force a page break if a multi-column mode is already set.
3640 However, if the current mode is single-column, starting a multi-column
3641 mode does @strong{not} force a page break.
3643 @Defmac {1C, , ms}
3644 Single-column mode.
3645 @endDefmac
3647 @Defmac {2C, , ms}
3648 Two-column mode.
3649 @endDefmac
3651 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3652 Multi-column mode.
3653 If you specify no arguments, it is equivalent to the
3654 @code{.2C} macro.
3655 Otherwise, @var{width} is the width of each column and
3656 @var{gutter} is the space between columns.
3657 The @code{MINGW} number register controls the default gutter width.
3658 @endDefmac
3660 @c ---------------------------------------------------------------------
3662 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3663 @subsubsection Creating a table of contents
3664 @cindex @file{ms}, creating table of contents
3665 @cindex Table of contents, creating (ms)
3667 The facilities in the @file{ms} macro package for creating
3668 a table of contents are semi-automated at best.
3669 Assuming that you want the table of contents to consist of
3670 the document's headings, you need to repeat those headings
3671 wrapped in @code{XS} and @code{XE} macros.
3673 @DefmacList {XS, [@Var{page}], ms}
3674 @DefmacItem {XA, [@Var{page}], ms}
3675 @DefmacListEnd {XE, , ms}
3676 These macros define a table of contents
3677 or an individual entry in the table of contents,
3678 depending on their use.
3679 The macros are very simple; they cannot indent a heading based on its level.
3680 The easiest way to work around this is to add tabs
3681 to the table of contents string.
3682 The following is an example:
3684 @Example
3685 @cartouche
3686 .NH 1
3687 Introduction
3689 Introduction
3694 .NH 2
3695 Methodology
3697         Methodology
3701 @end cartouche
3702 @endExample
3704 You can manually create a table of contents
3705 by beginning with the @code{XS} macro for the first entry,
3706 specifying the page number for that entry as the argument to @code{XS}.
3707 Add subsequent entries using the @code{XA} macro,
3708 specifying the page number for that entry as the argument to @code{XA}.
3709 The following is an example:
3711 @Example
3712 @cartouche
3713 .XS 1
3714 Introduction
3715 .XA 2
3716 A Brief History of the Universe
3717 .XA 729
3718 Details of Galactic Formation
3721 @end cartouche
3722 @endExample
3723 @endDefmac
3725 @Defmac {TC, [@code{no}], ms}
3726 Prints the table of contents on a new page,
3727 setting the page number to@w{ }@strong{i} (Roman numeral one).
3728 You should usually place this macro at the end of the
3729 file, since @code{groff} is a single-pass formatter and
3730 can only print what has been collected up to the point
3731 that the @code{TC} macro appears.
3733 The optional argument @code{no} suppresses printing
3734 the title specified by the string register @code{TOC}.
3735 @endDefmac
3737 @Defmac{PX, [@code{no}], ms}
3738 Prints the table of contents on a new page,
3739 using the current page numbering sequence.
3740 Use this macro to print a manually-generated table of contents
3741 at the beginning of your document.
3743 The optional argument @code{no} suppresses printing
3744 the title specified by the string register @code{TOC}.
3745 @endDefmac
3747 The @cite{Groff and Friends HOWTO}
3748 includes a @code{sed} script that automatically inserts
3749 @code{XS} and @code{XE} macro entries after each heading in a document.
3751 Altering the @code{NH} macro to automatically build the table
3752 of contents is perhaps initially more difficult, but would save
3753 a great deal of time in the long run if you use @file{ms} regularly.
3755 @c ---------------------------------------------------------------------
3757 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3758 @subsubsection Strings and Special Characters
3759 @cindex @file{ms}, strings
3760 @cindex @file{ms}, special characters
3761 @cindex @file{ms}, accent marks
3762 @cindex Accent marks
3763 @cindex Special characters
3764 @cindex Strings in @file{ms}
3766 The @file{ms} macros provide the following predefined strings.
3767 You can change the string definitions to help in creating
3768 documents in languages other than English.
3770 @Defstr {REFERENCES, ms}
3771 Contains the string printed at the beginning of the
3772 references (bibliography) page.
3773 The default is @samp{References}.
3774 @endDefstr
3776 @Defstr {ABSTRACT, ms}
3777 Contains the string printed at the beginning of the abstract.
3778 The default is @samp{ABSTRACT}.
3779 @endDefstr
3781 @Defstr {TOC, ms}
3782 Contains the string printed at the beginning of the table of contents.
3783 @endDefstr
3785 @DefstrList {MONTH1, ms}
3786 @DefstrItem {MONTH2, ms}
3787 @DefstrItem {MONTH3, ms}
3788 @DefstrItem {MONTH4, ms}
3789 @DefstrItem {MONTH5, ms}
3790 @DefstrItem {MONTH6, ms}
3791 @DefstrItem {MONTH7, ms}
3792 @DefstrItem {MONTH8, ms}
3793 @DefstrItem {MONTH9, ms}
3794 @DefstrItem {MONTH10, ms}
3795 @DefstrItem {MONTH11, ms}
3796 @DefstrListEnd {MONTH12, ms}
3797 Prints the full name of the month in dates.
3798 The default is @samp{January}, @samp{February}, etc.
3799 @endDefstr
3801 The following special characters are available:
3803 @Defstr {-, ms}
3804 Prints an em dash.
3805 @endDefstr
3807 @DefstrList {*Q, ms}
3808 @DefstrListEnd {*U, ms}
3809 Prints typographer's quotes in troff,
3810 plain quotes in nroff.
3811 @code{*Q} is the left quote and @code{*U} is the right quote.
3812 @endDefstr
3814 Improved accent marks are available in the @file{ms} macros.
3816 @Defmac {AM, , ms}
3817 Specify this macro at the beginning of your document
3818 to enable extended accent marks and special characters.
3819 This is a Berkeley extension.
3821 To use the accent marks, place them @strong{after}
3822 the character being accented.
3823 @endDefmac
3825 The following accent marks are available
3826 after invoking the @code{AM} macro:
3828 @Defstr {\', ms}
3829 Acute accent.
3830 @endDefstr
3832 @Defstr {\`, ms}
3833 Grave accent.
3834 @endDefstr
3836 @Defstr {^, ms}
3837 Circumflex.
3838 @endDefstr
3840 @Defstr {\,, ms}
3841 Cedilla.
3842 @endDefstr
3844 @Defstr {~, ms}
3845 Tilde.
3846 @endDefstr
3848 @Defstr {:, ms}
3849 Umlaut.
3850 @endDefstr
3852 @Defstr {v, ms}
3853 Hacek.
3854 @endDefstr
3856 @Defstr {_, ms}
3857 Macron (overbar).
3858 @endDefstr
3860 @Defstr {., ms}
3861 Underdot.
3862 @endDefstr
3864 @Defstr {o, ms}
3865 Ring above.
3866 @endDefstr
3868 The following are standalone characters
3869 available after invoking the @code{AM} macro:
3871 @Defstr {?, ms}
3872 Upside-down question mark.
3873 @endDefstr
3875 @Defstr {!, ms}
3876 Upside-down exclamation point.
3877 @endDefstr
3879 @Defstr {8, ms}
3880 German @ss{} ligature.
3881 @endDefstr
3883 @Defstr {3, ms}
3884 Yogh.
3885 @endDefstr
3887 @Defstr {Th, ms}
3888 Uppercase thorn.
3889 @endDefstr
3891 @Defstr {th, ms}
3892 Lowercase thorn.
3893 @endDefstr
3895 @Defstr {D-, ms}
3896 Uppercase eth.
3897 @endDefstr
3899 @Defstr {d-, ms}
3900 Lowercase eth.
3901 @endDefstr
3903 @Defstr {q, ms}
3904 Hooked o.
3905 @endDefstr
3907 @Defstr {ae, ms}
3908 Lowercase @ae{} ligature.
3909 @endDefstr
3911 @Defstr {Ae, ms}
3912 Uppercase @AE{} ligature.
3913 @endDefstr
3915 @c ---------------------------------------------------------------------
3917 @node Differences from AT&T ms,  , ms Page Layout, ms
3918 @subsection Differences from @acronym{AT&T} @file{ms}
3919 @cindex @file{ms}, differences from @acronym{AT&T}
3920 @cindex @acronym{AT&T}, @code{ms} differences
3922 This section lists the (minor) differences between the
3923 @code{groff -ms} macros and @acronym{AT&T}
3924 @code{troff -ms} macros.
3926 @menu
3927 * Missing ms Macros::
3928 * Additional ms Macros::
3929 @end menu
3931 @c ---------------------------------------------------------------------
3933 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3934 @subsubsection @code{troff} macros not appearing in @code{groff}
3936 Macros missing from @code{groff -ms}
3937 are cover page macros specific to Bell Labs.
3938 The macros known to be missing are:
3940 @table @code
3941 @item .TM
3942 Technical memorandum; a cover sheet style
3944 @item .IM
3945 Internal memorandum; a cover sheet style
3947 @item .MR
3948 Memo for record; a cover sheet style
3950 @item .MF
3951 Memo for file; a cover sheet style
3953 @item .EG
3954 Engineer's notes; a cover sheet style
3956 @item .TR
3957 Computing Science Tech Report; a cover sheet style
3959 @item .OK
3960 Other keywords
3962 @item .CS
3963 Cover sheet information
3965 @item .MH
3966 A cover sheet macro
3967 @end table
3969 @c ---------------------------------------------------------------------
3971 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
3972 @subsubsection @code{groff} macros not appearing in AT&T @code{troff}
3974 The @code{groff -ms} macros have a few minor extensions
3975 compared to the @acronym{AT&T} @code{troff -ms} macros.
3977 @Defmac {AM, , ms}
3978 Improved accent marks.
3979 @xref{ms Strings and Special Characters}, for details.
3980 @endDefmac
3982 @Defmac {DS, @t{I}, ms}
3983 Indented display.
3984 The default behavior of @acronym{AT&T} @code{troff -ms}
3985 was to indent; the @code{groff} default prints displays
3986 flush left with the body text.
3987 @endDefmac
3989 @Defmac {CW, , ms}
3990 Print text in @code{constant width} (Courier) font.
3991 @endDefmac
3993 @Defmac {IX, , ms}
3994 Indexing term (printed on standard error).
3995 You can write a script to capture and process an index
3996 generated in this manner.
3997 @endDefmac
3999 @sp 1
4000 The following additional number registers
4001 appear in @code{groff -ms}:
4003 @Defmpreg {MINGW, ms}
4004 Specifies a minimum space
4005 between columns (for multi-column output); this takes the
4006 place of the @code{GW} register that was documented but apparently
4007 not implemented in @acronym{AT&T} @code{troff}.
4008 @endDefmpreg
4010 @sp 1
4011 Several new string registers are available as well.
4012 You can change these to handle (for example) the local language.
4013 @xref{ms Strings and Special Characters}, for details.
4015 @c =====================================================================
4017 @node me, mm, ms, Macro Packages
4018 @section @file{me}
4019 @cindex @file{me}
4021 @c XXX documentation
4022 @c XXX this is a placeholder until we get stuff knocked into shape
4023 See the @file{meintro.me} and @file{meref.me} documents in
4024 groff's @file{doc} directory.
4027 @c =====================================================================
4029 @node mm,  , me, Macro Packages
4030 @section @file{mm}
4031 @cindex @file{mm}
4033 @c XXX documentation
4034 @c XXX this is a placeholder until we get stuff knocked into shape
4035 See the @code{mm} manpage (type @command{man 7 groff_mm} at
4036 the command line).
4039 @c =====================================================================
4040 @c =====================================================================
4042 @node gtroff Reference, Preprocessors, Macro Packages, Top
4043 @chapter @code{gtroff} Reference
4044 @cindex reference, @code{gtroff}
4045 @cindex @code{gtroff} reference
4047 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4048 Users of macro packages may skip it if not interested in details.
4051 @menu
4052 * Text::
4053 * Input Conventions::
4054 * Measurements::
4055 * Expressions::
4056 * Identifiers::
4057 * Embedded Commands::
4058 * Registers::
4059 * Manipulating Filling and Adjusting::
4060 * Manipulating Hyphenation::
4061 * Manipulating Spacing::
4062 * Tabs and Fields::
4063 * Character Translations::
4064 * Troff and Nroff Mode::
4065 * Line Layout::
4066 * Page Layout::
4067 * Page Control::
4068 * Fonts::
4069 * Sizes::
4070 * Strings::
4071 * Conditionals and Loops::
4072 * Writing Macros::
4073 * Page Motions::
4074 * Drawing Requests::
4075 * Traps::
4076 * Diversions::
4077 * Environments::
4078 * Suppressing output::
4079 * Colors::
4080 * I/O::
4081 * Postprocessor Access::
4082 * Miscellaneous::
4083 * Gtroff Internals::
4084 * Debugging::
4085 * Implementation Differences::
4086 * Summary::
4087 @end menu
4090 @c =====================================================================
4092 @node Text, Input Conventions, gtroff Reference, gtroff Reference
4093 @section Text
4094 @cindex text, @code{gtroff} processing
4096 @code{gtroff} input files contain text with control commands
4097 interspersed throughout.  But, even without control codes, @code{gtroff}
4098 still does several things with the input text:
4100 @itemize @bullet
4101 @item
4102 filling and adjusting
4104 @item
4105 adding additional space after sentences
4107 @item
4108 hyphenating
4110 @item
4111 inserting implicit line breaks
4112 @end itemize
4114 @menu
4115 * Filling and Adjusting::
4116 * Hyphenation::
4117 * Sentences::
4118 * Tab Stops::
4119 * Implicit Line Breaks::
4120 @end menu
4122 @c ---------------------------------------------------------------------
4124 @node Filling and Adjusting, Hyphenation, Text, Text
4125 @subsection Filling and Adjusting
4126 @cindex filling
4127 @cindex adjusting
4129 When @code{gtroff} reads text, it collects words from the input and fits
4130 as many of them together on one output line as it can.  This is known as
4131 @dfn{filling}.
4133 @cindex leading spaces
4134 @cindex spaces, leading and trailing
4135 @cindex extra spaces
4136 @cindex trailing spaces
4137 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
4138 it.  This means it widens the spacing between words until the text
4139 reaches the right margin (in the default adjustment mode).  Extra spaces
4140 between words are preserved, but spaces at the end of lines are ignored.
4141 Spaces at the front of a line cause a @dfn{break} (breaks are
4142 explained in @ref{Implicit Line Breaks})
4144 @xref{Manipulating Filling and Adjusting}.
4146 @c ---------------------------------------------------------------------
4148 @node Hyphenation, Sentences, Filling and Adjusting, Text
4149 @subsection Hyphenation
4150 @cindex hyphenation
4152 Since the odds are not great for finding a set of words, for every
4153 output line, which fit nicely on a line without inserting excessive
4154 amounts of space between words, @code{gtroff} hyphenates words so
4155 that it can justify lines without inserting too much space between
4156 words.  It uses an internal hyphenation algorithm (a simplified version
4157 of the algorithm used within @TeX{}) to indicate which words can be
4158 hyphenated and how to do so.  When a word is hyphenated, the first part
4159 of the word is added to the current filled line being output (with
4160 an attached hyphen), and the other portion is added to the next
4161 line to be filled.
4163 @xref{Manipulating Hyphenation}.
4165 @c ---------------------------------------------------------------------
4167 @node Sentences, Tab Stops, Hyphenation, Text
4168 @subsection Sentences
4169 @cindex sentences
4171 Although it is often debated, some typesetting rules say there should be
4172 different amounts of space after various punctuation marks.  For
4173 example, the @cite{Chicago typsetting manual} says that a period at the
4174 end of a sentence should have twice as much space following it as would
4175 a comma or a period as part of an abbreviation.
4177 @c XXX exact citation of Chicago manual
4179 @cindex sentence space
4180 @cindex space between sentences
4181 @cindex french-spacing
4182 @code{gtroff} does this by flagging certain characters (normally
4183 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4184 When @code{gtroff} encounters one of these characters at the end of a
4185 line, it appends a normal space followed by a @dfn{sentence space} in
4186 the formatted output.  (This justifies one of the conventions mentioned
4187 in @ref{Input Conventions}.)
4189 @cindex transparent characters
4190 @cindex character, transparent
4191 @cindex @code{dg} glyph, at end of sentence
4192 @cindex @code{rq} glyph, at end of sentence
4193 @cindex @code{"}, at end of sentence
4194 @cindex @code{'}, at end of sentence
4195 @cindex @code{)}, at end of sentence
4196 @cindex @code{]}, at end of sentence
4197 @cindex @code{*}, at end of sentence
4198 In addition, the following characters or glyphs are treated
4199 transparently while handling end-of-sentence characters: @samp{"},
4200 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{dg}, and @code{rq}.
4202 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4204 @cindex @code{\&}, at end of sentence
4205 To prevent the insertion of extra space after an end-of-sentence
4206 character (at the end of a line), append @code{\&}.
4208 @c ---------------------------------------------------------------------
4210 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4211 @subsection Tab Stops
4212 @cindex tab stops
4213 @cindex stops, tabulator
4214 @cindex tab character
4215 @cindex character, tabulator
4217 @cindex @acronym{EBCDIC} encoding
4218 @cindex encoding, @acronym{EBCDIC}
4219 @code{gtroff} translates @dfn{tabulator characters}, also called
4220 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4221 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4222 tabulator stop.  These tab stops are initially located every half inch
4223 across the page.  Using this, simple tables can be made easily.
4224 However, it can often be deceptive as the appearance (and width) of the
4225 text on a terminal and the results from @code{gtroff} can vary greatly.
4227 Also, a possible sticking point is that lines beginning with tab
4228 characters are still filled, again producing unexpected results.
4229 For example, the following input
4231 @multitable {12345678} {12345678} {12345678} {12345678}
4232 @item
4233 @tab 1 @tab 2 @tab 3
4234 @item
4235 @tab   @tab 4 @tab 5
4236 @end multitable
4238 @noindent
4239 produces
4241 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4242 @item
4243 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4244 @end multitable
4246 @xref{Tabs and Fields}.
4248 @c ---------------------------------------------------------------------
4250 @node Implicit Line Breaks,  , Tab Stops, Text
4251 @subsection Implicit Line Breaks
4252 @cindex implicit line breaks
4253 @cindex implicit breaks of lines
4254 @cindex line, implicit breaks
4255 @cindex break, implicit
4256 @cindex line break
4258 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4259 occurs, @code{gtroff} outputs the partially filled line
4260 (unjustified), and resumes collecting and filling text on the next output
4261 line.
4263 @cindex blank line
4264 @cindex empty line
4265 @cindex line, blank
4266 @cindex blank line macro (@code{blm})
4267 There are several ways to cause a break in @code{gtroff}.  A blank
4268 line not only causes a break, but it also outputs a one line vertical
4269 space (effectively a blank line).  Note that this behaviour can be
4270 modified with the blank line macro request @code{blm}.
4272 @c XXX xref for blm
4274 @cindex fill mode
4275 @cindex mode, fill
4276 A line that begins with a space causes a break and the space is
4277 output at the beginning of the next line.  Note that this space isn't
4278 adjusted, even in fill mode.
4280 The end of file also causes a break -- otherwise the last line of
4281 the document may vanish!
4283 Certain requests also cause breaks, implicitly or explicitly.  This is
4284 discussed in @ref{Manipulating Filling and Adjusting}.
4287 @c =====================================================================
4289 @node Input Conventions, Measurements, Text, gtroff Reference
4290 @section Input Conventions
4291 @cindex input conventions
4292 @cindex conventions for input
4294 Since @code{gtroff} does filling automatically, it is traditional in
4295 @code{groff} not to try and type things in as nicely formatted
4296 paragraphs.  These are some conventions commonly used when typing
4297 @code{gtroff} text:
4299 @itemize @bullet
4300 @item
4301 Break lines after punctuation, particularly at the end of a sentence
4302 and in other logical places.  Keep separate phrases on lines by
4303 themselves, as entire phrases are often added or deleted when editing.
4305 @item
4306 Try to keep lines less than 40-60@w{ }characters, to allow space for
4307 inserting more text.
4309 @item
4310 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4311 don't try using spaces to get proper indentation).
4312 @end itemize
4315 @c =====================================================================
4317 @node Measurements, Expressions, Input Conventions, gtroff Reference
4318 @section Measurements
4319 @cindex measurements
4321 @cindex units of measurement
4322 @cindex basic unit (@code{u})
4323 @cindex machine unit (@code{u})
4324 @cindex measurement unit
4325 @cindex @code{u} unit
4326 @cindex unit, @code{u}
4327 @code{gtroff} (like many other programs) requires numeric parameters to
4328 specify various measurements.  Most numeric parameters@footnote{those
4329 that specify vertical or horizontal motion or a type size} may have a
4330 @dfn{measurement unit} attached.  These units are specified as a single
4331 character which immediately follows the number or expression.  Each of
4332 these units are understood, by @code{gtroff}, to be a multiple of its
4333 @dfn{basic unit}.  So, whenever a different measurement unit is
4334 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4335 basic unit, represented by a @samp{u}, is a device dependent measurement
4336 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4337 inch.  The values may be given as fractional numbers; however,
4338 fractional basic units are always rounded to integers.
4340 Some of the measurement units are completely independent of any of the
4341 current settings (e.g.@: type size) of @code{gtroff}.
4343 @table @code
4344 @item i
4345 @cindex inch unit (@code{i})
4346 @cindex @code{i} unit
4347 @cindex unit, @code{i}
4348 Inches.  An antiquated measurement unit still in use in certain
4349 backwards countries with incredibly low-cost computer equipment.  One
4350 inch is equal to@w{ }2.54@dmn{cm}.
4352 @item c
4353 @cindex centimeter unit (@code{c})
4354 @cindex @code{c} unit
4355 @cindex unit, @code{c}
4356 Centimeters.  One centimeter is equal to@w{ }0.3937@dmn{in}.
4358 @item p
4359 @cindex point unit (@code{p})
4360 @cindex @code{p} unit
4361 @cindex unit, @code{p}
4362 Points.  This is a typesetter's measurement used for measure type size.
4363 It is 72@w{ }points to an inch.
4365 @item P
4366 @cindex pica unit (@code{P})
4367 @cindex @code{P} unit
4368 @cindex unit, @code{P}
4369 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
4370 12@w{ }points to a pica).
4372 @item s
4373 @itemx z
4374 @cindex @code{s} unit
4375 @cindex unit, @code{s}
4376 @cindex @code{z} unit
4377 @cindex unit, @code{z}
4378 @xref{Fractional Type Sizes}, for a discussion of these units.
4380 @item f
4381 @cindex @code{f} unit
4382 @cindex unit, @code{f}
4383 Fractions. Value is 65536.
4384 @xref{Colors}, for usage.
4385 @end table
4387 The other measurements understood by @code{gtroff} depend on
4388 settings currently in effect in @code{gtroff}.  These are very useful
4389 for specifying measurements which should look proper with any size of
4390 text.
4392 @table @code
4393 @item m
4394 @cindex em unit (@code{m})
4395 @cindex @code{m} unit
4396 @cindex unit, @code{m}
4397 Ems.  This unit is equal to the current font size in points.  So called
4398 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
4399 in the current font.
4401 @item n
4402 @cindex en unit (@code{n})
4403 @cindex @code{n} unit
4404 @cindex unit, @code{n}
4405 Ens.  This is half of an em.
4407 @item v
4408 @cindex vertical space unit (@code{v})
4409 @cindex space, vertical, unit (@code{v})
4410 @cindex @code{v} unit
4411 @cindex unit, @code{v}
4412 Vertical space.  This is equivalent to the current line spacing.
4413 @xref{Sizes}, for more information about this.
4415 @item M
4416 @cindex @code{M} unit
4417 @cindex unit, @code{M}
4418 100ths of an em.
4419 @end table
4421 @menu
4422 * Default Units::
4423 @end menu
4425 @c ---------------------------------------------------------------------
4427 @node Default Units,  , Measurements, Measurements
4428 @subsection Default Units
4429 @cindex default units
4430 @cindex units, default
4432 Many requests take a default unit.  While this can be helpful at times,
4433 it can cause strange errors in some expressions.  For example, the line
4434 length request expects em units.  Here are several attempts to get a
4435 line length of 3.5@w{ }inches and their results:
4437 @Example
4438 3.5i      @result{}   3.5i
4439 7/2       @result{}   0i
4440 7/2i      @result{}   0i
4441 7i/2      @result{}   0.1i
4442 7i/2u     @result{}   3.5i
4443 @endExample
4445 @noindent
4446 Everything is converted to basic units first.  In the above example it
4447 is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m} equals@w{
4448 }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}).  The value 7@dmn{i}/2
4449 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4450 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4451 0.1@dmn{i}.
4453 @cindex measurements, specifying safely
4454 Thus, the safest way to specify measurements is to always
4455 attach a scaling indicator.  If you want to multiply or divide by a
4456 certain scalar value, use @samp{u} as the unit for that value.
4459 @c =====================================================================
4461 @node Expressions, Identifiers, Measurements, gtroff Reference
4462 @section Expressions
4463 @cindex expressions
4465 @code{gtroff} has most arithmetic operators common to other languages:
4467 @c XXX more details; examples
4469 @itemize @bullet
4470 @item
4471 @cindex arithmetic operators
4472 @cindex operators, arithmetic
4473 @opindex +
4474 @opindex -
4475 @opindex /
4476 @opindex *
4477 @opindex %
4478 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4479 (division), @samp{*} (multiplication), @samp{%} (modulo).
4481 @code{gtroff} only provides integer arithmetic.  The internal type used
4482 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4483 signed integer.
4485 @item
4486 @cindex comparison operators
4487 @cindex operators, comparison
4488 @opindex <
4489 @opindex >
4490 @opindex >=
4491 @opindex <=
4492 @opindex =
4493 @opindex ==
4494 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4495 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4496 (equal), @samp{==} (the same as @samp{=}).
4498 @item
4499 @cindex logical operators
4500 @cindex operators, logical
4501 @opindex &
4502 @opindex :
4503 Logical: @samp{&} (logical and), @samp{:} (logical or).
4505 @item
4506 @cindex unary operators
4507 @cindex operators, unary
4508 @opindex -
4509 @opindex +
4510 @opindex !
4511 @cindex @code{if} request, and the @samp{!} operator
4512 @cindex @code{while} request, and the @samp{!} operator
4513 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4514 (just for completeness; does nothing in expressions), @samp{!} (logical
4515 not; this works only within @code{if} and @code{while} requests).  See
4516 below for the use of unary operators in motion requests.
4518 @item
4519 @cindex extremum operators
4520 @cindex operators, extremum
4521 @opindex >?
4522 @opindex <?
4523 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).  For example,
4524 @samp{5>?3} yields@w{ }@samp{5}.
4526 @c XXX add examples
4528 @item
4529 @cindex scaling operator
4530 @cindex operator, scaling
4531 Scaling: @code{(@var{c};@var{e})}.  Evaluate@w{ }@var{e} using@w{ }@var{c}
4532 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4533 indicators in the evaluation of@w{ }@var{e}.
4534 @end itemize
4536 @cindex parentheses
4537 @cindex order of evaluation in expressions
4538 @cindex expression, order of evaluation
4539 @opindex (
4540 @opindex )
4541 Parentheses may be used as in any other language.  However, in
4542 @code{gtroff} they are necessary to ensure order of evaluation.
4543 @code{gtroff} has no operator precedence; expressions are evaluated left
4544 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4545 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4546 expected.
4548 @cindex @code{+}, and page motion
4549 @cindex @code{-}, and page motion
4550 @cindex @code{|}, and page motion
4551 @cindex motion operators
4552 @cindex operators, motion
4553 For many requests which cause a motion on the page, the unary operators
4554 work differently.  The @samp{+} and @samp{-} operators then indicate a
4555 motion relative to the current position (down or up, respectively), and
4556 the @samp{|} operator indicates an absolute position on the page or
4557 input line.
4558 @c XXX xref
4559 @samp{+} and @samp{-} are also treated differently by the following
4560 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4561 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4562 @code{rt}, @code{ti}, @code{\R}, and @code{\s}.  Here the plus and minus
4563 signs indicate increments and decrements.
4565 @c XXX add more xref
4566 @xref{Setting Registers}.
4568 @cindex space characters in expressions
4569 @cindex expressions and space characters
4570 Due to the way arguments are parsed, spaces are not allowed in
4571 expressions, unless the entire expression is surrounded by parentheses.
4573 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4576 @c =====================================================================
4578 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4579 @section Identifiers
4580 @cindex identifiers
4582 Like any other language, @code{gtroff} has rules for properly formed
4583 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4584 almost any printable character, with the exception of the following
4585 characters:
4587 @itemize @bullet
4588 @item
4589 @cindex whitespace characters
4590 @cindex newline character
4591 @cindex character, whitespace
4592 Whitespace characters (spaces, tabs, and newlines).
4594 @item
4595 @cindex character, backspace
4596 @cindex backspace character
4597 @cindex @acronym{EBCDIC} encoding of backspace
4598 Backspace (@acronym{ASCII}@w{ }@code{0x08} or @acronym{EBCDIC}@w{
4599 }@code{0x16}) and character code @code{0x01}.
4601 @item
4602 @cindex invalid input characters
4603 @cindex input characters, invalid
4604 @cindex characters, invalid input
4605 @cindex Unicode
4606 The following input characters are invalid and are ignored if
4607 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4608 warning message of type @samp{input} (see @ref{Debugging}, for more
4609 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4610 @code{0x80}-@code{0x9F}.
4612 And here are the invalid input characters if @code{groff} runs on an
4613 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4614 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4615 @code{0x30}-@code{0x3F}.
4617 Currently, some of these reserved codepoints are used internally, thus
4618 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4619 character sets and encodings which use characters of these ranges.
4621 Note that invalid characters are removed before parsing; an
4622 identifier @code{foo}, followed by an invalid character, followed by
4623 @code{bar} is treated as @code{foobar}.
4624 @end itemize
4626 For example, any of the following is valid.
4628 @Example
4632 end-list
4634 @endExample
4636 @cindex @code{]}, as part of an identifier
4637 @noindent
4638 Note that identifiers longer than two characters with a closing bracket
4639 (@samp{]}) in its name can't be accessed with escape sequences which
4640 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4641 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4642 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4644 @c XXX xref
4646 @Defesc {\\A, ', ident, '}
4647 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4648 expands to the character@w{ }1 or@w{ }0 according to whether its
4649 argument (usually delimited by quotes) is or is not acceptable as the
4650 name of a string, macro, diversion, number register, environment, or
4651 font.  It returns@w{ }0 if no argument is given.  This is useful for
4652 looking up user input in some sort of associative table.
4654 @Example
4655 \A'end-list'
4656     @result{} 1
4657 @endExample
4658 @endDefesc
4660 @xref{Escapes}, for details on parameter delimiting characters.
4662 @c XXX add xrefs above
4664 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4665 @code{gtroff} needs to be told where identifiers end and text begins
4666 (and in different ways depending on their length):
4668 @itemize @bullet
4669 @item
4670 Single character.
4672 @cindex @code{(}, starting a two-character identifier
4673 @item
4674 Two characters.  Must be prefixed with @samp{(} in some situations.
4676 @cindex @code{[}, starting an identifier
4677 @cindex @code{]}, ending an identifier
4678 @item
4679 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4680 and@w{ }@samp{]} in some situations.  Any length identifier can be put
4681 in brackets.
4682 @end itemize
4684 @cindex undefined identifiers
4685 @cindex identifiers, undefined
4686 Unlike many other programming languages, undefined identifiers are
4687 silently ignored or expanded to nothing.
4688 When @code{gtroff} finds an undefined identifier, it emits a
4689 warning then:
4691 @itemize @bullet
4692 @item
4693 If the identifier is a string, macro, or diversion,
4694 @code{gtroff} defines it as empty.
4696 @item
4697 If the identifier is a number register, @code{gtroff}
4698 defines it with a value of@w{ }0.
4699 @end itemize
4701 @xref{Warnings}.
4703 @c XXX info about common identifier pool for strings and macros.
4705 @xref{Interpolating Registers}, and @ref{Strings}.
4708 @c =====================================================================
4710 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4711 @section Embedded Commands
4712 @cindex embedded commands
4713 @cindex commands, embedded
4715 Most documents need more functionality beyond filling, adjusting and
4716 implicit line breaking.  In order to gain further functionality,
4717 @code{gtroff} allows commands to be embedded into the text, in two ways.
4719 The first is a @dfn{request} which takes up an entire line, and does
4720 some large-scale operation (e.g.@: break lines, start new pages).
4722 The other is an @dfn{escape} which can be embedded anywhere in the text,
4723 or even as an argument to a request.
4724 @c XXX (Not always?)
4725 Escapes generally do more minor operations like sub- and superscripts,
4726 print a symbol, etc.
4728 @menu
4729 * Requests::
4730 * Macros::
4731 * Escapes::
4732 @end menu
4734 @c ---------------------------------------------------------------------
4736 @node Requests, Macros, Embedded Commands, Embedded Commands
4737 @subsection Requests
4738 @cindex requests
4740 @cindex control character (@code{.})
4741 @cindex character, control (@code{.})
4742 @cindex no-break control character (@code{'})
4743 @cindex character, no-break control (@code{'})
4744 @cindex control character, no-break (@code{'})
4745 A request line begins with a control character, which is either a single
4746 quote (@samp{'}, the @dfn{no-break control character}) or a period
4747 (@samp{.}, the normal @dfn{control character}).  These can be changed;
4748 see @ref{Character Translations}, for details.  After this there may be
4749 optional tabs or spaces followed by an identifier which is the name of
4750 the request.  This may be followed by any number of space-separated
4751 arguments (@emph{no} tabs here).
4753 @cindex structuring source code of documents or macro packages
4754 @cindex documents, structuring the source code
4755 @cindex macro packages, strucuring the source code
4756 Since a control character followed by whitespace only is ignored, it
4757 is common practice to use this feature for structuring the source code
4758 of documents or macro packages.
4760 @Example
4761 .de foo
4762 .  tm This is foo.
4766 .de bar
4767 .  tm This is bar.
4769 @endExample
4771 @cindex blank line
4772 @cindex blank line macro (@code{blm})
4773 Another possibility is to use the blank line macro request @code{blm}
4774 by assigning an empty macro to it.
4776 @Example
4777 .de do-nothing
4779 .blm do-nothing  \" activate blank line macro
4781 .de foo
4782 .  tm This is foo.
4786 .de bar
4787 .  tm This is bar.
4790 .blm             \" deactivate blank line macro
4791 @endExample
4793 @c XXX xref to blm
4795 @cindex zero width space character (@code{\&})
4796 @cindex character, zero width space (@code{\&})
4797 @cindex space character, zero width (@code{\&})
4798 @cindex @code{\&}, escaping control characters
4799 To begin a line with a control character without it being interpreted,
4800 precede it with @code{\&}.  This represents a zero width space, which
4801 means it does not affect the output.
4803 In most cases the period is used as a control character.  Several
4804 requests cause a break implicitly; using the single quote control
4805 character prevents this.
4807 @menu
4808 * Request Arguments::
4809 @end menu
4811 @node Request Arguments,  , Requests, Requests
4812 @subsubsection Request Arguments
4813 @cindex request arguments
4814 @cindex arguments to requests
4816 Arguments to requests (and macros) are processed much like the shell:
4817 The line is split into arguments according to spaces.  An argument
4818 which is intended to contain spaces can either be enclosed in double
4819 quotes, or have the spaces @dfn{escaped} with backslashes.
4821 Here are a few examples:
4823 @Example
4824 .uh The Mouse Problem
4825 .uh "The Mouse Problem"
4826 .uh The\ Mouse\ Problem
4827 @endExample
4829 @cindex @code{\~}, difference to @code{\@key{SP}}
4830 @cindex @code{\@key{SP}}, difference to @code{\~}
4831 @noindent
4832 The first line is the @code{uh} macro being called with 3 arguments,
4833 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
4834 same effect of calling the @code{uh} macro with one argument, @samp{The
4835 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4836 is ``classical'' in the sense that it can be found in most @code{troff}
4837 documents.  Nevertheless, it is not optimal in all situations, since
4838 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4839 can't stretch.  @code{gtroff} provides a different command @code{\~} to
4840 insert a stretchable, non-breaking space.}
4842 @cindex @code{"}, in a macro argument
4843 @cindex double quote, in a macro argument
4844 A double quote which isn't preceded by a space doesn't start a macro
4845 argument.  If not closing a string, it is printed literally.
4847 For example,
4849 @Example
4850 .xxx a" "b c" "de"fg"
4851 @endExample
4853 @noindent
4854 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4856 @cindex @code{ds} request, and double quotes
4857 Double quotes in the @code{ds} request are handled differently.
4858 @xref{Strings}, for more details.
4860 @c ---------------------------------------------------------------------
4862 @node Macros, Escapes, Requests, Embedded Commands
4863 @subsection Macros
4864 @cindex macros
4866 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
4867 which can be invoked by name.  They are called in the same manner as
4868 requests -- arguments also may be passed in the same manner.
4870 @xref{Writing Macros}, and @ref{Request Arguments}.
4872 @c ---------------------------------------------------------------------
4874 @node Escapes,  , Macros, Embedded Commands
4875 @subsection Escapes
4876 @cindex escapes
4878 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
4879 begin with a backslash and are followed by a single character which
4880 indicates the function to be performed.  The escape character can be
4881 changed; see @ref{Character Translations}.
4883 Escape sequences which require an identifier as a parameter accept three
4884 possible syntax forms.
4886 @itemize @bullet
4887 @item
4888 The next single character is the identifier.
4890 @cindex @code{(}, starting a two-character identifier
4891 @item
4892 If this single character is an opening parenthesis, take the following
4893 two characters as the identifier.  Note that there is no closing
4894 parenthesis after the identifier.
4896 @cindex @code{[}, starting an identifier
4897 @cindex @code{]}, ending an identifier
4898 @item
4899 If this single character is an opening bracket, take all characters
4900 until a closing bracket as the identifier.
4901 @end itemize
4903 @noindent
4904 Examples:
4906 @Example
4908 \n(XX
4909 \*[TeX]
4910 @endExample
4912 @cindex @code{'}, delimiting arguments
4913 @cindex argument delimiting characters
4914 @cindex characters, argument delimiting
4915 @cindex delimiting characters for arguments
4916 Other escapes may require several arguments and/or some special format.
4917 In such cases the argument is traditionally enclosed in single quotes
4918 (and quotes are always used in this manual for the definitions of escape
4919 sequences).  The enclosed text is then processed according to what that
4920 escape expects.  Example:
4922 @Example
4923 \l'1.5i\(bu'
4924 @endExample
4926 @cindex @code{\o}, possible quote characters
4927 @cindex @code{\b}, possible quote characters
4928 @cindex @code{\X}, possible quote characters
4929 Note that the quote character can be replaced with any other character
4930 which does not occur in the argument (even a newline or a space
4931 character) in the following escapes: @code{\o}, @code{\b}, and
4932 @code{\X}.  This makes e.g.
4934 @Example
4935 A caf
4940 in Paris
4941   @result{} A caf@'e in Paris
4942 @endExample
4944 @noindent
4945 possible, but it is better not to use this feature to avoid confusion.
4947 @cindex @code{\%}, used as delimiter
4948 @cindex @code{\@key{SP}}, used as delimiter
4949 @cindex @code{\|}, used as delimiter
4950 @cindex @code{\^}, used as delimiter
4951 @cindex @code{\@{}, used as delimiter
4952 @cindex @code{\@}}, used as delimiter
4953 @cindex @code{\'}, used as delimiter
4954 @cindex @code{\`}, used as delimiter
4955 @cindex @code{\-}, used as delimiter
4956 @cindex @code{\_}, used as delimiter
4957 @cindex @code{\!}, used as delimiter
4958 @cindex @code{\?}, used as delimiter
4959 @cindex @code{\@@}, used as delimiter
4960 @cindex @code{\)}, used as delimiter
4961 @cindex @code{\/}, used as delimiter
4962 @cindex @code{\,}, used as delimiter
4963 @cindex @code{\&}, used as delimiter
4964 @cindex @code{\~}, used as delimiter
4965 @cindex @code{\0}, used as delimiter
4966 @cindex @code{\a}, used as delimiter
4967 @cindex @code{\c}, used as delimiter
4968 @cindex @code{\d}, used as delimiter
4969 @cindex @code{\e}, used as delimiter
4970 @cindex @code{\E}, used as delimiter
4971 @cindex @code{\p}, used as delimiter
4972 @cindex @code{\r}, used as delimiter
4973 @cindex @code{\t}, used as delimiter
4974 @cindex @code{\u}, used as delimiter
4975 The following escapes sequences (which are handled similarly to
4976 characters since they don't take a parameter) are also allowed as
4977 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
4978 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
4979 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
4980 @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
4981 @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.  Again, don't
4982 use these if possible.
4984 @cindex @code{\A}, allowed delimiters
4985 @cindex @code{\Z}, allowed delimiters
4986 @cindex @code{\C}, allowed delimiters
4987 @cindex @code{\w}, allowed delimiters
4988 No newline characters as delimiters are allowed in the following
4989 escapes: @code{\A}, @code{\Z}, @code{\C}, and @code{\w}.
4991 @cindex @code{\D}, allowed delimiters
4992 @cindex @code{\h}, allowed delimiters
4993 @cindex @code{\H}, allowed delimiters
4994 @cindex @code{\l}, allowed delimiters
4995 @cindex @code{\L}, allowed delimiters
4996 @cindex @code{\N}, allowed delimiters
4997 @cindex @code{\R}, allowed delimiters
4998 @cindex @code{\s}, allowed delimiters
4999 @cindex @code{\S}, allowed delimiters
5000 @cindex @code{\v}, allowed delimiters
5001 @cindex @code{\x}, allowed delimiters
5002 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5003 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
5004 @code{\x} can't use the following characters as delimiters:
5006 @itemize @bullet
5007 @item
5008 @cindex numbers, and delimiters
5009 @cindex digits, and delimiters
5010 The digits @code{0}-@code{9}.
5012 @item
5013 @cindex operators, as delimiters
5014 @cindex @code{+}, as delimiter
5015 @cindex @code{-}, as delimiter
5016 @cindex @code{/}, as delimiter
5017 @cindex @code{*}, as delimiter
5018 @cindex @code{%}, as delimiter
5019 @cindex @code{<}, as delimiter
5020 @cindex @code{>}, as delimiter
5021 @cindex @code{=}, as delimiter
5022 @cindex @code{&}, as delimiter
5023 @cindex @code{:}, as delimiter
5024 @cindex @code{(}, as delimiter
5025 @cindex @code{)}, as delimiter
5026 @cindex @code{.}, as delimiter
5027 The (single-character) operators @samp{+-/*%<>=&:().}.
5029 @item
5030 @cindex space character
5031 @cindex character, space
5032 @cindex tab character
5033 @cindex character, tab
5034 @cindex newline character
5035 @cindex character, newline
5036 The space, tab, and newline characters.
5038 @item
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{\c}, used as delimiter
5050 @cindex @code{\e}, used as delimiter
5051 @cindex @code{\p}, used as delimiter
5052 All escape sequences except @code{\%}, @code{\@{}, @code{\@}},
5053 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
5054 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5055 @end itemize
5057 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
5058 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
5059 To have a backslash (actually, the current escape character) appear in the
5060 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
5061 These are very similar, and only differ with respect to being used in
5062 macros or diversions.  @xref{Implementation Differences}, @ref{Copy-in
5063 Mode}, and @ref{Diversions}, for more information.
5065 @c XXX explanation of \E
5067 @xref{Identifiers}, and @ref{Character Translations}.
5069 @menu
5070 * Comments::
5071 @end menu
5073 @node Comments,  , Escapes, Escapes
5074 @subsubsection Comments
5075 @cindex comments
5077 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5078 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5079 common forms of escapes is the comment.
5081 @Defesc {\\", , , }
5082 Start a comment.  Everything to the end of the input line is ignored.
5084 This may sound simple, but it can be tricky to keep the comments from
5085 interfering with the appearance of the final output.
5087 @cindex @code{ds} request, and comments
5088 @cindex @code{as} request, and comments
5089 If the escape is to the right of some text or a request, that portion
5090 of the line is ignored, but the space leading up to it is noticed by
5091 @code{gtroff}.  This only affects the @code{.ds} and @code{.as}
5092 request.
5094 @cindex tabs before comments
5095 @cindex comments, lining up with tabs
5096 One possibly irritating idiosyncracy is that tabs must not be used to
5097 line up comments.  Tabs are not treated as white space between the
5098 request and macro arguments.
5100 @cindex undefined request
5101 @cindex request, undefined
5102 A comment on a line by itself is treated as a blank line, because
5103 after eliminating the comment, that is all that remains:
5105 @Example
5106 Test
5107 \" comment
5108 Test
5109 @endExample
5111 @noindent
5112 produces
5114 @Example
5115 Test
5117 Test
5118 @endExample
5120 To avoid this, it is common to start the line with @code{.\"} which
5121 causes the line to be treated as an undefined request and thus ignored
5122 completely.
5124 @cindex @code{'}, as a comment
5125 Another commenting scheme seen sometimes is three consecutive single
5126 quotes (@code{'''}) at the beginning of a line.  This works, but
5127 @code{gtroff} gives a warning about an undefined macro (namely
5128 @code{''}), which is harmless, but irritating.
5129 @endDefesc
5131 @Defesc {\\#, , , }
5132 To avoid all this, @code{gtroff} has a new comment mechanism using the
5133 @code{\#} escape.  This escape works the same as @code{\"} except that
5134 the newline is also ignored:
5136 @Example
5137 Test
5138 \# comment
5139 Test
5140 @endExample
5142 @noindent
5143 produces
5145 @Example
5146 Test Test
5147 @endExample
5149 @noindent
5150 as expected.
5151 @endDefesc
5153 @Defreq {ig, yy}
5154 Ignore all input until @code{gtroff} encounters the macro named
5155 @code{.}@var{yy} on a line by itself (or @code{..} if @var{yy} is not
5156 specified).  This is useful for commenting out large blocks of text:
5158 @Example
5159 text text text...
5161 This is part of a large block
5162 of text that has been
5163 temporarily(?) commented out.
5165 We can restore it simply by removing
5166 the .ig request and the ".." at the
5167 end of the block.
5169 More text text text...
5170 @endExample
5172 @noindent
5173 produces
5175 @Example
5176 text text text@dots{}  More text text text@dots{}
5177 @endExample
5179 @noindent
5180 Note that the commented-out block of text does not
5181 cause a break.
5183 The input is read in copy-mode; auto-incremented registers @emph{are}
5184 affected (@pxref{Auto-increment}).
5185 @endDefreq
5188 @c =====================================================================
5190 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5191 @section Registers
5192 @cindex registers
5194 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5195 are a number of built-in registers, supplying anything from the date to
5196 details of formatting parameters.
5198 @xref{Identifiers}, for details on register identifiers.
5200 @menu
5201 * Setting Registers::
5202 * Interpolating Registers::
5203 * Auto-increment::
5204 * Assigning Formats::
5205 * Built-in Registers::
5206 @end menu
5208 @c ---------------------------------------------------------------------
5210 @node Setting Registers, Interpolating Registers, Registers, Registers
5211 @subsection Setting Registers
5212 @cindex setting registers (@code{nr}, @code{\R})
5213 @cindex registers, setting (@code{nr}, @code{\R})
5215 Define or set registers using the @code{nr} request or the
5216 @code{\R} escape.
5218 @DefreqList {nr, ident value}
5219 @DefescListEnd {\\R, ', ident value, '}
5220 Set number register @var{ident} to @var{value}.  If @var{ident}
5221 doesn't exist, @code{gtroff} creates it.
5223 The argument to @code{\R} usually has to be enclosed in quotes.
5224 @xref{Escapes}, for details on parameter delimiting characters.
5225 @endDefreq
5227 For example, the following two lines are equivalent:
5229 @Example
5230 .nr a 1
5231 \R'a 1'
5232 @endExample
5234 Both @code{nr} and @code{\R} have two additional special forms to
5235 increment or decrement a register.
5237 @DefreqList {nr, ident @t{+}@Var{value}}
5238 @DefreqItem {nr, ident @t{-}@Var{value}}
5239 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5240 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5241 Increment (decrement) register @var{ident} by @var{value}.
5243 @Example
5244 .nr a 1
5245 .nr a +1
5247     @result{} 2
5248 @endExample
5250 @cindex negating register values
5251 To assign the negated value of a register to another register, some care
5252 must be taken to get the desired result:
5254 @Example
5255 .nr a 7
5256 .nr b 3
5257 .nr a -\nb
5259     @result{} 4
5260 .nr a (-\nb)
5262     @result{} -3
5263 @endExample
5265 @noindent
5266 The surrounding parentheses prevent the interpretation of the minus sign
5267 as a decrementing operator.  An alternative is to start the assignment
5268 with a @samp{0}:
5270 @Example
5271 .nr a 7
5272 .nr b -3
5273 .nr a \nb
5275     @result{} 4
5276 .nr a 0\nb
5278     @result{} -3
5279 @endExample
5280 @endDefreq
5282 @Defreq {rr, ident}
5283 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5284 request is ignored.
5285 @endDefreq
5287 @Defreq {rnn, ident1 ident2}
5288 Rename number register @var{ident1} to @var{ident2}.  If either
5289 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5290 @endDefreq
5292 @Defreq {aln, ident1 ident2}
5293 Create an alias @var{ident1} for a number register @var{ident2}.  The
5294 new name and the old name are exactly equivalent.  If @var{ident1} is
5295 undefined, a warning of type @samp{reg} is generated, and the request
5296 is ignored.  @xref{Debugging}, for information about warnings.
5297 @endDefreq
5299 @c ---------------------------------------------------------------------
5301 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5302 @subsection Interpolating Registers
5303 @cindex interpolating registers (@code{\n})
5304 @cindex registers, interpolating (@code{\n})
5306 Numeric registers can be accessed via the @code{\n} escape.
5308 @cindex nested assignments
5309 @cindex assignments, nested
5310 @cindex indirect assignments
5311 @cindex assignments, indirect
5312 @DefescList {\\n, , i, }
5313 @DefescItem {\\n, @lparen{}, id, }
5314 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5315 Interpolate number register with name @var{ident} (one-character name@w{
5316 }@var{i}, two-character name @var{id}). This means that the value of the
5317 register is expanded in-place while @code{gtroff} is parsing the input line.
5318 Nested assignments (also called indirect assignments) are possible.
5320 @Example
5321 .nr a 5
5322 .nr as \na+\na
5323 \n(as
5324     @result{} 10
5325 @endExample
5327 @Example
5328 .nr a1 5
5329 .nr ab 6
5330 .ds str b
5331 .ds num 1
5332 \n[a\n[num]]
5333     @result{} 5
5334 \n[a\*[str]]
5335     @result{} 6
5336 @endExample
5337 @endDefesc
5339 @c ---------------------------------------------------------------------
5341 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5342 @subsection Auto-increment
5343 @cindex auto-increment
5344 @cindex increment, automatic
5346 Number registers can also be auto-incremented and auto-decremented.
5347 The increment or decrement value can be specified with a third
5348 argument to the @code{nr} request or @code{\R} escape.
5350 @cindex @code{\R}, difference to @code{nr}
5351 @Defreq {nr, ident value incr}
5352 Set number register @var{ident} to @var{value}; the increment for
5353 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5354 escape doesn't support this notation.
5355 @endDefreq
5357 To activate auto-incrementing, the escape @code{\n} has a special
5358 syntax form.
5360 @DefescList {\\n, +, i, }
5361 @DefescItem {\\n, -, i, }
5362 @DefescItem {\\n, @lparen{}+, id, }
5363 @DefescItem {\\n, @lparen{}-, id, }
5364 @DefescItem {\\n, +@lparen{}, id, }
5365 @DefescItem {\\n, -@lparen{}, id, }
5366 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5367 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5368 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5369 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5370 Before interpolating, increment or decrement @var{ident}
5371 (one-character name@w{ }@var{i}, two-character name @var{id}) by the
5372 auto-increment value as specified with the @code{nr} request (or the
5373 @code{\R} escape).  If no auto-increment value has been specified,
5374 these syntax forms are identical to @code{\n}.
5375 @endDefesc
5377 For example,
5379 @Example
5380 .nr a 0 1
5381 .nr xx 0 5
5382 .nr foo 0 -2
5383 \n+a, \n+a, \n+a, \n+a, \n+a
5385 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5387 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5388 @endExample
5390 @noindent
5391 produces
5393 @Example
5394 1, 2, 3, 4, 5
5395 -5, -10, -15, -20, -25
5396 -2, -4, -6, -8, -10
5397 @endExample
5399 @cindex increment value without changing the register
5400 @cindex value, incrementing without changing the register
5401 To change the increment value without changing the value of a register
5402 (@var{a} in the example), the following can be used:
5404 @Example
5405 .nr a \na 10
5406 @endExample
5408 @c ---------------------------------------------------------------------
5410 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5411 @subsection Assigning Formats
5412 @cindex assigning formats (@code{af})
5413 @cindex formats, assigning (@code{af})
5415 When a register is used in the text of an input file (as opposed to
5416 part of an expression), it is textually replaced (or interpolated)
5417 with a representation of that number.  This output format can be
5418 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5419 is done using the @code{af} request.
5421 @Defreq {af, ident format}
5422 Change the output format of a number register.  The first argument
5423 @var{ident} is the name of the number register to be changed, and the
5424 second argument @var{format} is the output format.  The following
5425 output formats are available:
5427 @table @code
5428 @item 1
5429 Decimal arabic numbers.  This is the default format: 0, 1, 2, 3,@w{
5430 }@enddots{}
5432 @item 0@dots{}0
5433 Decimal numbers with as many digits as specified.  So, @samp{00} would
5434 result in printing numbers as 01, 02, 03,@w{ }@enddots{}
5436 In fact, any digit instead of zero will do; @code{gtroff} only counts
5437 how many digits are specified.  As a consequence, @code{af}'s default
5438 format @samp{1} could be specified as @samp{0} also (and exactly this is
5439 returned by the @code{\g} escape, see below).
5441 @item I
5442 @cindex Roman numerals
5443 @cindex numerals, Roman
5444 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@enddots{}
5446 @item i
5447 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@enddots{}
5449 @item A
5450 Upper-case letters: 0, A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@enddots{}
5452 @item a
5453 Lower-case letters: 0, a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@enddots{}
5454 @end table
5456 Omitting the number register format causes a warning of type
5457 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5458 nonexistent format causes an error.
5460 The following example produces @samp{10, X, j, 010}:
5462 @Example
5463 .nr a 10
5464 .af a 1           \" the default format
5465 \na,
5466 .af a I
5467 \na,
5468 .af a a
5469 \na,
5470 .af a 001
5472 @endExample
5474 @cindex Roman numerals, maximum and minimum
5475 @cindex maximum values of Roman numerals
5476 @cindex minimum values of Roman numerals
5477 The largest number representable for the @samp{i} and @samp{I} formats
5478 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5479 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5480 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5481 thousand and Roman numeral ten thousand (Unicode code points
5482 @code{U+2182} and @code{U+2181}, respectively) are not available.
5484 If @var{ident} doesn't exist, it is created.
5486 @cindex read-only register, changing format
5487 @cindex changing format, read-only register
5488 Changing the output format of a read-only register causes an error.  It
5489 is necessary to first copy the register's value to a writeable register,
5490 then apply the @code{af} request to this other register.
5491 @endDefreq
5493 @cindex format of register (@code{\g})
5494 @cindex register, format (@code{\g})
5495 @DefescList {\\g, , i, }
5496 @DefescItem {\\g, @lparen{}, id, }
5497 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5498 Return the current format of the specified register @var{ident}
5499 (one-character name@w{ }@var{i}, two-character name @var{id}).  For
5500 example, @samp{\ga} after the previous example would produce the
5501 string @samp{000}.  If the register hasn't been defined yet, nothing
5502 is returned.
5503 @endDefesc
5505 @c ---------------------------------------------------------------------
5507 @node Built-in Registers,  , Assigning Formats, Registers
5508 @subsection Built-in Registers
5509 @cindex built-in registers
5510 @cindex registers, built-in
5512 The following lists some built-in registers which are not described
5513 elsewhere in this manual.  Any register which begins with a @samp{.} is
5514 read-only.  A complete listing of all built-in registers can be found in
5515 @ref{Register Index}.
5517 @table @code
5518 @item .H
5519 @cindex horizontal resolution register (@code{.H})
5520 @cindex resolution, horizontal, register (@code{.H})
5521 @vindex .H
5522 Horizontal resolution in basic units.
5524 @item .V
5525 @cindex vertical resolution register (@code{.V})
5526 @cindex resolution, vertical, register (@code{.V})
5527 @vindex .V
5528 Vertical resolution in basic units.
5530 @item dw
5531 @cindex day of the week register (@code{dw})
5532 @cindex date, day of the week register (@code{dw})
5533 @vindex dw
5534 Day of the week (1-7).
5536 @item dy
5537 @cindex day of the month register (@code{dy})
5538 @cindex date, day of the month register (@code{dy})
5539 @vindex dy
5540 Day of the month (1-31).
5542 @item mo
5543 @cindex month of the year register (@code{mo})
5544 @cindex date, month of the year register (@code{mo})
5545 @vindex mo
5546 Current month (1-12).
5548 @item year
5549 @cindex date, year register (@code{year}, @code{yr})
5550 @cindex year, current, register (@code{year}, @code{yr})
5551 @vindex year
5552 The current year.
5554 @item yr
5555 @vindex yr
5556 The current year minus@w{ }1900.  Unfortunately, the documentation of
5557 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5558 incorrectly claimed that @code{yr} contains the last two digits of the
5559 year.  That claim has never been true of either traditional @code{troff}
5560 or GNU @code{troff}.  Old @code{troff} input that looks like this:
5562 @Example
5563 '\" The following line stopped working after 1999
5564 This document was formatted in 19\n(yr.
5565 @endExample
5567 @noindent
5568 can be corrected as follows:
5570 @Example
5571 This document was formatted in \n[year].
5572 @endExample
5574 @noindent
5575 or, to be portable to older @code{troff} versions, as follows:
5577 @Example
5578 .nr y4 1900+\n(yr
5579 This document was formatted in \n(y4.
5580 @endExample
5582 @item .c
5583 @vindex .c
5584 @itemx c.
5585 @vindex c.
5586 @cindex input line number register (@code{.c}, @code{c.})
5587 @cindex line number, input, register (@code{.c}, @code{c.})
5588 The current @emph{input} line number.  Register @samp{.c} is read-only,
5589 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5590 affecting both @samp{.c} and @samp{c.}.
5592 @item ln
5593 @vindex ln
5594 @cindex output line number register (@code{ln})
5595 @cindex line number, output, register (@code{ln})
5596 The current @emph{output} line number after a call to the @code{nm}
5597 request to activate line numbering.
5599 @xref{Miscellaneous}, for more information about line numbering.
5601 @item .x
5602 @vindex .x
5603 @cindex major version number register (@code{.x})
5604 @cindex version number, major, register (@code{.x})
5605 The major version number.  For example, if the version number is@w{
5606 }1.03 then @code{.x} contains@w{ }@samp{1}.
5608 @item .y
5609 @vindex .y
5610 @cindex minor version number register (@code{.y})
5611 @cindex version number, minor, register (@code{.y})
5612 The minor version number.  For example, if the version number is@w{
5613 }1.03 then @code{.y} contains@w{ }@samp{03}.
5615 @item .Y
5616 @vindex .Y
5617 @cindex revision number register (@code{.Y})
5618 The revision number of @code{groff}.
5620 @item .g
5621 @vindex .g
5622 @cindex @code{gtroff} identification register (@code{.g})
5623 @cindex GNU-specific register (@code{.g})
5624 Always@w{ }1.  Macros should use this to determine whether they are
5625 running under GNU @code{troff}.
5627 @item .A
5628 @vindex .A
5629 @cindex @acronym{ASCII} approximation output register (@code{.A})
5630 If the command line option @option{-a} is used to produce an
5631 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5632 otherwise.  @xref{Groff Options}.
5634 @item .P
5635 @vindex .P
5636 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5637 page is actually being printed, i.e., if the @option{-o} option is being
5638 used to only print selected pages.  @xref{Groff Options}, for more
5639 information.
5641 @item .T
5642 @vindex .T
5643 If @code{gtroff} is called with the @option{-T} command line option, the
5644 number register @code{.T} is set to@w{ }1, and zero otherwise.
5645 @xref{Groff Options}.
5647 @stindex .T
5648 @cindex output device name string register (@code{.T})
5649 Additionally, @code{gtroff} predefines a single read-write string
5650 register @code{.T} which contains the current output device (for
5651 example, @samp{latin1} or @samp{ps}).
5652 @end table
5655 @c =====================================================================
5657 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5658 @section Manipulating Filling and Adjusting
5659 @cindex manipulating filling and adjusting
5660 @cindex filling and adjusting, manipulating
5661 @cindex adjusting and filling, manipulating
5662 @cindex justifying text
5663 @cindex text, justifying
5665 @cindex break
5666 @cindex line break
5667 @cindex @code{bp} request, causing implicit linebreak
5668 @cindex @code{ce} request, causing implicit linebreak
5669 @cindex @code{cf} request, causing implicit linebreak
5670 @cindex @code{fi} request, causing implicit linebreak
5671 @cindex @code{fl} request, causing implicit linebreak
5672 @cindex @code{in} request, causing implicit linebreak
5673 @cindex @code{nf} request, causing implicit linebreak
5674 @cindex @code{rj} request, causing implicit linebreak
5675 @cindex @code{sp} request, causing implicit linebreak
5676 @cindex @code{ti} request, causing implicit linebreak
5677 @cindex @code{trf} request, causing implicit linebreak
5678 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5679 Breaks}.  The @code{br} request likewise causes a break.  Several
5680 other requests also cause breaks, but implicitly.  These are
5681 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5682 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5684 @Defreq {br, }
5685 Break the current line, i.e., the input collected so far is emitted
5686 without adjustment.
5688 If the no-break control character is used, @code{gtroff} suppresses
5689 the break:
5691 @Example
5695     @result{} a b
5696 @endExample
5697 @endDefreq
5699 Initially, @code{gtroff} fills and adjusts text to both margins.
5700 Filling can be disabled via the @code{nf} request and re-enabled with
5701 the @code{fi} request.
5703 @cindex fill mode (@code{fi})
5704 @cindex mode, fill (@code{fi})
5705 @DefreqList {fi, }
5706 @DefregListEnd {.u}
5707 Activate fill mode (which is the default).  This request implicitly
5708 enables adjusting; it also inserts a break in the text currently being
5709 filled.  The read-only number register @code{.u} is set to@w{ }1.
5711 The fill mode status is associated with the current environment
5712 (@pxref{Environments}).
5713 @endDefreq
5715 @cindex no-fill mode (@code{nf})
5716 @cindex mode, no-fill (@code{nf})
5717 @Defreq {nf, }
5718 Activate no-fill mode.  Input lines are output as-is, retaining line
5719 breaks and ignoring the current line length.  This command implicitly
5720 disables adjusting; it also causes a break.  The number register
5721 @code{.u} is set to@w{ }0.
5723 The fill mode status is associated with the current environment
5724 (@pxref{Environments}).
5725 @endDefreq
5727 @DefreqList {ad, [@Var{mode}]}
5728 @DefregListEnd {.j}
5729 Set adjusting mode.
5731 Activation and deactivation of adjusting is done implicitly with
5732 calls to the @code{fi} or @code{nf} requests.
5734 @var{mode} can have one of the following values:
5736 @table @code
5737 @item l
5738 @cindex ragged-right
5739 Adjust text to the left margin.  This produces what is traditionally
5740 called ragged-right text.
5742 @item r
5743 @cindex ragged-left
5744 Adjust text to the right margin, producing ragged-left text.
5746 @item c
5747 @cindex centered text
5748 @cindex @code{ce} request, difference to @code{ad@w{ }c}
5749 Center filled text.  This is different to the @code{ce} request which
5750 only centers text without filling.
5752 @item b
5753 @itemx n
5754 Justify to both margins.  This is the default used by @code{gtroff}.
5755 @end table
5757 With no argument, @code{gtroff} adjusts lines in the same way it did
5758 before adjusting was deactivated (with a call to @code{na}, for
5759 example).
5761 @Example
5762 text
5763 .ad r
5764 text
5765 .ad c
5766 text
5768 text
5769 .ad  \" back to centering
5770 text
5771 @endExample
5773 @cindex adjustment mode register (@code{.j})
5774 The current adjustment mode is available in the read-only number
5775 register @code{.j}; it can be stored and subsequently used to set
5776 adjustment.
5778 The adjustment mode status is associated with the current environment
5779 (@pxref{Environments}).
5780 @endDefreq
5782 @Defreq {na, }
5783 Disable adjusting.  This request won't change the current adjustment
5784 mode: A subsequent call to @code{ad} uses the previous adjustment
5785 setting.
5787 The adjustment mode status is associated with the current environment
5788 (@pxref{Environments}).
5789 @endDefreq
5791 @Defesc {\\p, , , }
5792 Adjust the current line and cause a break.
5794 In most cases this produces very ugly results, since @code{gtroff}
5795 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5796 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5797 line by line:
5799 @Example
5800   This is an uninteresting sentence.
5801   This is an uninteresting sentence.\p
5802   This is an uninteresting sentence.
5803 @endExample
5805 @noindent
5806 is formatted as
5808 @Example
5809   This is  an uninteresting  sentence.   This  is an
5810   uninteresting                            sentence.
5811   This is an uninteresting sentence.
5812 @endExample
5813 @endDefesc
5815 @cindex word space size register (@code{.ss})
5816 @cindex size of word space register (@code{.ss})
5817 @cindex space between words register (@code{.ss})
5818 @cindex sentence space size register (@code{.sss})
5819 @cindex size of sentence space register (@code{.sss})
5820 @cindex space between sentences register (@code{.sss})
5821 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5822 @DefregItem {.ss}
5823 @DefregListEnd {.sss}
5824 Change the minimum size of a space between filled words.  It takes its
5825 units as one twelfth of the space width parameter for the current
5826 font.  Initially both the @var{word_space_size} and
5827 @var{sentence_space_size} are@w{ }12.
5829 @cindex fill mode
5830 @cindex mode, fill
5831 If two arguments are given to the @code{ss} request, the second
5832 argument sets the sentence space size.  If the second argument is not
5833 given, sentence space size is set to @var{word_space_size}.  The
5834 sentence space size is used in two circumstances: If the end of a
5835 sentence occurs at the end of a line in fill mode, then both an
5836 inter-word space and a sentence space are added; if two spaces follow
5837 the end of a sentence in the middle of a line, then the second space
5838 is a sentence space.  If a second argument is never given to the
5839 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5840 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5841 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5842 by either a newline or two spaces.
5844 The read-only number registers @code{.ss} and @code{.sss} hold the
5845 values of the parameters set by the first and second arguments of the
5846 @code{ss} request.
5848 The word space and sentence space values are associated with the current
5849 environment (@pxref{Environments}).
5851 Contrary to traditional Unix @code{troff}, this request is @emph{not}
5852 ignored if a tty output device is used; the given values are then
5853 rounded down to a multiple of@w{ }12.
5855 @c XXX xref implementation differences
5857 The request is ignored if there is no parameter.
5858 @endDefreq
5860 @cindex centering lines (@code{ce})
5861 @cindex lines, centering (@code{ce})
5862 @DefreqList {ce, [@Var{nnn}]}
5863 @DefregListEnd {.ce}
5864 Center text.  While the @w{@samp{.ad c}} request also centers text,
5865 it fills the text as well.  @code{ce} does not fill the
5866 text it affects.  This request causes a break.
5868 The following example demonstrates the differences.
5869 Here the input:
5871 @Example
5872 .ll 4i
5873 .ce 1000
5874 This is a small text fragment which shows the differences
5875 between the `.ce' and the `.ad c' request.
5876 .ce 0
5878 .ad c
5879 This is a small text fragment which shows the differences
5880 between the `.ce' and the `.ad c' request.
5881 @endExample
5883 @noindent
5884 And here the result:
5886 @Example
5887   This is a small text fragment which
5888          shows the differences
5889 between the `.ce' and the `.ad c' request.
5891   This is a small text fragment which
5892 shows the differences between the `.ce'
5893         and the `.ad c' request.
5894 @endExample
5896 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
5897 specifies the number of lines to be centered.  If the argument is zero
5898 or negative, centering is disabled.
5900 The basic length for centering text is the line length (as set with the
5901 @code{ll} request) minus the indentation (as set with the @code{in}
5902 request).  Temporary indentation is ignored.
5904 As can be seen in the previous example, it is a common idiom to turn
5905 on centering for a large number of lines, and to turn off centering
5906 after text to be centered.  This is useful for any request which takes
5907 a number of lines as an argument.
5909 The @code{.ce} read-only number register contains the number of lines
5910 remaining to be centered, as set by the @code{ce} request.
5911 @endDefreq
5913 @cindex justifying text (@code{rj})
5914 @cindex text, justifying (@code{rj})
5915 @cindex right-justifying (@code{rj})
5916 @DefreqList {rj, [@Var{nnn}]}
5917 @DefregListEnd {.rj}
5918 Justify unfilled text to the right margin.  Arguments are identical to
5919 the @code{ce} request.  The @code{.rj} read-only number register is
5920 the number of lines to be right-justified as set by the @code{rj}
5921 request.  This request causes a break.
5922 @endDefreq
5925 @c =====================================================================
5927 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
5928 @section Manipulating Hyphenation
5929 @cindex manipulating hyphenation
5930 @cindex hyphenation, manipulating
5932 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
5933 There are a number of ways to influence hyphenation.
5935 @DefreqList {hy, [@Var{mode}]}
5936 @DefregListEnd {.hy}
5937 Enable hyphenation.  The request has an optional numeric argument,
5938 @var{mode}, to restrict hyphenation if necessary:
5940 @table @code
5941 @item 1
5942 The default argument if @var{mode} is omitted.  Hyphenate without
5943 restrictions.  This is also the start-up value of @code{gtroff}.
5945 @item 2
5946 Do not hyphenate the last word on a page or column.
5948 @item 4
5949 Do not hyphenate the last two characters of a word.
5951 @item 8
5952 Do not hyphenate the first two characters of a word.
5953 @end table
5955 Values in the previous table are additive.  For example, the value@w{
5956 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
5957 two characters of a word.
5959 @cindex hyphenation restrictions register (@code{.hy})
5960 The current hyphenation restrictions can be found in the read-only
5961 number register @samp{.hy}.
5963 The hyphenation mode is associated with the current environment
5964 (@pxref{Environments}).
5965 @endDefreq
5967 @Defreq {nh, }
5968 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
5969 that the hyphenation mode of the last call to @code{hy} is not
5970 remembered.
5972 The hyphenation mode is associated with the current environment
5973 (@pxref{Environments}).
5974 @endDefreq
5976 @cindex explicit hyphen (@code{\%})
5977 @cindex hyphen, explicit (@code{\%})
5978 @cindex consecutive hyphenated lines (@code{hlm})
5979 @cindex lines, consecutive hyphenated (@code{hlm})
5980 @cindex hyphenated lines, consecutive (@code{hlm})
5981 @DefreqList {hlm, [@Var{nnn}]}
5982 @DefregItem {.hlm}
5983 @DefregListEnd {.hlc}
5984 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
5985 If this number is negative, there is no maximum.  The default value
5986 is@w{ }@minus{}1 if @var{nnn} is omitted.  This value is associated
5987 with the current environment (@pxref{Environments}).  Only lines
5988 output from a given environment count towards the maximum associated
5989 with that environment.  Hyphens resulting from @code{\%} are counted;
5990 explicit hyphens are not.
5992 The current setting of @code{hlm} is available in the @code{.hlm}
5993 read-only number register.  Also the number of immediately preceding
5994 consecutive hyphenated lines are available in the read-only number
5995 register @samp{.hlc}.
5996 @endDefreq
5998 @Defreq {hw, word1 word2 @dots{}}
5999 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
6000 words must be given with hyphens at the hyphenation points.  For
6001 example:
6003 @Example
6004 .hw in-sa-lub-rious
6005 @endExample
6007 @noindent
6008 Besides the space character, any character whose hyphenation code value
6009 is zero can be used to separate the arguments of @code{hw} (see the
6010 documentation for the @code{hcode} request below for more information).
6011 In addition, this request can be used more than once.
6013 Hyphenation exceptions specified with the @code{hw} request are
6014 associated with the current hyphenation language; it causes an error
6015 if there is no current hyphenation language.
6017 This request is ignored if there is no parameter.
6019 In old versions of @code{troff} there was a limited amount of space to
6020 store such information; fortunately, with @code{gtroff}, this is no
6021 longer a restriction.
6022 @endDefreq
6024 @cindex hyphenation character (@code{\%})
6025 @cindex character, hyphenation (@code{\%})
6026 @cindex disabling hyphenation (@code{\%})
6027 @cindex hyphenation, disabling (@code{\%})
6028 @Defesc {\\%, , , }
6029 To tell @code{gtroff} how to hyphenate words on the fly, use the
6030 @code{\%} escape, also known as the @dfn{hyphenation character}.
6031 Preceding a word with this character prevents it from being
6032 hyphenated; putting it inside a word indicates to @code{gtroff} that
6033 the word may be hyphenated at that point.  Note that this mechanism
6034 only affects that one occurrence of the word; to change the
6035 hyphenation of a word for the entire document, use the @code{hw}
6036 request.
6037 @endDefesc
6039 @Defreq {hc, [@Var{char}]}
6040 Change the hyphenation character to @var{char}.  This character then
6041 works the same as the @code{\%} escape, and thus, no longer appears in
6042 the output.  Without an argument, @code{hc} resets the hyphenation
6043 character to be @code{\%} (the default) only.
6045 The hyphenation character is associated with the current environment
6046 (@pxref{Environments}).
6047 @endDefreq
6049 @cindex hyphenation patterns (@code{hpf})
6050 @cindex patterns for hyphenation (@code{hpf})
6051 @Defreq {hpf, pattern_file}
6052 Read in a file of hyphenation patterns.  This file is searched for in
6053 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6054 searched for if the @option{-m@var{name}} option is specified.
6056 It should have the same format as the argument to the @code{\patterns}
6057 primitive in @TeX{} (without using @TeX{}'s macro expansion); the
6058 letters appearing in this file are interpreted as hyphenation codes.  A
6059 @samp{%} character in the patterns file introduces a comment that
6060 continues to the end of the line.
6062 If no @code{hpf} request is specified (either in the document or in a
6063 macro package), @code{gtroff} won't hyphenate at all.
6065 @pindex troffrc
6066 @pindex troffrc-end
6067 @pindex hyphen.us
6068 The set of hyphenation patterns is associated with the current language
6069 set by the @code{hla} request.  The @code{hpf} request is usually
6070 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6071 @file{troffrc} loads hyphenation patterns for American English (in file
6072 @file{hyphen.us}).
6074 Invoking @code{hpf} causes an error if there is no current hyphenation
6075 language.
6076 @endDefreq
6078 @cindex hyphenation code (@code{hcode})
6079 @cindex code, hyphenation (@code{hcode})
6080 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6081 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6082 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6083 input character (not a special character) other than a digit or a
6084 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6085 hyphenation set to itself, and each upper-case letter
6086 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6087 version of itself.
6089 This request is ignored if it has no parameter.
6090 @endDefreq
6092 @cindex hyphenation margin (@code{hym})
6093 @cindex margin for hyphenation (@code{hym})
6094 @cindex @code{ad} request, and hyphenation margin
6095 @DefreqList {hym, [@Var{length}]}
6096 @DefregListEnd {.hym}
6097 Set the (right) hyphenation margin to @var{length}.  If the current
6098 adjustment mode is not @samp{b} or @samp{n}, the line is not
6099 hyphenated if it is shorter than @var{length}.  Without an argument,
6100 the hyphenation margin is reset to its default value, which is@w{ }0.
6101 The default scaling indicator for this request is @samp{m}.  The
6102 hyphenation margin is associated with the current environment
6103 (@pxref{Environments}).
6105 A negative argument resets the hyphenation margin to zero, emitting
6106 a warning of type @samp{range}.
6108 @cindex hyphenation margin register (@code{.hym})
6109 The current hyphenation margin is available in the @code{.hym} read-only
6110 number register.
6111 @endDefreq
6113 @cindex hyphenation space (@code{hys})
6114 @cindex @code{ad} request, and hyphenation space
6115 @DefreqList {hys, [@Var{hyphenation_space}]}
6116 @DefregListEnd {.hys}
6117 Set the hyphenation space to @var{hyphenation_space}.  If the current
6118 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6119 if it can be justified by adding no more than @var{hyphenation_space}
6120 extra space to each word space.  Without argument, the hyphenation
6121 space is set to its default value, which is@w{ }0.  The default
6122 scaling indicator for this request is @samp{m}.  The hyphenation
6123 space is associated with the current environment
6124 (@pxref{Environments}).
6126 A negative argument resets the hyphenation space to zero, emitting a
6127 warning of type @samp{range}.
6129 @cindex hyphenation space register (@code{.hys})
6130 The current hyphenation space is available in the @code{.hys} read-only
6131 number register.
6132 @endDefreq
6134 @cindex soft hyphen character, setting (@code{shc})
6135 @cindex character, soft hyphen, setting (@code{shc})
6136 @cindex glyph, soft hyphen (@code{hy})
6137 @cindex soft hyphen glyph (@code{hy})
6138 @cindex @code{char} request, and soft hyphen character
6139 @cindex @code{tr} request, and soft hyphen character
6140 @Defreq {shc, [@Var{char}]}
6141 Set the soft hyphen character to @var{char}.  If the argument is
6142 omitted, the soft hyphen character is set to the default character
6143 @code{\(hy} (this is the start-up value of @code{gtroff} also).  The
6144 soft hyphen character is the character that is inserted when a word is
6145 hyphenated at a line break.  If the soft hyphen character does not
6146 exist in the font of the character immediately preceding a potential
6147 break point, then the line is not broken at that point.  Neither
6148 definitions (specified with the @code{char} request) nor translations
6149 (specified with the @code{tr} request) are considered when finding the
6150 soft hyphen character.
6151 @endDefreq
6153 @cindex @code{hpf} request, and hyphenation language
6154 @cindex @code{hw} request, and hyphenation language
6155 @pindex troffrc
6156 @pindex troffrc-end
6157 @DefreqList {hla, language}
6158 @DefregListEnd {.hla}
6159 Set the current hyphenation language to the string @var{language}.
6160 Hyphenation exceptions specified with the @code{hw} request and
6161 hyphenation patterns specified with the @code{hpf} request are both
6162 associated with the current hyphenation language.  The @code{hla}
6163 request is usually invoked by the @file{troffrc} or the
6164 @file{troffrc-end} files; @file{troffrc} sets the default language to
6165 @samp{us}.
6167 @cindex hyphenation language register (@code{.hla})
6168 The current hyphenation language is available as a string in the
6169 read-only number register @samp{.hla}.
6171 @Example
6172 .ds curr_language \n[.hla]
6173 \*[curr_language]
6174     @result{} us
6175 @endExample
6176 @endDefreq
6179 @c =====================================================================
6181 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6182 @section Manipulating Spacing
6183 @cindex manipulating spacing
6184 @cindex spacing, manipulating
6186 @Defreq {sp, [@Var{distance}]}
6187 Space downwards @var{distance}.  With no argument it advances 1@w{
6188 }line.  A negative argument causes @code{gtroff} to move up the page
6189 the specified distance.  If the argument is preceded by a @samp{|}
6190 then @code{gtroff} moves that distance from the top of the page.  This
6191 request causes a line break.  The default scaling indicator is @samp{v}.
6192 @endDefreq
6194 @cindex double spacing (@code{ls})
6195 @DefreqList {ls, [@Var{nnn}]}
6196 @DefregListEnd {.L}
6197 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6198 With no argument, @code{gtroff} uses the previous value before the
6199 last @code{ls} call.
6201 @Example
6202 .ls 2    \" This causes double-spaced output
6203 .ls 3    \" This causes triple-spaced output
6204 .ls      \" Again double spaced
6205 @endExample
6207 The line spacing is associated with the current environment
6208 (@pxref{Environments}).
6210 @cindex line spacing register (@code{.L})
6211 The read-only number register @code{.L} contains the current line
6212 spacing setting.
6213 @endDefreq
6215 @c XXX document \n[nl]
6216 @c XXX document \n[nl] == -1 if vertical position is zero
6218 @DefescList {\\x, ', spacing, '}
6219 @DefregListEnd {.a}
6220 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6221 to allow space for a tall construct (like an equation).  The @code{\x}
6222 escape does this.  The escape is given a numerical argument, usually
6223 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6224 is @samp{v}.  If this number is positive extra vertical space is
6225 inserted below the current line.  A negative number adds space above.
6226 If this escape is used multiple times on the same line, the maximum of
6227 the values is used.
6229 @xref{Escapes}, for details on parameter delimiting characters.
6231 @cindex extra vertical line space register (@code{.a})
6232 The @code{.a} read-only number register contains the most recent
6233 (nonnegative) extra vertical line space.
6235 @c XXX
6236 @ignore
6237 @Example
6238 ... example of inline equation ...
6239 @endExample
6240 @end ignore
6241 @endDefesc
6243 @cindex @code{sp} request, and no-space mode
6244 @cindex no-space mode (@code{ns})
6245 @cindex mode, no-space (@code{ns})
6246 @cindex blank lines, disabling
6247 @cindex lines, blank, disabling
6248 @DefreqList {ns, }
6249 @DefregListEnd {.ns}
6250 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6251 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6252 advance to the next page is also disabled, except if it is accompanied
6253 by a page number (see @ref{Page Control}, for more information).  This
6254 mode ends when actual text is output or the @code{rs} request is
6255 encountered.  The read-only number register @code{.ns} is set to@w{ }1.
6257 This request is useful for macros which want to avoid that subsequent
6258 macros inadvertently insert some vertical space before the text starts
6259 (for example, to set up the first paragraph after a section header).
6261 @c XXX xref
6262 @endDefreq
6264 @Defreq {rs, }
6265 Disable no-space mode.
6267 @c XXX xref
6268 @endDefreq
6271 @c =====================================================================
6273 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6274 @section Tabs and Fields
6275 @cindex tabs and fields
6276 @cindex fields and tabs
6278 @cindex @acronym{EBCDIC} encoding of a tab
6279 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6280 }5) causes a horizontal movement to the next tab stop (much
6281 like it did on a typewriter).
6283 @cindex tab character, non-interpreted (@code{\t})
6284 @Defesc {\\t, , , }
6285 This escape is a non-interpreted tab character.  In copy mode
6286 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6287 @endDefesc
6289 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6290 @DefregListEnd {.tabs}
6291 Change tab stop positions.  This request takes a series of tab
6292 specifiers as arguments (optionally divided into two groups with the
6293 letter @samp{T}) which indicate where each tab stop is to be
6294 (overriding any previous settings).
6296 Tab stops can be specified absolutely, i.e., as the distance from the
6297 left margin.  For example, the following sets 6@w{ }tab stops every
6298 one inch.
6300 @Example
6301 .ta 1i 2i 3i 4i 5i 6i
6302 @endExample
6304 Tab stops can also be specified using a leading @samp{+}
6305 which means that the specified tab stop is set relative to
6306 the previous tab stop.  For example, the following is equivalent to the
6307 previous example.
6309 @Example
6310 .ta 1i +1i +1i +1i +1i +1i
6311 @endExample
6313 @code{gtroff} supports an extended syntax to specify repeat values after
6314 the @samp{T} mark (these values are always taken as relative) -- this is
6315 the usual way to specify tabs set at equal intervals.  The following is,
6316 yet again, the same as the previous examples.  It does even more since
6317 it defines an infinite number of tab stops separated by one inch.
6319 @Example
6320 .ta T 1i
6321 @endExample
6323 Now we are ready to interpret the full syntax given at the beginning:
6324 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6325 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6326 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6327 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6329 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6330 20c 23c 28c 30c @dots{}}.
6332 The material in each tab column (i.e., the column between two tab stops)
6333 may be justified to the right or left or centered in the column.  This
6334 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6335 specifier.  The default justification is @samp{L}.  Example:
6337 @Example
6338 .ta 1i 2iC 2iR
6339 @endExample
6341 Some notes:
6343 @itemize @bullet
6344 @item
6345 The default unit of the @code{ta} request is @samp{m}.
6347 @item
6348 A tab stop is converted into a non-breakable horizontal movement which
6349 can be neither stretched nor squeezed.  For example,
6351 @Example
6352 .ds foo a\tb\tc
6353 .ta T 5i
6354 \*[foo]
6355 @endExample
6357 @noindent
6358 creates a single line which is a bit longer than 10@w{ }inches (a string
6359 is used to show exactly where the tab characters are).  Now consider the
6360 following:
6362 @Example
6363 .ds bar a\tb b\tc
6364 .ta T 5i
6365 \*[bar]
6366 @endExample
6368 @noindent
6369 @code{gtroff} first converts the tab stops of the line into unbreakable
6370 horizontal movements, then splits the line after the second @samp{b}
6371 (assuming a sufficiently short line length).  Usually, this isn't what
6372 the user wants.
6374 @item
6375 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6376 stop) are ignored except the first one which delimits the characters
6377 belonging to the last tab stop for right-justifying or centering.
6378 Consider the following example
6380 @Example
6381 .ds Z   foo\tbar\tfoo
6382 .ds ZZ  foo\tbar\tfoobar
6383 .ds ZZZ foo\tbar\tfoo\tbar
6384 .ta 2i 4iR
6385 \*[Z]
6387 \*[ZZ]
6389 \*[ZZZ]
6391 @endExample
6393 @noindent
6394 which produces the following output:
6396 @Example
6397 foo                 bar              foo
6398 foo                 bar           foobar
6399 foo                 bar              foobar
6400 @endExample
6402 @noindent
6403 The first line right-justifies the second `foo' relative to the tab
6404 stop.  The second line right-justifies `foobar'.  The third line finally
6405 right-justifies only `foo' because of the additional tab character which
6406 marks the end of the string belonging to the last defined tab stop.
6408 @item
6409 Tab stops are associated with the current environment
6410 (@pxref{Environments}).
6412 @item
6413 Calling @code{ta} without an argument removes all tab stops.
6415 @item
6416 @cindex tab stops, for tty output devices
6417 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}}.  This value
6418 is used even for tty output devices (contrary to @acronym{UNIX}
6419 @code{nroff} which has tab stops preset every 0.8@dmn{i}).
6421 @c XXX xref implementation differences
6422 @end itemize
6424 @cindex tab settings register (@code{.tabs})
6425 The read-only number register @code{.tabs} contains a string
6426 representation of the current tab settings suitable for use as an
6427 argument to the @code{ta} request.
6429 @Example
6430 .ds tab-string \n[.tabs]
6431 \*[tab-string]
6432     @result{} T120u
6433 @endExample
6434 @endDefreq
6436 @cindex tab repetition character (@code{tc})
6437 @cindex character, tab repetition (@code{tc})
6438 @Defreq {tc, [@Var{fill-char}]}
6439 Normally @code{gtroff} fills the space to the next tab stop with
6440 whitespace.  This can be changed with the @code{tc} request.  With no
6441 argument @code{gtroff} reverts to using whitespace, which is the
6442 default.  The value of this @dfn{tab repetition} character is
6443 associated with the current environment (@pxref{Environments}).
6444 @endDefreq
6446 @menu
6447 * Leaders::
6448 * Fields::
6449 @end menu
6451 @c ---------------------------------------------------------------------
6453 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6454 @subsection Leaders
6455 @cindex leaders
6457 Sometimes it may may be desirable to use the @code{tc} request to fill a
6458 particular tab stop with a given character (for example dots in a table
6459 of contents), but also normal tab stops on the rest of the line.  For
6460 this @code{gtroff} provides an alternate tab mechanism, called
6461 @dfn{leaders} which does just that.
6463 @cindex leader character
6464 A leader character (character code@w{ }1) behaves similarly to a tab
6465 character: It moves to the next tab stop.  The only difference is that
6466 for this movement, the fill character defaults to a period character and
6467 not to space.
6469 @cindex leader character, non-interpreted (@code{\a})
6470 @Defesc {\\a, , , }
6471 This escape is a non-interpreted leader character.  In copy mode
6472 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6473 character.
6474 @endDefesc
6476 @cindex leader repetition character (@code{lc})
6477 @cindex character, leader repetition (@code{lc})
6478 @Defreq {lc, [@Var{fill-char}]}
6479 Declare the leader character.  Without an argument, leaders act the
6480 same as tabs (i.e., using whitespace for filling).  @code{gtroff}'s
6481 start-up value is @samp{.}.  The value of this @dfn{leader repetition}
6482 character is associated with the current environment
6483 (@pxref{Environments}).
6484 @endDefreq
6486 @cindex table of contents
6487 @cindex contents, table of
6488 For a table of contents, to name an example, tab stops may be defined so
6489 that the section number is one tab stop, the title is the second with
6490 the remaining space being filled with a line of dots, and then the page
6491 number slightly separated from the dots.
6493 @Example
6494 .ds entry 1.1\tFoo\a\t12
6495 .lc .
6496 .ta 1i 5i +.25i
6497 \*[entry]
6498 @endExample
6500 @noindent
6501 This produces
6503 @Example
6504 1.1  Foo..........................................  12
6505 @endExample
6507 @c ---------------------------------------------------------------------
6509 @node Fields,  , Leaders, Tabs and Fields
6510 @subsection Fields
6511 @cindex fields
6513 @cindex field delimiting character (@code{fc})
6514 @cindex delimiting character for fields (@code{fc})
6515 @cindex character, field delimiting (@code{fc})
6516 @cindex field padding character (@code{fc})
6517 @cindex padding character for fields (@code{fc})
6518 @cindex character, field padding (@code{fc})
6519 @dfn{Fields} are a more general way of laying out tabular data.  A field
6520 is defined as the data between a pair of @dfn{delimiting characters}.
6521 It contains substrings which are separated by @dfn{padding characters}.
6522 The width of a field is the distance on the @emph{input} line from the
6523 position where the field starts to the next tab stop.  A padding
6524 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6525 command (thus it can even be negative) to make the sum of all substring
6526 lengths plus the stretchable space equal to the field width.  If more
6527 than one padding character is inserted, the available space is evenly
6528 distributed among them.
6530 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6531 Define a delimiting and a padding character for fields.  If the latter
6532 is missing, the padding character defaults to a space character.  If
6533 there is no argument at all, the field mechanism is disabled (which is
6534 the default).  Note that contrary to e.g.@: the tab repetition
6535 character, delimiting and padding characters are not associated to the
6536 current environment (@pxref{Environments}).
6538 Example:
6540 @Example
6541 .fc # ^
6542 .ta T 3i
6543 #foo^bar^smurf#
6545 #foo^^bar^smurf#
6546 @endExample
6548 @noindent
6549 and here the result:
6551 @Example
6552 foo         bar          smurf
6553 foo            bar       smurf
6554 @endExample
6555 @endDefreq
6558 @c =====================================================================
6560 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6561 @section Character Translations
6562 @cindex character translations
6563 @cindex translations of characters
6565 @cindex control character, changing (@code{cc})
6566 @cindex character, control, changing (@code{cc})
6567 @cindex no-break control character, changing (@code{c2})
6568 @cindex character, no-break control, changing (@code{c2})
6569 @cindex control character, no-break, changing (@code{c2})
6570 The control character (@samp{.}) and the no-break control character
6571 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6572 respectively.
6574 @Defreq {cc, [@Var{c}]}
6575 Set the control character to@w{ }@var{c}.  With no argument the default
6576 control character @samp{.} is restored.  The value of the control
6577 character is associated with the current environment
6578 (@pxref{Environments}).
6579 @endDefreq
6581 @Defreq {c2, [@Var{c}]}
6582 Set the no-break control character to@w{ }@var{c}.  With no argument the
6583 default control character @samp{'} is restored.  The value of the
6584 no-break control character is associated with the current environment
6585 (@pxref{Environments}).
6586 @endDefreq
6588 @cindex disabling @code{\\} (@code{eo})
6589 @cindex @code{\\}, disabling (@code{eo})
6590 @Defreq {eo, }
6591 Disable the escape mechanism completely.  After executing this
6592 request, the backslash character @samp{\} no longer starts an escape
6593 sequence.
6595 This request can be very helpful in writing macros since it is not
6596 necessary then to double the escape character.  Here an example:
6598 @Example
6599 .\" This is a simplified version of the
6600 .\" .BR request from the man macro package
6602 .de BR
6603 .  ds result \&
6604 .  while (\n[.$] >= 2) \@{\
6605 .    as result \fB\$1\fR\$2
6606 .    shift 2
6607 .  \@}
6608 .  if \n[.$] .as result \fB\$1
6609 \*[result]
6610 .  ft R
6613 @endExample
6614 @endDefreq
6616 @cindex escape character, changing (@code{ec})
6617 @cindex character, escape, changing (@code{ec})
6618 @Defreq {ec, [@Var{c}]}
6619 Set the escape character to@w{ }@var{c}.  With no argument the default
6620 escape character @samp{\} is restored.  It can be also used to
6621 re-enable the escape mechanism after an @code{eo} request.
6623 Note that changing the escape character globally will likely break
6624 macro packages since @code{gtroff} has no mechanism (like @TeX{}) to
6625 `intern' macros, i.e., to convert a macro definition into an internal
6626 form which is independent of its representation.  If a macro is
6627 called, it is executed literally.
6628 @endDefreq
6630 @Defesc {\\e, , , }
6631 This escape sequence prints the current escape character (which is the
6632 backslash character @samp{\} by default).
6633 @endDefesc
6635 A @dfn{translation} is a mapping of an input character to an output
6636 character.  The default mappings are given in the font definition files
6637 for the specific output device (@pxref{Font Files}); all mappings (both
6638 with @code{tr} and in the font definition files) occur at output time,
6639 i.e., the input character gets assigned the metric information of the
6640 mapped output character.
6642 @Defreq {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6643 Translate character @var{a} to@w{ }@var{b}, character @var{c} to@w{
6644 }@var{d}, etc.  If there is an odd number of arguments, the last one is
6645 translated to the space character.
6647 Some notes:
6649 @itemize @bullet
6650 @item
6651 @cindex @code{\(}, and translations
6652 @cindex @code{\[}, and translations
6653 @cindex @code{\'}, and translations
6654 @cindex @code{\`}, and translations
6655 @cindex @code{\-}, and translations
6656 @cindex @code{\_}, and translations
6657 @cindex @code{\C}, and translations
6658 @cindex @code{\N}, and translations
6659 @cindex @code{char} request, and translations
6660 @cindex special character
6661 @cindex character, special
6662 @cindex numbered character (@code{\N})
6663 @cindex character, numbered (@code{\N})
6664 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6665 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6666 characters defined with the @code{char} request, and numbered characters
6667 (@code{\N'@var{xxx}'}) can be translated also.
6669 @item
6670 @cindex @code{\e}, and translations
6671 The @code{\e} escape can be translated also.
6673 @item
6674 @cindex @code{\%}, and translations
6675 @cindex @code{\~}, and translations
6676 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
6677 @code{\%} and @code{\~} can't be mapped onto another character).
6679 @item
6680 @cindex backspace character and translations
6681 @cindex character, backspace, and translations
6682 @cindex leader character and translations
6683 @cindex character, leader, and translations
6684 @cindex newline character and translations
6685 @cindex character, newline, and translations
6686 @cindex tab character and translations
6687 @cindex character, tab, and translations
6688 @cindex @code{\a}, and translations
6689 @cindex @code{\t}, and translations
6690 The following characters can't be translated: space (with one exception,
6691 see below), backspace, newline, leader (and @code{\a}), tab (and
6692 @code{\t}).
6694 @item
6695 @cindex @code{shc} request, and translations
6696 Translations are not considered for finding the soft hyphen character
6697 set with the @code{shc} request.
6699 @item
6700 @cindex @code{\&}, and translations
6701 The character pair @samp{@var{c}\&} (this is an arbitrary character@w{
6702 }@var{c} followed by the zero width space character) maps this
6703 character to nothing.
6705 @Example
6706 .tr a\&
6707 foo bar
6708     @result{} foo br
6709 @endExample
6711 @noindent
6712 It is even possible to map the space character to nothing:
6714 @Example
6715 .tr aa \&
6716 foo bar
6717     @result{} foobar
6718 @endExample
6720 @noindent
6721 As shown in the example, the space character can't be the first
6722 character pair as an argument of @code{tr}.  Additionally, it is not
6723 possible to map the space character to any other character; requests
6724 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
6726 If justification is active, lines are justified in spite of the
6727 `empty' space character (but there is no minimal distance, i.e.@: the
6728 space character, between words).
6730 @item
6731 After an output character has been constructed (this happens at the
6732 moment immediately before the character is appended to an output
6733 character list, either by direct output, in a macro, diversion, or
6734 string), it is no longer affected by @code{tr}.
6736 @item
6737 Translating undefined characters is possible also; @code{tr} does not
6738 check whether the characters in its argument are defined.
6740 @c XXX xref
6742 @item
6743 Without an argument, the @code{tr} request is ignored.
6744 @end itemize
6745 @endDefreq
6747 @cindex @code{\!}, and @code{trnt}
6748 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6749 @code{trnt} is the same as the @code{tr} request except that the
6750 translations do not apply to text that is transparently throughput
6751 into a diversion with @code{\!}.  @xref{Diversions}, for more
6752 information.
6754 For example,
6756 @Example
6757 .tr ab
6758 .di x
6759 \!.tm a
6762 @endExample
6764 @noindent
6765 prints @samp{b} to the standard error stream; if @code{trnt} is used
6766 instead of @code{tr} it prints @samp{a}.
6767 @endDefreq
6770 @c =====================================================================
6772 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
6773 @section Troff and Nroff Mode
6774 @cindex troff mode
6775 @cindex mode, troff
6776 @cindex nroff mode
6777 @cindex mode, nroff
6779 Originally, @code{nroff} and @code{troff} were two separate programs,
6780 the former for tty output, the latter for everything else.  With GNU
6781 @code{troff}, both programs are merged into one executable, sending
6782 its output to a device driver (@code{grotty} for tty devices,
6783 @code{grops} for @sc{PostScript}, etc.) which interprets the
6784 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
6785 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
6786 since the differences are hardcoded.  For GNU @code{troff}, this
6787 distinction is not appropriate because @code{gtroff} simply takes the
6788 information given in the font files for a particular device without
6789 handling requests specially if a tty output device is used.
6791 Usually, a macro package can be used with all output devices.
6792 Nevertheless, it is sometimes necessary to make a distinction between
6793 tty and non-tty devices: @code{gtroff} provides two built-in
6794 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
6795 @code{while} requests to decide whether @code{gtroff} shall behave
6796 like @code{nroff} or like @code{troff}.
6798 @pindex troffrc
6799 @pindex troffrc-end
6800 @Defreq {troff, }
6801 Make the @samp{t} built-in condition true (and the @samp{n} built-in
6802 condition false) for @code{if}, @code{ie}, and @code{while}
6803 conditional requests.  This is the default if @code{gtroff}
6804 (@emph{not} @code{groff}) is started with the @option{-R} switch to
6805 avoid loading of the start-up files @file{troffrc} and
6806 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
6807 mode if the output device is not a tty (e.g.@: `ps').
6808 @endDefreq
6810 @pindex tty.tmac
6811 @Defreq {nroff, }
6812 Make the @samp{n} built-in condition true (and the @samp{t} built-in
6813 condition false) for @code{if}, @code{ie}, and @code{while}
6814 conditional requests.  This is the default if @code{gtroff} uses a tty
6815 output device; the code for switching to nroff mode is in the file
6816 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
6817 @endDefreq
6819 @xref{Conditionals and Loops}, for more details on built-in
6820 conditions.
6822 @c XXX move the following to grotty section
6824 @pindex less
6825 @cindex Teletype
6826 @cindex ISO 6249 SGR
6827 @cindex terminal control sequences
6828 @cindex control sequences, for terminals
6829 For tty output devices, underlining is done by emitting sequences of
6830 @samp{_} and @samp{\b} (the backspace character) before the actual
6831 character.  Literally, this is printing an underline character, then
6832 moving back one character position, and printing the actual character
6833 at the same position as the underline character (similar to a
6834 typewriter).  Usually, a modern terminal can't interpret this (and the
6835 original Teletype machines for which this sequence was appropriate are
6836 no longer in use).  You need a pager program like @code{less} which
6837 translates this into ISO 6429 SGR sequences to control terminals.
6839 @c =====================================================================
6841 @node Line Layout, Page Layout, Troff and Nroff Mode, gtroff Reference
6842 @section Line Layout
6843 @cindex line layout
6844 @cindex layout, line
6846 @cindex dimensions, line
6847 @cindex line dimensions
6848 The following drawing shows the dimensions which @code{gtroff} uses for
6849 placing a line of output onto the page.  They are labeled with the
6850 request which manipulates each dimension.
6852 @Example
6853                 -->| in |<--
6854                    |<-----------ll------------>|
6855               +----+----+----------------------+----+
6856               |    :    :                      :    |
6857               +----+----+----------------------+----+
6858            -->| po |<--
6859               |<--------paper width---------------->|
6860 @endExample
6862 @noindent
6863 These dimensions are:
6865 @ftable @code
6866 @item po
6867 @cindex left margin (@code{po})
6868 @cindex margin, left (@code{po})
6869 @cindex page offset (@code{po})
6870 @cindex offset, page (@code{po})
6871 @dfn{Page offset} -- this is the leftmost position of text on the final
6872 output, defining the @dfn{left margin}.
6874 @item in
6875 @cindex indentation (@code{in})
6876 @cindex line indentation (@code{in})
6877 @dfn{Indentation} -- this is the distance from the left margin where
6878 text is printed.
6880 @item ll
6881 @cindex line length (@code{ll})
6882 @cindex length of line (@code{ll})
6883 @dfn{Line length} -- this is the distance from the left margin to right
6884 margin.
6885 @end ftable
6887 @c XXX improve example
6889 @Example
6890 .in +.5i
6891 .ll -.5i
6892 A bunch of really boring text which should
6893 be indented from both margins.
6894 Replace me with a better (and more) example!
6895 .in -.5i
6896 .ll +.5i
6897 @endExample
6899 @pindex troffrc
6900 @DefreqList {po, [@Var{offset}]}
6901 @DefreqItem {po, @t{+}@Var{offset}}
6902 @DefreqItem {po, @t{-}@Var{offset}}
6903 @DefregListEnd {.o}
6904 Set horizontal page offset to @var{offset} (or increment or decrement
6905 the current value by @var{offset}).  Note that this request does not
6906 cause a break, so changing the page offset in the middle of text being
6907 filled may not yield the expected result.  The initial value is
6908 1@dmn{i}.  For tty output devices, it is set to 0 in the startup file
6909 @file{troffrc}; the default scaling indicator is @samp{m} (and
6910 not @samp{v} as incorrectly documented in the original
6911 @acronym{UNIX} troff manual).
6913 The current page offset can be found in the read-only number register
6914 @samp{.o}.
6916 If @code{po} is called without an argument, the page offset is reset to
6917 the previous value before the last call to @code{po}.
6919 @Example
6920 .po 3i
6921 \n[.o]
6922     @result{} 720
6923 .po -1i
6924 \n[.o]
6925     @result{} 480
6927 \n[.o]
6928     @result{} 720
6929 @endExample
6930 @endDefreq
6932 @DefreqList {in, [@Var{indent}]}
6933 @DefreqItem {in, @t{+}@Var{indent}}
6934 @DefreqItem {in, @t{-}@Var{indent}}
6935 @DefregListEnd {.i}
6936 Set indentation to @var{indent} (or increment or decrement the
6937 current value by @var{indent}).  This request causes a break.
6938 Initially, there is no indentation.
6940 If @code{in} is called without an argument, the indentation is reset to
6941 the previous value before the last call to @code{in}.  The default
6942 scaling indicator is @samp{m}.
6944 The indentation is associated with the current environment
6945 (@pxref{Environments}).
6947 If a negative indentation value is specified (which is not allowed),
6948 @code{gtroff} emits a warning of type @samp{range} and sets the
6949 indentation to zero.
6951 The effect of @code{in} is delayed until a partially collected line (if
6952 it exists) is output.  A temporary indent value is reset to zero also.
6954 The current indentation (as set by @code{in}) can be found in the
6955 read-only number register @samp{.i}.
6956 @endDefreq
6958 @DefreqList {ti, offset}
6959 @DefreqItem {ti, @t{+}@Var{offset}}
6960 @DefreqItem {ti, @t{-}@Var{offset}}
6961 @DefregListEnd {.in}
6962 Temporarily indent the next output line by @var{offset}.  If an
6963 increment or decrement value is specified, adjust the temporary
6964 indentation relative to the value set by the @code{in} request.
6966 This request causes a break; its value is associated with the current
6967 environment (@pxref{Environments}).  The default scaling indicator
6968 is @samp{m}.  A call of @code{ti} without an argument is ignored.
6970 If the total indentation value is negative (which is not allowed),
6971 @code{gtroff} emits a warning of type @samp{range} and sets the
6972 temporary indentation to zero.  `Total indentation' is either
6973 @var{offset} if specified as an absolute value, or the temporary plus
6974 normal indentation, if @var{offset} is given as a relative value.
6976 The effect of @code{ti} is delayed until a partially collected line (if
6977 it exists) is output.
6979 The read-only number register @code{.in} is the indentation that applies
6980 to the current output line.
6982 The difference between @code{.i} and @code{.in} is that the latter takes
6983 into account whether a partially collected line still uses the old
6984 indentation value or a temporary indentation value is active.
6985 @endDefreq
6987 @DefreqList {ll, [@Var{length}]}
6988 @DefreqItem {ll, @t{+}@Var{length}}
6989 @DefreqItem {ll, @t{-}@Var{length}}
6990 @DefregItem {.l}
6991 @DefregListEnd {.ll}
6992 Set the line length to @var{length} (or increment or decrement the
6993 current value by @var{length}).  Initially, the line length is set to
6994 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
6995 collected line (if it exists) is output.  The default scaling
6996 indicator is @samp{m}.
6998 If @code{ll} is called without an argument, the line length is reset to
6999 the previous value before the last call to @code{ll}.  If a negative
7000 line length is specified (which is not allowed), @code{gtroff} emits a
7001 warning of type @samp{range} and sets the line length to zero.
7003 The line length is associated with the current environment
7004 (@pxref{Environments}).
7006 @cindex line length register (@code{.l})
7007 The current line length (as set by @code{ll}) can be found in the
7008 read-only number register @samp{.l}.  The read-only number register
7009 @code{.ll} is the line length that applies to the current output line.
7011 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7012 and @code{.ll} is that the latter takes into account whether a partially
7013 collected line still uses the old line length value.
7014 @endDefreq
7017 @c =====================================================================
7019 @node Page Layout, Page Control, Line Layout, gtroff Reference
7020 @section Page Layout
7021 @cindex page layout
7022 @cindex layout, page
7024 @code{gtroff} provides some very primitive operations for controlling
7025 page layout.
7027 @cindex page length (@code{pl})
7028 @cindex length of page (@code{pl})
7029 @DefreqList {pl, [@Var{length}]}
7030 @DefreqItem {pl, @t{+}@Var{length}}
7031 @DefreqItem {pl, @t{-}@Var{length}}
7032 @DefregListEnd {.p}
7033 Set the @dfn{page length} to @var{length} (or increment or decrement
7034 the current value by @var{length}).  This is the length of the
7035 physical output page.  The default scaling indicator is @samp{v}.
7037 @cindex page length register (@code{.p})
7038 The current setting can be found in the read-only number register
7039 @samp{.p}.
7041 @cindex top margin
7042 @cindex margin, top
7043 @cindex bottom margin
7044 @cindex margin, bottom
7045 Note that this only specifies the size of the page, not the top and
7046 bottom margins.  Those are not set by @code{gtroff} directly.
7047 @xref{Traps}, for further information on how to do this.
7049 Negative @code{pl} values are possible also, but not very useful: No
7050 trap is sprung, and each line is output on a single page (thus
7051 suppressing all vertical spacing).
7053 If no argument or an invalid argument is given, @code{pl} sets the page
7054 length to 11@dmn{i}.
7055 @endDefreq
7057 @cindex headers
7058 @cindex footers
7059 @cindex titles
7060 @code{gtroff} provides several operations which help in setting up top
7061 and bottom titles (or headers and footers).
7063 @cindex title line (@code{tl})
7064 @cindex three-part title (@code{tl})
7065 @cindex page number character (@code{%})
7066 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7067 Print a @dfn{title line}.  It consists of three parts: a left
7068 justified portion, a centered portion, and a right justified portion.
7069 The argument separator @samp{'} can be replaced with any character not
7070 occurring in the title line.  The @samp{%} character is replaced with
7071 the current page number.  This character can be changed with the
7072 @code{pc} request (see below).
7074 Without argument, @code{tl} is ignored.
7076 Some notes:
7078 @itemize @bullet
7079 @item
7080 A title line is not restricted to the top or bottom of a page.
7082 @item
7083 @code{tl} prints the title line immediately, ignoring a partially filled
7084 line (which stays untouched).
7086 @item
7087 It is not an error to omit closing delimiters.  For example,
7088 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7089 title line with the left justified word @samp{foo}; the centered and
7090 right justfied parts are empty.
7092 @item
7093 Any modifications to the current environment within @code{tl} (e.g.@:
7094 changing the font or font size) are undone after processing @code{tl}.
7096 @item
7097 @code{tl} accepts the same parameter delimiting characters as the
7098 @code{\A} escape; see @ref{Escapes}.
7099 @end itemize
7100 @endDefreq
7102 @cindex length of title line (@code{lt})
7103 @cindex title line, length (@code{lt})
7104 @cindex title line length register (@code{.lt})
7105 @DefreqList {lt, [@Var{length}]}
7106 @DefreqItem {lt, @t{+}@Var{length}}
7107 @DefreqItem {lt, @t{-}@Var{length}}
7108 @DefregListEnd {.lt}
7109 The title line is printed using its own line length, which is
7110 specified (or incremented or decremented) with the @code{lt} request.
7111 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7112 line length is specified (which is not allowed), @code{gtroff} emits a
7113 warning of type @samp{range} and sets the title line length to zero.
7114 The default scaling indicator is @samp{m}.  If @code{lt} is called
7115 without an argument, the title length is reset to the previous value
7116 before the last call to @code{lt}.
7118 The current setting of this is available in the @code{.lt} read-only
7119 number register; it is associated with the current environment
7120 (@pxref{Environments}).
7122 @endDefreq
7124 @cindex page number (@code{pn})
7125 @cindex number, page (@code{pn})
7126 @DefreqList {pn, page}
7127 @DefreqItem {pn, @t{+}@Var{page}}
7128 @DefreqItem {pn, @t{-}@Var{page}}
7129 @DefregListEnd {.pn}
7130 Change (increase or decrease) the page number of the @emph{next} page.
7131 The only argument is the page number; the request is ignored without a
7132 parameter.
7134 The read-only number register @code{.pn} contains the number of the next
7135 page: either the value set by a @code{pn} request, or the number of the
7136 current page plus@w{ }1.
7137 @endDefreq
7139 @cindex page number register (@code{%})
7140 @Defreg {%}
7141 A read-write register holding the current page number.
7142 @endDefreg
7144 @cindex changing the page number character (@code{pc})
7145 @cindex page number character, changing (@code{pc})
7146 @vindex %
7147 @Defreq {pc, [@Var{char}]}
7148 Change the page number character (used by the @code{tl} request) to a
7149 different character.  With no argument, this mechanism is disabled.
7150 Note that this doesn't affect the number register@w{ }@code{%}.
7151 @endDefreq
7153 @xref{Traps}.
7156 @c =====================================================================
7158 @node Page Control, Fonts, Page Layout, gtroff Reference
7159 @section Page Control
7160 @cindex page control
7161 @cindex control, page
7163 @cindex new page (@code{bp})
7164 @cindex page, new (@code{bp})
7165 @DefreqList {bp, [@Var{page}]}
7166 @DefreqItem {bp, @t{+}@Var{page}}
7167 @DefreqListEnd {bp, @t{-}@Var{page}}
7168 Stop processing the current page and move to the next page.  This
7169 request causes a break.  It can also take an argument to set
7170 (increase, decrease) the page number of the next page.  The only
7171 difference between @code{bp} and @code{pn} is that @code{pn} does not
7172 cause a break or actually eject a page.
7174 @Example
7175 .de newpage                         \" define macro
7176 'bp                                 \" begin page
7177 'sp .5i                             \" vertical space
7178 .tl 'left top'center top'right top' \" title
7179 'sp .3i                             \" vertical space
7180 ..                                  \" end macro
7181 @endExample
7183 @cindex @code{bp} request, and top-level diversion
7184 @cindex top-level diversion and @code{bp}
7185 @cindex diversion, top-level, and @code{bp}
7186 @code{bp} has no effect if not called within the top-level diversion
7187 (@pxref{Diversions}).
7188 @endDefreq
7190 @cindex orphan lines, preventing with @code{ne}
7191 @cindex conditional page break (@code{ne})
7192 @cindex page break, conditional (@code{ne})
7193 @Defreq {ne, [@Var{space}]}
7194 It is often necessary to force a certain amount of space before a new
7195 page occurs.  This is most useful to make sure that there is not a
7196 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7197 request ensures that there is a certain distance, specified by the
7198 first argument, before the next page is triggered (see @ref{Traps},
7199 for further information).  The default unit for @code{ne} is @samp{v};
7200 the default value of @var{space} is@w{ }1@dmn{v} if no argument is
7201 given.
7203 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7204 do the following before each paragraph:
7206 @Example
7207 .ne 2
7208 text text text
7209 @endExample
7211 @code{ne} will then automatically cause a page break if there is space
7212 for one line only.
7213 @endDefreq
7215 @cindex @code{ne} request, comparison with @code{sv}
7216 @Defreq {sv, [@Var{space}]}
7217 @code{sv} is similar to the @code{ne} request; it reserves the
7218 specified amount of vertical space.  If the desired amount of space
7219 exists before the next trap (bottom page boundary), the space is
7220 output immediately (ignoring a partial filled line which stays
7221 untouched).  If there is not enough space, it is stored for later
7222 output via the @code{os} request.  The default value is@w{ }1@dmn{v}
7223 if no argument is given; the default unit is @samp{v}.
7224 @endDefreq
7227 @c =====================================================================
7229 @node Fonts, Sizes, Page Control, gtroff Reference
7230 @section Fonts
7231 @cindex fonts
7233 @code{gtroff} can switch fonts at any point in the text.
7235 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7236 These are Times Roman, Italic, Bold, and Bold Italic.  For non-tty
7237 devices, there is also at least one symbol font which contains various
7238 special symbols (Greek, mathematics).
7240 @menu
7241 * Changing Fonts::
7242 * Font Families::
7243 * Font Positions::
7244 * Using Symbols::
7245 * Special Fonts::
7246 * Artificial Fonts::
7247 * Ligatures and Kerning::
7248 @end menu
7250 @c ---------------------------------------------------------------------
7252 @node Changing Fonts, Font Families, Fonts, Fonts
7253 @subsection Changing Fonts
7254 @cindex fonts
7256 @cindex changing fonts (@code{ft}, @code{\f})
7257 @cindex fonts, changing (@code{ft}, @code{\f})
7258 @cindex @code{sty} request, and changing fonts
7259 @cindex @code{fam} request, and changing fonts
7260 @kindex styles
7261 @kindex family
7262 @pindex DESC
7263 @DefreqList {ft, [@Var{font}]}
7264 @DefescItem {\\f, , f, }
7265 @DefescItem {\\f, @lparen{}, fn, }
7266 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7267 The @code{ft} request and the @code{\f} escape change the current font
7268 to @var{font} (one-character name@w{ }@var{f}, two-character name
7269 @var{fn}).
7271 If @var{font} is a style name (as set with the @code{sty} request or
7272 with the @code{styles} command in the @file{DESC} file), use it within
7273 the current font family (as set with the @code{fam} request or with
7274 the @code{family} command in the @file{DESC} file).
7276 @cindex previous font (@code{ft}, @code{\fP})
7277 @cindex font, previous (@code{ft}, @code{\fP})
7278 With no argument or using @samp{P} as an argument, @code{.ft} switches
7279 to the previous font.  Use @code{\fP} or @code{\f[P]} to do this with
7280 the escape.
7282 Fonts are generally specified as upper-case strings, which are usually
7283 1@w{ }to 4 characters representing an abbreviation or acronym of the
7284 font name.  This is no limitation, just a convention.
7286 The example below produces two identical lines.
7288 @Example
7289 eggs, bacon,
7290 .ft B
7291 spam
7293 and sausage.
7295 eggs, bacon, \fBspam\fP and sausage.
7296 @endExample
7298 @xref{Font Positions}, for an alternative syntax.
7299 @endDefreq
7301 @cindex @code{ft} request, and font translations
7302 @cindex @code{ul} request, and font translations
7303 @cindex @code{bd} request, and font translations
7304 @cindex @code{\f}, and font translations
7305 @cindex @code{cs} request, and font translations
7306 @cindex @code{tkf} request, and font translations
7307 @cindex @code{special} request, and font translations
7308 @cindex @code{fspecial} request, and font translations
7309 @cindex @code{fp} request, and font translations
7310 @cindex @code{sty} request, and font translations
7311 @Defreq {ftr, f [@Var{g}]}
7312 Translate font@w{ }@var{f} to font@w{ }@var{g}.  Whenever a font named@w{
7313 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7314 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7315 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7316 font@w{ }@var{g} is used.  If @var{g} is missing or equal to@w{ }@var{f}
7317 the translation is undone.
7318 @endDefreq
7320 @c ---------------------------------------------------------------------
7322 @node Font Families, Font Positions, Changing Fonts, Fonts
7323 @subsection Font Families
7324 @cindex font families
7325 @cindex families, font
7326 @cindex font styles
7327 @cindex styles, font
7329 Due to the variety of fonts available, @code{gtroff} has added the
7330 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7331 specified as the concatenation of the font family and style.  Specifying
7332 a font without the family part causes @code{gtroff} to use that style of
7333 the current family.
7335 @cindex postscript fonts
7336 @cindex fonts, postscript
7337 Currently, only @sc{PostScript} fonts are set up to this mechanism.
7338 By default, @code{gtroff} uses the Times family with the four styles
7339 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7341 This way, it is possible to use the basic four fonts and to select a
7342 different font family on the command line (@pxref{Groff Options}).
7344 @cindex changing font family (@code{fam})
7345 @cindex font family, changing (@code{fam})
7346 @DefreqList {fam, [@Var{family}]}
7347 @DefregListEnd {.fam}
7348 Switch font family to @var{family}.  If no argument is given, switch
7349 back to the previous font family.  The value at start-up is @samp{T}.
7350 The current font family is available in the read-only number register
7351 @samp{.fam} (this is a string-valued register); it is associated with
7352 the current environment.
7354 @Example
7355 spam,
7356 .fam H    \" helvetica family
7357 spam,     \" used font is family H + style R = HR
7358 .ft B     \" family H + style B = font HB
7359 spam,
7360 .fam T    \" times family
7361 spam,     \" used font is family T + style B = TB
7362 .ft AR    \" font AR (not a style)
7363 baked beans,
7364 .ft R     \" family T + style R = font TR
7365 and spam.
7366 @endExample
7367 @endDefreq
7369 @cindex changing font style (@code{sty})
7370 @cindex font style, changing (@code{sty})
7371 @cindex @code{cs} request, and font styles
7372 @cindex @code{bd} request, and font styles
7373 @cindex @code{tkf} request, and font styles
7374 @cindex @code{uf} request, and font styles
7375 @cindex @code{fspecial} request, and font styles
7376 @Defreq {sty, n style}
7377 Associate @var{style} with font position@w{ }@var{n}.  A font position
7378 can be associated either with a font or with a style.  The current
7379 font is the index of a font position and so is also either a font or a
7380 style.  If it is a style, the font that is actually used is the font
7381 which name is the concatenation of the name of the current
7382 family and the name of the current style.  For example, if the current
7383 font is@w{ }1 and font position@w{ }1 is associated with style
7384 @samp{R} and the current font family is @samp{T}, then font
7385 @samp{TR} will be used.  If the current font is not a style, then the
7386 current family is ignored.  If the requests @code{cs}, @code{bd},
7387 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7388 they will instead be applied to the member of the current family
7389 corresponding to that style.
7391 @var{n}@w{ }must be a non-negative integer value.
7393 @pindex DESC
7394 @kindex styles
7395 The default family can be set with the @option{-f} option
7396 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7397 file controls which font positions (if any) are initially associated
7398 with styles rather than fonts.  For example, the default setting for
7399 @sc{PostScript} fonts
7401 @Example
7402 styles R I B BI
7403 @endExample
7405 @noindent
7406 is equivalent to
7408 @Example
7409 .sty 1 R
7410 .sty 2 I
7411 .sty 3 B
7412 .sty 4 BI
7413 @endExample
7415 @code{.fam} always checks whether the current font position is valid;
7416 this can give surprising results if the current font position is
7417 associated with a style.
7419 In the following example, we want to access the @sc{PostScript} font
7420 @code{FooBar} from the font family @code{Foo}:
7422 @Example
7423 .sty \n[.fp] Bar
7424 .fam Foo
7425     @result{} warning: can't find font `FooR'
7426 @endExample
7428 @noindent
7429 The default font position at start-up is@w{ }1; for the
7430 @sc{PostScript} device, this is associated with style @samp{R}, so
7431 @code{gtroff} tries to open @code{FooR}.
7433 A solution to this problem is to use a dummy font like the following:
7435 @Example
7436 .fp 0 dummy TR    \" set up dummy font at position 0
7437 .sty \n[.fp] Bar  \" register style `Bar'
7438 .ft 0             \" switch to font at position 0
7439 .fam Foo          \" activate family `Foo'
7440 .ft Bar           \" switch to font `FooBar'
7441 @endExample
7443 @xref{Font Positions}.
7444 @endDefreq
7446 @c ---------------------------------------------------------------------
7448 @node Font Positions, Using Symbols, Font Families, Fonts
7449 @subsection Font Positions
7450 @cindex font positions
7451 @cindex positions, font
7453 For the sake of old phototypesetters and compatibility with old versions
7454 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7455 on which various fonts are mounted.
7457 @cindex mounting font (@code{fp})
7458 @cindex font, mounting (@code{fp})
7459 @DefreqList {fp, pos font [@Var{external-name}]}
7460 @DefregItem {.f}
7461 @DefregListEnd {.fp}
7462 Mount font @var{font} at position @var{pos} (which must be a
7463 non-negative integer).  This numeric position can then be referred to
7464 with font changing commands.  When @code{gtroff} starts it is using
7465 font position@w{ }1 (which must exist; position@w{ }0 is unused
7466 usually at start-up).
7468 @cindex font position register (@code{.f})
7469 The current font in use, as a font position, is available in the
7470 read-only number register @samp{.f}.  This can be useful to remember the
7471 current font for later recall.  It is associated with the current
7472 environment (@pxref{Environments}).
7474 @Example
7475 .nr save-font \n[.f]
7476 .ft B
7477 ... text text text ...
7478 .ft \n[save-font]
7479 @endExample
7481 @cindex next free font position register (@code{.fp})
7482 The number of the next free font position is available in the read-only
7483 number register @samp{.fp}.  This is useful when mounting a new font,
7484 like so:
7486 @Example
7487 .fp \n[.fp] NEATOFONT
7488 @endExample
7490 @pindex DESC@r{, and font mounting}
7491 Fonts not listed in the @file{DESC} file are automatically mounted on
7492 the next available font position when they are referenced.  If a font
7493 is to be mounted explicitly with the @code{fp} request on an unused
7494 font position, it should be mounted on the first unused font position,
7495 which can be found in the @code{.fp} register.  Although @code{gtroff}
7496 does not enforce this strictly, it is not allowed to mount a font at a
7497 position whose number is much greater (approx.@: 1000 positions) than
7498 that of any currently used position.
7500 The @code{fp} request has an optional third argument.  This argument
7501 gives the external name of the font, which is used for finding the font
7502 description file.  The second argument gives the internal name of the
7503 font which is used to refer to the font in @code{gtroff} after it has
7504 been mounted.  If there is no third argument then the internal name is
7505 used as the external name.  This feature makes it possible to use
7506 fonts with long names in compatibility mode.
7507 @endDefreq
7509 Both the @code{ft} request and the @code{\f} escape have alternative
7510 syntax forms to access font positions.
7512 @cindex changing font position (@code{\f})
7513 @cindex font position, changing (@code{\f})
7514 @cindex @code{sty} request, and font positions
7515 @cindex @code{fam} request, and font positions
7516 @kindex styles
7517 @kindex family
7518 @pindex DESC
7519 @DefreqList {ft, nnn}
7520 @DefescItem {\\f, , n, }
7521 @DefescItem {\\f, @lparen{}, nn, }
7522 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
7523 Change the current font position to @var{nnn} (one-digit position@w{
7524 }@var{n}, two-digit position @var{nn}), which must be a non-negative
7525 integer.
7527 If @var{nnn} is associated with a style (as set with the @code{sty}
7528 request or with the @code{styles} command in the @file{DESC} file), use
7529 it within the current font family (as set with the @code{fam} request or
7530 with the @code{family} command in the @file{DESC} file).
7532 @Example
7533 this is font 1
7534 .ft 2
7535 this is font 2
7536 .ft                   \" switch back to font 1
7537 .ft 3
7538 this is font 3
7540 this is font 1 again
7541 @endExample
7543 @xref{Changing Fonts}, for the standard syntax form.
7544 @endDefreq
7546 @c ---------------------------------------------------------------------
7548 @node Using Symbols, Special Fonts, Font Positions, Fonts
7549 @subsection Using Symbols
7550 @cindex using symbols
7551 @cindex symbols, using
7553 @cindex glyph
7554 @cindex character
7555 @cindex ligature
7556 A @dfn{glyph} is a graphical representation of a @dfn{character}.
7557 While a character is an abstract entity containing semantic
7558 information, a glyph is something which can be actually seen on screen
7559 or paper.  It is possible that a character has multiple glyph
7560 representation forms (for example, the character `A' can be either
7561 written in a roman or an italic font, yielding two different glyphs);
7562 sometimes more than one character maps to a single glyph (this is a
7563 @dfn{ligature} -- the most common is `fi').
7565 @c XXX
7567 Please note that currently the distinction between glyphs and
7568 characters in this reference is not clearly carried out.  This will be
7569 improved eventually in the next revision.
7571 @cindex symbol
7572 @cindex special fonts
7573 @kindex fonts
7574 @pindex DESC
7575 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
7576 glyph names of a particular font are defined in its font file.  If the
7577 user requests a glyph not available in this font, @code{gtroff} looks
7578 up an ordered list of @dfn{special fonts}.  By default, the
7579 @sc{PostScript} output device supports the two special fonts @samp{SS}
7580 (slanted symbols) and @samp{S} (symbols) (the former is looked up
7581 before the latter).  Other output devices use different names for
7582 special fonts.  Fonts mounted with the @code{fonts} keyword in the
7583 @file{DESC} file are globally available.  To install additional
7584 special fonts locally (i.e.@: for a particular font), use the
7585 @code{fspecial} request.
7587 In summary, @code{gtroff} tries the following to find a given symbol:
7589 @itemize @bullet
7590 @item
7591 If the symbol has been defined with the @code{char} request, use it.
7592 This hides a symbol with the same name in the current font.
7594 @item
7595 Check the current font.
7597 @item
7598 If the symbol has been defined with the @code{fchar} request, use it.
7600 @item
7601 Check all fonts given with the @code{fspecial} request, in the order
7602 of appearance in @code{fspecial} calls.
7604 @item
7605 Check all fonts given with the @code{special} request, in the order
7606 of appearance in @code{special} calls (inclusively the special fonts
7607 defined in the @file{DESC} file, which come first).
7609 @item
7610 As a last resort, consult all fonts loaded up to now (in the order they
7611 have been called the first time) for special fonts and check them.
7612 @end itemize
7614 @xref{Font Files}, and @ref{Special Fonts}, for more details.
7616 @DefescList {\\, @lparen{}, nm, }
7617 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
7618 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
7619 special syntax for one-character names -- the natural form
7620 @samp{\@var{n}} would collide with escapes.
7622 If @var{name} is undefined, a warning of type @samp{char} is generated,
7623 and the escape is ignored.  @xref{Debugging}, for information about
7624 warnings.
7626 The list of available symbols is device dependent; see @ref{Glyph Name
7627 Index} for some of them discussed in this reference.
7629 @c XXX list of common symbols
7630 @endDefesc
7632 @cindex named character (@code{\C})
7633 @cindex character, named (@code{\C})
7634 @Defesc {\\C, ', xxx, '}
7635 Typeset the character named @var{xxx}.  Normally it is more convenient
7636 to use @code{\[@var{xxx}]}, but @code{\C} has the advantage that it is
7637 compatible with newer versions of @code{ditroff} and is available in
7638 compatibility mode.
7639 @endDefesc
7641 @cindex numbered character (@code{\N})
7642 @cindex character, numbered (@code{\N})
7643 @cindex @code{char} request, used with @code{\N}
7644 @cindex Unicode
7645 @Defesc {\\N, ', n, '}
7646 Typeset the character with code@w{ }@var{n} in the current font (this
7647 is @strong{not} the input character code).  @var{n}@w{ }can be any
7648 integer.  Most devices only have characters with codes between 0
7649 and@w{ }255; the Unicode output device uses codes in the range
7650 0--65535.  If the current font does not contain a character with that
7651 code, special fonts are @emph{not} searched.  The @code{\N} escape
7652 sequence can be conveniently used in conjunction with the @code{char}
7653 request:
7655 @Example
7656 .char \[phone] \f[ZD]\N'37'
7657 @endExample
7659 @noindent
7660 @pindex DESC
7661 @cindex unnamed characters
7662 @cindex characters, unnamed
7663 The code of each character is given in the fourth column in the font
7664 description file after the @code{charset} command.  It is possible to
7665 include unnamed characters in the font description file by using a
7666 name of @samp{---}; the @code{\N} escape sequence is the only way to
7667 use these.
7668 @endDefesc
7670 @c XXX should be `glyph', not `character'
7672 @cindex character properties (@code{cflags})
7673 @cindex properties of characters (@code{cflags})
7674 @Defreq {cflags, n c1 c2 @dots{}}
7675 Each character has certain properties associated with it.  These
7676 properties can be modified with the @code{cflags} request.  The first
7677 argument is the the sum of the desired flags and the remaining
7678 arguments are the characters to have those properties.  It is possible
7679 to omit the spaces between the characters.
7681 @table @code
7682 @item 1
7683 @cindex end-of-sentence characters
7684 @cindex characters, end-of-sentence
7685 the character ends sentences (initially characters @samp{.?!} have this
7686 property)
7688 @item 2
7689 @cindex hyphenating characters
7690 @cindex characters, hyphenation
7691 lines can be broken before the character (initially no characters have
7692 this property)
7694 @item 4
7695 @cindex @code{hy} glyph, and @code{cflags}
7696 @cindex @code{em} glyph, and @code{cflags}
7697 lines can be broken after the character (initially the characters
7698 @samp{-\(hy\(em} have this property)
7700 @item 8
7701 @cindex overlapping characters
7702 @cindex characters, overlapping
7703 @cindex @code{ul} glyph, and @code{cflags}
7704 @cindex @code{rn} glyph, and @code{cflags}
7705 @cindex @code{ru} glyph, and @code{cflags}
7706 the character overlaps horizontally (initially the characters
7707 @samp{\(ul\(rn\(ru} have this property)
7709 @item 16
7710 @cindex @code{br} glyph, and @code{cflags}
7711 the character overlaps vertically (initially character @samp{\(br} has
7712 this property)
7714 @item 32
7715 @cindex transparent characters
7716 @cindex character, transparent
7717 @cindex @code{"}, at end of sentence
7718 @cindex @code{'}, at end of sentence
7719 @cindex @code{)}, at end of sentence
7720 @cindex @code{]}, at end of sentence
7721 @cindex @code{*}, at end of sentence
7722 @cindex @code{dg} glyph, at end of sentence
7723 @cindex @code{rq} glyph, at end of sentence
7724 an end-of-sentence character followed by any number of characters with
7725 this property is treated as the end of a sentence if followed by a
7726 newline or two spaces; in other words the character is
7727 @dfn{transparent} for the purposes of end-of-sentence recognition --
7728 this is the same as having a zero space factor in @TeX{} (initially
7729 characters @samp{"')]*\(dg\(rq} have this property).
7730 @end table
7731 @endDefreq
7733 @cindex defining character (@code{char})
7734 @cindex character, defining (@code{char})
7735 @cindex creating new characters (@code{char})
7736 @cindex escape character, while defining character
7737 @cindex character, escape, while defining character
7738 @cindex @code{tr} request, and character definitions
7739 @cindex @code{cp} request, and character definitions
7740 @cindex @code{rc} request, and character definitions
7741 @cindex @code{lc} request, and character definitions
7742 @cindex @code{\l}, and character definitions
7743 @cindex @code{\L}, and character definitions
7744 @cindex @code{\&}, and character definitions
7745 @cindex @code{\e}, and character definitions
7746 @cindex @code{hcode} request, and character definitions
7747 @Defreq {char, c [@Var{string}]}
7748 Define a new character@w{ }@var{c} to be @var{string} (which can be
7749 empty).  Every time character@w{ }@var{c} needs to be printed,
7750 @var{string} is processed in a temporary environment and the result is
7751 wrapped up into a single object.  Compatibility mode is turned off and
7752 the escape character is set to @samp{\} while @var{string} is being
7753 processed.  Any emboldening, constant spacing or track kerning is
7754 applied to this object rather than to individual characters in
7755 @var{string}.  A character defined by this request can be used just
7756 like a normal character provided by the output device.  In particular,
7757 other characters can be translated to it with the @code{tr} request;
7758 it can be made the leader character by the @code{lc} request; repeated
7759 patterns can be drawn with the character using the @code{\l} and
7760 @code{\L} escape sequences; words containing the character can be
7761 hyphenated correctly, if the @code{hcode} request is used to give the
7762 character a hyphenation code.  There is a special anti-recursion
7763 feature: Use of character within the character's definition is handled
7764 like normal characters not defined with @code{char}.
7765 @endDefreq
7767 @cindex removing character definition (@code{rchar})
7768 @cindex character, removing definition (@code{rchar})
7769 @Defreq {rchar, c1 c2 @dots{}}
7770 Remove the definitions of characters @var{c1}, @var{c2},@w{
7771 }@enddots{} This undoes the effect of a @code{char} request.
7773 It is possible to omit the whitespace between arguments.
7774 @endDefreq
7776 @xref{Special Characters}.
7778 @c ---------------------------------------------------------------------
7780 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
7781 @subsection Special Fonts
7782 @cindex special fonts
7783 @cindex fonts, special
7785 @c XXX
7787 To be written.
7789 @c ---------------------------------------------------------------------
7791 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
7792 @subsection Artificial Fonts
7793 @cindex artificial fonts
7794 @cindex fonts, artificial
7796 There are a number of requests for artificially creating fonts.  These
7797 are largely vestiges of the days when output devices did not have a
7798 wide variety of fonts, and when @code{nroff} and @code{troff} were
7799 separate programs.  These are no longer necessary in GNU
7800 @code{troff}.  Nevertheless, they are supported.
7802 @cindex underlining (@code{ul})
7803 @Defreq {ul, [@Var{lines}]}
7804 The @code{ul} request normally underlines subsequent lines if a tty
7805 output device is used.  Otherwise, the lines are printed in italics
7806 (only the term `underlined' is used in the following).  The single
7807 argument is the number of input lines to be underlined; with no
7808 argument, the next line is underlined.  If @var{lines} is zero or
7809 negative, stop the effects of @code{ul} (if it was active).  Requests
7810 and empty lines do not count for computing the number of underlined
7811 input lines, even if they produce some output like @code{tl}.  Lines
7812 inserted by macros (e.g.@: invoked by a trap) do count.
7814 At the beginning of @code{ul}, the current font is stored and the
7815 underline font is activated.  Within the span of a @code{ul} request,
7816 it is possible to change fonts, but after the last line affected by
7817 @code{ul} the saved font is restored.
7819 This command is associated with the current environment
7820 (@pxref{Environments}).  The underline font can be changed with the
7821 @code{uf} request.
7823 @c XXX @xref should be changed to grotty
7825 @xref{Troff and Nroff Mode}, for a discussion how underlining is
7826 implemented in for tty output devices, and which problems can arise.
7828 The @code{ul} request does not underline spaces.
7829 @endDefreq
7831 @cindex continuous underlining (@code{cu})
7832 @cindex underlining, continuous (@code{cu})
7833 @Defreq {cu, [@Var{lines}]}
7834 The @code{cu} request is similar to @code{ul} but underlines spaces as
7835 well (if a tty output device is used).
7836 @endDefreq
7838 @cindex underline font (@code{uf})
7839 @cindex font for underlining (@code{uf})
7840 @Defreq {uf, font}
7841 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
7842 default, this is the font at position@w{ }2.  @var{font} can be either
7843 a non-negative font position or the name of a font.
7844 @endDefreq
7846 @cindex imitating bold face (@code{bd})
7847 @cindex bold face, imitating (@code{bd})
7848 @DefreqList {bd, font [@Var{offset}]}
7849 @DefreqItem {bd, font1 font2 [@Var{offset}]}
7850 @DefregListEnd {.b}
7851 Artificially create a bold font by printing each character twice,
7852 slightly offset.
7854 Two syntax forms are available.
7856 @itemize @bullet
7857 @item
7858 Imitate a bold font unconditionally.  The first argument specifies the
7859 font to embolden, and the second is the number of basic units, minus
7860 one, by which the two characters is offset.  If the second argument is
7861 missing, emboldening is turned off.
7863 @var{font} can be either a non-negative font position or the name of a
7864 font.
7866 @var{offset} is available in the @code{.b} read-only register if a
7867 special font is active; in the @code{bd} request, its default unit is
7868 @samp{u}.
7870 @cindex @code{fspecial} request, and imitating bold
7871 @kindex special
7872 @cindex embolding of special fonts
7873 @cindex special fonts, emboldening
7874 @item
7875 Imitate a bold form conditionally.  Embolden @var{font1} by
7876 @var{offset} only if font @var{font2} is the current font.  This
7877 command can be issued repeatedly to set up different emboldening
7878 values for different current fonts.  If the second argument is
7879 missing, emboldening is turned off for this particular current font.
7881 This affects special fonts only (either set up with the @code{special}
7882 command in font files or with the @code{fspecial} request).
7883 @end itemize
7884 @endDefreq
7886 @cindex constant character space mode (@code{cs})
7887 @cindex mode for constant character space (@code{cs})
7888 @cindex character, constant space
7889 @cindex @code{ps} request, and constant character space mode
7890 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
7891 Switch to and from constant character space mode.  If activated, the
7892 width of every character is @math{@var{width}/36} ems.  The em size is
7893 given absolutely by @var{em-size}; if this argument is missing, the em
7894 value is taken from the current font size (as set with the @code{ps}
7895 request) when the font is effectively in use.  Without second and
7896 third argument, constant character space mode is deactivated.
7898 Default unit for @var{em-size} is @samp{z}; @var{width} is an integer.
7899 @endDefreq
7901 @c ---------------------------------------------------------------------
7903 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
7904 @subsection Ligatures and Kerning
7905 @cindex ligatures and kerning
7906 @cindex kerning and ligatures
7908 Ligatures are groups of characters that are run together.  For
7909 example, the letters `f' and `i' can form a ligature `fi' as in the
7910 word `file'.  This produces a cleaner look (albeit subtle) to the
7911 printed output.  Usually, ligatures are not available in fonts for tty
7912 output devices.
7914 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
7915 typesetter that was the target of AT&T @code{troff} also supported
7916 `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or `expert'
7917 fonts may include ligatures for `ft' and `ct', although GNU
7918 @code{troff} does not support these (yet).
7920 @cindex activating ligatures (@code{lg})
7921 @cindex ligatures, activating (@code{lg})
7922 @cindex ligatures enabled register (@code{.lg})
7923 @DefreqList {lg, [@Var{flag}]}
7924 @DefregListEnd {.lg}
7925 The ligature mechanism can be switched on or off with the @code{lg}
7926 request; if the parameter is non-zero or missing, ligatures are
7927 enabled, otherwise disabled.  Default is on.  The current ligature
7928 mode can be found in the read-only number register @code{.lg} (set to
7929 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
7931 Setting the ligature mode to@w{ }2 enables the two-character ligatures
7932 (fi, fl, and ff) and disables the three-character ligatures (ffi and
7933 ffl).
7934 @endDefreq
7936 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
7937 modifies the distance between a character pair to improve readability.
7938 In most cases (but not always) the distance is decreased.
7939 @ifnotinfo
7940 For example, compare the combination of the letters `V' and `A'.  With
7941 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
7942 @end ifnotinfo
7943 Typewriter-like fonts and fonts for terminals where all characters
7944 have the same width don't use kerning.
7946 @cindex activating kerning (@code{kern})
7947 @cindex kerning, activating (@code{kern})
7948 @cindex kerning enabled register (@code{.kern})
7949 @DefreqList {kern, [@Var{flag}]}
7950 @DefregListEnd {.kern}
7951 Kerning can be activated with the @code{kern} request.  If the
7952 parameter is non-zero or missing, enable pairwise kerning, otherwise
7953 disable it.  The read-only number register @code{.kern} is set to@w{
7954 }1 if pairwise kerning is enabled, 0@w{ }otherwise.
7956 @cindex zero width space character (@code{\&})
7957 @cindex character, zero width space (@code{\&})
7958 @cindex space character, zero width (@code{\&})
7959 If the font description file contains pairwise kerning information,
7960 characters from that font are kerned.  Kerning between two characters
7961 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
7963 @xref{Font File Format}.
7964 @endDefreq
7966 @cindex track kerning
7967 @cindex kerning, track
7968 @dfn{Track kerning} expands or reduces the space between characters.
7969 This can be handy, for example, if you need to squeeze a long word
7970 onto a single line or spread some text to fill a narrow column.  It
7971 must be used with great care since it is usually considered bad
7972 typography if the reader notices the effect.
7974 @cindex activating track kerning (@code{tkf})
7975 @cindex track kerning, activating (@code{tkf})
7976 @Defreq {tkf, f s1 n1 s2 n2}
7977 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
7978 }@var{f} the width of every character is increased by an amount
7979 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
7980 the current point size is less than or equal to @var{s1} the width is
7981 increased by @var{n1}; if it is greater than or equal to @var{s2} the
7982 width is increased by @var{n2}; if the point size is greater than or
7983 equal to @var{s1} and less than or equal to @var{s2} the increase in
7984 width is a linear function of the point size.
7986 The default unit is @samp{z} for @var{s1} and @var{s2}, @samp{p} for
7987 @var{n1} and @var{n2}.
7988 @endDefreq
7990 Sometimes, when typesetting letters of different fonts, more or less
7991 space at such boundaries are needed.  There are two escapes to help
7992 with this.
7994 @cindex italic correction (@code{\/})
7995 @cindex correction, italic (@code{\/})
7996 @cindex correction between italic and roman character (@code{\/})
7997 @cindex roman character, correction after italic character (@code{\/})
7998 @cindex italic character, correction before roman character (@code{\/})
7999 @Defesc {\\/, , , }
8000 Increase the width of the preceding character so that the spacing
8001 between that character and the following character is correct if the
8002 following character is a roman character.  For example, if an
8003 italic@w{ }@code{f} is immediately followed by a roman right
8004 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8005 overlaps the top left of the right parenthesis.  Use this escape
8006 sequence whenever an italic character is immediately followed by a
8007 roman character without any intervening space.  This small amount of
8008 space is also called @dfn{italic correction}.
8010 @iftex
8011 @example
8012 @group
8013 \f[I]f\f[R])
8014     @result{} {@it f}@r{)}
8015 \f[I]f\/\f[R])
8016     @result{} @i{f}@r{)}
8017 @end group
8018 @end example
8019 @end iftex
8020 @endDefesc
8022 @cindex left italic correction (@code{\,})
8023 @cindex correction, left italic (@code{\,})
8024 @cindex roman character, correction before italic character (@code{\,})
8025 @cindex italic character, correction after roman character (@code{\,})
8026 @Defesc {\\\,, , , }
8027 Modify the spacing of the following character so that the spacing
8028 between that character and the preceding character is correct if the
8029 preceding character is a roman character.  Use this escape sequence
8030 whenever a roman character is immediately followed by an italic
8031 character without any intervening space.  In analogy to above, this
8032 space could be called @dfn{left italic correction}, but this term
8033 isn't used widely.
8035 @iftex
8036 @example
8037 @group
8038 q\f[I]f
8039     @result{} @r{q}@i{f}
8040 q\,\f[I]f
8041     @result{} @r{q}@math{@ptexcomma}@i{f}
8042 @end group
8043 @end example
8044 @end iftex
8045 @endDefesc
8047 @Defesc {\\&, , , }
8048 Insert a zero-width character, which is invisible.  Its intended use
8049 is to stop interaction of a character with its surrounding.
8051 @itemize @bullet
8052 @item
8053 It prevents the insertion of extra space after an end-of-sentence
8054 character.
8056 @Example
8057 Test.
8058 Test.
8059     @result{} Test.  Test.
8060 Test.\&
8061 Test.
8062     @result{} Test. Test.
8063 @endExample
8065 @item
8066 It prevents interpretation of a control character at the beginning of
8067 an input line.
8069 @Example
8070 .Test
8071     @result{} warning: `Test' not defined
8072 \&.Test
8073     @result{} .Test
8074 @endExample
8076 @item
8077 It prevents kerning between two characters.
8079 @ifnotinfo
8080 @example
8081 @group
8083     @result{} @r{VA}
8084 V\&A
8085     @result{} @r{V@w{}A}
8086 @end group
8087 @end example
8088 @end ifnotinfo
8090 @item
8091 It is needed to map an arbitrary character to nothing in the @code{tr}
8092 request (@pxref{Character Translations}).
8093 @end itemize
8094 @endDefesc
8097 @c =====================================================================
8099 @node Sizes, Strings, Fonts, gtroff Reference
8100 @section Sizes
8101 @cindex sizes
8103 @cindex baseline
8104 @cindex type size
8105 @cindex size of type
8106 @cindex vertical spacing
8107 @cindex spacing, vertical
8108 @code{gtroff} uses two dimensions with each line of text, type size
8109 and vertical spacing.  The @dfn{type size} is approximately the height
8110 of the tallest character.@footnote{This is usually the parenthesis.
8111 Note that in most cases the real dimensions of the glyphs in a font
8112 are @emph{not} related to its type size!  For example, the standard
8113 @sc{PostScript} font families `Times Roman', `Helvetica', and
8114 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8115 output, the size of `Helvetica' has to be reduced by one point, and
8116 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8117 spacing} is the amount of space @code{gtroff} allows for a line of
8118 text; normally, this is about 20%@w{ }larger than the current type
8119 size.  Ratios smaller than this can result in hard-to-read text;
8120 larger than this, it spreads the text out more vertically (useful for
8121 term papers).  By default, @code{gtroff} uses 10@w{ }point type on
8122 12@w{ }point spacing.
8124 @cindex leading
8125 The difference between type size and vertical spacing is known, by
8126 typesetters, as @dfn{leading}.
8128 @menu
8129 * Changing Type Sizes::
8130 * Fractional Type Sizes::
8131 @end menu
8133 @c ---------------------------------------------------------------------
8135 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8136 @subsection Changing Type Sizes
8138 @cindex changing type sizes (@code{ps}, @code{\s})
8139 @cindex type sizes, changing (@code{ps}, @code{\s})
8140 @cindex point sizes, changing (@code{ps}, @code{\s})
8141 @DefreqList {ps, [@Var{size}]}
8142 @DefreqItem {ps, @t{+}@Var{size}}
8143 @DefreqItem {ps, @t{-}@Var{size}}
8144 @DefescItem {\\s, , size, }
8145 @DefregListEnd {.s}
8146 Use the @code{ps} request or the @code{\s} escape to change (increase,
8147 decrease) the type size (in points).  Specify @var{size} as either an
8148 absolute point size, or as a relative change from the current size.
8149 The size@w{ }0, or no argument, goes back to the previous size.
8151 Default unit of @code{size} is @samp{z}.  If @code{size} is zero or
8152 negative, it is set to 1@dmn{u}.
8154 @cindex type size registers (@code{.s}, @code{.ps})
8155 @cindex point size registers (@code{.s}, @code{.ps})
8156 The read-only number register @code{.s} returns the point size in
8157 points as a decimal fraction.  This is a string.  To get the point
8158 size in scaled points, use the @code{.ps} register instead.
8160 @code{.s} is associated with the current environment
8161 (@pxref{Environments}).
8163 @Example
8164 snap, snap,
8165 .ps +2
8166 grin, grin,
8167 .ps +2
8168 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8169 .ps 10
8170 @endExample
8172 The @code{\s} escape may be called in a variety of ways.  Much like
8173 other escapes there must be a way to determine where the argument ends
8174 and the text begins.  Any of the following forms are valid:
8176 @table @code
8177 @item \s@var{n}
8178 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either
8179 0 or in the range 4 to@w{ }39.
8181 @item \s+@var{n}
8182 @itemx \s-@var{n}
8183 Increase or decrease the point size by @var{n}@w{ }points.  @var{n}@w{
8184 }must be exactly one digit.
8186 @item \s(@var{nn}
8187 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly
8188 two digits.
8190 @item \s+(@var{nn}
8191 @itemx \s-(@var{nn}
8192 @itemx \s(+@var{nn}
8193 @itemx \s(-@var{nn}
8194 Increase or decrease the point size by @var{nn}@w{ }points.  @var{nn}
8195 must be exactly two digits.
8196 @end table
8198 @xref{Fractional Type Sizes}, for yet another syntactical form of
8199 using the @code{\s} escape.
8201 Some devices may only have certain permissible sizes, in which case
8202 @code{gtroff} rounds to the nearest permissible size.
8203 @endDefreq
8205 @cindex changing vertical spacing (@code{vs})
8206 @cindex vertical spacing, changing (@code{vs})
8207 @cindex vertical spacing register (@code{.v})
8208 @DefreqList {vs, [@Var{space}]}
8209 @DefreqItem {vs, @t{+}@Var{space}}
8210 @DefreqItem {vs, @t{-}@Var{space}}
8211 @DefregListEnd {.v}
8212 Change (increase, decrease) the vertical spacing by @var{space}.  The
8213 default unit is @samp{p}.
8215 If @code{vs} is called without an argument, the vertical spacing is
8216 reset to the previous value before the last call to @code{vs}.
8218 @cindex @code{.V} register, and @code{vs}
8219 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8220 zero or negative; the vertical spacing is then set to the vertical
8221 resolution (as given in the @code{.V} register).
8223 The read-only number register @code{.v} contains the current vertical
8224 spacing; it is associated with the current environment
8225 (@pxref{Environments}).
8226 @endDefreq
8228 @c XXX example
8230 @ignore
8231 @Example
8232 ... .sz macro example?? ...
8233 @endExample
8234 @end ignore
8236 @c ---------------------------------------------------------------------
8238 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
8239 @subsection Fractional Type Sizes
8240 @cindex fractional type sizes
8241 @cindex type sizes, fractional
8243 @cindex @code{s} unit
8244 @cindex unit, @code{s}
8245 @cindex @code{z} unit
8246 @cindex unit, @code{z}
8247 @cindex @code{ps} request, with fractional type sizes
8248 @cindex @code{cs} request, with fractional type sizes
8249 @cindex @code{tkf} request, with fractional type sizes
8250 @cindex @code{\H}, with fractional type sizes
8251 @cindex @code{\s}, with fractional type sizes
8252 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
8253 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
8254 default).  There is a new scale indicator @samp{z} which has the
8255 effect of multiplying by @var{sizescale}.  Requests and escape
8256 sequences in @code{gtroff} interpret arguments that represent a point
8257 size as being in units of scaled points, but they evaluate each such
8258 argument using a default scale indicator of @samp{z}.  Arguments
8259 treated in this way are the argument to the @code{ps} request, the
8260 third argument to the @code{cs} request, the second and fourth
8261 arguments to the @code{tkf} request, the argument to the @code{\H}
8262 escape sequence, and those variants of the @code{\s} escape sequence
8263 that take a numeric expression as their argument (see below).
8265 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
8266 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
8267 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
8268 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
8270 @code{gtroff} disallows the use of the @samp{z} scale indicator in
8271 instances where it would make no sense, such as a numeric
8272 expression whose default scale indicator was neither @samp{u} nor
8273 @samp{z}.  Similarly it would make
8274 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
8275 numeric expression whose default scale indicator was @samp{z}, and so
8276 @code{gtroff} disallows this as well.
8278 There is also new scale indicator @samp{s} which multiplies by the
8279 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
8280 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
8281 scale indicators.
8283 @Defreg {.ps}
8284 A read-only number register returning the point size in scaled points.
8286 @code{.ps} is associated with the current environment
8287 (@pxref{Environments}).
8288 @endDefreg
8290 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
8291 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
8292 @cindex @code{.ps} register, in comparison with @code{.psr}
8293 @cindex @code{.s} register, in comparison with @code{.sr}
8294 @DefregList {.psr}
8295 @DefregListEnd {.sr}
8296 The last-requested point size in scaled points is contained in the
8297 @code{.psr} read-only number register.  The last requested point size
8298 in points as a decimal fraction can be found in @code{.sr}.  This is a
8299 string-valued read-only number register.
8301 Note that the requested point sizes are device-independent, whereas
8302 the values returned by the @code{.ps} and @code{.s} registers are not.
8303 For example, if a point size of 11@dmn{pt} is requested for a DVI
8304 device, 10.95@dmn{pt} are actually used (as specified in the
8305 @file{DESC} file).
8307 Both registers are associated with the current environment
8308 (@pxref{Environments}).
8309 @endDefreg
8311 The @code{\s} escape has the following syntax for working with
8312 fractional type sizes:
8314 @table @code
8315 @item \s[@var{n}]
8316 @itemx \s'@var{n}'
8317 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
8318 expression with a default scale indicator of @samp{z}.
8320 @item \s[+@var{n}]
8321 @itemx \s[-@var{n}]
8322 @itemx \s+[@var{n}]
8323 @itemx \s-[@var{n}]
8324 @itemx \s'+@var{n}'
8325 @itemx \s'-@var{n}'
8326 @itemx \s+'@var{n}'
8327 @itemx \s-'@var{n}'
8328 Increase or or decrease the point size by @var{n}@w{ }scaled points;
8329 @var{n}@w{ }is a numeric expression with a default scale indicator of
8330 @samp{z}.
8331 @end table
8333 @xref{Font Files}.
8336 @c =====================================================================
8338 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
8339 @section Strings
8340 @cindex strings
8342 @code{gtroff} has string variables, which are entirely for user
8343 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
8344 even this is a read-write string variable).
8346 @cindex string interpolation (@code{\*})
8347 @cindex string expansion (@code{\*})
8348 @cindex interpolation of strings (@code{\*})
8349 @cindex expansion of strings (@code{\*})
8350 @DefreqList {ds, name [@Var{string}]}
8351 @DefescItem {\\*, , n, }
8352 @DefescItem {\\*, @lparen{}, nm, }
8353 @DefescListEnd {\\*, @lbrack{}, name, @rbrack{}}
8354 Define and access a string variable @var{name} (one-character name@w{
8355 }@var{n}, two-character name @var{nm}).  If @var{name} already exists,
8356 @code{ds} overwrites the previous definition.
8358 Example:
8360 @Example
8361 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
8363 The \*(UX Operating System
8364 @endExample
8366 The @code{\*} escape @dfn{interpolates} (expands in-place) a
8367 previously-defined string variable.  To be more precise, the stored
8368 string is pushed onto the input stack which is then parsed by
8369 @code{gtroff}.  Similar to number registers, it is possible to nest
8370 strings, i.e. a string variables can be called within string
8371 variables.
8373 If the string named by the @code{\*} does not exist, it is defined as
8374 empty, and a warning of type @samp{mac} is emitted (see
8375 @ref{Debugging}, for more details).
8377 @cindex comments, with @code{ds}
8378 @cindex @code{ds} request, and comments
8379 @strong{Caution:} Unlike other requests, the second argument to the
8380 @code{ds} request takes up the entire line including trailing spaces.
8381 This means that comments on a line with such a request can introduce
8382 unwanted space into a string.
8384 @Example
8385 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
8386 @endExample
8388 @noindent
8389 Instead the comment should be put on another line or have the comment
8390 escape adjacent with the end of the string.
8392 @Example
8393 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
8394 @endExample
8396 @cindex trailing quotes
8397 @cindex quotes, trailing
8398 @cindex leading spaces with @code{ds}
8399 @cindex spaces with @code{ds}
8400 @cindex @code{ds} request, and leading spaces
8401 To produce leading space the string can be started with a double
8402 quote.  No trailing quote is needed; in fact, any trailing quote is
8403 included in your string.
8405 @Example
8406 .ds sign "           Yours in a white wine sauce,
8407 @endExample
8409 @cindex multi-line strings
8410 @cindex strings, multi-line
8411 @cindex newline character in strings, escaping
8412 @cindex escaping newline characters in strings
8413 Strings are not limited to a single line of text.  A string can span
8414 several lines by escaping the newlines with a backslash.  The
8415 resulting string is stored @emph{without} the newlines.
8417 @Example
8418 .ds foo lots and lots \
8419 of text are on these \
8420 next several lines
8421 @endExample
8423 It is not possible to have real newlines in a string.
8425 @cindex name space of macros and strings
8426 @cindex macros, shared name space with strings
8427 @cindex strings, shared name space with macros
8428 Strings, macros, and diversions (and boxes) share the same name space.
8429 Internally, even the same mechanism is used to store them.  This has
8430 some interesting consequences.  For example, it is possible to call a
8431 macro with string syntax and vice versa.
8433 @Example
8434 .de xxx
8435 a funny test.
8437 This is \*[xxx]
8438     @result{} This is a funny test.
8440 .ds yyy a funny test
8441 This is
8442 .yyy
8443     @result{} This is a funny test.
8444 @endExample
8446 Diversions and boxes can be also called with string syntax.  It is not
8447 possible to pass arguments to a macro if called with @code{\*}.
8449 Another consequence is that you can copy one-line diversions or boxes
8450 to a string.
8452 @Example
8453 .di xxx
8454 a \fItest\fR
8457 .ds yyy This is \*[xxx]\c
8458 \*[yyy].
8459     @result{} @r{This is a }@i{test}.
8460 @endExample
8462 @noindent
8463 As the previous example shows, it is possible to store formatted
8464 output in strings.  The @code{\c} escape prevents the insertion of an
8465 additional blank line in the output.
8467 Copying diversions longer than a single output line produces
8468 unexpected results.
8470 @Example
8471 .di xxx
8472 a funny
8474 test
8477 .ds yyy This is \*[xxx]\c
8478 \*[yyy].
8479     @result{} test This is a funny.
8480 @endExample
8482 Usually, it is not predictable whether a diversion contains one or
8483 more output lines, so this mechanism should be avoided.  With
8484 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
8485 final newline from a diversion.  Another disadvantage is that the
8486 spaces in the copied string are already formatted, making them
8487 unstretchable.  This can cause ugly results.
8489 @cindex stripping final newline in diversions
8490 @cindex diversions, stripping final newline
8491 @cindex final newline, stripping in diversions
8492 @cindex newline, final, stripping in diversions
8493 @cindex horizontal space, unformatting
8494 @cindex space, horizontal, unformatting
8495 @cindex unformatting horizontal space
8496 A clean solution to this problem is available in GNU @code{troff},
8497 using the requests @code{chop} to remove the final newline of a
8498 diversion, and @code{unformat} to make the horizontal spaces
8499 stretchable again.
8501 @Example
8502 .box xxx
8503 a funny
8505 test
8507 .box
8508 .chop xxx
8509 .unformat xxx
8510 This is \*[xxx].
8511     @result{} This is a funny test.
8512 @endExample
8514 @xref{Gtroff Internals}, for more information.
8515 @endDefreq
8517 @cindex appending to strings (@code{as})
8518 @cindex strings, appending (@code{as})
8519 @Defreq {as, name [@Var{string}]}
8520 The @code{as} request is similar to @code{ds} but appends @var{string}
8521 to the string stored as @var{name} instead of redefining it.  If
8522 @var{name} doesn't exist yet, it is created.
8524 @Example
8525 .as sign " with shallots, onions and garlic,
8526 @endExample
8527 @endDefreq
8529 Rudimentary string manipulation routines are given with the next two
8530 requests.
8532 @cindex substring (@code{substring})
8533 @Defreq {substring, str n1 [@Var{n2}]}
8534 Replace the string in register@w{ }@var{str} with the substring
8535 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
8536 in the string has index one.  If @var{n2} is omitted, it is taken to
8537 be equal to the string's length.  If the index value @var{n1} or
8538 @var{n2} is negative or zero, it is counted from the end of the
8539 string, going backwards: The last character has index@w{ }0, the
8540 character before the last character has index@w{ }@minus{}1, etc.
8542 @Example
8543 .ds xxx abcdefgh
8544 .substring xxx 2 -3
8545 \*[xxx]
8546     @result{} bcde
8547 @endExample
8548 @endDefreq
8550 @cindex length of a string (@code{length})
8551 @cindex string, length of (@code{length})
8552 @Defreq {length, reg str}
8553 Compute the length of @var{str} and returns it in the number
8554 register@w{ }@var{reg}.  If @var{reg} doesn't exist, it is created.
8556 @Example
8557 .ds xxx abcdefgh
8558 .length yyy xxx
8559 \n[yyy]
8560     @result{} 8
8561 @endExample
8562 @endDefreq
8564 @cindex rename request (@code{rn})
8565 @cindex rename macro (@code{rn})
8566 @cindex rename string (@code{rn})
8567 @Defreq {rn, xx yy}
8568 Rename the request, macro, or string @var{xx} to @var{yy}.
8569 @endDefreq
8571 @cindex remove request (@code{rm})
8572 @cindex remove macro (@code{rm})
8573 @cindex remove string (@code{rm})
8574 @Defreq {rm, xx}
8575 Remove the request, macro, or string @var{xx}.  @code{gtroff} treats
8576 subsequent invocations as if the object had never been defined.
8577 @endDefreq
8579 @cindex alias, creating (@code{als})
8580 @cindex creating alias (@code{als})
8581 @Defreq {als, new old}
8582 Create an alias named @var{new} for the request, string, macro, or
8583 diversion object named @var{old}.  The new name and the old name are
8584 exactly equivalent (it is similar to a hard rather than a soft
8585 link). If @var{old} is undefined, @code{gtroff} generates a warning of
8586 type @samp{mac} and ignores the request.
8587 @endDefreq
8589 @Defreq {chop, xx}
8590 Remove (chop) the last character from the macro, string, or diversion
8591 named @var{xx}. This is useful for removing the newline from the end
8592 of diversions that are to be interpolated as strings.  This command
8593 can be used repeatedly; see @ref{Gtroff Internals}, for details on
8594 nodes inserted by @code{gtroff} automatically.
8595 @endDefreq
8597 @xref{Identifiers}, and @ref{Comments}.
8600 @c =====================================================================
8602 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
8603 @section Conditionals and Loops
8604 @cindex conditionals and loops
8605 @cindex loops and conditionals
8607 @menu
8608 * Operators in Conditionals::
8609 * if-else::
8610 * while::
8611 @end menu
8613 @c ---------------------------------------------------------------------
8615 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
8616 @subsection Operators in Conditionals
8618 @cindex @code{if} request, operators to use with it
8619 @cindex @code{while} request, operators to use with it
8620 In @code{if} and @code{while} requests, there are several more
8621 operators available:
8623 @table @code
8624 @item e
8625 @itemx o
8626 True if the current page is even or odd numbered (respectively).
8628 @item n
8629 True if the document is being processed in nroff mode (i.e., the
8630 @code{.nroff} command has been issued).
8632 @item t
8633 True if the document is being processed in troff mode (i.e., the
8634 @code{.troff} command has been issued).
8636 @item v
8637 Always false.
8639 @item '@var{xxx}'@var{yyy}'
8640 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
8641 characters can be used in place of the single quotes; the same set of
8642 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
8643 @code{gtroff} formats the strings before being compared:
8645 @Example
8646 .ie "|"\fR|\fP" \
8647 true
8648 .el \
8649 false
8650     @result{} true
8651 @endExample
8653 @noindent
8654 The resulting motions, character sizes, and fonts have to
8655 match,@footnote{The created output nodes must be identical.
8656 @xref{Gtroff Internals}.} and not the individual motion, size, and
8657 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
8658 both result in a roman @samp{|} character with the same point size and
8659 at the same location on the page, so the strings are equal.  If
8660 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
8661 would be ``false'' because (the first) @samp{|} produces an italic
8662 @samp{|} rather than a roman one.
8664 @item r @var{xxx}
8665 True if there is a number register named @var{xxx}.
8667 @item d @var{xxx}
8668 True if there is a string, macro, diversion, or request named @var{xxx}.
8670 @item m @var{xxx}
8671 True if there is a color named @var{xxx}.
8673 @item c @var{ch}
8674 True if there is a character @var{ch} available; @var{ch} is either an
8675 @acronym{ASCII} character or a special character (@code{\(@var{ch}} or
8676 @code{\[@var{ch}]}); the condition is also true if @var{ch} has been
8677 defined by the @code{char} request.
8678 @end table
8680 Note that these operators can't be combined with other operators like
8681 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
8682 between the exclamation mark and the operator) can be used to negate
8683 the result.
8685 @Example
8686 .nr xxx 1
8687 .ie !r xxx \
8688 true
8689 .el \
8690 false
8691     @result{} false
8692 @endExample
8694 A whitespace after @samp{!} always evaluates to zero (this bizarre
8695 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
8697 @Example
8698 .nr xxx 1
8699 .ie ! r xxx \
8700 true
8701 .el \
8702 false
8703     @result{} r xxx true
8704 @endExample
8706 It is possible to omit the whitespace before the argument to the
8707 @samp{r}, @samp{d}, and @samp{c} operators.
8709 @xref{Expressions}.
8711 @c ---------------------------------------------------------------------
8713 @node if-else, while, Operators in Conditionals, Conditionals and Loops
8714 @subsection if-else
8715 @cindex if-else
8717 @code{gtroff} has if-then-else constructs like other languages, although
8718 the formatting can be painful.
8720 @Defreq {if, expr anything}
8721 Evaluate the expression @var{expr}, and executes @var{anything} (the
8722 remainder of the line) if @var{expr} evaluates to non-zero (true).
8723 @var{anything} is interpreted as though it was on a line by itself
8724 (except that leading spaces are swallowed).  @xref{Expressions}, for
8725 more info.
8727 @Example
8728 .nr xxx 1
8729 .nr yyy 2
8730 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
8731     @result{} true
8732 @endExample
8733 @endDefreq
8735 @c XXX .nop request
8737 @DefreqList {ie, expr anything}
8738 @DefreqListEnd {el, anything}
8739 Use the @code{ie} and @code{el} requests to write an if-then-else.
8740 The first request is the `if' part and the latter is the `else' part.
8742 @Example
8743 .ie n .ls 2 \" double spacing in nroff
8744 .el   .ls 1 \" single spacing in troff
8745 @endExample
8746 @endDefreq
8748 @c this is a bug in makeinfo: you can't have `@{' as an argument
8749 @c to deffn
8751 @cindex begin of conditional block (@code{\@{})
8752 @cindex end of conditional block (@code{\@}})
8753 @cindex conditional block, begin (@code{\@{})
8754 @cindex conditional block, end (@code{\@}})
8755 @cindex block, conditional, begin (@code{\@{})
8756 @cindex block, condititional, end (@code{\@}})
8757 @c @DefescList {\\@@@{, , , }
8758 @c @DefescListEnd {\\@@@}, , , }
8759 In many cases, an if (or if-else) construct needs to execute more than
8760 one request.  This can be done using the @code{\@{} and @code{\@}}
8761 escapes.  The following example shows the possible ways to use these
8762 escapes (note the position of the opening and closing braces).
8764 @Example
8765 .ie t \@{\
8766 .    ds lq ``
8767 .    ds rq ''
8768 .\@}
8769 .el \
8770 .\@{\
8771 .    ds lq "
8772 .    ds rq "\@}
8773 @endExample
8774 @c @endDefesc
8776 @xref{Expressions}.
8778 @c ---------------------------------------------------------------------
8780 @node while,  , if-else, Conditionals and Loops
8781 @subsection while
8782 @cindex while
8784 @code{gtroff} provides a looping construct using the @code{while}
8785 request, which is used much like the @code{if} (and related) requests.
8787 @Defreq {while, expr anything}
8788 Evaluate the expression @var{expr}, and repeatedly execute
8789 @var{anything} (the remainder of the line) until @var{expr} evaluates
8790 to@w{ }0.
8792 @Example
8793 .nr a 0 1
8794 .while (\na < 9) \@{\
8795 \n+a,
8796 .\@}
8797 \n+a
8798     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
8799 @endExample
8801 Some remarks.
8803 @cindex @code{de} request, and @code{while}
8804 @itemize @bullet
8805 @item
8806 The body of a @code{while} request is treated like the body of a
8807 @code{de} request: @code{gtroff} temporarily stores it in a macro
8808 which is deleted after the loop has been exited.  It can considerably
8809 slow down a macro if the body of the @code{while} request (within the
8810 macro) is large.  Each time the macro is executed, the @code{while}
8811 body is parsed and stored again as a temporary macro.
8813 @Example
8814 .de xxx
8815 .  nr num 10
8816 .  while (\\n[num] > 0) \@{\
8817 .    \" many lines of code
8818 .    nr num -1
8819 .  \@}
8821 @endExample
8823 @cindex recursive macros
8824 @cindex macros, recursive
8825 @noindent
8826 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
8827 doesn't have the @code{while} request) is to use a recursive macro
8828 instead which is parsed only once during its definition.
8830 @Example
8831 .de yyy
8832 .  if (\\n[num] > 0) \@{\
8833 .    \" many lines of code
8834 .    nr num -1
8835 .    yyy
8836 .  \@}
8839 .de xxx
8840 .  nr num 10
8841 .  yyy
8843 @endExample
8845 @noindent
8846 Note that the number of available recursion levels is set to@w{ }1000
8847 (this is a compile-time constant value of @code{gtroff}).
8849 @item
8850 The closing brace of a @code{while} body must end a line.
8852 @Example
8853 .if 1 \@{\
8854 .  nr a 0 1
8855 .  while (\n[a] < 10) \@{\
8856 .    nop \n+[a]
8857 .\@}\@}
8858     @result{} unbalanced \@{ \@}
8859 @endExample
8860 @end itemize
8861 @endDefreq
8863 @cindex @code{while} request, confusing with @code{br}
8864 @cindex @code{break} request, in a @code{while} loop
8865 @cindex @code{continue} request, in a @code{while} loop
8866 @Defreq {break, }
8867 Break out of a @code{while} loop.  Be sure not to confuse this with
8868 the @code{br} request (causing a line break).
8869 @endDefreq
8871 @Defreq {continue, }
8872 Finishes the current iteration of a @code{while} loop, immediately
8873 restarting the next iteration.
8874 @endDefreq
8876 @xref{Expressions}.
8879 @c =====================================================================
8881 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
8882 @section Writing Macros
8883 @cindex writing macros
8884 @cindex macros, writing
8886 A @dfn{macro} is a collection of text and embedded commands which can
8887 be invoked multiple times.  Use macros to define common operations.
8889 @Defreq {de, name [@Var{end}]}
8890 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
8891 lines (starting with the next one) into an internal buffer until it
8892 encounters the line @samp{..} (two dots).  The optional second
8893 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
8895 There can be whitespace after the first dot in the line containing the
8896 ending token (either @samp{.} or macro @samp{@var{end}}).
8898 Here a small example macro called @samp{P} which causes a break and
8899 inserts some vertical space.  It could be used to separate paragraphs.
8901 @Example
8902 .de P
8903 .  br
8904 .  sp .8v
8906 @endExample
8908 @c XXX add info about macro definitions in macros.
8910 @c XXX give example for end macro.
8912 @c XXX add info about indirect macro calls:
8914 @c .de xxx
8915 @c from yyy\c
8916 @c ..
8918 @c test \*[xxx] test
8919 @c   => test from yyy test
8921 @c XXX info about common identifier pool for strings, macros, and
8922 @c     diversions.
8923 @endDefreq
8925 @cindex appending, to a macro (@code{am})
8926 @cindex macro appending (@code{am})
8927 @Defreq {am, xx}
8928 Works similarly to @code{de} except it appends onto the macro named
8929 @var{xx}.  So, to make the previously defined @samp{P} macro actually
8930 do indented instead of block paragraphs, add the necessary code to the
8931 existing macro like this:
8933 @Example
8934 .am P
8935 .ti +5n
8937 @endExample
8938 @endDefreq
8940 @cindex alias, creating (@code{als})
8941 @cindex creating alias (@code{als})
8942 @xref{Strings}, for the @code{als} request to rename a macro.
8944 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
8945 @code{as} requests only create a new object if the name of the macro,
8946 diversion or string diversion is currently undefined or if it is
8947 defined to be a request; normally they modify the value of an existing
8948 object.
8950 @menu
8951 * Copy-in Mode::
8952 * Parameters::
8953 @end menu
8955 @c ---------------------------------------------------------------------
8957 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
8958 @subsection Copy-in Mode
8959 @cindex copy-in mode
8960 @cindex mode, copy-in
8962 @cindex @code{\n}, when reading text for a macro
8963 @cindex @code{\$}, when reading text for a macro
8964 @cindex @code{\*}, when reading text for a macro
8965 @cindex @code{\\}, when reading text for a macro
8966 @cindex \@key{RET}, when reading text for a macro
8967 When @code{gtroff} reads in the text for a macro or diversion, it copies
8968 the text (including request lines, but excluding escapes) into an
8969 internal buffer.  Escapes are converted into an internal form,
8970 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
8971 @code{\@key{RET}} which are evaluated and inserted into the text where
8972 the escape was located.  This is known as @dfn{copy-in} mode or
8973 @dfn{copy} mode.
8975 What this means is that you can specify when these escapes are to be
8976 evaluated (either at copy-in time or at the time of use) by insulating
8977 the escapes with an extra backslash.  Compare this to the @code{\def}
8978 and @code{\edef} commands in @TeX{}.
8980 The following example prints the numbers 20 and@w{ }10:
8982 @Example
8983 .nr x 20
8984 .de y
8985 .nr x 10
8986 \&\nx
8987 \&\\nx
8990 @endExample
8992 @c ---------------------------------------------------------------------
8994 @node Parameters,  , Copy-in Mode, Writing Macros
8995 @subsection Parameters
8996 @cindex parameters
8998 @cindex number of arguments register (@code{.$})
8999 @vindex .$
9000 The arguments to a macro can be examined using a variety of escapes.
9001 The number of arguments is available in the @code{.$} number register.
9002 Any individual argument can be retrieved with one of the following
9003 escapes:
9005 @cindex copy-in mode, and macro arguments
9006 @cindex macro arguments (@code{\$})
9007 @cindex arguments, macro (@code{\$})
9008 @DefescList {\\$, n, , }
9009 @DefescItem {\\$, @lparen{}, nn, }
9010 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
9011 The escapes @code{\$@var{n}}, @code{\$(@var{nn}} and
9012 @code{\$[@var{nnn}]} retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or
9013 @var{nnn}@dmn{th} argument.  As usual, the first form only accepts a
9014 single number (larger than zero), the second a two-digit number (larger
9015 or equal to@w{ }10), and the third any positive integer value (larger
9016 than zero).  Macros can have an unlimited number of arguments.  Note
9017 that due to copy-in mode, use two backslashes on these in actual use to
9018 prevent interpolation until the macro is actually invoked.
9019 @endDefesc
9021 @Defreq {shift, [@Var{n}]}
9022 Shifts the arguments 1@w{ }position, or as
9023 many positions as specified by its argument.  After executing this
9024 request, argument@w{ }@var{i} becomes argument @var{i}-@var{n};
9025 arguments 1 to@w{ }@var{n} are no longer available.  Shifting by
9026 negative amounts is currently undefined.
9027 @endDefreq
9029 @DefescList {\\$*, , , }
9030 @DefescListEnd {\\$@@, , , }
9031 In some cases it is convenient to use all of the arguments at once (for
9032 example, to pass the arguments along to another macro).  The @code{\$*}
9033 escape concatenates all the arguments separated by spaces.  A
9034 similar escape is @code{\$@@}, which concatenates all the
9035 arguments with each surrounded by double quotes, and separated by
9036 spaces.
9037 @endDefesc
9039 @cindex macro name register (@code{\$0})
9040 @cindex @code{als} request, and @code{\$0}
9041 @cindex @code{als} request, use with @code{\$0}
9042 @Defesc {\\$0, , , }
9043 The name used to invoke the current macro.
9044 The @code{als} request can make a macro have more than one name.
9046 @Example
9047 .de vl
9048 .ie \\n(.$=1 .ds Vl Pre-Release Version
9049 .el          .ds Vl Version \\$3, \\$4.
9051 @endExample
9053 @noindent
9054 This would be called as
9056 @Example
9057 .vl $Id$
9058 @endExample
9059 @endDefesc
9061 @xref{Request Arguments}.
9064 @c =====================================================================
9066 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
9067 @section Page Motions
9068 @cindex page motions
9069 @cindex motions, page
9071 @xref{Manipulating Spacing}, for a discussion of the main request for
9072 vertical motion, @code{sp}.
9074 @cindex marking page location (@code{mk})
9075 @cindex page location, marking (@code{mk})
9076 @cindex location, page, marking (@code{mk})
9077 @cindex returning to marked page location (@code{rt})
9078 @cindex page location, returning to marked (@code{rt})
9079 @cindex location, page, returning to marked (@code{rt})
9080 @DefreqList {mk, [@Var{reg}]}
9081 @DefreqListEnd {rt, [@Var{dist}]}
9082 The request @code{mk} can be used to mark a location on a page, for
9083 movement to later.  This request takes a register name as an argument
9084 in which to store the current page location.  With no argument it
9085 stores the location in an internal register.  The results of this can
9086 be used later by the @code{rt} or the @code{sp} request (or the
9087 @code{\v} escape).
9089 The @code{rt} request returns @emph{upwards} to the location marked
9090 with the last @code{mk} request.  If used with an argument, return to
9091 a position which distance from the top of the page is @var{dist} (no
9092 previous call to @code{mk} is necessary in this case).
9094 @c XXX example
9095 @ignore
9096 @Example
9097 ... dual column example ...
9098 @endExample
9099 @end ignore
9100 @endDefreq
9102 The following escapes give fine control of movements about the page.
9104 @cindex vertical motion (@code{\v})
9105 @cindex motion, vertical (@code{\v})
9106 @Defesc {\\v, ', e, '}
9107 The @code{\v'@var{e}'} escape enables arbitrary vertical motion from the
9108 current location on the page.  The argument@w{ }@var{e} specifies the
9109 distance to move; positive is downwards and negative upwards.  The
9110 default unit for this escape @samp{v}.  Beware, however, that
9111 @code{gtroff} continues text processing at the point where the motion
9112 ends, so you should always balance motions to avoid interference with
9113 text processing.
9115 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
9116 consider a page bottom trap macro which prints a marker in the margin to
9117 indicate continuation of a footnote or something similar.
9118 @endDefesc
9120 There are some special case escapes for vertical motion.
9122 @ftable @code
9123 @item \r
9124 move upwards@w{ }1@dmn{v}.
9126 @item \u
9127 move upwards@w{ }.5@dmn{v}.
9129 @item \d
9130 move down@w{ }.5@dmn{v}.
9131 @end ftable
9133 @cindex inserting horizontal space (@code{\h})
9134 @cindex horizontal space (@code{\h})
9135 @cindex space, horizontal (@code{\h})
9136 @Defesc {\\h, ', e, '}
9137 The @code{\h'@var{e}'} escape provides horizontal motions.  The
9138 expression@w{ }@var{e} indicates how far to move: positive is rightwards
9139 and negative leftwards.
9140 @c XXX Is there a default unit for this?
9141 @endDefesc
9143 There are a number of special case escapes for horizontal motion:
9145 @ftable @code
9146 @item \@key{SP}
9147 An unbreakable and unpaddable (i.e.@: not expanded during filling)
9148 space.  (Note: This is a backslash followed by a space.)
9150 @item \~
9151 An unbreakable space that stretches like a normal inter-word space
9152 when a line is adjusted.
9154 @item \|
9155 A 1/6@dmn{th} em space.  Ignored for tty output devices (rounded to
9156 zero).
9158 @item \^
9159 A 1/12@dmn{th} em space.  Ignored for tty output devices (rounded to
9160 zero).
9162 @item \0
9163 A space the size of a digit.
9165 @item \&
9166 @cindex zero width space character (@code{\&})
9167 @cindex character, zero width space (@code{\&})
9168 @cindex space character, zero width (@code{\&})
9169 A zero width space.
9171 @item \)
9172 Like @code{\&} except that it behaves like a character declared with
9173 the @code{cflags} request to be transparent for the purposes of
9174 end-of-sentence recognition.
9175 @end ftable
9177 The following string sets the @TeX{} logo:
9179 @Example
9180 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
9181 @endExample
9183 @cindex width escape (@code{\w})
9184 @cindex escape, width (@code{\w})
9185 @Defesc {\\w, ', text, '}
9186 Used as @code{\w'@var{text}'},
9187 returns the width of the specified @var{text} in basic units.
9188 This allows horizontal movement based on the width of some
9189 arbitrary text (e.g.@: given as an argument to a macro).
9191 @c XXX example
9193 @ignore
9194 @Example
9195 ... strlen example ...
9196 @endExample
9197 @end ignore
9199 Font changes may occur in @var{text} which don't affect current
9200 settings.
9202 After use, @code{\w} sets several registers:
9204 @table @code
9205 @item st
9206 @itemx sb
9207 @vindex st
9208 @vindex sb
9209 The highest and lowest point, respectively, in @var{text}.
9211 @item rst
9212 @itemx rsb
9213 @vindex rst
9214 @vindex rsb
9215 Like the @code{st} and @code{sb} registers, but takes account of the
9216 heights and depths of characters.
9218 @item ct
9219 @vindex ct
9220 Defines the kinds of characters occurring in @var{text}:
9222 @table @asis
9223 @item 0
9224 only short characters, no descenders or tall characters.
9226 @item 1
9227 at least one descender.
9229 @item 2
9230 at least one tall character.
9232 @item 3
9233 at least one each of a descender and a tall character.
9234 @end table
9236 @item ssc
9237 @vindex ssc
9238 The amount of horizontal space (possibly negative) that should be added
9239 to the last character before a subscript.
9241 @item skw
9242 @vindex skw
9243 How far to right of the center of the last character in the @code{\w}
9244 argument, the center of an accent from a roman font should be placed
9245 over that character.
9246 @end table
9247 @endDefesc
9249 @Defesc {\\k, ', x, '}
9250 Stores the current horizontal position in register@w{ }@var{x}.
9251 Use this, for example, to return to the beginning of a string
9252 for highlighting or other decoration.
9253 @endDefesc
9255 @Defreg {.k}
9256 A read-only number register containing the current horizontal output
9257 position.
9258 @endDefreg
9260 @c XXX documentation
9263 @c =====================================================================
9265 @node Drawing Requests, Traps, Page Motions, gtroff Reference
9266 @section Drawing Requests
9267 @cindex drawing requests
9268 @cindex requests for drawing
9270 @code{gtroff} provides a number of ways to draw lines and other figures
9271 on the page.  Used in combination with the page motion commands (see
9272 @ref{Page Motions}, for more info), a wide variety of figures can be
9273 drawn.  However, for complex drawings these operations can be quite
9274 cumbersome, and it may be wise to use graphic preprocessors like
9275 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
9276 information.
9278 All drawing is done via escapes.
9280 @cindex drawing horizontal lines (@code{\l})
9281 @cindex horizontal line, drawing (@code{\l})
9282 @cindex line, horizontal, drawing (@code{\l})
9283 @Defesc {\\l, ', l c, '}
9284 Draws a line rightwards from the current
9285 location.  The full syntax for this escape is:
9287 @Example
9288 \l'@var{l}@var{c}'
9289 @endExample
9291 @noindent
9292 where @var{l} is the length of the line to be drawn, starting at the
9293 current location; positive numbers draw to the right, and negative
9294 numbers draw towards the left.  This can also be specified absolutely
9295 (i.e.@: with a leading @samp{|}) which draws back to the beginning
9296 of the line.
9298 @cindex underscore character
9299 @cindex character, underscore
9300 @cindex line drawing character
9301 @cindex character for line drawing
9302 The optional second parameter@w{ }@var{c} is a character to draw the line
9303 with.  If this second argument is not specified, @code{gtroff} uses
9304 the underscore character.
9306 @cindex zero width space character (@code{\&})
9307 @cindex character, zero width space (@code{\&})
9308 @cindex space character, zero width (@code{\&})
9309 To separate the two arguments (to prevent @code{gtroff} from
9310 interpreting a drawing character as a scaling indicator) use @code{\&}.
9312 Here a small useful example:
9314 @Example
9315 .de box
9316 \(br\\$*\(br\l'|0\(rn'\l'|0\(ul'
9318 @endExample
9320 @cindex @code{|}, used as a box rule
9321 @noindent
9322 Note that this works by outputting a box rule (a vertical line), then
9323 the text given as an argument and then another box rule.  Then the line
9324 drawing escapes both draw from the current location to the beginning of
9325 the @emph{input} line.
9326 @endDefesc
9328 @cindex drawing vertical lines (@code{\L})
9329 @cindex vertical line drawing (@code{\L})
9330 @cindex line, vertical, drawing (@code{\L})
9331 @cindex line drawing character
9332 @cindex character for line drawing
9333 @cindex box rule character
9334 @cindex character, box rule
9335 @Defesc {\\L, ', l c, '}
9336 Draws vertical lines.  Its parameters are
9337 similar to the @code{\l} escape.  The
9338 movement is downwards for positive values,
9339 and upwards for negative values.  The
9340 default character is the box rule character.  As with the vertical
9341 motion escapes, text processing blindly continues where the line
9342 ends.
9344 @c XXX example
9346 @ignore
9347 @Example
9348 ...box macro...
9349 @endExample
9350 @end ignore
9351 @endDefesc
9353 @Defesc {\\D, ', command arg @dots{}, '}
9354 The @code{\D} escape provides a variety of drawing functions.
9355 Note that on character devices, only vertical and horizontal lines are
9356 supported within @code{grotty}.
9358 @table @code
9359 @item \D'l @var{dx} @var{dy}'
9360 Draw a line from the current location to the relative point specified by
9361 (@var{dx},@var{dy}).
9363 @c XXX example
9365 @ignore
9366 @Example
9367 ...revised box macro...
9368 @endExample
9369 @end ignore
9371 @item \D'c @var{d}'
9372 @cindex circle drawing (@code{\D})
9373 @cindex drawing a circle (@code{\D})
9374 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
9375 current position.
9377 @item \D'C @var{d}'
9378 Draw a solid circle with the same parameters as an outlined circle.
9380 @item \D'e @var{dx} @var{dy}'
9381 @cindex drawing an ellipse (@code{\D})
9382 @cindex ellipse drawing (@code{\D})
9383 Draw an ellipse with a horizontal diameter of @var{dx} and a vertical
9384 diameter of @var{dy} with the leftmost point at the current position.
9386 @item \D'E @var{dx} @var{dy}'
9387 Draw a solid ellipse with the same parameters as an outlined ellipse.
9389 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
9390 @cindex arc drawing (@code{\D})
9391 @cindex drawing an arc (@code{\D})
9392 Draw an arc clockwise from the current location through the two
9393 specified locations (@var{dx1},@var{dy1}) and (@var{dx2},@var{dy2}).
9395 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
9396 @cindex drawing a spline (@code{\D})
9397 @cindex spline drawing (@code{\D})
9398 Draw a spline from the current location to (@var{dx1},@var{dy1}) and
9399 then to (@var{dx2},@var{dy2}), and so on.
9401 @item \D'f @var{n}'
9402 @cindex gray shading (@code{\D})
9403 @cindex shading (@code{\D})
9404 @cindex shades for filling objects (@code{\D})
9405 Set the shade of gray to be used for filling solid objects to@w{
9406 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
9407 corresponds solid white and 1000 to solid black, and values in between
9408 correspond to intermediate shades of gray.  This applies only to solid
9409 circles, solid ellipses and solid polygons.  By default, a level of@w{
9410 }1000 is used.
9412 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
9413 @cindex drawing a polygon (@code{\D})
9414 @cindex polygon drawing (@code{\D})
9415 Draw a polygon from the current location to (@var{dx1},@var{dy1}) and
9416 then to (@var{dx2},@var{dy2}) and so on.  When the specified data points
9417 are exhausted, a line is drawn back to the starting point.
9419 @c XXX example
9421 @ignore
9422 @Example
9423 ... box example (yes, again)...
9424 @endExample
9425 @end ignore
9427 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
9428 Draw a solid polygon with the same parameters as an outlined polygon.
9430 @c XXX example
9432 @ignore
9433 @Example
9434 ... shaded box example ...
9435 @endExample
9436 @end ignore
9438 @item \D't @var{n}'
9439 @cindex line thickness (@code{\D})
9440 @cindex thickness of lines (@code{\D})
9441 Set the current line thickness to @var{n}@w{ }machine units.  A value of
9442 zero selects the smallest available line thickness.  A negative value
9443 makes the line thickness proportional to the current point size (this is
9444 the default behaviour of @code{ditroff}).
9445 @end table
9446 @endDefesc
9448 @cindex pile, character (@code{\b})
9449 @cindex character pile (@code{\b})
9450 @cindex stacking characters (@code{\b})
9451 @Defesc {\\b, ', string, '}
9452 @dfn{Piles} a sequence of characters
9453 vertically, and centers it vertically on the current line.  Use it
9454 to build large brackets and braces.
9456 @Example
9457 \b'\(lt\(bv\(lk\(bv\(lb'
9458 @endExample
9459 @endDefesc
9461 @xref{Drawing Functions}.
9464 @c =====================================================================
9466 @node Traps, Diversions, Drawing Requests, gtroff Reference
9467 @section Traps
9468 @cindex traps
9470 @dfn{Traps} are locations, which, when reached, call a specified
9471 macro.  These traps can occur at a given location on the page, at a
9472 given location in the current diversion, after a certain number of input
9473 lines or at the end of input.
9475 @menu
9476 * Page Location Traps::
9477 * Diversion Traps::
9478 * Input Line Traps::
9479 * End-of-input Traps::
9480 @end menu
9482 @c ---------------------------------------------------------------------
9484 @node Page Location Traps, Diversion Traps, Traps, Traps
9485 @subsection Page Location Traps
9486 @cindex page location traps
9487 @cindex traps, page location
9489 @dfn{Page location traps} perform an action when @code{gtroff}
9490 reaches a certain vertical location on the page.  Page location
9491 traps have a variety of purposes, including:
9493 @itemize
9494 @item
9495 setting headers and footers
9497 @item
9498 setting body text in multiple columns
9500 @item
9501 setting footnotes
9502 @end itemize
9504 @cindex enabling vertical position traps (@code{vpt})
9505 @cindex vertical position traps, enabling (@code{vpt})
9506 @cindex vertical position trap enable register (@code{.vpt})
9507 @DefreqList {vpt, flag}
9508 @DefregListEnd {.vpt}
9509 Enables vertical position traps if @var{flag} is non-zero, or disables
9510 them otherwise.  Vertical position traps are traps set by the @code{wh}
9511 or @code{dt} requests.  Traps set by the @code{it} request are not
9512 vertical position traps.  The parameter that controls whether vertical
9513 position traps are enabled is global.  Initially vertical position traps
9514 are enabled.  The current setting of this is available in the
9515 @code{.vpt} read-only number register.
9516 @endDefreq
9518 @Defreq {wh, dist macro}
9519 Sets a page location trap.  Positive values for @var{dist} set
9520 the trap relative to the top of the page; negative values set
9521 the trap relative to the bottom of the page.
9523 @var{macro} is the name of the macro to execute when the
9524 trap is sprung.
9526 @cindex page headers
9527 @cindex page footers
9528 @cindex headers
9529 @cindex footers
9530 The following is a simple example of how many macro packages
9531 set headers and footers.
9533 @Example
9534 .de hd                \" Page header
9535 'sp .5i
9536 .tl 'Title''date'
9537 'sp .3i
9539 .de fo                \" Page footer
9540 'sp 1v
9541 .tl ''%''
9544 .wh 0   hd            \" trap at top of the page
9545 .wh -1i fo            \" trap one inch from bottom
9546 @endExample
9547 @endDefreq
9549 @cindex distance to next trap register (@code{.t})
9550 @cindex trap, distance, register (@code{.t})
9551 @Defreg {.t}
9552 A read-only number register holding the distance to the next trap.
9553 @endDefreg
9555 @cindex changing trap location (@code{ch})
9556 @cindex trap, changing location (@code{ch})
9557 @Defreq {ch, dist macro}
9558 Changes the location of a trap.
9559 The first argument is the name of the macro to be invoked at
9560 the trap, and the second argument is the new location for the trap
9561 (note that the parameters are specified the opposite of the @code{.wh} request).
9562 This is useful for building up footnotes in a diversion to allow more
9563 space at the bottom of the page for them.
9565 @c XXX
9567 @ignore
9568 @Example
9569 ... (simplified) footnote example ...
9570 @endExample
9571 @end ignore
9572 @endDefreq
9574 @Defreg {.ne}
9575 The read-only number register @code{.ne} contains the amount of space
9576 that was needed in the last @code{ne} request that caused a trap to be
9577 sprung.  Useful in conjunction with the @code{.trunc} register.
9578 @xref{Page Control}, for more information.
9579 @endDefreg
9581 @cindex @code{ne} request, and the @code{.trunc} register
9582 @cindex truncated vertical space register (@code{.trunc})
9583 @Defreg {.trunc}
9584 A read-only register containing the amount of vertical space truncated
9585 by the most recently sprung vertical position trap, or, if the trap was
9586 sprung by an @code{ne} request, minus the amount of vertical motion
9587 produced by the @code{ne} request.  In other words, at the point a trap
9588 is sprung, it represents the difference of what the vertical position
9589 would have been but for the trap, and what the vertical position
9590 actually is.
9591 @endDefreg
9593 @c ---------------------------------------------------------------------
9595 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
9596 @subsection Diversion Traps
9597 @cindex diversion traps
9598 @cindex traps, diversion
9600 @cindex @code{.t} register, and diversions
9601 @cindex setting diversion trap (@code{dt})
9602 @cindex diversion trap, setting (@code{dt})
9603 @cindex trap, diversion, setting (@code{dt})
9604 @Defreq {dt, dist macro}
9605 Sets a trap @emph{within} a diversion.
9606 @var{dist} is the first argument is the location of the trap
9607 (identical to the @code{.wh} request)
9608 and @var{macro} is the name of the macro to be invoked.  The
9609 number register @code{.t} still works within diversions.
9610 @xref{Diversions}, for more information.
9611 @endDefreq
9613 @c ---------------------------------------------------------------------
9615 @node Input Line Traps, End-of-input Traps, Diversion Traps, Traps
9616 @subsection Input Line Traps
9617 @cindex input line traps
9618 @cindex traps, input line
9620 @cindex setting input line trap (@code{it})
9621 @cindex input line trap, setting (@code{it})
9622 @cindex trap, input line, setting (@code{it})
9623 @Defreq {it, n macro}
9624 Sets an input line trap.
9625 @var{n}@w{ }is the number of lines of input which may be read before
9626 @dfn{springing} the trap, @var{macro} is the macro to be invoked.
9627 Request lines are not counted as input lines.
9629 For example, one possible use is to have a macro which prints the
9630 next @var{n}@w{ }lines in a bold font.
9632 @Example
9633 .de B
9634 .it \\$1 B-end
9635 .ft B
9637 .de B-end
9638 .ft R
9640 @endExample
9641 @endDefreq
9643 @c ---------------------------------------------------------------------
9645 @node End-of-input Traps,  , Input Line Traps, Traps
9646 @subsection End-of-input Traps
9647 @cindex end-of-input traps
9648 @cindex traps, end-of-input
9650 @cindex setting end-of-input trap (@code{em})
9651 @cindex end-of-input trap, setting (@code{em})
9652 @cindex trap, end-of-input, setting (@code{em})
9653 @cindex end-of-input macro (@code{em})
9654 @cindex macro, end-of-input (@code{em})
9655 @Defreq {em, macro}
9656 Sets a trap at the end of input.  The @var{macro}
9657 specified is executed after the last line of the
9658 input file has been processed.
9660 For example, if the document had to have a section at the bottom of the
9661 last page for someone to approve it, the @code{em} request could be
9662 used.
9664 @Example
9665 .de approval
9666 .ne 5v
9667 .sp |(\\n(.t-6v)
9668 .in +4i
9669 .lc _
9671 Approved:\t\a
9673 Date:\t\t\a
9675 .em approval
9676 @endExample
9677 @endDefreq
9680 @c =====================================================================
9682 @node Diversions, Environments, Traps, gtroff Reference
9683 @section Diversions
9684 @cindex diversions
9686 In @code{gtroff} it is possible to @dfn{divert} text into a named
9687 storage area.  Due to the similarity to defining macros it is sometimes
9688 said to be stored in a macro.  This is used for saving text for output
9689 at a later time, which is useful for keeping blocks of text on the same
9690 page, footnotes, tables of contents and indices.
9692 @c XXX describe top-level diversion
9693 @c XXX index entry for top-level diversion
9695 @cindex beginning diversion (@code{di})
9696 @cindex diversion, beginning (@code{di})
9697 @cindex ending diversion (@code{di})
9698 @cindex diversion, ending (@code{di})
9699 @cindex appending to diversion (@code{da})
9700 @cindex diversion, appending (@code{da})
9701 @DefreqList {di, macro}
9702 @DefreqListEnd {da, macro}
9703 Begins a diversion.  Like the @code{de}
9704 request, it takes an argument of a macro name to divert subsequent text
9705 into.  The @code{da} macro appends to an existing diversion.
9707 @code{di} or @code{da} without an argument ends the diversion.
9709 @c XXX example
9711 @ignore
9712 @Example
9713 ... end-note example ...
9714 @endExample
9715 @end ignore
9716 @endDefreq
9718 @cindex @code{nl} register, and @code{.d}
9719 @cindex nested diversions
9720 @cindex diversion, nested
9721 @cindex diversion name register (@code{.z})
9722 @cindex vertical position in diversion register (@code{.d})
9723 @cindex position, vertical, in diversion, register (@code{.d})
9724 @cindex diversion, vertical position in, register (@code{.d})
9725 @DefregList {.z}
9726 @DefregListEnd {.d}
9727 Diversions may be nested.  The read-only number register @code{.z}
9728 contains the name of the current diversion (this is a string-valued
9729 register).  The read-only number register @code{.d} contains the current
9730 vertical place in the diversion.  If not in a diversion it is the same
9731 as the register @code{nl}.
9732 @endDefreg
9734 @c XXX more info
9736 @Defreg {.h}
9737 The @dfn{high-water mark} on the current page.  It corresponds to the
9738 text baseline of the lowest line on the page.  This is a read-only
9739 register.
9740 @endDefreg
9742 @DefregList {dn}
9743 @DefregListEnd {dl}
9744 After completing a diversion, the read-write number registers @code{dn}
9745 and @code{dl} contain the vertical and horizontal size of the diversion.
9747 @example
9748 @group
9749 .\" Center text both horizontally & vertically
9751 .\" Enclose macro definitions in .eo and .ec
9752 .\" to avoid the doubling of the backslash
9754 .\" macro .(c starts centering mode
9755 .de (c
9756 .  br
9757 .  nf
9758 .  di @@c
9760 @end group
9761 @group
9762 .\" macro .)c terminates centering mode
9763 .de )c
9764 .  br
9765 .  di
9766 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
9767 .  sp \n[@@s]u
9768 .  ce 1000
9769 .  @@c
9770 .  ce 0
9771 .  sp \n[@@s]u
9772 .  br
9773 .  fi
9774 .  rr @@s
9775 .  rm @@s
9776 .  rm @@c
9778 .\" End of macro definitions, restore escape mechanism
9780 @end group
9781 @end example
9782 @endDefreg
9784 @cindex transparent output (@code{\!})
9785 @cindex output, transparent (@code{\!})
9786 @DefescList {\\!, , , }
9787 @DefescListEnd {\\?, , @Var{anything}, \\?}
9788 Prevents requests, macros and escapes from being
9789 interpreted when read into a diversion.  This takes the given text
9790 and @dfn{transparently} embeds it into the diversion.  This is useful for
9791 macros which shouldn't be invoked until the diverted text is actually
9792 output.
9794 @c XXX anything is read in copy mode. (what about \! ??)
9796 The @code{\!} escape transparently embeds text up to
9797 and including the end of the line.
9798 The @code{\?} escape transparently embeds text until the next
9799 occurrence of the @code{\?} escape.  For example:
9801 @Example
9802 \?@var{anything}\?
9803 @endExample
9805 @noindent
9806 @var{anything} may not contain newlines; use @code{\!}  to embed
9807 newlines in a diversion.  The escape sequence @code{\?} is also
9808 recognized in copy mode and turned into a single internal code; it is
9809 this code that terminates anything.  Thus the following example
9810 prints@w{ }4.
9812 @Example
9813 .nr x 1
9815 .di d
9816 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
9818 .nr x 2
9819 .di e
9822 .nr x 3
9823 .di f
9826 .nr x 4
9828 @endExample
9829 @endDefesc
9831 @cindex unformatting diversions (@code{asciify})
9832 @cindex diversion, unformatting (@code{asciify})
9833 @Defreq {asciify, div}
9834 @dfn{Unformats} the diversion specified by @var{div}
9835 in such a way that @acronym{ASCII} and space characters that
9836 were formatted and diverted are treated like ordinary input
9837 characters when the diversion is reread.  It can be also used for gross
9838 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
9840 @Example
9841 .tr @@.
9842 .di x
9843 @@nr n 1
9846 .tr @@@@
9847 .asciify x
9849 @endExample
9851 @xref{Copy-in Mode}.
9852 @endDefreq
9855 @c =====================================================================
9857 @node Environments, Suppressing output, Diversions, gtroff Reference
9858 @section Environments
9859 @cindex environments
9861 It happens frequently that some text should be printed in a certain
9862 format regardless of what may be in effect at the time, for example, in
9863 a trap invoked macro to print headers and footers.  To solve this
9864 @code{gtroff} processes text in @dfn{environments}.  An
9865 environment contains most of the parameters that control text
9866 processing.  It is possible to switch amongst these environments; by
9867 default @code{gtroff} processes text in environment@w{ }0.  The
9868 following is the information kept in an environment.
9870 @itemize @bullet
9871 @item
9872 font parameters (size, family, style, character height and slant, space
9873 and sentence space size)
9875 @item
9876 page parameters (line length, title length, vertical spacing,
9877 line spacing, indentation, line numbering, hyphenation data)
9879 @item
9880 fill and adjust mode
9882 @item
9883 tab stops, tab and leader characters, escape character, no-break and
9884 hyphen indicators, margin character data
9886 @item
9887 partially collected lines
9888 @end itemize
9890 These environments may be given arbitrary names (see @ref{Identifiers},
9891 for more info).  Old versions of @code{troff} only had environments
9892 named @samp{0}, @samp{1} and @samp{2}.
9894 @cindex switching environment (@code{ev})
9895 @cindex environment, switching (@code{ev})
9896 @cindex environment number/name register (@code{.ev})
9897 @DefreqList {ev, env}
9898 @DefregListEnd {.ev}
9899 Switches to another environment.  The argument @var{env} is the name of
9900 the environment to switch to.  With no argument, @code{gtroff} switches
9901 back to the previous environment.  There is no limit on the number of
9902 named environments; they are created the first time that they are
9903 referenced.  The @code{.ev} read-only register contains the name or
9904 number of the current environment.  This is a string-valued register.
9906 Note that a call to @code{ev} (with argument) pushes the previously
9907 active environment onto a stack.  If, say, environments @samp{foo},
9908 @samp{bar}, and @samp{zap} are called (in that order), the first
9909 @code{ev} request without parameter switches back to environment
9910 @samp{bar} (which is popped off the stack), and a second call
9911 switches back to environment @samp{foo}.
9913 @c XXX example
9915 @ignore
9916 @Example
9917 ... page break macro, revised ...
9918 @endExample
9919 @end ignore
9921 Here is an example:
9923 @Example
9924 .ev footnote-env
9925 .fam N
9926 .ps 6
9927 .vs 8
9928 .ll -.5i
9933 .ev footnote-env
9934 \(dg Note the large, friendly letters.
9936 @endExample
9937 @endDefreq
9939 @cindex copying environment (@code{evc})
9940 @cindex environment, copying (@code{evc})
9941 @Defreq {evc, env}
9942 Copies the environment @var{env} into the current environment.
9943 @endDefreq
9946 @c =====================================================================
9948 @node Suppressing output, Colors, Environments, gtroff Reference
9949 @section Suppressing output
9951 @cindex suppressing output (@code{\O})
9952 @cindex output, suppressing (@code{\O})
9953 @Defesc {\\O, , num, }
9954 Disables or enables output depending on the value of @var{num}:
9956 @table @samp
9957 @item \O0
9958 Disable any ditroff glyphs from being emitted to the device driver,
9959 provided that the escape occurs at the outer level (see @code{\O3} and
9960 @code{\O4}).
9962 @item \O1
9963 Enable output of glyphs, provided that the escape occurs at the outer
9964 level.
9965 @end table
9967 @vindex opminx
9968 @vindex opminy
9969 @vindex opmaxx
9970 @vindex opmaxy
9971 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
9972 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
9973 @xref{Register Index}.  These four registers mark the top left and
9974 bottom right hand corners of a box which encompasses all written glyphs.
9976 @table @samp
9977 @item \O2
9978 Provided that the escape occurs at the outer level, enable output of
9979 glyphs and also write out to @code{stderr} the page number and four
9980 registers encompassing the glyphs previously written since the last call
9981 to @code{\O}.
9983 @item \O3
9984 Begin a nesting level.  This is really an internal mechanism for
9985 @code{grohtml} while producing images.  They are generated by running
9986 the troff source through troff to the postscript device and ghostscript
9987 to produce images in PNG format.  The @code{\O3} escape will start a new
9988 page if the device is not html (to reduce the possibility of images
9989 crossing a page boundary).
9991 @item \O4
9992 End a nesting level.
9994 @item \O[5Pfilename]
9995 This escape is @code{grohtml} specific.  Provided that this escape
9996 occurs at the outer nesting level write the @code{filename} to
9997 @code{stderr}.  The position of the image, @var{P}, must be specified
9998 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
9999 right, centered, inline).  @var{filename} will be associated with the
10000 production of the next inline image.
10001 @end table
10002 @endDefesc
10005 @c =====================================================================
10007 @node Colors, I/O, Suppressing output, gtroff Reference
10008 @section Colors
10010 @Defreq {defcolor, ident scheme color_components}
10011 Define color with name @var{ident}.  @var{scheme} can be one of  the
10012 following values: @code{rgb} (three components), @code{cym} (three
10013 components), @code{cmyk} (four components), and @code{gray} or
10014 @code{grey} (one component).
10016 @cindex default color
10017 @cindex color, default
10018 Color components can be given either as a hexadecimal string or as
10019 positive decimal integers in the range 0--65535.  A hexadecimal string
10020 contains all color components concatenated.  It must start with either
10021 @code{#} or @code{##}; the former specifies hex values in the range
10022 0--255 (which are internally multiplied by@w{ }257), the latter in the
10023 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
10024 (magenta).  The default color name @c{default} can't be redefined; its
10025 value is device-specific (usually black).  It is possible that the
10026 default color for @code{\m} and @code{\M} is not identical.
10028 @cindex @code{f} unit, and colors
10029 @cindex unit, @code{f}, and colors
10030 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
10031 its value by 65536; this makes it convenient to specify color components
10032 as fractions in the range 0 to@w{ }1 (1f equals 65536u).  Example:
10034 @Example
10035 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
10036 @endExample
10038 Note that @code{f} is the default scaling indicator for the
10039 @code{defcolor} request, thus the above statement is equivalent to
10041 @Example
10042 .defcolor darkgreen rgb 0.1 0.5 0.2
10043 @endExample
10044 @endDefreq
10046 @DefescList {\\m, , c, }
10047 @DefescItem {\\m, @lparen{}, co, }
10048 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
10049 Set drawing color.  The following example shows how to turn the next four
10050 words red.
10052 @Example
10053 \m[red]these are in red\mP and these words are in black.
10054 @endExample
10056 The escape @code{\mP} returns to the previous color.
10057 @endDefesc
10059 @DefescList {\\M, , c, }
10060 @DefescItem {\\M, @lparen{}, co, }
10061 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
10062 Set background color for filled objects drawn with the
10063 @code{\D'@dots{}'} commands.
10065 A red ellipse can be created with the following code:
10067 @Example
10068 \M[red]\h'0.5i'\D'E 2i 1i'\Mp
10069 @endExample
10071 The escape @code{\MP} returns to the previous fill color.
10072 @endDefesc
10074 @c =====================================================================
10076 @node I/O, Postprocessor Access, Colors, gtroff Reference
10077 @section I/O
10078 @cindex i/o
10079 @cindex input and output requests
10080 @cindex requests for input and output
10081 @cindex output and input requests
10083 @code{gtroff} has several requests for including files:
10085 @cindex including a file (@code{so})
10086 @cindex file inclusion (@code{so})
10087 @Defreq {so, file}
10088 Reads in the specified @var{file} and
10089 includes it in place of the @code{so} request.  This is quite useful for
10090 large documents, e.g.@: keeping each chapter in a separate file.
10091 @xref{gsoelim}, for more information.
10092 @endDefreq
10094 @Defreq {mso, file}
10095 Identical to the @code{so} request except that @code{gtroff}
10096 searches for the specified
10097 @var{file} in the same directories as macro files for the
10098 the @option{-m} command line option.  If the file name to be included
10099 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
10100 to include @file{tmac.@var{name}} and vice versa.
10101 @endDefreq
10103 @cindex transparent output (@code{cf}, @code{trf})
10104 @cindex output, transparent (@code{cf}, @code{trf})
10105 @DefreqList {cf, file}
10106 @DefreqListEnd {trf, file}
10107 Transparently outputs the contents of @var{file}.  Each line is output
10108 as it were preceded by @code{\!}; however, the lines are not subject to
10109 copy mode interpretation.  If the file does not end with a newline, then
10110 a newline is added.  For example, to define a macro@w{ }@code{x}
10111 containing the contents of file@w{ }@file{f}, use
10113 @Example
10114 .di x
10115 .trf f
10117 @endExample
10119 The request @w{@code{.cf @var{filename}}}, when used in a diversion,
10120 embeds an object in the diversion which, when reread, causes the
10121 contents of @var{filename} to be transparently copied through to the
10122 output.
10124 In @acronym{UNIX} @code{troff}, the contents of @var{filename}
10125 is immediately copied through to the output regardless of whether there
10126 is a current diversion; this behaviour is so anomalous that it must be
10127 considered a bug.  This request causes a line break.
10129 @cindex @code{trf} request, and invalid characters
10130 With @code{trf}, unlike @code{cf}, the file cannot contain characters
10131 such as NUL that are not valid @code{gtroff} input characters
10132 (@pxref{Identifiers}).  This request causes a line break.
10133 @endDefreq
10135 @cindex processing next file (@code{nx})
10136 @cindex file, processing next (@code{nx})
10137 @cindex next file, processing (@code{nx})
10138 @Defreq {nx, }
10139 Forces @code{gtroff} to continue processing of
10140 the file specified as an argument.
10141 @endDefreq
10143 @cindex reading from standard input (@code{rd})
10144 @cindex standard input, reading from (@code{rd})
10145 @cindex input, standard, reading from (@code{rd})
10146 @Defreq {rd, }
10147 The @code{rd} request reads from standard input, and includes what is
10148 read as though it were part of the input file.  Text is read until a
10149 blank line is encountered.
10150 @endDefreq
10152 @cindex form letters
10153 @cindex letters, form
10154 Using the @code{nx} and @code{rd} requests,
10155 it is easy to set up form letters.  The form
10156 letter template is constructed like this:
10158 @Example
10160 \*(td
10161 .sp 2
10167 Body of letter.
10169 .nx repeat.let
10170 @endExample
10172 @cindex @code{ex} request, used with @code{nx} and @code{rd}
10173 @noindent
10174 When this is run, the following file should be redirected in.  Note that
10175 requests included in this file are executed as though they were part of
10176 the form letter.  The last block of input is the @code{ex} requests
10177 which tells groff to stop processing.  If this was not there, groff
10178 would not know when to stop.
10180 @Example
10181 Trent A. Fisher
10182 708 NW 19th Av., #202
10183 Portland, OR  97209
10185 Dear Trent,
10187 Len Adollar
10188 4315 Sierra Vista
10189 San Diego, CA  92103
10191 Dear Mr. Adollar,
10194 @endExample
10196 @Defreq {pi, pipe}
10197 Pipes the output of @code{gtroff} to the shell command(s)
10198 specified by @var{pipe}.  This request must occur before
10199 @code{gtroff} has a chance to print anything.
10200 @endDefreq
10202 @DefreqList {sy, cmds}
10203 @DefregListEnd {systat}
10204 In @dfn{unsafe} mode, executes the shell command(s) specified by
10205 @var{cmds}.  The output is not saved anyplace, so it is up to the user
10206 to do so.
10208 @c XXX add info about safer and unsafe mode
10210 For example, the following example introduces the current time
10211 into a document:
10213 @cindex time, current
10214 @cindex current time
10215 @pindex perl
10216 @Example
10217 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
10218              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
10219 .so /tmp/x\n[$$]
10220 .sy rm /tmp/x\n[$$]
10221 \nH:\nM:\nS
10222 @endExample
10224 @noindent
10225 Note that this works by having the @code{perl} script (run by @code{sy})
10226 print out the @code{nr} requests which set the number registers
10227 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in with
10228 the @code{so} request.
10230 @cindex @code{system()} return value register (@code{systat})
10231 The @code{systat} read-write number register contains the return value
10232 of the @code{system()} function executed by the last @code{sy} request.
10233 @endDefreq
10235 @cindex opening file (@code{open})
10236 @cindex file, opening (@code{open})
10237 @cindex appending to file (@code{opena})
10238 @cindex file, appending to (@code{opena})
10239 @DefreqList {open, stream file}
10240 @DefreqListEnd {opena, stream file}
10241 Opens the specified @var{file} for writing and
10242 associates the specified @var{stream} with it.
10244 The @code{opena} is like @code{open}, but if the file exists, append to
10245 it instead of truncating it.
10246 @endDefreq
10248 @cindex copy-in mode, and @code{write} requests
10249 @cindex mode, copy-in, and @code{write} requests
10250 @cindex writing to file (@code{write})
10251 @cindex file, writing to (@code{write})
10252 @Defreq {write, stream data}
10253 Writes to the file associated with the specified @var{stream}.
10254 The stream must previously have
10255 been the subject of an open request.  The remainder of the line is
10256 interpreted as the @code{ds} request reads its second argument: A
10257 leading @samp{"} is stripped, and it is read in copy-in mode.
10258 @endDefreq
10260 @cindex closing file (@code{close})
10261 @cindex file, closing (@code{close})
10262 @Defreq {close, stream}
10263 Closes the specified @var{stream};
10264 the stream is no longer an acceptable argument to the
10265 @code{write} request.
10267 @c XXX example
10269 @ignore
10270 @Example
10271 ... example of open write &c...
10272 @endExample
10273 @end ignore
10274 @endDefreq
10276 @Defesc {\\V, ', xxx, '}
10277 Interpolates the contents of the specified
10278 environment variable, as returned by the function @code{getenv}.
10279 Specify the argument to @code{\V} as an identifier, i.e.@:
10280 @samp{\V@var{x}}, @samp{\V(@var{xx}} or @samp{\V[@var{xxx}]}.  @code{\V}
10281 is interpreted in copy-in mode.
10282 @endDefesc
10285 @c =====================================================================
10287 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
10288 @section Postprocessor Access
10289 @cindex postprocessor access
10290 @cindex access of postprocessor
10292 There are two escapes which give information directly to the
10293 postprocessor.  This is particularly useful for embedding
10294 @sc{PostScript} into the final document.
10296 @Defesc {\\X, ', xxx, '}
10297 Embeds its argument into the @code{gtroff}
10298 output preceded with @w{@samp{x X}}.
10299 @endDefesc
10301 @Defesc {\\Y, ', xxx, '}
10302 The @code{\Y} escape is called with an identifier (i.e.@:
10303 @code{\Y@var{x}}, @code{\Y(@var{xx}} or @code{\Y[@var{xxx}]}).  This is
10304 approximately equivalent to @samp{\X'\*[@var{xxx}]'}.  However, the
10305 contents of the string or macro @var{xxx} are not interpreted; also it
10306 is permitted for @var{xxx} to have been defined as a macro and thus
10307 contain newlines (it is not permitted for the argument to @code{\X} to
10308 contain newlines).  The inclusion of newlines requires an extension to
10309 the @acronym{UNIX} @code{troff} output format, and confuses drivers
10310 that do not know about this extension.
10311 @endDefesc
10313 @xref{Output Devices}.
10316 @c =====================================================================
10318 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
10319 @section Miscellaneous
10320 @cindex miscellaneous
10322 This section documents parts of @code{gtroff} which cannot (yet) be
10323 categorized elsewhere in this manual.
10325 @cindex printing line numbers (@code{nm})
10326 @cindex line numbers, printing (@code{nm})
10327 @cindex numbers, line, printing (@code{nm})
10328 @Defreq {nm, start inc space indent}
10329 Prints line numbers in the left margin.
10330 @var{start} is the line number of the @emph{next}
10331 output line; this defaults to@w{ }1.  @var{inc} indicates on
10332 which lines numbers are printed, i.e.@: 5 means put line numbers on
10333 every 5@w{ }lines; this defaults to@w{ }1.  @var{space} is the
10334 space to be left between the number and the text; this defaults to@w{
10335 }1.  The fourth argument is the indentation of the line numbers.
10336 Without arguments, line numbers are turned off.
10337 @endDefreq
10339 @c XXX xref ln register
10341 @Defreq {nn, [@Var{skip}]}
10342 Temporarily turns off line numbering.  The
10343 argument is the number of lines not to be numbered; this defaults
10344 to@w{ }1.
10346 @c XXX (does this disable incrementing or display?)
10348 @c XXX example
10350 @ignore
10351 @Example
10352 ... line numbering example ...
10353 @endExample
10354 @end ignore
10355 @endDefreq
10357 @cindex margin characters (@code{mc})
10358 @cindex characters for margins (@code{mc})
10359 @Defreq {mc, char dist}
10360 Prints margin characters to the right of the text.
10361 The first argument is the character to be
10362 printed, and the second argument is the distance away from the main body
10363 text.  With no arguments the margin characters are turned off.  If this
10364 occurs before a break, no margin character is printed.
10366 @pindex nrchbar
10367 @pindex changebar
10368 This is quite useful for indicating text that has changed, and, in fact,
10369 there are programs available for doing this (they are called
10370 @code{nrchbar} and @code{changebar} and can be found in any
10371 @samp{comp.sources.unix} archive.
10373 @c XXX example
10375 @ignore
10376 @Example
10377 ... margin char example ...
10378 @endExample
10379 @end ignore
10380 @endDefreq
10382 @pindex soelim
10383 @cindex multi-file documents
10384 @cindex documents, multi-file
10385 @cindex setting input line number (@code{lf})
10386 @cindex input line number, setting (@code{lf})
10387 @cindex number, input line, setting (@code{lf})
10388 @Defreq {lf, line filename}
10389 A debugging aid for
10390 documents which are split into many files, then put together
10391 with @code{soelim} and other preprocessors.  The second argument is the
10392 name of the file and the first argument is the input line number in
10393 that file.  This way @code{gtroff} can produce error messages which are
10394 intelligible to the user.
10396 @c XXX example
10398 @ignore
10399 @Example
10400 ... example of soelim'ed doc ...
10401 @endExample
10402 @end ignore
10403 @endDefreq
10406 @c =====================================================================
10408 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
10409 @section @code{gtroff} Internals
10411 @cindex input token
10412 @cindex token, input
10413 @cindex output node
10414 @cindex node, output
10415 @code{gtroff} processes input in three steps.  One or more input
10416 characters are converted to an @dfn{input token}.  Then, one or more
10417 input tokens are converted to an @dfn{output node}.  Finally, output
10418 nodes are converted to the intermediate output language understood by
10419 all output devices.
10421 For example, the input string @samp{fi\[:u]} is converted in a
10422 character token @samp{f}, a character token @samp{i}, and a special
10423 token @samp{:u} (representing u@w{ }umlaut).  Later on, the character
10424 tokens @samp{f} and @samp{i} are merged to a single output node
10425 representing the ligature glyph @samp{fi}; the same happens with
10426 @samp{:u}.  All output glyph nodes are `processed' which means that
10427 they are invariably associated with a given font, font size, advance
10428 width, etc.  During the formatting process, @code{gtroff} itself adds
10429 various nodes to control the data flow.
10431 Macros, diversions, and strings collect elements in two chained lists:
10432 a list of input tokens which have been passed unprocessed, and a list
10433 of output nodes.  Consider the following the diversion.
10435 @Example
10436 .di xxx
10442 @endExample
10444 @noindent
10445 It contains these elements.
10447 @multitable {@i{vertical size node}} {token list} {element number}
10448 @item node list               @tab token list @tab element number
10450 @item @i{line start node}     @tab ---        @tab 1
10451 @item @i{glyph node @code{a}} @tab ---        @tab 2
10452 @item @i{word space node}     @tab ---        @tab 3
10453 @item ---                     @tab @code{b}   @tab 4
10454 @item ---                     @tab @code{\n}  @tab 5
10455 @item @i{glyph node @code{c}} @tab ---        @tab 6
10456 @item @i{vertical size node}  @tab ---        @tab 7
10457 @item @i{vertical size node}  @tab ---        @tab 8
10458 @item ---                     @tab @code{\n}  @tab 9
10459 @end multitable
10461 @cindex @code{\v}, internal representation
10462 @noindent
10463 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
10464 (which are always present) specify the vertical extent of the last
10465 line, possibly modified by @code{\v}.  The @code{br} request finishes
10466 the current partial line, inserting a newline input token which is
10467 subsequently converted to a space when the diversion is reread.  Note
10468 that the word space node has a fixed width which isn't stretchable
10469 anymore.  To convert horizontal space nodes back to input tokens, use
10470 the @code{unformat} request.
10472 Macros only contain elements in the token list (and the node list is
10473 empty); diversions and strings can contain elements in both lists.
10476 @c =====================================================================
10478 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
10479 @section Debugging
10480 @cindex debugging
10482 @code{gtroff} is not easy to debug, but there are some useful features
10483 and strategies for debugging.
10485 @cindex printing to stderr (@code{tm})
10486 @cindex stderr, printing to (@code{tm})
10487 @Defreq {tm, string}
10488 Sends the @var{string} to the standard error stream;
10489 this is very useful for printing debugging output among other things.
10490 @endDefreq
10492 @cindex aborting (@code{ab})
10493 @Defreq {ab, [@Var{string}]}
10494 Similar to the @code{tm} request, except that
10495 it causes @code{gtroff} to stop processing.  With no argument it
10496 prints @samp{User Abort}.
10497 @endDefreq
10499 @cindex @code{ex} request, use in debugging
10500 @cindex exiting (@code{ex})
10501 @Defreq {ex, }
10502 The @code{ex} request also causes @code{gtroff} to stop processing
10503 if encountered at the topmost level; see also @ref{I/O}.
10504 @endDefreq
10506 When doing something involved it is useful to leave the debugging
10507 statements in the code and have them turned on by a command line flag.
10509 @Example
10510 .if \n(DB .tm debugging output
10511 @endExample
10513 @noindent
10514 To activate these statements say
10516 @Example
10517 groff -rDB=1 file
10518 @endExample
10520 @c XXX .tm1, .tmc requests
10522 If it is known in advance that there will be many errors and no useful
10523 output, @code{gtroff} can be forced to suppress formatted output with
10524 the @option{-z} flag.
10526 @cindex dumping symbol table (@code{pm})
10527 @cindex symbol table, dumping (@code{pm})
10528 @Defreq {pm, }
10529 The @code{pm} request prints out the entire symbol table on @code{stderr}.
10530 @endDefreq
10532 @cindex dumping number registers (@code{pnr})
10533 @cindex number registers, dumping (@code{pnr})
10534 @Defreq {pnr, }
10535 Prints the names and contents of all
10536 currently defined number registers on @code{stderr}.
10537 @endDefreq
10539 @cindex dumping traps (@code{ptr})
10540 @cindex traps, dumping (@code{ptr})
10541 @Defreq {ptr, }
10542 Prints the names and positions of all traps
10543 (not including input line traps and diversion traps) on @code{stderr}.
10544 Empty slots in the page trap list are printed as well, because they can
10545 affect the priority of subsequently planted traps.
10546 @endDefreq
10548 @cindex flush output (@code{fl})
10549 @cindex output, flush (@code{fl})
10550 @cindex interactive use of @code{gtroff}
10551 @cindex @code{gtroff}, interactive use
10552 @Defreq {fl, }
10553 Instructs @code{gtroff} to flush its output
10554 immediately.  The intent is for interactive use.
10555 @code{gtroff}; there is little other use for it.  This
10556 request causes a line break.
10557 @endDefreq
10559 @cindex backtrace of input stack (@code{backtrace})
10560 @cindex input stack, backtrace (@code{backtrace})
10561 @Defreq {backtrace, }
10562 The @code{backtrace} request prints a backtrace of the input stack
10563 to the standard error stream.
10564 @endDefreq
10566 @cindex warnings
10567 @code{gtroff} has command line options for printing out more warnings
10568 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
10569 or an error occurs.  The most verbose level of warnings is @option{-ww}.
10571 @cindex level of warnings (@code{warn})
10572 @cindex warnings, level (@code{warn})
10573 @DefreqList {warn, [@Var{flags}]}
10574 @DefregListEnd {.warn}
10575 Controls the level of warnings checked for.  The @var{flags} are the sum
10576 of the numbers associated with each warning that is to be enabled; all
10577 other warnings are disabled.  The number associated with each warning is
10578 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
10579 and @w{@code{.warn 1}} disables all warnings except that about missing
10580 characters.  If an argument is not given, all warnings are enabled.
10582 The read-only number register @code{.warn} contains the current warning
10583 level.
10584 @endDefreq
10586 @menu
10587 * Warnings::
10588 @end menu
10590 @c ---------------------------------------------------------------------
10592 @node Warnings,  , Debugging, Debugging
10593 @subsection Warnings
10594 @cindex warnings
10596 The warnings that can be given to @code{gtroff} are divided into the
10597 following categories.  The name associated with each warning is used by
10598 the @option{-w} and @option{-W} options; the number is used by the
10599 @code{warn} request and by the @code{.warn} register.
10601 @table @samp
10602 @item char
10603 @itemx 1
10604 Non-existent characters.  This is enabled by default.
10606 @item number
10607 @itemx 2
10608 Invalid numeric expressions.  This is enabled by default.
10609 @xref{Expressions}.
10611 @item break
10612 @itemx 4
10613 @cindex fill mode
10614 @cindex mode, fill
10615 In fill mode, lines which could not be broken so that their length was
10616 less than the line length.  This is enabled by default.
10618 @item delim
10619 @itemx 8
10620 Missing or mismatched closing delimiters.
10622 @item el
10623 @itemx 16
10624 @cindex @code{ie} request, and warnings
10625 @cindex @code{el} request, and warnings
10626 Use of the @code{el} request with no matching @code{ie} request.
10627 @xref{if-else}.
10629 @item scale
10630 @itemx 32
10631 Meaningless scaling indicators.
10633 @item range
10634 @itemx 64
10635 Out of range arguments.
10637 @item syntax
10638 @itemx 128
10639 Dubious syntax in numeric expressions.
10641 @item di
10642 @itemx 256
10643 @cindex @code{di} request, and warnings
10644 @cindex @code{da} request, and warnings
10645 Use of @code{di} or @code{da} without an argument when there is no
10646 current diversion.
10648 @item mac
10649 @itemx 512
10650 @cindex @code{de} request, and warnings
10651 @c XXX more index entries
10652 Use of undefined strings, macros and diversions.  When an undefined
10653 string, macro or diversion is used, that string is automatically defined
10654 as empty.  So, in most cases, at most one warning is given for each
10655 name.
10657 @item  reg
10658 @itemx 1024
10659 @cindex @code{nr} request, and warnings
10660 @c XXX more index entries
10661 Use of undefined number registers.  When an undefined number register is
10662 used, that register is automatically defined to have a value of@w{ }0.
10663 A definition is automatically made with a value of@w{ }0.  So, in most
10664 cases, at most one warning is given for use of a particular name.
10666 @item  tab
10667 @itemx 2048
10668 Use of a tab character where a number was expected.
10670 @item  right-brace
10671 @itemx 4096
10672 @cindex @code{\@}}, debugging
10673 Use of @code{\@}} where a number was expected.
10675 @item  missing
10676 @itemx 8192
10677 Requests that are missing non-optional arguments.
10679 @item  input
10680 @itemx 16384
10681 Invalid input characters.
10683 @item  escape
10684 @itemx 32768
10685 Unrecognized escape sequences.  When an unrecognized escape sequence is
10686 encountered, the escape character is ignored.
10688 @item  space
10689 @itemx 65536
10690 @cindex compatibility mode
10691 Missing space between a request or macro and its argument.  This warning
10692 is given when an undefined name longer than two characters is
10693 encountered, and the first two characters of the name make a defined
10694 name.  The request or macro is not invoked.  When this warning is
10695 given, no macro is automatically defined.  This is enabled by default.
10696 This warning never occurs in compatibility mode.
10698 @item  font
10699 @itemx 131072
10700 Non-existent fonts.  This is enabled by default.
10702 @item all
10703 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
10704 intended that this covers all warnings that are useful with traditional
10705 macro packages.
10707 @item w
10708 All warnings.
10709 @end table
10712 @c =====================================================================
10714 @node Implementation Differences, Summary, Debugging, gtroff Reference
10715 @section Implementation Differences
10716 @cindex implementation differences
10717 @cindex differences in implementation
10718 @cindex incompatibilities with Unix @code{troff}
10719 @cindex compatibility mode
10720 @cindex mode, compatibility
10722 GNU @code{troff} has a number of features which cause incompatibilities
10723 with documents written with old versions of @code{troff}.
10725 @cindex long names
10726 @cindex names, long
10727 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
10728 interprets
10730 @Example
10731 .dsabcd
10732 @endExample
10734 @cindex @code{\*}, incompatibilities with Unix @code{troff}
10735 @cindex @code{\n}, incompatibilities with Unix @code{troff}
10736 @noindent
10737 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
10738 @code{troff} interprets this as a call of a macro named
10739 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
10740 @code{\*[} or @code{\n[} as references to a string or number register
10741 called @samp{[}.  In GNU @code{troff}, however, this is normally
10742 interpreted as the start of a long name.  In compatibility mode GNU
10743 @code{troff} interprets long names in the traditional way
10744 (which means that they are not recognized as names).
10745 Compatibility mode can be turned on with the @option{-C} command line
10746 option, and turned on or off with the @code{cp} request.  The number
10747 register @code{.C} is@w{ }1 if compatibility mode is on, 0@w{
10748 }otherwise.
10750 @cindex input level in delimited arguments
10751 @cindex delimited arguments, incompatibilities with Unix @code{troff}
10752 Two other features are controlled by @option{-C}.  If not in
10753 compatibility mode, GNU @code{troff} preserves the input level in
10754 delimited arguments:
10756 @Example
10757 .ds xx '
10758 \w'abc\*(xxdef'
10759 @endExample
10761 @noindent
10762 In compatibility mode, the string @samp{72def'} is returned; without
10763 @option{-C} the resulting string is @samp{168} (assuming a TTY output
10764 device).
10766 @cindex @code{\f}, incompatibilities with Unix @code{troff}
10767 @cindex @code{\H}, incompatibilities with Unix @code{troff}
10768 @cindex @code{\R}, incompatibilities with Unix @code{troff}
10769 @cindex @code{\s}, incompatibilities with Unix @code{troff}
10770 @cindex @code{\S}, incompatibilities with Unix @code{troff}
10771 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
10772 @code{\S} are transparent for recognizing the beginning of a line only
10773 in compatibility mode (this is a rather obscure feature).  For example,
10774 the code
10776 @Example
10777 .de xx
10778 Hallo!
10780 \fB.xx\fP
10781 @endExample
10783 prints @samp{Hallo!} in bold face if in compatibility mode, and
10784 @samp{.xx} in bold face otherwise.
10786 @cindex @code{\A}, incompatibilities with Unix @code{troff}
10787 @cindex @code{\|}, incompatibilities with Unix @code{troff}
10788 @cindex @code{\^}, incompatibilities with Unix @code{troff}
10789 @cindex @code{\&}, incompatibilities with Unix @code{troff}
10790 @cindex @code{\@{}, incompatibilities with Unix @code{troff}
10791 @cindex @code{\@}}, incompatibilities with Unix @code{troff}
10792 @cindex @code{\@key{SP}}, incompatibilities with Unix @code{troff}
10793 @cindex @code{\'}, incompatibilities with Unix @code{troff}
10794 @cindex @code{\`}, incompatibilities with Unix @code{troff}
10795 @cindex @code{\-}, incompatibilities with Unix @code{troff}
10796 @cindex @code{\_}, incompatibilities with Unix @code{troff}
10797 @cindex @code{\!}, incompatibilities with Unix @code{troff}
10798 @cindex @code{\%}, incompatibilities with Unix @code{troff}
10799 @cindex @code{\c}, incompatibilities with Unix @code{troff}
10800 GNU @code{troff} does not allow the use of the escape sequences
10801 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
10802 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
10803 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
10804 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
10805 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
10806 avoiding use of these escape sequences in names.
10808 @cindex fractional point sizes
10809 @cindex point sizes, fractional
10810 @cindex @code{ps} request, incompatibilities with Unix @code{troff}
10811 Fractional point sizes cause one noteworthy incompatibility.  In
10812 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
10813 indicators and thus
10815 @Example
10816 .ps 10u
10817 @endExample
10819 @noindent
10820 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
10821 sets the point size to 10@w{ }scaled points.  @xref{Fractional Type
10822 Sizes}, for more information.
10824 @cindex @code{bd} request, incompatibilities with Unix @code{troff}
10825 @cindex @code{cs} request, incompatibilities with Unix @code{troff}
10826 @cindex @code{tkf} request, incompatibilities with Unix @code{troff}
10827 @cindex @code{tr} request, incompatibilities with Unix @code{troff}
10828 @cindex @code{fp} request, incompatibilities with Unix @code{troff}
10829 @cindex input and output characters, compatibility with Unix
10830 @cindex output characters, compatibility with Unix
10831 @cindex characters, input and output, compatibility with Unix
10832 In GNU @code{troff} there is a fundamental difference between
10833 unformatted, input characters, and formatted, output characters.
10834 Everything that affects how an output character is output is stored
10835 with the character; once an output character has been constructed it is
10836 unaffected by any subsequent requests that are executed, including
10837 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
10838 Normally output characters are constructed from input characters at the
10839 moment immediately before the character is added to the current output
10840 line.  Macros, diversions and strings are all, in fact, the same type of
10841 object; they contain lists of input characters and output characters in
10842 any combination.  An output character does not behave like an input
10843 character for the purposes of macro processing; it does not inherit any
10844 of the special properties that the input character from which it was
10845 constructed might have had.  For example,
10847 @Example
10848 .di x
10849 \\\\
10853 @endExample
10855 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
10856 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
10857 @cindex @code{\e}, incompatibilities with Unix @code{troff}
10858 @cindex @code{\!}, incompatibilities with Unix @code{troff}
10859 @cindex @code{\?}, incompatibilities with Unix @code{troff}
10860 @cindex transparent output, incompatibilities with Unix @code{troff}
10861 @cindex output, transparent, incompatibilities with Unix @code{troff}
10862 @noindent
10863 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
10864 is turned into one output backslash and the resulting output backslashes
10865 are not interpreted as escape characters when they are reread.
10866 @acronym{UNIX} @code{troff} would interpret them as escape characters
10867 when they were reread and would end up printing one @samp{\}.  The
10868 correct way to obtain a printable backslash is to use the @code{\e}
10869 escape sequence: This always prints a single instance of the current
10870 escape character, regardless of whether or not it is used in a
10871 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
10872 @code{troff}.@footnote{To be completely independent of the current
10873 escape character, use @code{\(rs} which represents a reverse solidus
10874 (backslash) glyph.}  To store, for some reason, an escape sequence in a
10875 diversion that will be interpreted when the diversion is reread, either
10876 use the traditional @code{\!} transparent output facility, or, if this
10877 is unsuitable, the new @code{\?} escape sequence.
10879 @xref{Diversions}, for more information.
10882 @c =====================================================================
10884 @node Summary,  , Implementation Differences, gtroff Reference
10885 @section Summary
10886 @cindex summary
10888 @c XXX documentation
10892 @c =====================================================================
10893 @c =====================================================================
10895 @node Preprocessors, Output Devices, gtroff Reference, Top
10896 @chapter Preprocessors
10897 @cindex preprocessors
10899 This chapter describes all preprocessors that come with @code{groff} or
10900 which are freely available.
10902 @menu
10903 * geqn::
10904 * gtbl::
10905 * gpic::
10906 * ggrn::
10907 * grap::
10908 * grefer::
10909 * gsoelim::
10910 @end menu
10913 @c =====================================================================
10915 @node geqn, gtbl, Preprocessors, Preprocessors
10916 @section @code{geqn}
10917 @cindex @code{eqn}, the program
10918 @cindex @code{geqn}, the program
10920 @c XXX
10922 @menu
10923 * Invoking geqn::
10924 @end menu
10926 @c ---------------------------------------------------------------------
10928 @node Invoking geqn,  , geqn, geqn
10929 @subsection Invoking @code{geqn}
10930 @cindex invoking @code{geqn}
10931 @cindex @code{geqn}, invoking
10933 @c XXX
10936 @c =====================================================================
10938 @node gtbl, gpic, geqn, Preprocessors
10939 @section @code{gtbl}
10940 @cindex @code{tbl}, the program
10941 @cindex @code{gtbl}, the program
10943 @c XXX
10945 @menu
10946 * Invoking gtbl::
10947 @end menu
10949 @c ---------------------------------------------------------------------
10951 @node Invoking gtbl,  , gtbl, gtbl
10952 @subsection Invoking @code{gtbl}
10953 @cindex invoking @code{gtbl}
10954 @cindex @code{gtbl}, invoking
10956 @c XXX
10959 @c =====================================================================
10961 @node gpic, ggrn, gtbl, Preprocessors
10962 @section @code{gpic}
10963 @cindex @code{pic}, the program
10964 @cindex @code{gpic}, the program
10966 @c XXX
10968 @menu
10969 * Invoking gpic::
10970 @end menu
10972 @c ---------------------------------------------------------------------
10974 @node Invoking gpic,  , gpic, gpic
10975 @subsection Invoking @code{gpic}
10976 @cindex invoking @code{gpic}
10977 @cindex @code{gpic}, invoking
10979 @c XXX
10982 @c =====================================================================
10984 @node ggrn, grap, gpic, Preprocessors
10985 @section @code{ggrn}
10986 @cindex @code{grn}, the program
10987 @cindex @code{ggrn}, the program
10989 @c XXX
10991 @menu
10992 * Invoking ggrn::
10993 @end menu
10995 @c ---------------------------------------------------------------------
10997 @node Invoking ggrn,  , ggrn, ggrn
10998 @subsection Invoking @code{ggrn}
10999 @cindex invoking @code{ggrn}
11000 @cindex @code{ggrn}, invoking
11002 @c XXX
11005 @c =====================================================================
11007 @node grap, grefer, ggrn, Preprocessors
11008 @section @code{grap}
11009 @cindex @code{grap}, the program
11011 A free implementation of @code{grap}, written by Ted Faber,
11012 is available as an extra package from the following address:
11014 @display
11015 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
11016 @end display
11019 @c =====================================================================
11021 @node grefer, gsoelim, grap, Preprocessors
11022 @section @code{grefer}
11023 @cindex @code{refer}, the program
11024 @cindex @code{grefer}, the program
11026 @c XXX
11028 @menu
11029 * Invoking grefer::
11030 @end menu
11032 @c ---------------------------------------------------------------------
11034 @node Invoking grefer,  , grefer, grefer
11035 @subsection Invoking @code{grefer}
11036 @cindex invoking @code{grefer}
11037 @cindex @code{grefer}, invoking
11039 @c XXX
11042 @c =====================================================================
11044 @node gsoelim,  , grefer, Preprocessors
11045 @section @code{gsoelim}
11046 @cindex @code{soelim}, the program
11047 @cindex @code{gsoelim}, the program
11049 @c XXX
11051 @menu
11052 * Invoking gsoelim::
11053 @end menu
11055 @c ---------------------------------------------------------------------
11057 @node Invoking gsoelim,  , gsoelim, gsoelim
11058 @subsection Invoking @code{gsoelim}
11059 @cindex invoking @code{gsoelim}
11060 @cindex @code{gsoelim}, invoking
11062 @c XXX
11066 @c =====================================================================
11067 @c =====================================================================
11069 @node Output Devices, File formats, Preprocessors, Top
11070 @chapter Output Devices
11071 @cindex output devices
11072 @cindex devices for output
11074 @c XXX
11076 @menu
11077 * Special Characters::
11078 * grotty::
11079 * grops::
11080 * grodvi::
11081 * grolj4::
11082 * grolbp::
11083 * grohtml::
11084 * gxditview::
11085 @end menu
11088 @c =====================================================================
11090 @node Special Characters, grotty, Output Devices, Output Devices
11091 @section Special Characters
11092 @cindex special characters
11093 @cindex characters, special
11095 @c XXX
11097 @xref{Font Files}.
11100 @c =====================================================================
11102 @node grotty, grops, Special Characters, Output Devices
11103 @section @code{grotty}
11104 @cindex @code{grotty}, the program
11106 @c XXX
11108 @menu
11109 * Invoking grotty::
11110 @end menu
11112 @c ---------------------------------------------------------------------
11114 @node Invoking grotty,  , grotty, grotty
11115 @subsection Invoking @code{grotty}
11116 @cindex invoking @code{grotty}
11117 @cindex @code{grotty}, invoking
11119 @c XXX
11122 @c =====================================================================
11124 @node grops, grodvi, grotty, Output Devices
11125 @section @code{grops}
11126 @cindex @code{grops}, the program
11128 @c XXX
11130 @menu
11131 * Invoking grops::
11132 * Embedding PostScript::
11133 @end menu
11135 @c ---------------------------------------------------------------------
11137 @node Invoking grops, Embedding PostScript, grops, grops
11138 @subsection Invoking @code{grops}
11139 @cindex invoking @code{grops}
11140 @cindex @code{grops}, invoking
11142 @c XXX
11144 @c ---------------------------------------------------------------------
11146 @node Embedding PostScript,  , Invoking grops, grops
11147 @subsection Embedding @sc{PostScript}
11148 @cindex embedding postscript
11149 @cindex postscript, embedding
11151 @c XXX
11154 @c =====================================================================
11156 @node grodvi, grolj4, grops, Output Devices
11157 @section @code{grodvi}
11158 @cindex @code{grodvi}, the program
11160 @c XXX
11162 @menu
11163 * Invoking grodvi::
11164 @end menu
11166 @c ---------------------------------------------------------------------
11168 @node Invoking grodvi,  , grodvi, grodvi
11169 @subsection Invoking @code{grodvi}
11170 @cindex invoking @code{grodvi}
11171 @cindex @code{grodvi}, invoking
11173 @c XXX
11176 @c =====================================================================
11178 @node grolj4, grolbp, grodvi, Output Devices
11179 @section @code{grolj4}
11180 @cindex @code{grolj4}, the program
11182 @c XXX
11184 @menu
11185 * Invoking grolj4::
11186 @end menu
11188 @c ---------------------------------------------------------------------
11190 @node Invoking grolj4,  , grolj4, grolj4
11191 @subsection Invoking @code{grolj4}
11192 @cindex invoking @code{grolj4}
11193 @cindex @code{grolj4}, invoking
11195 @c XXX
11198 @c =====================================================================
11200 @node grolbp, grohtml, grolj4, Output Devices
11201 @section @code{grolbp}
11202 @cindex @code{grolbp}, the program
11204 @c XXX
11206 @menu
11207 * Invoking grolbp::
11208 @end menu
11210 @c ---------------------------------------------------------------------
11212 @node Invoking grolbp,  , grolbp, grolbp
11213 @subsection Invoking @code{grolbp}
11214 @cindex invoking @code{grolbp}
11215 @cindex @code{grolbp}, invoking
11217 @c XXX
11220 @c =====================================================================
11222 @node grohtml, gxditview, grolbp, Output Devices
11223 @section @code{grohtml}
11224 @cindex @code{grohtml}, the program
11226 @c XXX
11228 @menu
11229 * Invoking grohtml::
11230 * grohtml specific registers and strings::
11231 @end menu
11233 @c ---------------------------------------------------------------------
11235 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
11236 @subsection Invoking @code{grohtml}
11237 @cindex invoking @code{grohtml}
11238 @cindex @code{grohtml}, invoking
11240 @c XXX
11242 @c ---------------------------------------------------------------------
11244 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
11245 @subsection @code{grohtml} specific registers and strings
11246 @cindex registers specific to @code{grohtml}
11247 @cindex strings specific to @code{grohtml}
11248 @cindex @code{grohtml}, registers and strings
11250 @DefmpregList {ps4html, grohtml}
11251 @DefstrListEnd {www-image-template, grohtml}
11252 The registers @code{ps4html} and @code{www-image-template} are defined
11253 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
11254 the @code{troff} input, marks up the inline equations and passes the
11255 result firstly to
11257 @example
11258 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
11259 @end example
11261 @noindent
11262 and secondly to
11264 @example
11265 troff -Thtml
11266 @end example
11268 The postscript device is used to create all the image files, and the
11269 register @code{ps4html} enables the macro sets to ignore floating
11270 keeps, footers, and headings.
11272 The register @code{www-image-template} is set to the user specified
11273 template name or the default name.
11274 @endDefmpreg
11277 @c =====================================================================
11279 @node gxditview,  , grohtml, Output Devices
11280 @section @code{gxditview}
11281 @cindex @code{gxditview}, the program
11283 @c XXX
11285 @menu
11286 * Invoking gxditview::
11287 @end menu
11289 @c ---------------------------------------------------------------------
11291 @node Invoking gxditview,  , gxditview, gxditview
11292 @subsection Invoking @code{gxditview}
11293 @cindex invoking @code{gxditview}
11294 @cindex @code{gxditview}, invoking
11296 @c XXX
11297 @c X11's xditview
11301 @c =====================================================================
11302 @c =====================================================================
11304 @node File formats, Installation, Output Devices, Top
11305 @chapter File formats
11306 @cindex file formats
11307 @cindex formats, file
11309 @c XXX
11311 @menu
11312 * gtroff Output::
11313 * Font Files::
11314 @end menu
11317 @c =====================================================================
11319 @node gtroff Output, Font Files, File formats, File formats
11320 @section @code{gtroff} Output
11321 @cindex @code{gtroff} output
11322 @cindex output, @code{gtroff}
11324 This section describes the format output of GNU @code{troff}.  The
11325 output format used by GNU @code{troff} is very similar -- but
11326 not identical -- to that used by
11327 @acronym{UNIX} device-independent @code{troff} (@code{ditroff}).
11329 @menu
11330 * Output Format::
11331 * Device Control::
11332 * Drawing Functions::
11333 * Line Continuation::
11334 @end menu
11336 @c ---------------------------------------------------------------------
11338 @node Output Format, Device Control, gtroff Output, gtroff Output
11339 @subsection Output Format
11340 @cindex output format
11341 @cindex format of output
11343 @cindex 8-bit input
11344 @cindex input, 8-bit
11345 The output format is text based, as opposed to a binary format (like
11346 @TeX{} DVI).  The output format is @w{8-bit} clean, thus single
11347 characters can have the eighth bit set, as can the names of fonts and
11348 special characters.
11350 The output format consists of single command characters with attached
11351 parameters which are separated from subsequent text by whitespace or a
11352 newline.
11354 The names of characters and fonts can be of arbitrary length; drivers
11355 should not assume that they are only two characters long (as
11356 @code{ditroff} does).
11358 When a character is to be printed, that character is always in the
11359 current font.  Unlike @code{ditroff}, it is not necessary for drivers to
11360 search special fonts to find a character.
11362 @table @code
11363 @item H@var{n}
11364 @c XXX
11366 @item V@var{n}
11367 @c XXX
11369 @item h@var{n}
11370 @c XXX
11372 @item v@var{n}
11373 @c XXX
11375 @item c@var{n}
11376 @c XXX
11378 @item C@var{n}
11379 @c XXX
11381 @item @var{nn}@var{c}
11382 @c XXX
11384 @item t@var{xxx}
11385 @var{xxx} is any sequence of characters terminated by a space or a
11386 newline; the first character should be printed at the current position,
11387 the the current horizontal position should be increased by the width of
11388 the first character, and so on for each character.  The width of the
11389 character is that given in the font file, appropriately scaled for the
11390 current point size, and rounded so that it is a multiple of the
11391 horizontal resolution.  Special characters cannot be printed using this
11392 command.
11394 @kindex tcommand
11395 @pindex DESC@r{, and @code{tcommand}}
11396 This command is only allowed if the @samp{tcommand} line is present in
11397 the @file{DESC} file.
11399 @item u@var{n} @var{xxx}
11400 This is same as the @samp{t} command except that after printing each
11401 character, the current horizontal position is increased by the sum of
11402 the width of that character and@w{ }@var{n}.
11404 This command is only allowed if the @samp{tcommand} line is present in
11405 the @file{DESC} file.
11407 @item n@var{a}@var{b}
11408 @c XXX
11410 @item p@var{n}
11411 @c XXX
11413 @item s@var{n}
11414 @kindex sizescale
11415 @pindex DESC@r{, and @code{sizescale}}
11416 The argument to the @samp{s} command is in scaled points (units of
11417 points/@var{n}, where @var{n} is the argument to the @samp{sizescale}
11418 command in the @file{DESC} file).
11420 @item f@var{n}
11421 @item x @dots{} \n
11422 Device control.
11423 @c XXX more info
11425 @item D@var{c} @var{x}@dots{}\n
11426 @c XXX
11427 @end table
11429 @c ---------------------------------------------------------------------
11431 @node Device Control, Drawing Functions, Output Format, gtroff Output
11432 @subsection Device Control
11433 @cindex device control
11434 @cindex control of devices
11436 The @samp{x} command is normally followed by a letter or word indicating
11437 the function to perform, followed by white space separated arguments.
11439 The first argument can be abbreviated to the first letter.
11441 @table @code
11442 @item x init
11443 @c XXX
11445 @item x T
11446 @c XXX
11448 @item x res @var{n} @var{h} @var{v}
11449 @c XXX
11451 @item x H
11452 @c XXX more info
11453 The argument to the @w{@samp{x Height}} command is also in scaled
11454 points.
11455 @end table
11457 The first three output commands are guaranteed to be:
11459 @Example
11460 x T device
11461 x res n h v
11462 x init
11463 @endExample
11465 @noindent
11466 For example, the input
11468 @Example
11469 crunchy \fH\s+2frog\s0\fP!?
11470 @endExample
11472 @noindent
11473 produces
11475 @c XXX example
11477 @ignore
11478 @Example
11479 ... sample output here ...
11480 @endExample
11481 @end ignore
11483 @c ---------------------------------------------------------------------
11485 @node Drawing Functions, Line Continuation, Device Control, gtroff Output
11486 @subsection Drawing Functions
11487 @cindex drawing functions
11488 @cindex functions for drawing
11490 @pindex gpic
11491 The @samp{D} drawing command has been extended.  These extensions are
11492 used by GNU @code{pic} only if the @option{-x} option is given.
11494 @xref{Drawing Requests}.
11496 @table @code
11497 @c XXX ...
11498 @item Df @var{n}
11499 Set the shade of gray to be used for filling solid objects to@w{
11500 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
11501 corresponds solid white and 1000 to solid black, and values in between
11502 correspond to intermediate shades of gray.  This applies only to solid
11503 circles, solid ellipses and solid polygons.  By default, a level of@w{
11504 }1000 is used.  Whatever color a solid object has, it should
11505 completely obscure everything beneath it.  A value greater than@w{ }1000
11506 or less than@w{ }0 can also be used: this means fill with the shade of
11507 gray that is currently being used for lines and text.  Normally this
11508 is black, but some drivers may provide a way of changing this.
11510 @item DC @var{d}
11511 Draw a solid circle with a diameter of@w{ }@var{d} with the leftmost
11512 point at the current position.
11514 @item DE @var{dx} @var{dy}
11515 Draw a solid ellipse with a horizontal diameter of@w{ }@var{dx} and a
11516 vertical diameter of@w{ }@var{dy} with the leftmost point at the current
11517 position.
11519 @item Dp @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
11520 Draw a polygon with automatic closure.  The first vertex is at the
11521 current position, the second vertex at an offset (@var{dx1},@var{dy1})
11522 from the current position, the second vertex at an offset
11523 (@var{dx2},@var{dy2}) from the first vertex, and so on up to the
11524 @var{n}@dmn{th} vertex.  At the moment, GNU @code{pic} only uses this
11525 command to generate triangles and rectangles.
11527 @item DP @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
11528 Like @code{Dp} but draw a solid rather than outlined polygon.
11530 @item Dt @var{n}
11531 @cindex line thickness
11532 @cindex thickness of lines
11533 Set the current line thickness to @var{n}@w{ }machine units.
11534 Traditionally, @acronym{UNIX} @code{troff} drivers use a line thickness
11535 proportional to the current point size; drivers should continue to do
11536 this if no @code{Dt} command has been given, or if a @code{Dt} command
11537 has been given with a negative value of@w{ }@var{n}.  A zero value of@w{
11538 }@var{n} selects the smallest available line thickness.
11539 @end table
11541 A difficulty arises in how the current position should be changed after
11542 the execution of these commands.  This is not of great importance since
11543 the code generated by GNU @code{pic} does not depend on this.  Given a
11544 drawing command of the form
11546 @Example
11547 \D'@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}'
11548 @endExample
11550 @cindex @code{\w}, and drawing commands
11551 @cindex @code{st} register, and drawing commands
11552 @cindex @code{sb} register, and drawing commands
11553 @noindent
11554 where @var{c} is not one of @samp{c}, @samp{e}, @samp{l}, @samp{a} or
11555 @samp{~}, @acronym{UNIX} @code{troff} treats each x@w{ }value
11556 as a horizontal quantity, and each y@w{ }value as a vertical
11557 quantity; it assumes that the width of the drawn object is the sum of
11558 all x@w{ }values, and that the height is the sum of all y@w{ }values.
11559 (The assumption about the height can be seen by examining the @code{st}
11560 and @code{sb} registers after using such a @code{D}@w{ }command in a
11561 @code{\w} escape sequence.)  This rule also holds for all the original
11562 drawing commands with the exception of @code{De}.  For the sake of
11563 compatibility GNU @code{troff} also follows this rule, even though it
11564 produces an ugly result in the case of the @code{Df}, @code{Dt}, and, to
11565 a lesser extent, @code{DE}@w{ }commands.  Thus after executing a
11566 @code{D}@w{ }command of the form
11568 @Example
11569 D@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}
11570 @endExample
11572 @noindent
11573 the current position should be increased horizontally by the sum of all
11574 x@w{ }values and vertically by the sum of all y@w{ }values.
11576 @c ---------------------------------------------------------------------
11578 @node Line Continuation,  , Drawing Functions, gtroff Output
11579 @subsection Line Continuation
11580 @cindex line continuation in output commands
11581 @cindex output commands, line continuation
11583 There is a continuation convention which permits the argument to the
11584 @w{@samp{x X}} command to contain newlines: When outputting the argument
11585 to the @w{@samp{x X}} command, GNU @code{troff} follows each newline
11586 in the argument with a @samp{+} character (as usual, it terminates
11587 the entire argument with a newline); thus if the line after the line
11588 containing the @w{@samp{x X}} command starts with @samp{+}, then the
11589 newline ending the line containing the @w{@samp{x X}} command should be
11590 treated as part of the argument to the @w{@samp{x X}} command, the
11591 @samp{+} should be ignored, and the part of the line following the
11592 @samp{+} should be treated like the part of the line following the
11593 @w{@samp{x X}} command.
11596 @c =====================================================================
11598 @node Font Files,  , gtroff Output, File formats
11599 @section Font Files
11600 @cindex font files
11601 @cindex files, font
11603 The @code{gtroff} font format is roughly a superset of the
11604 @code{ditroff} font format.  Unlike the @code{ditroff} font format,
11605 there is no associated binary format; all files are text files.  The
11606 font files for device @var{name} are stored in a directory
11607 @file{dev@var{name}}.  There are two types of file: a device description
11608 file called @file{DESC} and for each font@w{ }@var{f} a font file
11609 called@w{ }@file{@var{f}}.
11611 @menu
11612 * DESC File Format::
11613 * Font File Format::
11614 @end menu
11616 @c ---------------------------------------------------------------------
11618 @node DESC File Format, Font File Format, Font Files, Font Files
11619 @subsection @file{DESC} File Format
11620 @cindex @file{DESC} file format
11621 @cindex font description file format
11622 @cindex format of font description file
11623 @pindex DESC@r{ file format}
11625 The @file{DESC} file can contain the following types of line:
11627 @table @code
11628 @item res @var{n}
11629 @kindex res
11630 There are @var{n}@w{ }machine units per inch.
11632 @item hor @var{n}
11633 @kindex hor
11634 The horizontal resolution is @var{n}@w{ }machine units.
11636 @item vert @var{n}
11637 @kindex vert
11638 The vertical resolution is @var{n}@w{ }machine units.
11640 @item sizescale @var{n}
11641 @kindex sizescale
11642 The scale factor for point sizes.  By default this has a value of@w{ }1.
11643 One scaled point is equal to one point/@var{n}.  The arguments to the
11644 @code{unitwidth} and @code{sizes} commands are given in scaled points.
11645 @xref{Fractional Type Sizes}, for more information.
11647 @item unitwidth @var{n}
11648 @kindex unitwidth
11649 Quantities in the font files are given in machine units for fonts whose
11650 point size is @var{n}@w{ }scaled points.
11652 @item tcommand
11653 @kindex tcommand
11654 This means that the postprocessor can handle the @samp{t} and @samp{u}
11655 output commands.
11657 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
11658 @kindex sizes
11659 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
11660 @var{sn} scaled points.  The list of sizes must be terminated by a@w{
11661 }0.  Each @var{si} can also be a range of sizes @var{m}-@var{n}.  The
11662 list can extend over more than one line.
11664 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
11665 @kindex styles
11666 The first @var{m}@w{ }font positions are associated with styles
11667 @var{S1} @dots{} @var{Sm}.
11669 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
11670 @kindex fonts
11671 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
11672 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
11673 styles.  This command may extend over more than one line.  A font name
11674 of@var{ }0 means no font is mounted on the corresponding font position.
11676 @item family @var{fam}
11677 @kindex family
11678 The default font family is @var{fam}.
11680 @item charset
11681 @kindex charset
11682 This line and everything following in the file are ignored.  It is
11683 allowed for the sake of backwards compatibility.
11684 @end table
11686 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
11687 are mandatory.  Other commands are ignored by @code{gtroff} but may be
11688 used by postprocessors to store arbitrary information about the device
11689 in the @file{DESC} file.
11691 @c XXX add other commands resp. xrefs to output devices
11692 @c XXX add obsolete commands
11694 @c ---------------------------------------------------------------------
11696 @node Font File Format,  , DESC File Format, Font Files
11697 @subsection Font File Format
11698 @cindex font file format
11699 @cindex format of font files
11701 A font file has two sections.  The first section is a sequence of lines
11702 each containing a sequence of blank delimited words; the first word in
11703 the line is a key, and subsequent words give a value for that key.
11705 @table @code
11706 @item name @var{f}
11707 @kindex name
11708 The name of the font is@w{ }@var{f}.
11710 @item spacewidth @var{n}
11711 @kindex spacewidth
11712 The normal width of a space is@w{ }@var{n}.
11714 @item slant @var{n}
11715 @kindex slant
11716 The characters of the font have a slant of @var{n}@w{ }degrees.
11717 (Positive means forward.)
11719 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
11720 @kindex ligatures
11721 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
11722 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
11723 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
11724 terminated with a@w{ }0.  The list of ligatures may not extend over more
11725 than one line.
11727 @item special
11728 @kindex special
11729 The font is special; this means that when a character is requested that
11730 is not present in the current font, it is searched for in any
11731 special fonts that are mounted.
11732 @end table
11734 Other commands are ignored by @code{gtroff} but may be used by
11735 postprocessors to store arbitrary information about the font in the font
11736 file.
11738 @cindex comments in font files
11739 @cindex font files, comments
11740 @kindex #
11741 The first section can contain comments which start with the @samp{#}
11742 character and extend to the end of a line.
11744 The second section contains one or two subsections.  It must contain a
11745 @code{charset} subsection and it may also contain a @code{kernpairs}
11746 subsection.  These subsections can appear in any order.  Each
11747 subsection starts with a word on a line by itself.
11749 @kindex charset
11750 The word @code{charset} starts the character set subsection.  The
11751 @code{charset} line is followed by a sequence of lines.  Each line gives
11752 information for one character.  A line comprises a number of fields
11753 separated by blanks or tabs.  The format is
11755 @c XXX fix it for new HTML additions
11757 @Example
11758 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
11759 @endExample
11761 @cindex 8-bit input
11762 @cindex input, 8-bit
11763 @cindex accessing unnamed characters with @code{\N}
11764 @cindex unnamed characters, accessing with @code{\N}
11765 @cindex characters, unnamed, accessing with @code{\N}
11766 @kindex ---
11767 @noindent
11768 @var{name} identifies the character: If @var{name} is a single
11769 character@w{ }@var{c} then it corresponds to the @code{gtroff} input
11770 character@w{ }@var{c}; if it is of the form @samp{\@var{c}} where @var{c}
11771 is a single character, then it corresponds to the @code{gtroff} input
11772 character@w{ }\@var{c}; otherwise it corresponds to the groff input
11773 character @samp{\[@var{name}]}.  (If it is exactly two characters
11774 @var{xx} it can be entered as @samp{\(@var{xx}}.)  @code{gtroff}
11775 supports 8-bit characters; however some utilities have difficulties with
11776 eight-bit characters.  For this reason, there is a convention that the
11777 name @samp{char@var{n}} is equivalent to the single character whose code
11778 is@w{ }@var{n}.  For example, @samp{char163} would be equivalent to the
11779 character with code@w{ }163 which is the pounds sterling sign in @w{ISO
11780 Latin-1} character set.  The name @samp{---} is special and indicates
11781 that the character is unnamed; such characters can only be used by means
11782 of the @code{\N} escape sequence in @code{gtroff}.
11784 @c XXX input encodings vs. output encodings
11786 The @var{type} field gives the character type:
11788 @table @code
11789 @item 1
11790 the character has an descender, for example, `p';
11792 @item 2
11793 the character has an ascender, for example, `b';
11795 @item 3
11796 the character has both an ascender and a descender, for example, `('.
11797 @end table
11799 The @var{code} field gives the code which the postprocessor uses to
11800 print the character.  The character can also be input to @code{gtroff}
11801 using this code by means of the @code{\N} escape sequence.  The code can
11802 be any integer.  If it starts with @samp{0} it is interpreted as
11803 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
11804 hexadecimal.
11806 Anything on the line after the @var{code} field is ignored.
11808 The @var{metrics} field has the form:
11810 @Example
11811 @var{width}[,@var{height}[,@var{depth}[,@var{italic_correction}
11812   [,@var{left_italic_correction}[,@var{subscript_correction}]]]]]
11813 @endExample
11815 @noindent
11816 There must not be any spaces between these subfields (it has been split
11817 here into two lines for better legibility only).  Missing subfields are
11818 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
11819 there is no associated binary format, these values are not required to
11820 fit into a variable of type @samp{char} as they are in @code{ditroff}.
11821 The @var{width} subfield gives the width of the character.  The
11822 @var{height} subfield gives the height of the character (upwards is
11823 positive); if a character does not extend above the baseline, it should
11824 be given a zero height, rather than a negative height.  The @var{depth}
11825 subfield gives the depth of the character, that is, the distance below
11826 the lowest point below the baseline to which the character extends
11827 (downwards is positive); if a character does not extend below above the
11828 baseline, it should be given a zero depth, rather than a negative depth.
11829 The @var{italic_correction} subfield gives the amount of space that
11830 should be added after the character when it is immediately to be
11831 followed by a character from a roman font.  The
11832 @var{left_italic_correction} subfield gives the amount of space that
11833 should be added before the character when it is immediately to be
11834 preceded by a character from a roman font.  The
11835 @var{subscript_correction} gives the amount of space that should be
11836 added after a character before adding a subscript.  This should be less
11837 than the italic correction.
11839 A line in the @code{charset} section can also have the format
11841 @Example
11842 @var{name} "
11843 @endExample
11845 @noindent
11846 This indicates that @var{name} is just another name for the character
11847 mentioned in the preceding line.
11849 @kindex kernpairs
11850 The word @code{kernpairs} starts the kernpairs section.  This contains a
11851 sequence of lines of the form:
11853 @Example
11854 @var{c1} @var{c2} @var{n}
11855 @endExample
11857 @noindent
11858 This means that when character @var{c1} appears next to character
11859 @var{c2} the space between them should be increased by@w{ }@var{n}.
11860 Most entries in the kernpairs section have a negative value for@w{
11861 }@var{n}.
11865 @c =====================================================================
11866 @c =====================================================================
11868 @node Installation, Request Index, File formats, Top
11869 @chapter Installation
11870 @cindex installation
11872 @c XXX
11876 @c =====================================================================
11877 @c =====================================================================
11879 @node Request Index, Escape Index, Installation, Top
11880 @chapter Request Index
11882 Requests appear without the leading control character (normally either
11883 @samp{.} or @samp{'}).
11885 @printindex rq
11889 @c =====================================================================
11890 @c =====================================================================
11892 @node Escape Index, Operator Index, Request Index, Top
11893 @chapter Escape Index
11895 @printindex es
11899 @c =====================================================================
11900 @c =====================================================================
11902 @node Operator Index, Register Index, Escape Index, Top
11903 @chapter Operator Index
11905 @printindex op
11909 @c =====================================================================
11910 @c =====================================================================
11912 @node Register Index, Macro Index, Operator Index, Top
11913 @chapter Register Index
11915 The macro package or program a specific register belongs to is appended in
11916 brackets.
11918 A register name@w{ }@code{x} consisting of exactly one character can be
11919 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
11920 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
11921 of any length can be accessed as @samp{\n[xxx]}.
11923 @printindex vr
11927 @c =====================================================================
11928 @c =====================================================================
11930 @node Macro Index, String Index, Register Index, Top
11931 @chapter Macro Index
11933 The macro package a specific macro belongs to is appended in brackets.
11934 They appear without the leading control character (normally @samp{.}).
11936 @printindex ma
11940 @c =====================================================================
11941 @c =====================================================================
11943 @node String Index, Glyph Name Index, Macro Index, Top
11944 @chapter String Index
11946 The macro package or program a specific string belongs to is appended in
11947 brackets.
11949 A string name@w{ }@code{x} consisting of exactly one character can be
11950 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
11951 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
11952 of any length can be accessed as @samp{\*[xxx]}.
11955 @printindex st
11959 @c =====================================================================
11960 @c =====================================================================
11962 @node Glyph Name Index, Font File Keyword Index, String Index, Top
11963 @chapter Glyph Name Index
11965 A glyph name @code{xx} consisting of exactly two characters can be
11966 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
11967 accessed as @samp{\[xxx]}.
11969 @c XXX
11973 @c =====================================================================
11974 @c =====================================================================
11976 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
11977 @chapter Font File Keyword Index
11979 @printindex ky
11983 @c =====================================================================
11984 @c =====================================================================
11986 @node Program and File Index, Concept Index, Font File Keyword Index, Top
11987 @chapter Program  and File Index
11989 @printindex pg
11993 @c =====================================================================
11994 @c =====================================================================
11996 @node Concept Index,  , Program and File Index, Top
11997 @chapter Concept Index
11999 @printindex cp
12003 @summarycontents
12004 @contents
12005 @bye