* src/roff/troff/input.cc (token::next): Make \H behave consistently
[s-roff.git] / doc / groff.texinfo
blob65491a5da78ef9580306797990e5b1938f609c44
1 \input texinfo   @c -*-texinfo-*-
3 @c
4 @c Please convert this manual with `texi2dvi -e groff.texinfo' due to a bug
5 @c in texinfo regarding expansion of user-defined macros.
6 @c
7 @c You need texinfo 4.2 or newer to format this document!
8 @c
10 @c %**start of header (This is for running Texinfo on a region.)
11 @setfilename  groff
12 @settitle The GNU Troff Manual
13 @setchapternewpage odd
14 @footnotestyle separate
15 @c %**end of header (This is for running Texinfo on a region.)
18 @c We use the following indices:
20 @c   cindex: concepts
21 @c   rqindex: requests
22 @c   esindex: escapes
23 @c   vindex: registers
24 @c   kindex: commands in font files
25 @c   pindex: programs and files
26 @c   tindex: environment variables
27 @c   maindex: macros
28 @c   stindex: strings
29 @c   opindex: operators
31 @c tindex and cindex are merged.
33 @defcodeindex rq
34 @defcodeindex es
35 @defcodeindex ma
36 @defcodeindex st
37 @defcodeindex op
38 @syncodeindex tp cp
41 @c to avoid uppercasing in @deffn while converting to info, we define
42 @c our special @Var{}
44 @c due to a (not officially documented) `feature' in makeinfo 4.0,
45 @c macros are not expanded in @deffn (but the macro definition is
46 @c properly removed), so we have to define @Var{} directly in TeX also
48 @macro Var{arg}
49 \arg\
50 @end macro
51 @tex
52 \gdef\Var#1{\var{#1}}
53 @end tex
56 @c To assure correct HTML translation, some ugly hacks are necessary.
57 @c While processing a @def... request, the HTML translator looks at the
58 @c next line to decide whether it should start indentation or not.  If
59 @c it is something starting with @def... (e.g. @deffnx), it doesn't.
60 @c So we must assure during macro expansion that a @def... is seen.
62 @c The following macros have to be used:
64 @c One item:
66 @c   @Def...
68 @c Two items:
70 @c   @Def...List
71 @c   @Def...ListEnd
73 @c More than two:
75 @c   @Def...List
76 @c   @Def...Item
77 @c   @Def...Item
78 @c   ...
79 @c   @Def...ListEnd
81 @c The definition block must end with
83 @c   @endDef...
85 @c The above is valid for texinfo 4.0f.
88 @c a dummy macro to assure the `@def...'
90 @macro defdummy
91 @end macro
94 @c definition of requests
96 @macro Defreq{name, arg}
97 @deffn Request @t{.\name\} \arg\
98 @rqindex \name\
99 @end macro
101 @macro DefreqList{name, arg}
102 @deffn Request @t{.\name\} \arg\
103 @defdummy
104 @rqindex \name\
105 @end macro
107 @macro DefreqItem{name, arg}
108 @deffnx Request @t{.\name\} \arg\
109 @defdummy
110 @rqindex \name\
111 @end macro
113 @macro DefreqListEnd{name, arg}
114 @deffnx Request @t{.\name\} \arg\
115 @rqindex \name\
116 @end macro
118 @macro endDefreq
119 @end deffn
120 @end macro
123 @c definition of escapes
125 @macro Defesc{name, delimI, arg, delimII}
126 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
127 @esindex \name\
128 @end macro
130 @macro DefescList{name, delimI, arg, delimII}
131 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
132 @defdummy
133 @esindex \name\
134 @end macro
136 @macro DefescItem{name, delimI, arg, delimII}
137 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
138 @defdummy
139 @esindex \name\
140 @end macro
142 @macro DefescListEnd{name, delimI, arg, delimII}
143 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
144 @esindex \name\
145 @end macro
147 @macro endDefesc
148 @end deffn
149 @end macro
152 @c definition of registers
154 @macro Defreg{name}
155 @deffn Register @t{\\n[\name\]}
156 @vindex \name\
157 @end macro
159 @macro DefregList{name}
160 @deffn Register @t{\\n[\name\]}
161 @defdummy
162 @vindex \name\
163 @end macro
165 @macro DefregItem{name}
166 @deffnx Register @t{\\n[\name\]}
167 @defdummy
168 @vindex \name\
169 @end macro
171 @macro DefregListEnd{name}
172 @deffnx Register @t{\\n[\name\]}
173 @vindex \name\
174 @end macro
176 @macro endDefreg
177 @end deffn
178 @end macro
181 @c definition of registers specific to macro packages, preprocessors, etc.
183 @macro Defmpreg{name, package}
184 @deffn Register @t{\\n[\name\]}
185 @vindex \name\ @r{[}\package\@r{]}
186 @end macro
188 @macro DefmpregList{name, package}
189 @deffn Register @t{\\n[\name\]}
190 @defdummy
191 @vindex \name\ @r{[}\package\@r{]}
192 @end macro
194 @macro DefmpregItem{name, package}
195 @deffnx Register @t{\\n[\name\]}
196 @defdummy
197 @vindex \name\ @r{[}\package\@r{]}
198 @end macro
200 @macro DefmpregListEnd{name, package}
201 @deffnx Register @t{\\n[\name\]}
202 @vindex \name\ @r{[}\package\@r{]}
203 @end macro
205 @macro endDefmpreg
206 @end deffn
207 @end macro
210 @c definition of macros
212 @macro Defmac{name, arg, package}
213 @defmac @t{.\name\} \arg\
214 @maindex \name\ @r{[}\package\@r{]}
215 @end macro
217 @macro DefmacList{name, arg, package}
218 @defmac @t{.\name\} \arg\
219 @defdummy
220 @maindex \name\ @r{[}\package\@r{]}
221 @end macro
223 @macro DefmacItem{name, arg, package}
224 @defmacx @t{.\name\} \arg\
225 @defdummy
226 @maindex \name\ @r{[}\package\@r{]}
227 @end macro
229 @macro DefmacListEnd{name, arg, package}
230 @defmacx @t{.\name\} \arg\
231 @maindex \name\ @r{[}\package\@r{]}
232 @end macro
234 @macro endDefmac
235 @end defmac
236 @end macro
239 @c definition of strings
241 @macro Defstr{name, package}
242 @deffn String @t{\\*[\name\]}
243 @stindex \name\ @r{[}\package\@r{]}
244 @end macro
246 @macro DefstrList{name, package}
247 @deffn String @t{\\*[\name\]}
248 @defdummy
249 @stindex \name\ @r{[}\package\@r{]}
250 @end macro
252 @macro DefstrItem{name, package}
253 @deffnx String @t{\\*[\name\]}
254 @defdummy
255 @stindex \name\ @r{[}\package\@r{]}
256 @end macro
258 @macro DefstrListEnd{name, package}
259 @deffnx String @t{\\*[\name\]}
260 @stindex \name\ @r{[}\package\@r{]}
261 @end macro
263 @macro endDefstr
264 @end deffn
265 @end macro
268 @c our example macro
270 @macro Example
271 @example
272 @group
273 @end macro
275 @macro endExample
276 @end group
277 @end example
278 @end macro
281 @c We need special parentheses and brackets:
283 @c . Real parentheses in @deffn produce an error while compiling with
284 @c   TeX
285 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
287 @c This is true for texinfo 4.0.
289 @ifnottex
290 @macro lparen
292 @end macro
293 @macro rparen
295 @end macro
296 @macro lbrack
298 @end macro
299 @macro rbrack
301 @end macro
302 @end ifnottex
304 @iftex
305 @macro lparen
306 @@lparen
307 @end macro
308 @macro rparen
309 @@rparen
310 @end macro
311 @macro lbrack
312 @@lbrack
313 @end macro
314 @macro rbrack
315 @@rbrack
316 @end macro
317 @end iftex
320 @c Note: We say `Roman numerals' but `roman font'.
323 @c XXX comment all examples
326 @dircategory Miscellaneous
327 @direntry
328 * Groff: (groff).  The GNU troff document formatting system.
329 @end direntry
332 @smallbook
335 @iftex
336 @finalout
337 @end iftex
340 @ifinfo
341 This Info file documents GNU troff version 1.18.
343 Published by the Free Software Foundation
344 59 Temple Place, Suite 330
345 Boston, MA  02111-1307  USA
347 Copyright (C) 1994-2000, 2001, 2002 Free Software Foundation, Inc.
349 Permission is granted to make and distribute verbatim copies of this
350 manual provided the copyright notice and this permission notice are
351 preserved on all copies.
353 @ignore
354 Permission is granted to process this file through TeX and print the
355 results, provided the printed document carries copying permission notice
356 identical to this one except for the removal of this paragraph (this
357 paragraph not being relevant to the printed manual).
359 @end ignore
360 Permission is granted to copy and distribute modified versions of this
361 manual under the conditions for verbatim copying, provided that the
362 entire resulting derived work is distributed under the terms of a
363 permission notice identical to this one.
365 Permission is granted to copy and distribute translations of this manual
366 into another language, under the above conditions for modified versions,
367 except that this permission notice may be stated in a translation
368 approved by the Foundation.
370 Permission is granted to copy and distribute modified versions of this
371 manual under the conditions for verbatim copying, provided also that the
372 section entitled ``GNU General Public License'' is included exactly as
373 in the original, and provided that the entire resulting derived work is
374 distributed under the terms of a permission notice identical to this
375 one.
377 Permission is granted to copy and distribute translations of this manual
378 into another language, under the above conditions for modified versions,
379 except that the section entitled ``GNU General Public License'' may be
380 included in a translation approved by the Free Software Foundation
381 instead of in the original English.
382 @end ifinfo
385 @titlepage
386 @title groff
387 @subtitle The GNU implementation of @code{troff}
388 @subtitle Edition 1.18
389 @subtitle Spring 2002
390 @author by Trent A.@w{ }Fisher
391 @author and Werner Lemberg
393 @c Include the Distribution inside the titlepage environment so
394 @c that headings are turned off.  Headings on and off do not work.
396 @page
397 @vskip 0pt plus 1filll
398 Copyright @copyright@w{ }1994-2000, 2001, 2002 Free Software
399 Foundation,@w{ }Inc.
400 @sp 2
401 Version 1.18 of @code{groff}, @*
402 Spring 2002
403 @sp 2
404 Published by the Free Software Foundation @*
405 59 Temple Place, Suite 330 @*
406 Boston, MA  02111-1307  USA
409 Permission is granted to make and distribute verbatim copies of this
410 manual provided the copyright notice and this permission notice are
411 preserved on all copies.
413 Permission is granted to copy and distribute modified versions of this
414 manual under the conditions for verbatim copying, provided also that the
415 section entitled ``GNU General Public License'' is included exactly as
416 in the original, and provided that the entire resulting derived work is
417 distributed under the terms of a permission notice identical to this
418 one.
420 Permission is granted to copy and distribute translations of this manual
421 into another language, under the above conditions for modified versions,
422 except that the section entitled ``GNU General Public License'' may be
423 included in a translation approved by the Free Software Foundation
424 instead of in the original English.
426 Cover art by Etienne Suvasa.
427 @end titlepage
428 @page
432 @node Top, Copying, (dir), (dir)
434 @ifinfo
435 This Info file documents groff version 1.18, the GNU implementation of
436 the troff typesetting system.
438 This is an in-progress document; contributions, comments, or
439 contributions are welcome.  Send them to bug-groff@@gnu.org.
440 @end ifinfo
442 @menu
443 * Copying::
444 * Introduction::
445 * Invoking groff::
446 * Tutorial for Macro Users::
447 * Macro Packages::
448 * gtroff Reference::
449 * Preprocessors::
450 * Output Devices::
451 * File formats::
452 * Installation::
453 * Request Index::
454 * Escape Index::
455 * Operator Index::
456 * Register Index::
457 * Macro Index::
458 * String Index::
459 * Glyph Name Index::
460 * Font File Keyword Index::
461 * Program and File Index::
462 * Concept Index::
463 @end menu
467 @node Copying, Introduction, Top, Top
468 @cindex copying
469 @unnumbered GNU GENERAL PUBLIC LICENSE
470 @center Version 2, June 1991
472 @display
473 Copyright @copyright{}@w{ }1989, 1991 Free Software Foundation, Inc.
474 59@w{ }Temple Place, Suite@w{ }330, Boston, MA@w{ }02111, USA
476 Everyone is permitted to copy and distribute verbatim copies of this
477 license document, but changing it is not allowed.
478 @end display
480 @unnumberedsec Preamble
482 The licenses for most software are designed to take away your freedom to
483 share and change it.  By contrast, the GNU General Public License is
484 intended to guarantee your freedom to share and change free software --
485 to make sure the software is free for all its users.  This General
486 Public License applies to most of the Free Software Foundation's
487 software and to any other program whose authors commit to using it.
488 (Some other Free Software Foundation software is covered by the GNU
489 Library General Public License instead.)  You can apply it to your
490 programs, too.
492 When we speak of free software, we are referring to freedom, not price.
493 Our General Public Licenses are designed to make sure that you have the
494 freedom to distribute copies of free software (and charge for this
495 service if you wish), that you receive source code or can get it if you
496 want it, that you can change the software or use pieces of it in new
497 free programs; and that you know you can do these things.
499 To protect your rights, we need to make restrictions that forbid anyone
500 to deny you these rights or to ask you to surrender the rights.  These
501 restrictions translate to certain responsibilities for you if you
502 distribute copies of the software, or if you modify it.
504 For example, if you distribute copies of such a program, whether gratis
505 or for a fee, you must give the recipients all the rights that you have.
506 You must make sure that they, too, receive or can get the source code.
507 And you must show them these terms so they know their rights.
509 We protect your rights with two steps: (1)@w{ }copyright the software,
510 and (2)@w{ }offer you this license which gives you legal permission to
511 copy, distribute and/or modify the software.
513 Also, for each author's protection and ours, we want to make certain
514 that everyone understands that there is no warranty for this free
515 software.  If the software is modified by someone else and passed on, we
516 want its recipients to know that what they have is not the original, so
517 that any problems introduced by others will not reflect on the original
518 authors' reputations.
520 Finally, any free program is threatened constantly by software patents.
521 We wish to avoid the danger that redistributors of a free program will
522 individually obtain patent licenses, in effect making the program
523 proprietary.  To prevent this, we have made it clear that any patent
524 must be licensed for everyone's free use or not licensed at all.
526 The precise terms and conditions for copying, distribution and
527 modification follow.
529 @iftex
530 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
531 @end iftex
532 @ifinfo
533 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
534 @end ifinfo
536 @enumerate 0
537 @item
538 This License applies to any program or other work which contains a
539 notice placed by the copyright holder saying it may be distributed under
540 the terms of this General Public License.  The ``Program'', below,
541 refers to any such program or work, and a ``work based on the Program''
542 means either the Program or any derivative work under copyright law:
543 that is to say, a work containing the Program or a portion of it, either
544 verbatim or with modifications and/or translated into another language.
545 (Hereinafter, translation is included without limitation in the term
546 ``modification''.)  Each licensee is addressed as ``you''.
548 Activities other than copying, distribution and modification are not
549 covered by this License; they are outside its scope.  The act of running
550 the Program is not restricted, and the output from the Program is
551 covered only if its contents constitute a work based on the Program
552 (independent of having been made by running the Program).  Whether that
553 is true depends on what the Program does.
555 @item
556 You may copy and distribute verbatim copies of the Program's source code
557 as you receive it, in any medium, provided that you conspicuously and
558 appropriately publish on each copy an appropriate copyright notice and
559 disclaimer of warranty; keep intact all the notices that refer to this
560 License and to the absence of any warranty; and give any other
561 recipients of the Program a copy of this License along with the Program.
563 You may charge a fee for the physical act of transferring a copy, and
564 you may at your option offer warranty protection in exchange for a fee.
566 @item
567 You may modify your copy or copies of the Program or any portion of it,
568 thus forming a work based on the Program, and copy and distribute such
569 modifications or work under the terms of Section@w{ }1 above, provided
570 that you also meet all of these conditions:
572 @enumerate a
573 @item
574 You must cause the modified files to carry prominent notices stating
575 that you changed the files and the date of any change.
577 @item
578 You must cause any work that you distribute or publish, that in whole or
579 in part contains or is derived from the Program or any part thereof, to
580 be licensed as a whole at no charge to all third parties under the terms
581 of this License.
583 @item
584 If the modified program normally reads commands interactively when run,
585 you must cause it, when started running for such interactive use in the
586 most ordinary way, to print or display an announcement including an
587 appropriate copyright notice and a notice that there is no warranty (or
588 else, saying that you provide a warranty) and that users may
589 redistribute the program under these conditions, and telling the user
590 how to view a copy of this License.  (Exception: if the Program itself
591 is interactive but does not normally print such an announcement, your
592 work based on the Program is not required to print an announcement.)
593 @end enumerate
595 These requirements apply to the modified work as a whole.  If
596 identifiable sections of that work are not derived from the Program, and
597 can be reasonably considered independent and separate works in
598 themselves, then this License, and its terms, do not apply to those
599 sections when you distribute them as separate works.  But when you
600 distribute the same sections as part of a whole which is a work based on
601 the Program, the distribution of the whole must be on the terms of this
602 License, whose permissions for other licensees extend to the entire
603 whole, and thus to each and every part regardless of who wrote it.
605 Thus, it is not the intent of this section to claim rights or contest
606 your rights to work written entirely by you; rather, the intent is to
607 exercise the right to control the distribution of derivative or
608 collective works based on the Program.
610 In addition, mere aggregation of another work not based on the Program
611 with the Program (or with a work based on the Program) on a volume of a
612 storage or distribution medium does not bring the other work under the
613 scope of this License.
615 @item
616 You may copy and distribute the Program (or a work based on it, under
617 Section@w{ }2) in object code or executable form under the terms of
618 Sections@w{ }1 and@w{ }2 above provided that you also do one of the
619 following:
621 @enumerate a
622 @item
623 Accompany it with the complete corresponding machine-readable source
624 code, which must be distributed under the terms of Sections@w{ }1 and@w{
625 }2 above on a medium customarily used for software interchange; or,
627 @item
628 Accompany it with a written offer, valid for at least three years, to
629 give any third party, for a charge no more than your cost of physically
630 performing source distribution, a complete machine-readable copy of the
631 corresponding source code, to be distributed under the terms of
632 Sections@w{ }1 and@w{ }2 above on a medium customarily used for software
633 interchange; or,
635 @item
636 Accompany it with the information you received as to the offer to
637 distribute corresponding source code.  (This alternative is allowed only
638 for noncommercial distribution and only if you received the program in
639 object code or executable form with such an offer, in accord with
640 Subsection@w{ }b above.)
641 @end enumerate
643 The source code for a work means the preferred form of the work for
644 making modifications to it.  For an executable work, complete source
645 code means all the source code for all modules it contains, plus any
646 associated interface definition files, plus the scripts used to control
647 compilation and installation of the executable.  However, as a special
648 exception, the source code distributed need not include anything that is
649 normally distributed (in either source or binary form) with the major
650 components (compiler, kernel, and so on) of the operating system on
651 which the executable runs, unless that component itself accompanies the
652 executable.
654 If distribution of executable or object code is made by offering access
655 to copy from a designated place, then offering equivalent access to copy
656 the source code from the same place counts as distribution of the source
657 code, even though third parties are not compelled to copy the source
658 along with the object code.
660 @item
661 You may not copy, modify, sublicense, or distribute the Program except
662 as expressly provided under this License.  Any attempt otherwise to
663 copy, modify, sublicense or distribute the Program is void, and will
664 automatically terminate your rights under this License.  However,
665 parties who have received copies, or rights, from you under this License
666 will not have their licenses terminated so long as such parties remain
667 in full compliance.
669 @item
670 You are not required to accept this License, since you have not signed
671 it.  However, nothing else grants you permission to modify or distribute
672 the Program or its derivative works.  These actions are prohibited by
673 law if you do not accept this License.  Therefore, by modifying or
674 distributing the Program (or any work based on the Program), you
675 indicate your acceptance of this License to do so, and all its terms and
676 conditions for copying, distributing or modifying the Program or works
677 based on it.
679 @item
680 Each time you redistribute the Program (or any work based on the
681 Program), the recipient automatically receives a license from the
682 original licensor to copy, distribute or modify the Program subject to
683 these terms and conditions.  You may not impose any further restrictions
684 on the recipients' exercise of the rights granted herein.  You are not
685 responsible for enforcing compliance by third parties to this License.
687 @item
688 If, as a consequence of a court judgment or allegation of patent
689 infringement or for any other reason (not limited to patent issues),
690 conditions are imposed on you (whether by court order, agreement or
691 otherwise) that contradict the conditions of this License, they do not
692 excuse you from the conditions of this License.  If you cannot
693 distribute so as to satisfy simultaneously your obligations under this
694 License and any other pertinent obligations, then as a consequence you
695 may not distribute the Program at all.  For example, if a patent license
696 would not permit royalty-free redistribution of the Program by all those
697 who receive copies directly or indirectly through you, then the only way
698 you could satisfy both it and this License would be to refrain entirely
699 from distribution of the Program.
701 If any portion of this section is held invalid or unenforceable under
702 any particular circumstance, the balance of the section is intended to
703 apply and the section as a whole is intended to apply in other
704 circumstances.
706 It is not the purpose of this section to induce you to infringe any
707 patents or other property right claims or to contest validity of any
708 such claims; this section has the sole purpose of protecting the
709 integrity of the free software distribution system, which is implemented
710 by public license practices.  Many people have made generous
711 contributions to the wide range of software distributed through that
712 system in reliance on consistent application of that system; it is up to
713 the author/donor to decide if he or she is willing to distribute
714 software through any other system and a licensee cannot impose that
715 choice.
717 This section is intended to make thoroughly clear what is believed to be
718 a consequence of the rest of this License.
720 @item
721 If the distribution and/or use of the Program is restricted in certain
722 countries either by patents or by copyrighted interfaces, the original
723 copyright holder who places the Program under this License may add an
724 explicit geographical distribution limitation excluding those countries,
725 so that distribution is permitted only in or among countries not thus
726 excluded.  In such case, this License incorporates the limitation as if
727 written in the body of this License.
729 @item
730 The Free Software Foundation may publish revised and/or new versions of
731 the General Public License from time to time.  Such new versions will be
732 similar in spirit to the present version, but may differ in detail to
733 address new problems or concerns.
735 Each version is given a distinguishing version number.  If the Program
736 specifies a version number of this License which applies to it and ``any
737 later version'', you have the option of following the terms and
738 conditions either of that version or of any later version published by
739 the Free Software Foundation.  If the Program does not specify a version
740 number of this License, you may choose any version ever published by the
741 Free Software Foundation.
743 @item
744 If you wish to incorporate parts of the Program into other free programs
745 whose distribution conditions are different, write to the author to ask
746 for permission.  For software which is copyrighted by the Free Software
747 Foundation, write to the Free Software Foundation; we sometimes make
748 exceptions for this.  Our decision will be guided by the two goals of
749 preserving the free status of all derivatives of our free software and
750 of promoting the sharing and reuse of software generally.
752 @iftex
753 @heading NO WARRANTY
754 @end iftex
755 @ifinfo
756 @center NO WARRANTY
757 @end ifinfo
759 @item
760 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
761 THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW@.  EXCEPT WHEN
762 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
763 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER
764 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
765 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE@.
766 THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
767 YOU@.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
768 NECESSARY SERVICING, REPAIR OR CORRECTION.
770 @item
771 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
772 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
773 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
774 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
775 DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
776 (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
777 INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
778 THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
779 OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
780 @end enumerate
782 @iftex
783 @heading END OF TERMS AND CONDITIONS
784 @end iftex
785 @ifinfo
786 @center END OF TERMS AND CONDITIONS
787 @end ifinfo
790 @page
791 @unnumberedsec How to Apply These Terms to Your New Programs
793 If you develop a new program, and you want it to be of the greatest
794 possible use to the public, the best way to achieve this is to make it
795 free software which everyone can redistribute and change under these
796 terms.
798 To do so, attach the following notices to the program.  It is safest to
799 attach them to the start of each source file to most effectively convey
800 the exclusion of warranty; and each file should have at least the
801 ``copyright'' line and a pointer to where the full notice is found.
803 @smallexample
804 @var{one line to give the program's name and an idea of what it does.}
805 Copyright (C) 19@var{yy} @var{name of author}
807 This program is free software; you can redistribute it and/or modify
808 it under the terms of the GNU General Public License as published by
809 the Free Software Foundation; either version 2 of the License, or (at
810 your option) any later version.
812 This program is distributed in the hope that it will be useful, but
813 WITHOUT ANY WARRANTY; without even the implied warranty of
814 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@.  See the GNU
815 General Public License for more details.
817 You should have received a copy of the GNU General Public License
818 along with this program; if not, write to the Free Software
819 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
820 @end smallexample
822 Also add information on how to contact you by electronic and paper mail.
824 If the program is interactive, make it output a short notice like this
825 when it starts in an interactive mode:
827 @smallexample
828 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
829 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type
830 `show w'.  This is free software, and you are welcome to redistribute
831 it under certain conditions; type `show c' for details.
832 @end smallexample
834 The hypothetical commands @samp{show@w{ }w} and @samp{show@w{ }c} should
835 show the appropriate parts of the General Public License.  Of course,
836 the commands you use may be called something other than @samp{show@w{
837 }w} and @samp{show@w{ }c}; they could even be mouse-clicks or menu items
838 -- whatever suits your program.
840 You should also get your employer (if you work as a programmer) or your
841 school, if any, to sign a ``copyright disclaimer'' for the program, if
842 necessary.  Here is a sample; alter the names:
844 @smallexample
845 @group
846 Yoyodyne, Inc., hereby disclaims all copyright interest
847 in the program `Gnomovision' (which makes passes at compilers)
848 written by James Hacker.
850 @var{signature of Ty Coon}, 1 April 1989
851 Ty Coon, President of Vice
852 @end group
853 @end smallexample
855 This General Public License does not permit incorporating your program
856 into proprietary programs.  If your program is a subroutine library, you
857 may consider it more useful to permit linking proprietary applications
858 with the library.  If this is what you want to do, use the GNU Library
859 General Public License instead of this License.
863 @c =====================================================================
864 @c =====================================================================
866 @node Introduction, Invoking groff, Copying, Top
867 @chapter Introduction
868 @cindex introduction
870 GNU @code{troff} (or @code{groff}) is a system for typesetting
871 documents.  @code{troff} is very flexible and has been in existence (and
872 use) for about 3@w{ }decades.  It is quite widespread and firmly
873 entrenched in the @acronym{UNIX} community.
875 @menu
876 * What Is groff?::
877 * History::
878 * groff Capabilities::
879 * Macro Package Intro::
880 * Preprocessor Intro::
881 * Output device intro::
882 * Credits::
883 @end menu
886 @c =====================================================================
888 @node What Is groff?, History, Introduction, Introduction
889 @section What Is @code{groff}?
890 @cindex what is @code{groff}?
891 @cindex @code{groff} -- what is it?
893 @code{groff} belongs to an older generation of document preparation
894 systems, which operate more like compilers than the more recent
895 interactive @acronym{WYSIWYG}@footnote{What You See Is What You Get}
896 systems.  @code{groff} and its contemporary counterpart, @TeX{}, both
897 work using a @dfn{batch} paradigm: The input (or @dfn{source}) files are
898 normal text files with embedded formatting commands.  These files can
899 then be processed by @code{groff} to produce a typeset document on a
900 variety of devices.
902 Likewise, @code{groff} should not be confused with a @dfn{word
903 processor}, since that term connotes an integrated system that includes
904 an editor and a text formatter.  Also, many word processors follow the
905 @acronym{WYSIWYG} paradigm discussed earlier.
907 Although @acronym{WYSIWYG} systems may be easier to use, they have a
908 number of disadvantages compared to @code{troff}:
910 @itemize @bullet
911 @item
912 They must be used on a graphics display to work on a document.
914 @item
915 Most of the @acronym{WYSIWYG} systems are either non-free or are not
916 very portable.
918 @item
919 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
921 @item
922 It is difficult to have a wide range of capabilities available within
923 the confines of a GUI/window system.
925 @item
926 It is more difficult to make global changes to a document.
927 @end itemize
929 @quotation
930 ``GUIs normally make it simple to accomplish simple actions and
931 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
932 @code{comp.unix.wizards})
933 @end quotation
936 @c =====================================================================
938 @node History, groff Capabilities, What Is groff?, Introduction
939 @section History
940 @cindex history
942 @cindex @code{runoff}, the program
943 @cindex @code{rf}, the program
944 @code{troff} can trace its origins back to a formatting program called
945 @code{runoff}, written by J.@w{ }E.@w{ }Saltzer, which ran on MIT's CTSS
946 operating system in the mid-sixties.  This name came from the common
947 phrase of the time ``I'll run off a document.''  Bob Morris ported it to
948 the 635 architecture and called the program @code{roff} (an abbreviation
949 of @code{runoff}).  It was rewritten as @code{rf} for the @w{PDP-7}
950 (before having @acronym{UNIX}), and at the same time (1969), Doug
951 McIllroy rewrote an extended and simplified version of @code{roff} in
952 the @acronym{BCPL} programming language.
954 @cindex @code{roff}, the program
955 The first version of @acronym{UNIX} was developed on a @w{PDP-7} which
956 was sitting around Bell Labs.  In 1971 the developers wanted to get a
957 @w{PDP-11} for further work on the operating system.  In order to
958 justify the cost for this system, they proposed that they would
959 implement a document formatting system for the AT&T patents division.
960 This first formatting program was a reimplementation of McIllroy's
961 @code{roff}, written by J.@w{ }F.@w{ }Ossanna.
963 @cindex @code{nroff}, the program
964 When they needed a more flexible language, a new version of @code{roff}
965 called @code{nroff} (``Newer @code{roff}'') was written.  It had a much
966 more complicated syntax, but provided the basis for all future versions.
967 When they got a Graphic Systems CAT Phototypesetter, Ossanna wrote a
968 version of @code{nroff} that would drive it.  It was dubbed
969 @code{troff}, for ``typesetter @code{roff}'', although many people have
970 speculated that it actually means ``Times @code{roff}'' because of the
971 use of the Times font family in @code{troff} by default.  As such, the
972 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
974 With @code{troff} came @code{nroff} (they were actually the same program
975 except for some @samp{#ifdef}s), which was for producing output for line
976 printers and character terminals.  It understood everything @code{troff}
977 did, and ignored the commands which were not applicable (e.g.@: font
978 changes).
980 Since there are several things which cannot be done easily in
981 @code{troff}, work on several preprocessors began.  These programs would
982 transform certain parts of a document into @code{troff}, which made a
983 very natural use of pipes in @acronym{UNIX}.
985 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
986 specified in a much simpler and more intuitive manner.  @code{tbl} is a
987 preprocessor for formatting tables.  The @code{refer} preprocessor (and
988 the similar program, @code{bib}) processes citations in a document
989 according to a bibliographic database.
991 Unfortunately, Ossanna's @code{troff} was written in @w{PDP-11} assembly
992 language and produced output specifically for the CAT phototypesetter.
993 He rewrote it in C, although it was now 7000@w{ }lines of uncommented
994 code and still dependent on the CAT.  As the CAT became less common, and
995 was no longer supported by the manufacturer, the need to make it support
996 other devices became a priority.  However, before this could be done,
997 Ossanna was killed in an auto accident.
999 @pindex ditroff
1000 @cindex @code{ditroff}, the program
1001 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
1002 newly rewritten version produced a device independent code which was
1003 very easy for postprocessors to read and translate to the appropriate
1004 printer codes.  Also, this new version of @code{troff} (called
1005 @code{ditroff} for ``device independent @code{troff}'') had several
1006 extensions, which included drawing functions.
1008 Due to the additional abilities of the new version of @code{troff},
1009 several new preprocessors appeared.  The @code{pic} preprocessor
1010 provides a wide range of drawing functions.  Likewise the @code{ideal}
1011 preprocessor did the same, although via a much different paradigm.  The
1012 @code{grap} preprocessor took specifications for graphs, but, unlike
1013 other preprocessors, produced @code{pic} code.
1015 James Clark began work on a GNU implementation of @code{ditroff} in
1016 early@w{ }1989.  The first version, @code{groff}@w{ }0.3.1, was released
1017 June@w{ }1990.  @code{groff} included:
1019 @itemize @bullet
1020 @item
1021 A replacement for @code{ditroff} with many extensions.
1023 @item
1024 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
1026 @item
1027 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
1028 X@w{ }windows.  GNU @code{troff} also eliminated the need for a
1029 separate @code{nroff} program with a postprocessor which would produce
1030 @acronym{ASCII} output.
1032 @item
1033 A version of the @file{me} macros and an implementation of the
1034 @file{man} macros.
1035 @end itemize
1037 Also, a front-end was included which could construct the, sometimes
1038 painfully long, pipelines required for all the post- and preprocessors.
1040 Development of GNU @code{troff} progressed rapidly, and saw the
1041 additions of a replacement for @code{refer}, an implementation of the
1042 @file{ms} and @file{mm} macros, and a program to deduce how to format a
1043 document (@code{grog}).
1045 It was declared a stable (i.e.@: non-beta) package with the release of
1046 version@w{ }1.04 around November@w{ }1991.
1048 Beginning in@w{ }1999, @code{groff} has new maintainers (the package was
1049 an orphan for a few years).  As a result, new features and programs like
1050 @code{grn}, a preprocessor for gremlin images, and an output device to
1051 produce @acronym{HTML} output have been added.
1054 @c =====================================================================
1056 @node groff Capabilities, Macro Package Intro, History, Introduction
1057 @section @code{groff} Capabilities
1058 @cindex @code{groff} capabilities
1059 @cindex capabilities of @code{groff}
1061 So what exactly is @code{groff} capable of doing?  @code{groff} provides
1062 a wide range of low-level text formatting operations.  Using these, it
1063 is possible to perform a wide range of formatting tasks, such as
1064 footnotes, table of contents, multiple columns, etc.  Here's a list of
1065 the most important operations supported by @code{groff}:
1067 @itemize @bullet
1068 @item
1069 text filling, adjusting, and centering
1071 @item
1072 hyphenation
1074 @item
1075 page control
1077 @item
1078 font and character size control
1080 @item
1081 vertical spacing (i.e.@: double spacing)
1083 @item
1084 line length and indenting
1086 @item
1087 macros, strings, diversions, and traps
1089 @item
1090 number registers
1092 @item
1093 tabs, leaders, and fields
1095 @item
1096 input and output conventions and character translation
1098 @item
1099 overstrike, bracket, line drawing, and zero-width functions
1101 @item
1102 local horizontal and vertical motions and the width function
1104 @item
1105 three-part titles
1107 @item
1108 output line numbering
1110 @item
1111 conditional acceptance of input
1113 @item
1114 environment switching
1116 @item
1117 insertions from the standard input
1119 @item
1120 input/output file switching
1122 @item
1123 output and error messages
1124 @end itemize
1127 @c =====================================================================
1129 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
1130 @section Macro Packages
1131 @cindex macro packages
1133 Since @code{groff} provides such low-level facilities, it can be quite
1134 difficult to use by itself.  However, @code{groff} provides a
1135 @dfn{macro} facility to specify how certain routine operations (e.g.@w{
1136 }starting paragraphs, printing headers and footers, etc.)@: should be
1137 done.  These macros can be collected together into a @dfn{macro
1138 package}.  There are a number of macro packages available; the most
1139 common (and the ones described in this manual) are @file{man},
1140 @file{mdoc}, @file{me}, @file{ms}, and @file{mm}.
1143 @c =====================================================================
1145 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
1146 @section Preprocessors
1147 @cindex preprocessors
1149 Although @code{groff} provides most functions needed to format a
1150 document, some operations would be unwieldy (e.g.@: to draw pictures).
1151 Therefore, programs called @dfn{preprocessors} were written which
1152 understand their own language and produce the necessary @code{groff}
1153 operations.  These preprocessors are able to differentiate their own
1154 input from the rest of the document via markers.
1156 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
1157 from the preprocessor into @code{groff}.  Any number of preprocessors
1158 may be used on a given document; in this case, the preprocessors are
1159 linked together into one pipeline.  However, in @code{groff}, the user
1160 does not need to construct the pipe, but only tell @code{groff} what
1161 preprocessors to use.
1163 @code{groff} currently has preprocessors for producing tables
1164 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
1165 (@code{pic} and @code{grn}), and for processing bibliographies
1166 (@code{refer}).  An associated program which is useful when dealing with
1167 preprocessors is @code{soelim}.
1169 A free implementation of @code{grap}, a preprocessor for drawing graphs,
1170 can be obtained as an extra package; @code{groff} can use @code{grap}
1171 also.
1173 There are other preprocessors in existence, but, unfortunately, no free
1174 implementations are available.  Among them are preprocessors for drawing
1175 mathematical pictures (@code{ideal}) and chemical structures
1176 (@code{chem}).
1179 @c =====================================================================
1181 @node Output device intro, Credits, Preprocessor Intro, Introduction
1182 @section Output Devices
1183 @cindex postprocessors
1184 @cindex output devices
1185 @cindex devices for output
1187 @code{groff} actually produces device independent code which may be
1188 fed into a postprocessor to produce output for a particular device.
1189 Currently, @code{groff} has postprocessors for @sc{PostScript}
1190 devices, character terminals, X@w{ }Windows (for previewing), @TeX{}
1191 DVI format, HP LaserJet@w{ }4 and Canon LBP printers (which use
1192 @acronym{CAPSL}), and @acronym{HTML}.
1195 @c =====================================================================
1197 @node Credits,  , Output device intro, Introduction
1198 @section Credits
1199 @cindex credits
1201 Large portions of this manual were taken from existing documents, most
1202 notably, the manual pages for the @code{groff} package by James Clark,
1203 and Eric Allman's papers on the @file{me} macro package.
1205 The section on the @file{man} macro package is partly based on Susan@w{
1206 }G.@: Kleinmann's @file{groff_man} manual page written for the Debian
1207 GNU/Linux system.
1211 @c =====================================================================
1212 @c =====================================================================
1214 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
1215 @chapter Invoking @code{groff}
1216 @cindex invoking @code{groff}
1217 @cindex @code{groff} invocation
1219 This section focuses on how to invoke the @code{groff} front end.  This
1220 front end takes care of the details of constructing the pipeline among
1221 the preprocessors, @code{gtroff} and the postprocessor.
1223 It has become a tradition that GNU programs get the prefix @samp{g} to
1224 distinguish it from its original counterparts provided by the host (see
1225 @ref{Environment}, for more details).  Thus, for example, @code{geqn} is
1226 GNU @code{eqn}.  On operating systems like Linux or the Hurd, which
1227 don't contain proprietary software, and on MS-DOS/MS-Windows, where
1228 @code{troff} and associated programs are not available at all, this
1229 prefix is omitted since GNU @code{troff} is the only used incarnation of
1230 @code{troff}.  Exception: @code{groff} is never replaced by @code{roff}.
1232 @menu
1233 * Groff Options::
1234 * Environment::
1235 * Invocation Examples::
1236 @end menu
1239 @c =====================================================================
1241 @node Groff Options, Environment, Invoking groff, Invoking groff
1242 @section Options
1243 @cindex options
1245 @pindex groff
1246 @pindex gtroff
1247 @pindex gpic
1248 @pindex geqn
1249 @pindex ggrn
1250 @pindex grap
1251 @pindex gtbl
1252 @pindex grefer
1253 @pindex gsoelim
1254 @code{groff} normally runs the @code{gtroff} program and a postprocessor
1255 appropriate for the selected device.  The default device is @samp{ps}
1256 (but it can be changed when @code{groff} is configured and built).  It
1257 can optionally preprocess with any of @code{gpic}, @code{geqn},
1258 @code{gtbl}, @code{ggrn}, @code{grap}, @code{grefer}, or @code{gsoelim}.
1260 This section only documents options to the @code{groff} front end.  Many
1261 of the arguments to @code{groff} are passed on to @code{gtroff},
1262 therefore those are also included.  Arguments to pre- or postprocessors
1263 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
1264 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
1265 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
1266 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
1267 grolbp}, and @ref{Invoking gxditview}.
1269 The command line format for @code{groff} is:
1271 @Example
1272 groff [ -abceghilpstvzCEGNRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
1273       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
1274       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
1275       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
1276       [ @var{files}@dots{} ]
1277 @endExample
1279 The command line format for @code{gtroff} is as follows.
1281 @Example
1282 gtroff [ -abcivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
1283        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
1284        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
1285        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
1286 @endExample
1288 @noindent
1289 Obviously, many of the options to @code{groff} are actually passed on to
1290 @code{gtroff}.
1292 Options without an argument can be grouped behind a single@w{ }@option{-}.
1293 A filename of@w{ }@file{-} denotes the standard input.  It is possible to
1294 have whitespace between an option and its parameter.
1296 The @code{grog} command can be used to guess the correct @code{groff}
1297 command to format a file.
1299 Here's the description of the command-line options:
1301 @cindex command-line options
1302 @table @samp
1303 @item -h
1304 Print a help message.
1306 @item -e
1307 Preprocess with @code{geqn}.
1309 @item -t
1310 Preprocess with @code{gtbl}.
1312 @item -g
1313 Preprocess with @code{ggrn}.
1315 @item -G
1316 Preprocess with @code{grap}.
1318 @item -p
1319 Preprocess with @code{gpic}.
1321 @item -s
1322 Preprocess with @code{gsoelim}.
1324 @item -c
1325 Suppress color output.
1327 @item -R
1328 Preprocess with @code{grefer}.  No mechanism is provided for passing
1329 arguments to @code{grefer} because most @code{grefer} options have
1330 equivalent commands which can be included in the file.  @xref{grefer},
1331 for more details.
1333 @pindex troffrc
1334 @pindex troffrc-end
1335 Note that @code{gtroff} also accepts a @option{-R} option, which is not
1336 accessible via @code{groff}.  This option prevents the loading of the
1337 @file{troffrc} and @file{troffrc-end} files.
1339 @item -v
1340 Make programs run by @code{groff} print out their version number.
1342 @item -V
1343 Print the pipeline on @code{stdout} instead of executing it.
1345 @item -z
1346 Suppress output from @code{gtroff}.  Only error messages are printed.
1348 @item -Z
1349 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
1350 automatically runs the appropriate postprocessor.
1352 @item -P@var{arg}
1353 Pass @var{arg} to the postprocessor.  Each argument should be passed
1354 with a separate @option{-P} option.  Note that @code{groff} does not
1355 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1357 @item -l
1358 Send the output to a spooler for printing.  The command used for this is
1359 specified by the @code{print} command in the device description file
1360 (see @ref{Font Files}, for more info).  If not present, @option{-l} is
1361 ignored.
1363 @item -L@var{arg}
1364 Pass @var{arg} to the spooler.  Each argument should be passed with a
1365 separate @option{-L} option.  Note that @code{groff} does not prepend
1366 a @samp{-} to @var{arg} before passing it to the postprocessor.
1367 If the @code{print} keyword in the device description file is missing,
1368 @option{-L} is ignored.
1370 @item -T@var{dev}
1371 Prepare output for device @var{dev}.  The default device is @samp{ps},
1372 unless changed when @code{groff} was configured and built.  The
1373 following are the output devices currently available:
1375 @table @code
1376 @item ps
1377 For @sc{PostScript} printers and previewers.
1379 @item dvi
1380 For @TeX{} DVI format.
1382 @item X75
1383 For a 75@dmn{dpi} X11 previewer.
1385 @item X75-12
1386 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font.
1388 @item X100
1389 For a 100@dmn{dpi} X11 previewer.
1391 @item X100-12
1392 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font.
1394 @item ascii
1395 For typewriter-like devices.
1397 @item latin1
1398 For typewriter-like devices that support the @w{Latin-1} (@w{ISO
1399 8859-1}) character set.
1401 @item utf8
1402 For typewriter-like devices which use the Unicode (@w{ISO 10646})
1403 character set with @w{UTF-8} encoding.
1405 @item cp1047
1406 @cindex @acronym{EBCDIC} encoding
1407 @cindex encoding, @acronym{EBCDIC}
1408 @cindex encoding, cp1047
1409 @cindex cp1047
1410 @cindex IBM cp1047
1411 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1412 cp1047.
1414 @item lj4
1415 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
1417 @item lbp
1418 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1419 printers).
1421 @pindex pre-grohtml
1422 @pindex post-grohtml
1423 @cindex @code{grohtml}, the program
1424 @item html
1425 To produce @acronym{HTML} output.  Note that the @acronym{HTML} driver
1426 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1427 postprocessor (@code{post-grohtml}).
1428 @end table
1430 @cindex output device name string register (@code{.T})
1431 @cindex output device usage number register (@code{.T})
1432 The predefined @code{gtroff} string register @code{.T} contains the
1433 current output device; the read-only number register @code{.T} is set
1434 to@w{ }1 if this option is used (which is always true if @code{groff} is
1435 used to call @code{gtroff}).  @xref{Built-in Registers}.
1437 The postprocessor to be used for a device is specified by the
1438 @code{postpro} command in the device description file.  (@xref{Font
1439 Files}, for more info.)  This can be overridden with the @option{-X}
1440 option.
1442 @item -X
1443 Preview with @code{gxditview} instead of using the usual postprocessor.
1444 This is unlikely to produce good results except with @option{-Tps}.
1446 Note that this is not the same as using @option{-TX75} or
1447 @option{-TX100} to view a document with @code{gxditview}: The former
1448 uses the metrics of the specified device, whereas the latter uses
1449 X-specific fonts and metrics.
1451 @item -N
1452 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1453 the @option{-N} option in @code{geqn}.
1455 @cindex @code{open} request, and safer mode
1456 @cindex @code{opena} request, and safer mode
1457 @cindex @code{pso} request, and safer mode
1458 @cindex @code{sy} request, and safer mode
1459 @cindex @code{pi} request, and safer mode
1460 @item -S
1461 Safer mode.  Pass the @option{-S} option to @code{gpic} and disable the
1462 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1463 requests.  For security reasons, this is enabled by default.
1465 @item -U
1466 Unsafe mode.  Reverts to the old unsafe behaviour.
1468 @item -a
1469 @cindex @acronym{ASCII} approximation output register (@code{.A})
1470 Generate an @acronym{ASCII} approximation of the typeset output.  The
1471 read-only register @code{.A} is then set to@w{ }1.  @xref{Built-in
1472 Registers}.  A typical example is
1474 @Example
1475 groff -a -man -Tdvi troff.man | less
1476 @endExample
1478 @noindent
1479 which shows how lines are broken for the DVI device.  Note that this
1480 option is rather useless today since graphic output devices are
1481 available virtually everywhere.
1483 @item -b
1484 Print a backtrace with each warning or error message.  This backtrace
1485 should help track down the cause of the error.  The line numbers given
1486 in the backtrace may not always be correct: @code{gtroff} can get
1487 confused by @code{as} or @code{am} requests while counting line numbers.
1489 @item -i
1490 Read the standard input after all the named input files have been
1491 processed.
1493 @item -w@var{name}
1494 Enable warning @var{name}.  Available warnings are described in
1495 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1497 @item -W@var{name}
1498 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1500 @item -E
1501 Inhibit all error messages.
1503 @item -C
1504 Enable compatibility mode.  @xref{Implementation Differences}, for the
1505 list of incompatibilities between @code{groff} and traditional Unix
1506 @code{troff}.
1508 @item -d@var{cs}
1509 @itemx -d@var{name}=s
1510 Define @var{c} or @var{name} to be a string@w{ }@var{s}.  @var{c}@w{ }must
1511 be a one-letter name; @var{name} can be of arbitrary length.  All string
1512 assignments happen before loading any macro file (including the start-up
1513 file).
1515 @item -f@var{fam}
1516 Use @var{fam} as the default font family.  @xref{Font Families}.
1518 @item -m@var{name}
1519 Read in the file @file{@var{name}.tmac}.  Normally @code{groff} searches
1520 for this in its macro directories.  If it isn't found, it tries
1521 @file{tmac.@var{name}} (and searches in the same directories).
1523 @c XXX document local and system macro dirs
1525 @item -n@var{num}
1526 Number the first page @var{num}.
1528 @item -o@var{list}
1529 @cindex print current page register (@code{.P})
1530 Output only pages in @var{list}, which is a comma-separated list of page
1531 ranges; @samp{@var{n}} means print page@w{ }@var{n}, @samp{@var{m}-@var{n}}
1532 means print every page between @var{m} and@w{ }@var{n}, @samp{-@var{n}}
1533 means print every page up to@w{ }@var{n}, @samp{@var{n}-} means print every
1534 page beginning with@w{ }@var{n}.  @code{gtroff} exits after printing the
1535 last page in the list.  All the ranges are inclusive on both ends.
1537 Within @code{gtroff}, this information can be extracted with the
1538 @samp{.P} register.  @xref{Built-in Registers}.
1540 If your document restarts page numbering at the beginning of each
1541 chapter, then @code{gtroff} prints the specified page range for each
1542 chapter.
1544 @item -r@var{cn}
1545 @itemx -r@var{name}=@var{n}
1546 Set number register@w{ }@var{c} or @var{name} to the value@w{ }@var{n}.
1547 @var{c}@w{ }must be a one-letter name; @var{name} can be of arbitrary
1548 length.  @var{n}@w{ }can be any @code{gtroff} numeric expression.  All
1549 register  assignments happen before loading any macro file (including
1550 the start-up file).
1552 @item -F@var{dir}
1553 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1554 (@var{name} is the name of the device), for the @file{DESC} file, and
1555 for font files before looking in the standard directories.
1557 @item -M@var{dir}
1558 Search directory @file{@var{dir}} for macro files before the standard
1559 directories.
1561 @item -I@var{dir}
1562 This option is as described in @ref{gsoelim}.  It implies the
1563 @option{-s} option.
1564 @end table
1567 @c =====================================================================
1569 @node Environment, Invocation Examples, Groff Options, Invoking groff
1570 @section Environment
1571 @cindex environment variables
1572 @cindex variables in environment
1574 There are also several environment variables (of the operating system,
1575 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1577 @table @code
1578 @item GROFF_COMMAND_PREFIX
1579 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1580 If this is set to@w{ }@var{X}, then @code{groff} runs @code{@var{X}troff}
1581 instead of @code{gtroff}.  This also applies to @code{tbl}, @code{pic},
1582 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}.  It does not
1583 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1584 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1586 @c XXX document default values
1588 @item GROFF_TMAC_PATH
1589 @tindex GROFF_TMAC_PATH@r{, environment variable}
1590 A colon-separated list of directories in which to search for macro files
1591 (before the default directories are tried).
1593 @c XXX document local and system macro dirs
1595 @item GROFF_TYPESETTER
1596 @tindex GROFF_TYPESETTER@r{, environment variable}
1597 The default output device.
1599 @item GROFF_FONT_PATH
1600 @tindex GROFF_FONT_PATH@r{, environment variable}
1601 A colon-separated list of directories in which to search for the
1602 @code{dev}@var{name} directory (before the default directories are
1603 tried).
1605 @item GROFF_BIN_PATH
1606 @tindex GROFF_BIN_PATH@r{, environment variable}
1607 This search path, followed by @code{PATH}, is used for commands executed
1608 by @code{groff}.
1610 @item GROFF_TMPDIR
1611 @tindex GROFF_TMPDIR@r{, environment variable}
1612 @tindex TMPDIR@r{, environment variable}
1613 The directory in which @code{groff} creates temporary files.  If this is
1614 not set and @env{TMPDIR} is set, temporary files are created in that
1615 directory.  Otherwise temporary files are created in a system-dependent
1616 default directory (on Unix and GNU/Linux systems, this is usually
1617 @file{/tmp}).  @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1618 @code{post-grohtml} can create temporary files in this directory.
1619 @end table
1621 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1622 rather than colons, to separate the directories in the lists described
1623 above.
1626 @c =====================================================================
1628 @node Invocation Examples,  , Environment, Invoking groff
1629 @section Invocation Examples
1630 @cindex invocation examples
1631 @cindex examples of invocation
1633 This section lists several common uses of @code{groff} and the
1634 corresponding command lines.
1636 @Example
1637 groff file
1638 @endExample
1640 @noindent
1641 This command processes @file{file} without a macro package or a
1642 preprocessor.  The output device is the default, @samp{ps}, and the
1643 output is sent to @code{stdout}.
1645 @Example
1646 groff -t -mandoc -Tascii file | less
1647 @endExample
1649 @noindent
1650 This is basically what a call to the @code{man} program does.
1651 @code{gtroff} processes the manual page @file{file} with the
1652 @file{mandoc} macro file (which in turn either calls the @file{man} or
1653 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1654 the @acronym{ASCII} output device.  Finally, the @code{less} pager
1655 displays the result.
1657 @Example
1658 groff -X -m me file
1659 @endExample
1661 @noindent
1662 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1663 package.  Since no @option{-T} option is specified, use the default
1664 device (@samp{ps}).  Note that you can either say @w{@samp{-m me}} or
1665 @w{@samp{-me}}; the latter is an anachronism from the early days of
1666 @acronym{UNIX}.@footnote{The same is true for the other main macro
1667 packages that come with @code{groff}: @file{man}, @file{mdoc},
1668 @file{ms}, @file{mm}, and @file{mandoc}.  This won't work in general;
1669 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1670 @w{@samp{-m trace}} must be used.}
1672 @Example
1673 groff -man -rD1 -z file
1674 @endExample
1676 @noindent
1677 Check @file{file} with the @file{man} macro package, forcing
1678 double-sided printing -- don't produce any output.
1680 @menu
1681 * grog::
1682 @end menu
1684 @c ---------------------------------------------------------------------
1686 @node grog,  , Invocation Examples, Invocation Examples
1687 @subsection @code{grog}
1689 @pindex grog
1690 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1691 and/or macro packages are required for formatting them, and prints the
1692 @code{groff} command including those options on the standard output.  It
1693 generates one or more of the options @option{-e}, @option{-man},
1694 @option{-me}, @option{-mm}, @option{-ms}, @option{-mdoc},
1695 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1696 @option{-s}, and @option{-t}.
1698 A special file name@w{ }@file{-} refers to the standard input.  Specifying
1699 no files also means to read the standard input.  Any specified options
1700 are included in the printed command.  No space is allowed between
1701 options and their arguments.  The only options recognized are
1702 @option{-C} (which is also passed on) to enable compatibility mode, and
1703 @option{-v} (if it is the only parameter) to print the version number.
1705 For example,
1707 @Example
1708 grog -Tdvi paper.ms
1709 @endExample
1711 @noindent
1712 guesses the appropriate command to print @file{paper.ms} and then prints
1713 it to the command line after adding the @option{-Tdvi} option.  For
1714 direct execution, enclose the call to @code{grog} in backquotes at the
1715 @acronym{UNIX} shell prompt:
1717 @Example
1718 `grog -Tdvi paper.ms` > paper.dvi
1719 @endExample
1721 @noindent
1722 As seen in the example, it is still necessary to redirect the output to
1723 something meaningful (i.e.@: either a file or a pager program like
1724 @code{less}).
1728 @c =====================================================================
1729 @c =====================================================================
1731 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1732 @chapter Tutorial for Macro Users
1733 @cindex tutorial for macro users
1734 @cindex macros, tutorial for users
1735 @cindex user's tutorial for macros
1736 @cindex user's macro tutorial
1738 Most users tend to use a macro package to format their papers.  This
1739 means that the whole breadth of @code{groff} is not necessary for most
1740 people.  This chapter covers the material needed to efficiently use a
1741 macro package.
1743 @menu
1744 * Basics::
1745 * Common Features::
1746 @end menu
1749 @c =====================================================================
1751 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1752 @section Basics
1753 @cindex basics of macros
1754 @cindex macro basics
1756 This section covers some of the basic concepts necessary to understand
1757 how to use a macro package.@footnote{This section is derived from
1758 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1759 References are made throughout to more detailed information, if desired.
1761 @code{gtroff} reads an input file prepared by the user and outputs a
1762 formatted document suitable for publication or framing.  The input
1763 consists of text, or words to be printed, and embedded commands
1764 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1765 format the output.  For more detail on this, see @ref{Embedded
1766 Commands}.
1768 The word @dfn{argument} is used in this chapter to mean a word or number
1769 which appears on the same line as a request, and which modifies the
1770 meaning of that request.  For example, the request
1772 @Example
1774 @endExample
1776 @noindent
1777 spaces one line, but
1779 @Example
1780 .sp 4
1781 @endExample
1783 @noindent
1784 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1785 request which says to space four lines instead of one.  Arguments are
1786 separated from the request and from each other by spaces (@emph{no}
1787 tabs).  More details on this can be found in @ref{Request Arguments}.
1789 The primary function of @code{gtroff} is to collect words from input
1790 lines, fill output lines with those words, justify the right-hand margin
1791 by inserting extra spaces in the line, and output the result.  For
1792 example, the input:
1794 @Example
1795 Now is the time
1796 for all good men
1797 to come to the aid
1798 of their party.
1799 Four score and seven
1800 years ago,...
1801 @endExample
1803 @noindent
1804 is read, packed onto output lines, and justified to produce:
1806 @quotation
1807 Now is the time for all good men to come to the aid of their party.
1808 Four score and seven years ago,@dots{}
1809 @end quotation
1811 @cindex break
1812 @cindex line break
1813 Sometimes a new output line should be started even though the current
1814 line is not yet full; for example, at the end of a paragraph.  To do
1815 this it is possible to cause a @dfn{break}, which starts a new output
1816 line.  Some requests cause a break automatically, as normally do blank
1817 input lines and input lines beginning with a space.
1819 Not all input lines are text to be formatted.  Some input lines are
1820 requests which describe how to format the text.  Requests always have a
1821 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1822 the input line.
1824 The text formatter also does more complex things, such as automatically
1825 numbering pages, skipping over page boundaries, putting footnotes in the
1826 correct place, and so forth.
1828 Here are a few hints for preparing text for input to @code{gtroff}.
1830 @itemize @bullet
1831 @item
1832 First, keep the input lines short.  Short input lines are easier to
1833 edit, and @code{gtroff} packs words onto longer lines anyhow.
1835 @item
1836 In keeping with this, it is helpful to begin a new line after every
1837 comma or phrase, since common corrections are to add or delete sentences
1838 or phrases.
1840 @item
1841 End each sentence with two spaces -- or better, start each sentence on a
1842 new line.  @code{gtroff} recognizes characters that usually end a
1843 sentence, and inserts sentence space accordingly.
1845 @item
1846 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1847 enough to hyphenate words as needed, but is not smart enough to take
1848 hyphens out and join a word back together.  Also, words such as
1849 ``mother-in-law'' should not be broken over a line, since then a space
1850 can occur where not wanted, such as ``@w{mother- in}-law''.
1851 @end itemize
1853 @cindex double spacing (@code{ls})
1854 @cindex spacing
1855 @code{gtroff} double spaces output text automatically if you use the
1856 request @w{@samp{.ls 2}}.  Reactivate single spaced mode by typing
1857 @w{@samp{.ls 1}}.
1859 A number of requests allow to change the way the output looks,
1860 sometimes called the @dfn{layout} of the output page.  Most of these
1861 requests adjust the placing of @dfn{white space} (blank lines or
1862 spaces).
1864 @cindex new page (@code{bp})
1865 The @samp{.bp} request starts a new page, causing a line break.
1867 @cindex blank line (@code{sp})
1868 @cindex empty line (@code{sp})
1869 @cindex line, empty (@code{sp})
1870 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1871 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1872 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1873 @var{N}@w{ }centimeters).  For example, the input:
1875 @Example
1876 .sp 1.5i
1877 My thoughts on the subject
1879 @endExample
1881 @noindent
1882 leaves one and a half inches of space, followed by the line ``My
1883 thoughts on the subject'', followed by a single blank line (more
1884 measurement units are available, see @ref{Measurements}).
1886 @cindex centering lines (@code{ce})
1887 @cindex lines, centering (@code{ce})
1888 Text lines can be centered by using the @code{ce} request.  The line
1889 after @code{ce} is centered (horizontally) on the page.  To center more
1890 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1891 of lines to center), followed by the @var{N}@w{ }lines.  To center many
1892 lines without counting them, type:
1894 @Example
1895 .ce 1000
1896 lines to center
1897 .ce 0
1898 @endExample
1900 @noindent
1901 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1902 lines, in other words, stop centering.
1904 @cindex line break (@code{br})
1905 @cindex break (@code{br})
1906 All of these requests cause a break; that is, they always start a new
1907 line.  To start a new line without performing any other action, use
1908 @code{br}.
1911 @c =====================================================================
1913 @node Common Features,  , Basics, Tutorial for Macro Users
1914 @section Common Features
1915 @cindex common features
1916 @cindex features, common
1918 @code{gtroff} provides very low-level operations for formatting a
1919 document.  There are many common routine operations which are done in
1920 all documents.  These common operations are written into @dfn{macros}
1921 and collected into a @dfn{macro package}.
1923 All macro packages provide certain common capabilities which fall into
1924 the following categories.
1926 @menu
1927 * Paragraphs::
1928 * Sections and Chapters::
1929 * Headers and Footers::
1930 * Page Layout Adjustment::
1931 * Displays::
1932 * Footnotes and Annotations::
1933 * Table of Contents::
1934 * Indices::
1935 * Paper Formats::
1936 * Multiple Columns::
1937 * Font and Size Changes::
1938 * Predefined Strings::
1939 * Preprocessor Support::
1940 * Configuration and Customization::
1941 @end menu
1943 @c ---------------------------------------------------------------------
1945 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1946 @subsection Paragraphs
1947 @cindex paragraphs
1949 One of the most common and most used capability is starting a
1950 paragraph.  There are a number of different types of paragraphs, any
1951 of which can be initiated with macros supplied by the macro package.
1952 Normally, paragraphs start with a blank line and the first line
1953 indented, like the text in this manual.  There are also block style
1954 paragraphs, which omit the indentation:
1956 @Example
1957 Some   men  look   at  constitutions   with  sanctimonious
1958 reverence, and deem them like the ark of the covenant, too
1959 sacred to be touched.
1960 @endExample
1962 @noindent
1963 And there are also indented paragraphs which begin with a tag or label
1964 at the margin and the remaining text indented.
1966 @example
1967 @group
1968 one   This is  the first paragraph.  Notice  how the first
1969       line of  the resulting  paragraph lines up  with the
1970       other lines in the paragraph.
1971 @end group
1972 @group
1973 longlabel
1974       This  paragraph   had  a  long   label.   The  first
1975       character of text on the first line does not line up
1976       with  the  text  on  second  and  subsequent  lines,
1977       although they line up with each other.
1978 @end group
1979 @end example
1981 A variation of this is a bulleted list.
1983 @c XXX description
1985 @c ---------------------------------------------------------------------
1987 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1988 @subsection Sections and Chapters
1990 Most macro packages supply some form of section headers.  The simplest
1991 kind is simply the heading on a line by itself in bold type.  Others
1992 supply automatically numbered section heading or different heading
1993 styles at different levels.  Some, more sophisticated, macro packages
1994 supply macros for starting chapters and appendices.
1996 @c ---------------------------------------------------------------------
1998 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
1999 @subsection Headers and Footers
2001 Every macro package gives some way to manipulate the headers and footers
2002 (or @dfn{titles}) on each page.  Some packages allow for different ones
2003 on the even and odd pages (for material printed in a book form).
2005 The titles are called three-part titles, that is, there is a
2006 left-justified part, a centered part, and a right-justified part.  An
2007 automatically generated page number may be put in any of these fields
2008 with the @samp{%} character (see @ref{Page Layout}, for more details).
2010 @c ---------------------------------------------------------------------
2012 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
2013 @subsection Page Layout
2015 Most macro packages let the user specify top and bottom margins and
2016 other details about the appearance of the printed pages.
2018 @c ---------------------------------------------------------------------
2020 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2021 @subsection Displays
2022 @cindex displays
2024 Displays are sections of text to be set off from the body of the paper.
2025 Major quotes, tables, and figures are types of displays, as are all the
2026 examples used in this document.
2028 @cindex quotes, major
2029 @cindex major quotes
2030 @dfn{Major quotes} are quotes which are several lines long, and hence
2031 are set in from the rest of the text without quote marks around them.
2033 @cindex list
2034 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
2035 should be used when the material to be printed should not be filled and
2036 justified like normal text, such as columns of figures or the examples
2037 used in this paper.
2039 @cindex keep
2040 A @dfn{keep} is a display of lines which are kept on a single page if
2041 possible.  An example for a keep might be a diagram.  Keeps differ from
2042 lists in that lists may be broken over a page boundary whereas keeps are
2043 not.
2045 @cindex keep, floating
2046 @cindex floating keep
2047 Floating keeps move relative to the text.  Hence, they are good for
2048 things which are referred to by name, such as ``See figure@w{ }3''.  A
2049 floating keep appears at the bottom of the current page if it fits;
2050 otherwise, it appears at the top of the next page.  Meanwhile, the
2051 surrounding text `flows' around the keep, thus leaving no blank areas.
2053 @c ---------------------------------------------------------------------
2055 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2056 @subsection Footnotes and Annotations
2057 @cindex footnotes
2058 @cindex annotations
2060 There are a number of requests to save text for later printing.
2062 @dfn{Footnotes} are printed at the bottom of the current page.
2064 @cindex delayed text
2065 @dfn{Delayed text} is very similar to a footnote except that it is
2066 printed when called for explicitly.  This allows a list of references to
2067 appear (for example) at the end of each chapter, as is the convention in
2068 some disciplines.
2070 Most macro packages which supply this functionality also supply a means
2071 of automatically numbering either type of annotation.
2073 @c ---------------------------------------------------------------------
2075 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2076 @subsection Table of Contents
2077 @cindex table of contents
2078 @cindex contents, table of
2080 @dfn{Tables of contents} are a type of delayed text having a tag
2081 (usually the page number) attached to each entry after a row of dots.
2082 The table accumulates throughout the paper until printed, usually after
2083 the paper has ended.  Many macro packages provide the ability to have
2084 several tables of contents (e.g.@: a standard table of contents, a list
2085 of tables, etc).
2087 @c ---------------------------------------------------------------------
2089 @node Indices, Paper Formats, Table of Contents, Common Features
2090 @subsection Indices
2091 @cindex index, in macro package
2093 While some macro packages use the term @dfn{index}, none actually
2094 provide that functionality.  The facilities they call indices are
2095 actually more appropriate for tables of contents.
2097 @c ---------------------------------------------------------------------
2099 @node Paper Formats, Multiple Columns, Indices, Common Features
2100 @subsection Paper Formats
2101 @cindex paper formats
2103 Some macro packages provide stock formats for various kinds of
2104 documents.  Many of them provide a common format for the title and
2105 opening pages of a technical paper.  The @file{mm} macros in particular
2106 provide formats for letters and memoranda.
2108 @c ---------------------------------------------------------------------
2110 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2111 @subsection Multiple Columns
2113 Some macro packages (but not @file{man}) provide the ability to have two
2114 or more columns on a page.
2116 @c ---------------------------------------------------------------------
2118 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2119 @subsection Font and Size Changes
2121 The built-in font and size functions are not always intuitive, so all
2122 macro packages provide macros to make these operations simpler.
2124 @c ---------------------------------------------------------------------
2126 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2127 @subsection Predefined Strings
2129 Most macro packages provide various predefined strings for a variety of
2130 uses; examples are sub- and superscripts, printable dates, quotes and
2131 various special characters.
2133 @c ---------------------------------------------------------------------
2135 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2136 @subsection Preprocessor Support
2138 All macro packages provide support for the various preprocessors and may
2139 extend their functionality.
2141 For example, all macro packages mark tables (which are processed with
2142 @code{gtbl}) by placing them between @code{.TS} and @code{.TE} macros.
2143 The @file{ms} macro package has an option, @code{.TS@w{}H}, that prints
2144 a caption at the top of a new page (when the table is too long to fit on
2145 a single page).
2147 @c ---------------------------------------------------------------------
2149 @node Configuration and Customization,  , Preprocessor Support, Common Features
2150 @subsection Configuration and Customization
2152 Some macro packages provide means of customizing many of the details of
2153 how the package behaves.  This ranges from setting the default type size
2154 to changing the appearance of section headers.
2158 @c =====================================================================
2159 @c =====================================================================
2161 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2162 @chapter Macro Packages
2163 @cindex macro packages
2164 @cindex packages, macros
2166 This chapter documents the main macro packages that come with
2167 @code{groff}.
2169 @menu
2170 * man::
2171 * mdoc::
2172 * ms::
2173 * me::
2174 * mm::
2175 @end menu
2178 @c =====================================================================
2180 @node man, mdoc, Macro Packages, Macro Packages
2181 @section @file{man}
2182 @cindex manual pages
2183 @pindex an.tmac
2184 @pindex man.tmac
2185 @pindex man-old.tmac
2187 This is the most popular and probably the most important macro package
2188 of @code{groff}.  It is easy to use, and a vast majority of manual pages
2189 are based on it.
2191 @menu
2192 * Man options::
2193 * Man usage::
2194 * Man font macros::
2195 * Miscellaneous man macros::
2196 * Predefined man strings::
2197 * Preprocessors in man pages::
2198 @end menu
2200 @c ---------------------------------------------------------------------
2202 @node Man options, Man usage, man, man
2203 @subsection Options
2205 The command line format for using the @file{man} macros with
2206 @code{groff} is:
2208 @Example
2209 groff -m man [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
2210       [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
2211 @endExample
2213 @noindent
2214 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2216 @table @code
2217 @item -rcR=1
2218 This option (the default if a tty output device is used) creates a
2219 single, very long page instead of multiple pages.  Use @code{-rcR=0}
2220 to disable it.
2222 @item -rC1
2223 If more than one manual page is given on the command line, number the
2224 pages continuously, rather than starting each at@w{ }1.
2226 @item -rD1
2227 Double-sided printing.  Footers for even and odd pages are formatted
2228 differently.
2230 @item -rP@var{nnn}
2231 Page numbering starts with @var{nnn} rather than with@w{ }1.
2233 @item -rS@var{xx}
2234 Use @var{xx} (which can be 10, 11, or@w{ }12@dmn{pt}) as the base
2235 document font size instead of the default value of@w{ }10@dmn{pt}.
2237 @item -rX@var{nnn}
2238 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2239 @var{nnn}c, etc.  For example, the option @option{-rX2} produces the
2240 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2241 @end table
2243 @c ---------------------------------------------------------------------
2245 @node Man usage, Man font macros, Man options, man
2246 @subsection Usage
2247 @cindex @code{man} macros
2248 @cindex macros for manual pages [@code{man}]
2250 @pindex man.local
2251 This section describes the available macros for manual pages.  For
2252 further customization, put additional macros and requests into the file
2253 @file{man.local} which is loaded immediately after the @file{man}
2254 package.
2256 @Defmac {TH, title section [@Var{extra1}] [@Var{extra2}] [@Var{extra3}], man}
2257 Set the title of the man page to @var{title} and the section to
2258 @var{section}, which must have a value between 1 and@w{ }8.  The value
2259 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
2260 to indicate a specific subsection of the man pages.
2262 Both @var{title} and @var{section} are positioned at the left and right
2263 in the header line (with @var{section} in parentheses immediately
2264 appended to @var{title}.  @var{extra1} is positioned in the middle of
2265 the footer line.  @var{extra2} is positioned at the left in the footer
2266 line (or at the left on even pages and at the right on odd pages if
2267 double-sided printing is active).  @var{extra3} is centered in the
2268 header line.
2270 For @acronym{HTML} output, headers and footers are completely suppressed.
2272 Additionally, this macro starts a new page; the new line number is@w{ }1
2273 again (except if the @option{-rC1} option is given on the command line)
2274 -- this feature is intended only for formatting multiple man pages; a
2275 single man page should contain exactly one @code{TH} macro at the
2276 beginning of the file.
2277 @endDefmac
2279 @Defmac {SH, [@Var{heading}], man}
2280 Set up an unnumbered section heading sticking out to the left.  Prints
2281 out all the text following @code{SH} up to the end of the line (or the
2282 text in the next line if there is no argument to @code{SH}) in bold
2283 face, one size larger than the base document size.  Additionally, the
2284 left margin for the following text is reset to its default value.
2285 @endDefmac
2287 @Defmac {SS, [@Var{heading}], man}
2288 Set up an unnumbered (sub)section heading.  Prints out all the text
2289 following @code{SS} up to the end of the line (or the text in the next
2290 line if there is no argument to @code{SS}) in bold face, at the same
2291 size as the base document size.  Additionally, the left margin for the
2292 following text is reset to its default value.
2293 @endDefmac
2295 @Defmac {TP, [@Var{nnn}], man}
2296 Set up an indented paragraph with label.  The indentation is set to
2297 @var{nnn} if that argument is supplied (the default unit is @samp{n}
2298 if omitted), otherwise it is set to the default indentation value.
2300 The first line of text following this macro is interpreted as a string
2301 to be printed flush-left, as it is appropriate for a label.  It is not
2302 interpreted as part of a paragraph, so there is no attempt to fill the
2303 first line with text from the following input lines.  Nevertheless, if
2304 the label is not as wide as the indentation, then the paragraph starts
2305 at the same line (but indented), continuing on the following lines.
2306 If the label is wider than the indentation, then the descriptive part
2307 of the paragraph begins on the line following the label, entirely
2308 indented.  Note that neither font shape nor font size of the label is
2309 set to a default value; on the other hand, the rest of the text has
2310 default font settings.
2311 @endDefmac
2313 @DefmacList {LP, , man}
2314 @DefmacItem {PP, , man}
2315 @DefmacListEnd {P, , man}
2316 These macros are mutual aliases.  Any of them causes a line break at
2317 the current position, followed by a vertical space downwards by the
2318 amount specified by the @code{PD} macro.  The font size and shape are
2319 reset to the default value (10@dmn{pt} roman).  Finally, the current
2320 left margin is restored.
2321 @endDefmac
2323 @Defmac {IP, [@Var{designator}] [@Var{nnn}], man}
2324 Set up an indented paragraph, using @var{designator} as a tag to mark
2325 its beginning.  The indentation is set to @var{nnn} if that argument
2326 is supplied (default unit is @samp{n}), otherwise the default
2327 indentation value is used.  Font size and face of the paragraph (but
2328 not the designator) are reset to their default values.  To start an
2329 indented paragraph with a particular indentation but without a
2330 designator, use @samp{""} (two double quotes) as the first argument of
2331 @code{IP}.
2333 For example, to start a paragraph with bullets as the designator and
2334 4@dmn{en} indentation, write
2336 @Example
2337 .IP \(bu 4
2338 @endExample
2339 @endDefmac
2341 @cindex hanging indentation [@code{man}]
2342 @cindex @code{man} macros, hanging indentation
2343 @Defmac {HP, [@Var{nnn}], man}
2344 Set up a paragraph with hanging left indentation.  The indentation is
2345 set to @var{nnn} if that argument is supplied (default unit is
2346 @samp{n}), otherwise the default indentation value is used.  Font size
2347 and face are reset to their default values.
2348 @endDefmac
2350 @cindex left margin, how to move [@code{man}]
2351 @cindex @code{man} macros, moving left margin
2352 @Defmac {RS, [@Var{nnn}], man}
2353 Move the left margin to the right by the value @var{nnn} if specified
2354 (default unit is @samp{n}); otherwise the default indentation value
2355 is used.  Calls to the @code{RS} macro can be nested.
2356 @endDefmac
2358 @Defmac {RE, [@Var{nnn}], man}
2359 Move the left margin back to level @var{nnn}; if no argument is given,
2360 it moves one level back.  The first level (i.e., no call to @code{RS}
2361 yet) has number@w{ }1, and each call to @code{RS} increases the level
2362 by@w{ }1.
2363 @endDefmac
2365 @cindex line breaks, with vertical space [@code{man}]
2366 @cindex @code{man} macros, line breaks with vertical space
2367 To summarize, the following macros cause a line break with the insertion
2368 of vertical space (which amount can be changed with the @code{PD}
2369 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2370 @code{P}), @code{IP}, and @code{HP}.
2372 @cindex line breaks, without vertical space [@code{man}]
2373 @cindex @code{man} macros, line breaks without vertical space
2374 The macros @code{RS} and @code{RE} also cause a break but do not insert
2375 vertical space.
2377 @c ---------------------------------------------------------------------
2379 @node Man font macros, Miscellaneous man macros, Man usage, man
2380 @subsection Macros to set fonts
2381 @cindex font selection [@code{man}]
2382 @cindex @code{man} macros, how to set fonts
2384 The standard font is roman; the default text size is 10@w{ }point.
2386 @Defmac {SM, [@Var{text}], man}
2387 Set the text on the same line or the text on the next line in a font
2388 that is one point size smaller than the default font.
2389 @endDefmac
2391 @cindex boldface [@code{man}]
2392 @cindex @code{man} macros, boldface
2393 @Defmac {SB, [@Var{text}], man}
2394 Set the text on the same line or the text on the next line in boldface
2395 font, one point size smaller than the default font.
2396 @endDefmac
2398 @Defmac {BI, text, man}
2399 Set its arguments alternately in bold face and italic.  Thus,
2401 @Example
2402 .BI this "word and" that
2403 @endExample
2405 @noindent
2406 would set ``this'' and ``that'' in bold face, and ``word and'' in
2407 italics.
2408 @endDefmac
2410 @Defmac {IB, text, man}
2411 Set its arguments alternately in italic and bold face.
2412 @endDefmac
2414 @Defmac {RI, text, man}
2415 Set its arguments alternately in roman and italic.
2416 @endDefmac
2418 @Defmac {IR, text, man}
2419 Set its arguments alternately in italic and roman.
2420 @endDefmac
2422 @Defmac {BR, text, man}
2423 Set its arguments alternately in bold face and roman.
2424 @endDefmac
2426 @Defmac {RB, text, man}
2427 Set its arguments alternately in roman and bold face.
2428 @endDefmac
2430 @Defmac {B, [@Var{text}], man}
2431 Set @var{text} in bold face.  If no text is present on the line where
2432 the macro is called, then the text of the next line appears in bold
2433 face.
2434 @endDefmac
2436 @cindex italic fonts [@code{man}]
2437 @cindex @code{man} macros, italic fonts
2438 @Defmac {I, [@Var{text}], man}
2439 Set @var{text} in italic.  If no text is present on the line where the
2440 macro is called, then the text of the next line appears in italic.
2441 @endDefmac
2443 @c ---------------------------------------------------------------------
2445 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2446 @subsection Miscellaneous macros
2448 @pindex grohtml
2449 @cindex @code{man} macros, default indentation
2450 @cindex default indentation [@code{man}]
2451 The default indentation is 7.2@dmn{n} for all output devices except for
2452 @code{grohtml} which ignores indentation.
2454 @cindex tab stops [@code{man}]
2455 @cindex @code{man} macros, tab stops
2456 @Defmac {DT, , man}
2457 Set tabs every 0.5@w{ }inches.  Since this macro is always called
2458 during a @code{TH} request, it makes sense to call it only if the tab
2459 positions have been changed.
2460 @endDefmac
2462 @cindex empty space before a paragraph [@code{man}]
2463 @cindex @code{man} macros, empty space before a paragraph
2464 @Defmac {PD, [@Var{nnn}], man}
2465 Adjust the empty space before a new paragraph (or section).  The
2466 optional argument gives the amount of space (default unit is
2467 @samp{v}); without parameter, the value is reset to its default value
2468 (1@w{ }line for tty devices, 0.4@dmn{v}@w{ }otherwise).
2469 @endDefmac
2471 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2472 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2474 @c ---------------------------------------------------------------------
2476 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2477 @subsection Predefined strings
2479 The following strings are defined:
2481 @Defstr {S, man}
2482 Switch back to the default font size.
2483 @endDefstr
2485 @Defstr {R, man}
2486 The `registered' sign.
2487 @endDefstr
2489 @Defstr {Tm, man}
2490 The `trademark' sign.
2491 @endDefstr
2493 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2494 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2495 @DefstrList {lq, man}
2496 @DefstrListEnd {rq, man}
2497 Left and right quote.  This is equal to @code{\(lq} and @code{\(rq},
2498 respectively.
2499 @endDefstr
2501 @c ---------------------------------------------------------------------
2503 @node Preprocessors in man pages,  , Predefined man strings, man
2504 @subsection Preprocessors in @file{man} pages
2506 @cindex preprocessor, calling convention
2507 @cindex calling convention of preprocessors
2508 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2509 become common usage to make the first line of the man page look like
2510 this:
2512 @Example
2513 '\" @var{word}
2514 @endExample
2516 @pindex geqn@r{, invocation in manual pages}
2517 @pindex grefer@r{, invocation in manual pages}
2518 @pindex gtbl@r{, invocation in manual pages}
2519 @pindex man@r{, invocation of preprocessors}
2520 @noindent
2521 Note the single space character after the double quote.  @var{word}
2522 consists of letters for the needed preprocessors: @samp{e} for
2523 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2524 Modern implementations of the @code{man} program read this first line
2525 and automatically call the right preprocessor(s).
2528 @c =====================================================================
2530 @node mdoc, ms, man, Macro Packages
2531 @section @file{mdoc}
2532 @cindex @file{mdoc}
2534 @c XXX documentation
2535 @c XXX this is a placeholder until we get stuff knocked into shape
2536 See the @code{mdoc} manpage (type @command{man 7 groff_mdoc} at
2537 the command line).
2540 @c =====================================================================
2542 @node ms, me, mdoc, Macro Packages
2543 @section @file{ms}
2544 @cindex @file{ms}
2546 The @file{-ms}
2547 macros are suitable for reports, letters, books,
2548 user manuals, and so forth.
2549 The package provides macros for cover pages, section headings,
2550 paragraphs, lists, footnotes, pagination,
2551 and a table of contents.
2553 @menu
2554 * ms Intro::
2555 * General ms Structure::
2556 * ms Document Control Registers::
2557 * ms Cover Page Macros::
2558 * ms Body Text::
2559 * ms Page Layout::
2560 * Differences from AT&T ms::
2561 @end menu
2563 @c ---------------------------------------------------------------------
2565 @node ms Intro, General ms Structure, ms, ms
2566 @subsection Introduction to @file{ms}
2568 The original @file{-ms} macros were included with
2569 @acronym{AT&T} @code{troff} as well as the
2570 @file{man} macros.
2571 While the @file{man} package is intended for brief documents
2572 that can be read on-line as well as printed, the @file{ms}
2573 macros are suitable for longer documents that are meant to be
2574 printed rather than read on-line.
2576 The @file{ms} macro package included with @code{groff}
2577 is a complete, bottom-up re-implementation.
2578 Several macros (specific to @acronym{AT&T}
2579 or Berkeley) are not included, while several new commands are.
2580 @xref{Differences from AT&T ms}, for more information.
2582 @c ---------------------------------------------------------------------
2584 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2585 @subsection General structure of an @file{ms} document
2586 @cindex @file{ms}, general structure
2588 The @file{ms} macro package expects a certain amount of structure,
2589 but not as much as packages such as @file{man} or @file{mdoc}.
2591 The simplest documents can begin with a paragraph macro
2592 (such as @code{LP} or @code{PP}),
2593 and consist of text separated by paragraph macros
2594 or even blank lines.
2595 Longer documents have a structure as follows:
2597 @table @strong
2598 @item Document type
2599 If you invoke the @code{RP}
2600 (report) macro on the first line of the document,
2601 @code{groff} prints the cover page information on its own page;
2602 otherwise it prints the information on the
2603 first page with your document text immediately following.
2604 Other document formats found in @acronym{AT&T} @code{troff}
2605 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2606 @code{groff}.
2608 @item Format and layout
2609 By setting number registers,
2610 you can change your document's type (font and size),
2611 margins, spacing, headers and footers, and footnotes.
2612 @xref{ms Document Control Registers}, for more details.
2614 @item Cover page
2615 A cover page consists of a title, the author's name and institution,
2616 an abstract, and the date.
2617 @footnote{Actually, only the title is required.}
2618 @xref{ms Cover Page Macros}, for more details.
2620 @item Body
2621 Following the cover page is your document.
2622 You can use the @file{ms}
2623 macros to write reports, letters, books, and so forth.
2624 The package is designed for structured documents,
2625 consisting of paragraphs interspersed with headings
2626 and augmented by lists, footnotes, tables, and other
2627 common constructs.
2628 @xref{ms Body Text}, for more details.
2630 @item Table of contents
2631 Longer documents usually include a table of contents,
2632 which you can invoke by placing the
2633 @code{TC}
2634 macro at the end of your document.
2635 The @file{ms}
2636 macros have minimal indexing facilities, consisting of the
2637 @code{IX} macro, which prints an entry on standard error.
2638 Printing the table of contents at the end is necessary since
2639 @code{groff} is a single-pass text formatter,
2640 thus it cannot determine the page number of each section
2641 until that section has actually been set and printed.
2642 Since @file{ms} output is intended for hardcopy,
2643 you can manually relocate the pages containing
2644 the table of contents between the cover page and the
2645 body text after printing.
2646 @end table
2648 @c ---------------------------------------------------------------------
2650 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2651 @subsection Document control registers
2652 @cindex @file{ms}, document control registers
2654 The following is a list of document control number registers.
2655 For the sake of consistency,
2656 set registers related to margins at the beginning of your document,
2657 or just after the @code{RP} macro.
2658 You can set other registers later in your document,
2659 but you should keep them together at the beginning
2660 to make them easy to find and edit as necessary.
2662 @unnumberedsubsubsec Margin Settings
2664 @Defmpreg {PO, ms}
2665 Defines the page offset (i.e.@: the left margin).
2666 There is no explicit right margin setting; the combination of
2667 the @code{PO} and @code{LL} registers implicitly define the
2668 right margin width.
2670 Effective: next page.
2672 Default value: 1@dmn{i}.
2673 @endDefmpreg
2675 @Defmpreg {LL, ms}
2676 Defines the line length (i.e.@: the width of the body text).
2678 Effective: next paragraph.
2680 Default: 6@dmn{i}.
2681 @endDefmpreg
2683 @Defmpreg {LT, ms}
2684 Defines the title length (i.e.@: the header and footer width).
2685 This is usually the same as @code{LL}, but not necessarily.
2687 Effective: next paragraph.
2689 Default: 6@dmn{i}.
2690 @endDefmpreg
2692 @Defmpreg {HM, ms}
2693 Defines the header margin height at the top of the page.
2695 Effective: next page.
2697 Default: 1@dmn{i}.
2698 @endDefmpreg
2700 @Defmpreg {FM, ms}
2701 Defines the footer margin height at the bottom of the page.
2703 Effective: next page.
2705 Default: 1@dmn{i}.
2706 @endDefmpreg
2708 @unnumberedsubsubsec Text Settings
2710 @Defmpreg {PS, ms}
2711 Defines the point size of the body text.
2713 Effective: next paragraph.
2715 Default: 10@dmn{p}.
2716 @endDefmpreg
2718 @Defmpreg {VS, ms}
2719 Defines the space between lines (line height plus leading).
2721 Effective: next paragraph.
2723 Default: 12@dmn{p}.
2724 @endDefmpreg
2726 @unnumberedsubsubsec Paragraph Settings
2728 @Defmpreg {PI, ms}
2729 Defines the initial indent of a @code{.PP} paragraph.
2731 Effective: next paragraph.
2733 Default: 5@dmn{n}.
2734 @endDefmpreg
2736 @Defmpreg {PD, ms}
2737 Defines the space between paragraphs.
2739 Effective: next paragraph.
2741 Default: 0.3@dmn{v}.
2742 @endDefmpreg
2744 @Defmpreg {QI, ms}
2745 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2747 Effective: next paragraph.
2749 Default: 5@dmn{n}.
2750 @endDefmpreg
2752 @unnumberedsubsubsec Footnote Settings
2754 @Defmpreg {FL, ms}
2755 Defines the length of a footnote.
2757 Effective: next footnote.
2759 Default: @math{@code{@\n[LL]} * 5 / 6}.
2760 @endDefmpreg
2762 @Defmpreg {FI, ms}
2763 Defines the footnote indent.
2765 Effective: next footnote.
2767 Default: 2@dmn{n}.
2768 @endDefmpreg
2770 @Defmpreg {FF, ms}
2771 The footnote format:
2772 @table @code
2773 @item 0
2774 Prints the footnote number as a superscript; indents the footnote (default).
2776 @item 1
2777 Prints the number followed by a period (like 1.)
2778 and indents the footnote.
2780 @item 2
2781 Like 1, without an indent.
2783 @item 3
2784 Like 1, but prints the footnote number as a hanging paragraph.
2785 @end table
2787 Effective: next footnote.
2789 Default: 0.
2790 @endDefmpreg
2792 @unnumberedsubsubsec Miscellaneous Number Registers
2794 @Defmpreg {MINGW, ms}
2795 Defines the minimum width between columns in a multi-column document.
2797 Effective: next page.
2799 Default: 2@dmn{n}.
2800 @endDefmpreg
2802 @c ---------------------------------------------------------------------
2804 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2805 @subsection Cover page macros
2806 @cindex @file{ms}, cover page macros
2807 @cindex Cover page macros, @file{ms}
2809 Use the following macros to create a cover page for your document
2810 in the order shown.
2812 @Defmac {RP, [@code{no}], ms}
2813 Specifies the report format for your document.
2814 The report format creates a separate cover page.
2815 The default action (no @code{.RP}
2816 macro) is to print a subset of the
2817 cover page on page 1 of your document.
2819 If you use the word @code{no} as an optional argument,
2820 @code{groff} prints a title page but
2821 does not repeat any of the title page information
2822 (title, author, abstract, etc.)
2823 on page 1 of the document.
2824 @endDefmac
2826 @Defmac {DA, [@dots{}], ms}
2827 (optional) Print the current date, or the arguments to the macro if any,
2828 on the title page (if specified) and in the footers.
2829 This is the default for @code{nroff}.
2830 @endDefmac
2832 @Defmac {ND, [@dots{}], ms}
2833 (optional) Print the current date, or the arguments to the macro if any,
2834 on the title page (if specified) but not in the footers.
2835 This is the default for @code{troff}.
2836 @endDefmac
2838 @Defmac {TL, , ms}
2839 Specifies the document title.
2840 @code{groff} collects text following the @code{.TL}
2841 macro into the title, until reaching the author name or abstract.
2842 @endDefmac
2844 @Defmac {AU, , ms}
2845 Specifies the author's name, which appears on the
2846 line (or lines) immediately following.
2847 You can specify multiple authors as follows:
2849 @Example
2851 John Doe
2853 University of West Bumblefuzz
2855 Martha Buck
2857 Monolithic Corporation
2860 @endExample
2861 @endDefmac
2863 @Defmac {AI, , ms}
2864 Specifies the author's institution.
2865 You can specify multiple institutions in the same way
2866 that you specify multiple authors.
2867 @endDefmac
2869 @Defmac {AB, [@code{no}], ms}
2870 Begins the abstract.
2871 The default is to print the word @acronym{ABSTRACT},
2872 centered and in italics, above the text of the abstract.
2873 The word @code{no} as an optional argument suppresses this heading.
2874 @endDefmac
2876 @Defmac {AE, , ms}
2877 End the abstract.
2878 @endDefmac
2880 The following is example mark-up for a title page.
2881 @cindex Title page, example markup
2882 @cindex Example markup, title page
2884 @Example
2885 @cartouche
2888 The Inevitability of Code Bloat
2889 in Commercial and Free Software
2891 J. Random Luser
2893 University of West Bumblefuzz
2895 This report examines the long-term growth
2896 of the code bases in two large, popular software
2897 packages; the free Emacs and the commercial
2898 Microsoft Word.
2899 While differences appear in the type or order
2900 of features added, due to the different
2901 methodologies used, the results are the same
2902 in the end.
2904 The free software approach is shown to be
2905 superior in that while free software can
2906 become as bloated as commercial offerings,
2907 free software tends to have fewer serious
2908 bugs and the added features are in line with
2909 user demand.
2912 ... the rest of the paper follows ...
2913 @end cartouche
2914 @endExample
2916 @c ---------------------------------------------------------------------
2918 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2919 @subsection Body text
2920 @cindex @file{ms}, body text
2922 This section describes macros used to mark up the body of your document.
2923 Examples include paragraphs, sections, and other groups.
2925 @menu
2926 * Paragraphs in ms::
2927 * Headings in ms::
2928 * Highlighting in ms::
2929 * Lists in ms::
2930 * Indents in ms::
2931 * Tabstops in ms::
2932 * ms Displays and Keeps::
2933 * ms Insertions::
2934 * Example multi-page table::
2935 * ms Footnotes::
2936 @end menu
2938 @c ---------------------------------------------------------------------
2940 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2941 @subsubsection Paragraphs
2942 @cindex @file{ms}, paragraph macros
2944 The following paragraph types are available.
2946 @Defmac {PP, , ms}
2947 Sets a paragraph with an initial indent.
2948 @endDefmac
2950 @Defmac {LP, , ms}
2951 Sets a paragraph with no initial indent.
2952 @endDefmac
2954 @Defmac {QP, , ms}
2955 Sets a paragraph that is indented at both left and right margins.
2956 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2957 The next paragraph or heading returns margins to normal.
2958 @endDefmac
2960 @Defmac {XP, , ms}
2961 Sets a paragraph whose lines are indented,
2962 except for the first line.
2963 This is a Berkeley extension.
2964 @endDefmac
2966 The following markup uses all four paragraph macros.
2968 @Example
2969 @cartouche
2970 .NH 2
2971 Cases used in the study
2973 The following software and versions were
2974 considered for this report.
2976 For commercial software, we chose
2977 .B "Microsoft Word for Windows" ,
2978 starting with version 1.0 through the
2979 current version (Word 2000).
2981 For free software, we chose
2982 .B Emacs ,
2983 from its first appearance as a standalone
2984 editor through the current version (v20).
2985 See [Bloggs 2002] for details.
2987 Franklin's Law applied to software:
2988 software expands to outgrow both
2989 RAM and disk space over time.
2991 Bibliography:
2993 Bloggs, Joseph R.,
2994 .I "Everyone's a Critic" ,
2995 Underground Press, March 2002.
2996 A definitive work that answers all questions
2997 and criticisms about the quality and usability of
2998 free software.
3000 @end cartouche
3001 @endExample
3003 @c ---------------------------------------------------------------------
3005 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3006 @subsubsection Headings
3007 @cindex @file{ms}, heading macros
3009 Use headings to create a hierarchical structure for your document.
3010 The @file{ms} macros print headings in @strong{bold},
3011 using the same font family and point size as the body text.
3013 The following describes the heading macros:
3015 @DefmacList {NH, @Var{curr-level}, ms}
3016 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3017 Numbered heading.
3018 The argument is either a numeric argument to indicate the
3019 level of the heading, or the letter@w{ }@code{S} followed by numeric
3020 arguments to set the heading level explicitly.
3022 If you specify heading levels out of sequence, such as invoking
3023 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
3024 prints a warning on standard error.
3025 @endDefmac
3027 @Defmac {SH, , ms}
3028 Unnumbered subheading.
3029 @endDefmac
3031 @c ---------------------------------------------------------------------
3033 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3034 @subsubsection Highlighting
3035 @cindex @file{ms}, highlighting macros
3037 The @file{ms} macros provide a variety of methods to highlight
3038 or emphasize text:
3040 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3041 Sets its first argument in @strong{bold type}.
3042 If you specify a second argument, @code{groff} prints it in the
3043 previous font after the bold text, with no intervening space
3044 (this allows you to set punctuation after the highlighted text
3045 without highlighting the punctuation).
3046 Similarly, it prints the third argument (if any) in the previous
3047 font @strong{before} the first argument.
3048 For example,
3050 @Example
3051 .B foo ) (
3052 @endExample
3054 prints (@strong{foo}).
3056 If you give this macro no arguments, @code{groff}
3057 prints all text following in bold until
3058 the next highlighting, paragraph, or heading macro.
3059 @endDefmac
3061 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3062 Sets its first argument in roman (or regular) type.
3063 It operates similarly to the @code{B}@w{ }macro otherwise.
3064 @endDefmac
3066 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3067 Sets its first argument in @emph{italic type}.
3068 It operates similarly to the @code{B}@w{ }macro otherwise.
3069 @endDefmac
3071 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3072 Sets its first argument in a @code{constant width face}.
3073 It operates similarly to the @code{B}@w{ }macro otherwise.
3074 @endDefmac
3076 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3077 Sets its first argument in bold italic type.
3078 It operates similarly to the @code{B}@w{ }macro otherwise.
3079 @endDefmac
3081 @Defmac {BX, [@Var{txt}], ms}
3082 Prints its argument and draws a box around it.
3083 If you want to box a string that contains spaces,
3084 use a digit-width space (@code{\0}).
3085 @endDefmac
3087 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3088 Prints its first argument with an underline.
3089 If you specify a second argument, @code{groff}
3090 prints it in the previous font after
3091 the underlined text, with no intervening space.
3092 @endDefmac
3094 @Defmac {LG, , ms}
3095 Prints all text following in larger type
3096 (two points larger than the current point size) until
3097 the next font size, highlighting, paragraph, or heading macro.
3098 You can specify this macro multiple times
3099 to enlarge the point size as needed.
3100 @endDefmac
3102 @Defmac {SM, , ms}
3103 Prints all text following in smaller type
3104 (two points smaller than the current point size) until
3105 the next type size, highlighting, paragraph, or heading macro.
3106 You can specify this macro multiple times
3107 to reduce the point size as needed.
3108 @endDefmac
3110 @Defmac {NL, , ms}
3111 Prints all text following in the normal point size
3112 (that is, the value of the @code{PS} register).
3113 @endDefmac
3115 @c ---------------------------------------------------------------------
3117 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
3118 @subsubsection Lists
3119 @cindex @file{ms}, list macros
3121 The @code{.IP} macro handles duties for all lists.
3123 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3124 The @var{marker} is usually a bullet character (@code{\[bu]})
3125 for unordered lists, a number (or auto-incrementing number
3126 register) for numbered lists, or a word or phrase for indented
3127 (glossary-style) lists.
3129 The @var{width} specifies the indent for the body of each list item;
3130 its default unit is @samp{n}.
3131 Once specified, the indent remains the same for all
3132 list items in the document until specified again.
3133 @endDefmac
3135 The following is an example of a bulleted list.
3136 @cindex Example markup, bulleted list (ms)
3137 @cindex Bulleted list, example markup (ms)
3139 @Example
3140 A bulleted list:
3141 .IP \[bu] 2
3142 lawyers
3143 .IP \[bu]
3144 guns
3145 .IP \[bu]
3146 money
3147 @endExample
3149 Produces:
3151 @Example
3152 A bulleted list:
3154 o lawyers
3156 o guns
3158 o money
3159 @endExample
3161 @sp 1
3163 The following is an example of a numbered list.
3164 @cindex Example markup, numbered list (ms)
3165 @cindex Numbered list, example markup (ms)
3167 @Example
3168 .nr step 1 1
3169 A numbered list:
3170 .IP \n[step] 3
3171 lawyers
3172 .IP \n+[step]
3173 guns
3174 .IP \n+[step]
3175 money
3176 @endExample
3178 Produces:
3180 @Example
3181 A numbered list:
3183 1. lawyers
3185 2. guns
3187 3. money
3188 @endExample
3190 Note the use of the auto-incrementing number
3191 register in this example.
3193 @sp 1
3194 The following is an example of a glossary-style list.
3195 @cindex Example markup, glossary-style list (ms)
3196 @cindex Glossary-style list, example markup (ms)
3198 @Example
3199 A glossary-style list:
3200 .IP lawyers 0.4i
3201 Two or more attorneys.
3202 .IP guns
3203 Firearms, preferably
3204 large-caliber.
3205 .IP money
3206 Gotta pay for those
3207 lawyers and guns!
3208 @endExample
3210 Produces:
3212 @Example
3213 A glossary-style list:
3215 lawyers
3216       Two or more attorneys.
3218 guns  Firearms, preferably large-caliber.
3220 money
3221       Gotta pay for those lawyers and guns!
3222 @endExample
3224 In the last example, the @code{IP} macro places the definition
3225 on the same line as the term if it has enough space; otherwise,
3226 it breaks to the next line and starts the definition below the
3227 term.
3228 This may or may not be the effect you want, especially if some
3229 of the definitions break and some do not.
3230 The following examples show two possible ways to force a break.
3232 The first workaround uses the @code{.br}
3233 request to force a break after printing the term or label.
3235 @Example
3236 @cartouche
3237 A glossary-style list:
3238 .IP lawyers 0.4i
3239 Two or more attorneys.
3240 .IP guns
3242 Firearms, preferably large-caliber.
3243 .IP money
3244 Gotta pay for those lawyers and guns!
3245 @end cartouche
3246 @endExample
3248 @sp 1
3249 The second workaround uses the @code{\p} escape to force the break.
3250 Note the space following the escape; this is important.
3251 If you omit the space, @code{groff} prints the first word on
3252 the same line as the term or label (if it fits) @strong{then}
3253 breaks the line.
3255 @Example
3256 @cartouche
3257 A glossary-style list:
3258 .IP lawyers 0.4i
3259 Two or more attorneys.
3260 .IP guns
3261 \p Firearms, preferably large-caliber.
3262 .IP money
3263 Gotta pay for those lawyers and guns!
3264 @end cartouche
3265 @endExample
3267 @sp 1
3268 To set nested lists, use the @code{RS} and @code{RE} macros.
3269 @xref{Indents in ms}, for more information.
3270 @cindex @file{ms}, nested lists
3271 @cindex Nested lists (ms)
3273 For example:
3275 @Example
3276 @cartouche
3277 .IP \[bu] 2
3278 Lawyers:
3280 .IP \[bu]
3281 Dewey,
3282 .IP \[bu]
3283 Cheatham,
3284 .IP \[bu]
3285 and Howe.
3287 .IP \[bu]
3288 Guns
3289 @end cartouche
3290 @endExample
3292 Produces:
3294 @Example
3295 o Lawyers:
3297   o  Dewey,
3299   o  Cheatham,
3301   o  and Howe.
3303 o Guns
3304 @endExample
3306 @c ---------------------------------------------------------------------
3308 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3309 @subsubsection Indents
3311 In many situations,
3312 you may need to indent a section of text
3313 while still wrapping and filling.
3314 @xref{Lists in ms},
3315 for an example of nested lists.
3317 @DefmacList {RS, , ms}
3318 @DefmacListEnd {RE, , ms}
3319 These macros begin and end an indented section.
3320 The @code{PI} register controls the amount of indent,
3321 allowing the indented text to line up under hanging
3322 and indented paragraphs.
3323 @endDefmac
3325 @xref{ms Displays and Keeps},
3326 for macros to indent and turn off filling.
3328 @c ---------------------------------------------------------------------
3330 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3331 @subsubsection Tab Stops
3333 Use the @code{ta} request to define tab stops as needed.
3334 @xref{Tabs and Fields}.
3336 @Defmac{TA, , ms}
3337 Use this macro to reset the tab stops to the default for @file{ms}
3338 (every 5n).
3339 You can redefine the @code{TA} macro to create a different set
3340 of default tab stops.
3341 @endDefmac
3343 @c ---------------------------------------------------------------------
3345 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3346 @subsubsection Displays and keeps
3347 @cindex @file{ms}, displays
3348 @cindex @file{ms}, keeps
3349 @cindex Keeps (ms)
3350 @cindex Displays (ms)
3352 Use displays to show text-based examples or figures
3353 (such as code listings).
3355 Displays turn off filling, so lines of code are displayed
3356 as-is without inserting @code{br} requests in between each line.
3357 Displays can be @dfn{kept} on a single page, or allowed
3358 to break across pages.
3360 @DefmacList {DS, @t{L}, ms}
3361 @DefmacItem {LD, , ms}
3362 @DefmacListEnd {DE, , ms}
3363 Left-justified display.
3364 The @samp{.DS L} call generates a page break, if necessary,
3365 to keep the entire display on one page.
3366 The @code{LD} macro allows the display to break across pages.
3367 The @code{DE} macro ends the display.
3368 @endDefmac
3370 @DefmacList {DS, @t{I}, ms}
3371 @DefmacItem {ID, , ms}
3372 @DefmacListEnd {DE, , ms}
3373 Indents the display as defined by the @code{DI} register.
3374 The @samp{.DS I} call generates a page break, if necessary,
3375 to keep the entire display on one page.
3376 The @code{ID} macro allows the display to break across pages.
3377 The @code{DE} macro ends the display.
3378 @endDefmac
3380 @DefmacList {DS, @t{B}, ms}
3381 @DefmacItem {BD, , ms}
3382 @DefmacListEnd {DE, , ms}
3383 Sets a block-centered display: the entire display is left-justified,
3384 but indented so that the longest line in the display is centered
3385 on the page.
3386 The @samp{.DS B} call generates a page break, if necessary,
3387 to keep the entire display on one page.
3388 The @code{BD} macro allows the display to break across pages.
3389 The @code{DE} macro ends the display.
3390 @endDefmac
3392 @DefmacList {DS, @t{C}, ms}
3393 @DefmacItem {CD, , ms}
3394 @DefmacListEnd {DE, , ms}
3395 Sets a centered display: each line in the display is centered.
3396 The @samp{.DS C} call generates a page break, if necessary,
3397 to keep the entire display on one page.
3398 The @code{CD} macro allows the display to break across pages.
3399 The @code{DE} macro ends the display.
3400 @endDefmac
3402 @DefmacList {DS, @t{R}, ms}
3403 @DefmacItem {RD, , ms}
3404 @DefmacListEnd {DE, , ms}
3405 Right-justifies each line in the display.
3406 The @samp{.DS R} call generates a page break, if necessary,
3407 to keep the entire display on one page.
3408 The @code{RD} macro allows the display to break across pages.
3409 The @code{DE} macro ends the display.
3410 @endDefmac
3412 @sp 1
3413 On occasion, you may want to @dfn{keep} other text together on a page.
3414 For example, you may want to keep two paragraphs together, or
3415 a paragraph that refers to a table (or list, or other item)
3416 immediately following.
3417 The @file{ms} macros provide the @code{KS} and @code{KE}
3418 macros for this purpose.
3420 @DefmacList {KS, , ms}
3421 @DefmacListEnd {KE, , ms}
3422 The @code{KS} macro begins a block of text to be kept on a
3423 single page, and the @code{KE} macro ends the block.
3424 @endDefmac
3426 @DefmacList {KF, , ms}
3427 @DefmacListEnd {KE, , ms}
3428 Specifies a @dfn{floating keep};
3429 if the keep cannot fit on the current page, @code{groff}
3430 holds the contents of the keep and allows text following
3431 the keep (in the source file) to fill in the remainder of
3432 the current page.
3433 When the page breaks, whether by an explicit @code{bp}
3434 request or by reaching the end of the page, @code{groff}
3435 prints the floating keep at the top of the new page.
3436 This is useful for printing large graphics or tables
3437 that do not need to appear exactly where specified.
3438 @endDefmac
3440 You can also use the @code{ne} request to force a page break if
3441 there is not enough vertical space remaining on the page.
3443 @sp 1
3444 Use the following macros to draw a box around a section of
3445 text (such as a display).
3447 @DefmacList {B1, , ms}
3448 @DefmacListEnd {B2, , ms}
3449 Marks the beginning and ending of text that is to have a
3450 box drawn around it.
3451 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3452 Text in the box is automatically placed in a diversion (keep).
3453 @endDefmac
3455 @c ---------------------------------------------------------------------
3457 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3458 @subsubsection Tables, figures, equations, and references
3459 @cindex @file{ms}, tables
3460 @cindex @file{ms}, figures
3461 @cindex @file{ms}, equations
3462 @cindex @file{ms}, references
3463 @cindex Tables (ms)
3464 @cindex Figures (ms)
3465 @cindex Equations (ms)
3466 @cindex References (ms)
3468 The @file{ms} macros support the standard
3469 @code{groff} preprocessors:
3470 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3471 @pindex tbl
3472 @pindex pic
3473 @pindex eqn
3474 @pindex refer
3475 You mark text meant for preprocessors by enclosing it
3476 in pairs of tags as follows.
3478 @DefmacList {TS, [@code{H}], ms}
3479 @DefmacListEnd {TE, , ms}
3480 Denotes a table, to be processed by the @code{tbl} preprocessor.
3481 The optional argument@w{ }@code{H} to @code{TS} instructs @code{groff}
3482 to create a running header with the information
3483 up to the @code{TH} macro.
3484 @code{groff} prints the header at the beginning of the
3485 table; if the table runs onto another page, @code{groff}
3486 prints the header on the next page as well.
3487 @endDefmac
3489 @DefmacList {PS, , ms}
3490 @DefmacListEnd {PE, , ms}
3491 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3492 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3493 @code{pic} manual available on the Web as a reference, or by using
3494 a graphics program such as @code{xfig}.
3495 @endDefmac
3497 @DefmacList {EQ, [@Var{align}], ms}
3498 @DefmacListEnd {EN, , ms}
3499 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3500 The optional @var{align} argument can be @code{C}, @code{L}, or@w{
3501 }@code{I} to center (the default), left-justify, or indent the equation.
3502 @endDefmac
3504 @DefmacList {[, , ms}
3505 @DefmacListEnd {], , ms}
3506 Denotes a reference, to be processed by the @code{refer} preprocessor.
3507 The @acronym{GNU} @cite{refer(1)} manpage provides a comprehensive
3508 reference to the preprocessor and the format of the bibliographic
3509 database.
3510 @endDefmac
3512 @menu
3513 * Example multi-page table::
3514 @end menu
3516 @c ---------------------------------------------------------------------
3518 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3519 @subsubsection An example multi-page table
3520 @cindex Example markup, multi-page table (ms)
3521 @cindex Multi-page table, example markup (ms)
3523 The following is an example of how to set up a
3524 table that may print across two or more pages.
3526 @Example
3527 @cartouche
3528 .TS H
3529 allbox expand;
3530 cb | cb .
3531 Text      ...of heading...
3535 l | l .
3536 ... the rest of the table follows...
3539 @end cartouche
3540 @endExample
3542 @c ---------------------------------------------------------------------
3544 @node ms Footnotes,  , Example multi-page table, ms Body Text
3545 @subsubsection Footnotes
3546 @cindex @file{ms}, footnotes
3547 @cindex Footnotes (ms)
3549 The @file{ms} macro package has a flexible footnote system.
3550 You can specify either numbered footnotes or symbolic footnotes
3551 (that is, using a marker such as a dagger symbol).
3553 @Defstr {*, ms}
3554 Specifies the location of a numbered footnote marker in the text.
3555 @endDefesc
3557 @DefmacList {FS, , ms}
3558 @DefmacListEnd {FE, , ms}
3559 Specifies the text of the footnote.
3560 The default action is to create a numbered footnote;
3561 you can create a symbolic footnote by specifying
3562 a @dfn{mark} character
3563 (such as @code{\[dg]} for the dagger character)
3564 in the body text and as an argument to the @code{FS} macro,
3565 followed by the text of the footnote
3566 and the @code{FE} macro.
3567 @endDefmac
3569 You can control how @code{groff}
3570 prints footnote numbers by changing the value of the
3571 @code{FF} register.  @xref{ms Document Control Registers}.
3573 @c ---------------------------------------------------------------------
3575 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3576 @subsection Page layout
3577 @cindex @file{ms}, page layout
3578 @cindex Page layout (ms)
3580 The default output from the @file{ms}
3581 macros provides a minimalist page layout:
3582 it prints a single column, with the page number centered at the top
3583 of each page.
3584 It prints no footers.
3586 You can change the layout by setting
3587 the proper number registers and strings.
3589 @menu
3590 * ms Headers and Footers::
3591 * ms Margins::
3592 * ms Multiple Columns::
3593 * ms TOC::
3594 * ms Strings and Special Characters::
3595 @end menu
3597 @c ---------------------------------------------------------------------
3599 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3600 @subsubsection Headers and footers
3601 @cindex @file{ms}, headers
3602 @cindex @file{ms}, footers
3603 @cindex Headers (ms)
3604 @cindex Footers (ms)
3606 For documents that do not distinguish between odd and even pages,
3607 set the following strings:
3609 @DefstrList {LH, ms}
3610 @DefstrItem {CH, ms}
3611 @DefstrListEnd {RH, ms}
3612 Sets the left, center, and right headers.
3613 @endDefstr
3615 @DefstrList {LF, ms}
3616 @DefstrItem {CF, ms}
3617 @DefstrListEnd {RF, ms}
3618 Sets the left, center, and right footers.
3619 @endDefstr
3621 @sp 1
3622 For documents that need different information printed in the
3623 even and odd pages, use the following macros:
3625 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3626 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3627 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3628 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3629 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3630 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3631 This is more flexible than defining the individual strings.
3633 You can replace the quote (@code{'}) marks with any character not
3634 appearing in the header or footer text.
3635 @endDefmac
3637 @c ---------------------------------------------------------------------
3639 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3640 @subsubsection Margins
3641 @cindex @file{ms}, margins
3643 You control margins using a set of number registers.
3644 @xref{ms Document Control Registers}, for details.
3646 @c ---------------------------------------------------------------------
3648 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3649 @subsubsection Multiple columns
3650 @cindex @file{ms}, multiple columns
3651 @cindex Multiple columns (ms)
3653 The @file{ms} macros can set text in as many columns as will
3654 reasonably fit on the page.
3655 The following macros are available;
3656 all of them force a page break if a multi-column mode is already set.
3657 However, if the current mode is single-column, starting a multi-column
3658 mode does @strong{not} force a page break.
3660 @Defmac {1C, , ms}
3661 Single-column mode.
3662 @endDefmac
3664 @Defmac {2C, , ms}
3665 Two-column mode.
3666 @endDefmac
3668 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3669 Multi-column mode.
3670 If you specify no arguments, it is equivalent to the
3671 @code{.2C} macro.
3672 Otherwise, @var{width} is the width of each column and
3673 @var{gutter} is the space between columns.
3674 The @code{MINGW} number register controls the default gutter width.
3675 @endDefmac
3677 @c ---------------------------------------------------------------------
3679 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3680 @subsubsection Creating a table of contents
3681 @cindex @file{ms}, creating table of contents
3682 @cindex Table of contents, creating (ms)
3684 The facilities in the @file{ms} macro package for creating
3685 a table of contents are semi-automated at best.
3686 Assuming that you want the table of contents to consist of
3687 the document's headings, you need to repeat those headings
3688 wrapped in @code{XS} and @code{XE} macros.
3690 @DefmacList {XS, [@Var{page}], ms}
3691 @DefmacItem {XA, [@Var{page}], ms}
3692 @DefmacListEnd {XE, , ms}
3693 These macros define a table of contents
3694 or an individual entry in the table of contents,
3695 depending on their use.
3696 The macros are very simple; they cannot indent a heading based on its level.
3697 The easiest way to work around this is to add tabs
3698 to the table of contents string.
3699 The following is an example:
3701 @Example
3702 @cartouche
3703 .NH 1
3704 Introduction
3706 Introduction
3711 .NH 2
3712 Methodology
3714         Methodology
3718 @end cartouche
3719 @endExample
3721 You can manually create a table of contents
3722 by beginning with the @code{XS} macro for the first entry,
3723 specifying the page number for that entry as the argument to @code{XS}.
3724 Add subsequent entries using the @code{XA} macro,
3725 specifying the page number for that entry as the argument to @code{XA}.
3726 The following is an example:
3728 @Example
3729 @cartouche
3730 .XS 1
3731 Introduction
3732 .XA 2
3733 A Brief History of the Universe
3734 .XA 729
3735 Details of Galactic Formation
3738 @end cartouche
3739 @endExample
3740 @endDefmac
3742 @Defmac {TC, [@code{no}], ms}
3743 Prints the table of contents on a new page,
3744 setting the page number to@w{ }@strong{i} (Roman numeral one).
3745 You should usually place this macro at the end of the
3746 file, since @code{groff} is a single-pass formatter and
3747 can only print what has been collected up to the point
3748 that the @code{TC} macro appears.
3750 The optional argument @code{no} suppresses printing
3751 the title specified by the string register @code{TOC}.
3752 @endDefmac
3754 @Defmac{PX, [@code{no}], ms}
3755 Prints the table of contents on a new page,
3756 using the current page numbering sequence.
3757 Use this macro to print a manually-generated table of contents
3758 at the beginning of your document.
3760 The optional argument @code{no} suppresses printing
3761 the title specified by the string register @code{TOC}.
3762 @endDefmac
3764 The @cite{Groff and Friends HOWTO}
3765 includes a @code{sed} script that automatically inserts
3766 @code{XS} and @code{XE} macro entries after each heading in a document.
3768 Altering the @code{NH} macro to automatically build the table
3769 of contents is perhaps initially more difficult, but would save
3770 a great deal of time in the long run if you use @file{ms} regularly.
3772 @c ---------------------------------------------------------------------
3774 @node ms Strings and Special Characters,  , ms TOC, ms Page Layout
3775 @subsubsection Strings and Special Characters
3776 @cindex @file{ms}, strings
3777 @cindex @file{ms}, special characters
3778 @cindex @file{ms}, accent marks
3779 @cindex Accent marks
3780 @cindex Special characters
3781 @cindex Strings in @file{ms}
3783 The @file{ms} macros provide the following predefined strings.
3784 You can change the string definitions to help in creating
3785 documents in languages other than English.
3787 @Defstr {REFERENCES, ms}
3788 Contains the string printed at the beginning of the
3789 references (bibliography) page.
3790 The default is @samp{References}.
3791 @endDefstr
3793 @Defstr {ABSTRACT, ms}
3794 Contains the string printed at the beginning of the abstract.
3795 The default is @samp{ABSTRACT}.
3796 @endDefstr
3798 @Defstr {TOC, ms}
3799 Contains the string printed at the beginning of the table of contents.
3800 @endDefstr
3802 @DefstrList {MONTH1, ms}
3803 @DefstrItem {MONTH2, ms}
3804 @DefstrItem {MONTH3, ms}
3805 @DefstrItem {MONTH4, ms}
3806 @DefstrItem {MONTH5, ms}
3807 @DefstrItem {MONTH6, ms}
3808 @DefstrItem {MONTH7, ms}
3809 @DefstrItem {MONTH8, ms}
3810 @DefstrItem {MONTH9, ms}
3811 @DefstrItem {MONTH10, ms}
3812 @DefstrItem {MONTH11, ms}
3813 @DefstrListEnd {MONTH12, ms}
3814 Prints the full name of the month in dates.
3815 The default is @samp{January}, @samp{February}, etc.
3816 @endDefstr
3818 The following special characters are available:
3820 @Defstr {-, ms}
3821 Prints an em dash.
3822 @endDefstr
3824 @DefstrList {*Q, ms}
3825 @DefstrListEnd {*U, ms}
3826 Prints typographer's quotes in troff,
3827 plain quotes in nroff.
3828 @code{*Q} is the left quote and @code{*U} is the right quote.
3829 @endDefstr
3831 Improved accent marks are available in the @file{ms} macros.
3833 @Defmac {AM, , ms}
3834 Specify this macro at the beginning of your document
3835 to enable extended accent marks and special characters.
3836 This is a Berkeley extension.
3838 To use the accent marks, place them @strong{after}
3839 the character being accented.
3840 @endDefmac
3842 The following accent marks are available
3843 after invoking the @code{AM} macro:
3845 @Defstr {\', ms}
3846 Acute accent.
3847 @endDefstr
3849 @Defstr {\`, ms}
3850 Grave accent.
3851 @endDefstr
3853 @Defstr {^, ms}
3854 Circumflex.
3855 @endDefstr
3857 @Defstr {\,, ms}
3858 Cedilla.
3859 @endDefstr
3861 @Defstr {~, ms}
3862 Tilde.
3863 @endDefstr
3865 @deffn String @t{\*[:]}
3866 @ifnotinfo
3867 @stindex : @r{[}ms@r{]}
3868 @end ifnotinfo
3869 @ifinfo
3870 @stindex @r{<colon>} @r{[}ms@r{]}
3871 @end ifinfo
3872 Umlaut.
3873 @end deffn
3875 @Defstr {v, ms}
3876 Hacek.
3877 @endDefstr
3879 @Defstr {_, ms}
3880 Macron (overbar).
3881 @endDefstr
3883 @Defstr {., ms}
3884 Underdot.
3885 @endDefstr
3887 @Defstr {o, ms}
3888 Ring above.
3889 @endDefstr
3891 The following are standalone characters
3892 available after invoking the @code{AM} macro:
3894 @Defstr {?, ms}
3895 Upside-down question mark.
3896 @endDefstr
3898 @Defstr {!, ms}
3899 Upside-down exclamation point.
3900 @endDefstr
3902 @Defstr {8, ms}
3903 German @ss{} ligature.
3904 @endDefstr
3906 @Defstr {3, ms}
3907 Yogh.
3908 @endDefstr
3910 @Defstr {Th, ms}
3911 Uppercase thorn.
3912 @endDefstr
3914 @Defstr {th, ms}
3915 Lowercase thorn.
3916 @endDefstr
3918 @Defstr {D-, ms}
3919 Uppercase eth.
3920 @endDefstr
3922 @Defstr {d-, ms}
3923 Lowercase eth.
3924 @endDefstr
3926 @Defstr {q, ms}
3927 Hooked o.
3928 @endDefstr
3930 @Defstr {ae, ms}
3931 Lowercase @ae{} ligature.
3932 @endDefstr
3934 @Defstr {Ae, ms}
3935 Uppercase @AE{} ligature.
3936 @endDefstr
3938 @c ---------------------------------------------------------------------
3940 @node Differences from AT&T ms,  , ms Page Layout, ms
3941 @subsection Differences from @acronym{AT&T} @file{ms}
3942 @cindex @file{ms}, differences from @acronym{AT&T}
3943 @cindex @acronym{AT&T}, @code{ms} differences
3945 This section lists the (minor) differences between the
3946 @code{groff -ms} macros and @acronym{AT&T}
3947 @code{troff -ms} macros.
3949 @menu
3950 * Missing ms Macros::
3951 * Additional ms Macros::
3952 @end menu
3954 @c ---------------------------------------------------------------------
3956 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3957 @subsubsection @code{troff} macros not appearing in @code{groff}
3959 Macros missing from @code{groff -ms}
3960 are cover page macros specific to Bell Labs.
3961 The macros known to be missing are:
3963 @table @code
3964 @item .TM
3965 Technical memorandum; a cover sheet style
3967 @item .IM
3968 Internal memorandum; a cover sheet style
3970 @item .MR
3971 Memo for record; a cover sheet style
3973 @item .MF
3974 Memo for file; a cover sheet style
3976 @item .EG
3977 Engineer's notes; a cover sheet style
3979 @item .TR
3980 Computing Science Tech Report; a cover sheet style
3982 @item .OK
3983 Other keywords
3985 @item .CS
3986 Cover sheet information
3988 @item .MH
3989 A cover sheet macro
3990 @end table
3992 @c ---------------------------------------------------------------------
3994 @node Additional ms Macros,  , Missing ms Macros, Differences from AT&T ms
3995 @subsubsection @code{groff} macros not appearing in AT&T @code{troff}
3997 The @code{groff -ms} macros have a few minor extensions
3998 compared to the @acronym{AT&T} @code{troff -ms} macros.
4000 @Defmac {AM, , ms}
4001 Improved accent marks.
4002 @xref{ms Strings and Special Characters}, for details.
4003 @endDefmac
4005 @Defmac {DS, @t{I}, ms}
4006 Indented display.
4007 The default behavior of @acronym{AT&T} @code{troff -ms}
4008 was to indent; the @code{groff} default prints displays
4009 flush left with the body text.
4010 @endDefmac
4012 @Defmac {CW, , ms}
4013 Print text in @code{constant width} (Courier) font.
4014 @endDefmac
4016 @Defmac {IX, , ms}
4017 Indexing term (printed on standard error).
4018 You can write a script to capture and process an index
4019 generated in this manner.
4020 @endDefmac
4022 @sp 1
4023 The following additional number registers
4024 appear in @code{groff -ms}:
4026 @Defmpreg {MINGW, ms}
4027 Specifies a minimum space
4028 between columns (for multi-column output); this takes the
4029 place of the @code{GW} register that was documented but apparently
4030 not implemented in @acronym{AT&T} @code{troff}.
4031 @endDefmpreg
4033 @sp 1
4034 Several new string registers are available as well.
4035 You can change these to handle (for example) the local language.
4036 @xref{ms Strings and Special Characters}, for details.
4039 @c =====================================================================
4041 @node me, mm, ms, Macro Packages
4042 @section @file{me}
4043 @cindex @file{me}
4045 @c XXX documentation
4046 @c XXX this is a placeholder until we get stuff knocked into shape
4047 See the @file{meintro.me} and @file{meref.me} documents in
4048 groff's @file{doc} directory.
4051 @c =====================================================================
4053 @node mm,  , me, Macro Packages
4054 @section @file{mm}
4055 @cindex @file{mm}
4057 @c XXX documentation
4058 @c XXX this is a placeholder until we get stuff knocked into shape
4059 See the @code{mm} manpage (type @command{man 7 groff_mm} at
4060 the command line).
4063 @c =====================================================================
4064 @c =====================================================================
4066 @node gtroff Reference, Preprocessors, Macro Packages, Top
4067 @chapter @code{gtroff} Reference
4068 @cindex reference, @code{gtroff}
4069 @cindex @code{gtroff} reference
4071 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4072 Users of macro packages may skip it if not interested in details.
4075 @menu
4076 * Text::
4077 * Input Conventions::
4078 * Measurements::
4079 * Expressions::
4080 * Identifiers::
4081 * Embedded Commands::
4082 * Registers::
4083 * Manipulating Filling and Adjusting::
4084 * Manipulating Hyphenation::
4085 * Manipulating Spacing::
4086 * Tabs and Fields::
4087 * Character Translations::
4088 * Troff and Nroff Mode::
4089 * Line Layout::
4090 * Line Control::
4091 * Page Layout::
4092 * Page Control::
4093 * Fonts::
4094 * Sizes::
4095 * Strings::
4096 * Conditionals and Loops::
4097 * Writing Macros::
4098 * Page Motions::
4099 * Drawing Requests::
4100 * Traps::
4101 * Diversions::
4102 * Environments::
4103 * Suppressing output::
4104 * Colors::
4105 * I/O::
4106 * Postprocessor Access::
4107 * Miscellaneous::
4108 * Gtroff Internals::
4109 * Debugging::
4110 * Implementation Differences::
4111 * Summary::
4112 @end menu
4115 @c =====================================================================
4117 @node Text, Input Conventions, gtroff Reference, gtroff Reference
4118 @section Text
4119 @cindex text, @code{gtroff} processing
4121 @code{gtroff} input files contain text with control commands
4122 interspersed throughout.  But, even without control codes, @code{gtroff}
4123 still does several things with the input text:
4125 @itemize @bullet
4126 @item
4127 filling and adjusting
4129 @item
4130 adding additional space after sentences
4132 @item
4133 hyphenating
4135 @item
4136 inserting implicit line breaks
4137 @end itemize
4139 @menu
4140 * Filling and Adjusting::
4141 * Hyphenation::
4142 * Sentences::
4143 * Tab Stops::
4144 * Implicit Line Breaks::
4145 @end menu
4147 @c ---------------------------------------------------------------------
4149 @node Filling and Adjusting, Hyphenation, Text, Text
4150 @subsection Filling and Adjusting
4151 @cindex filling
4152 @cindex adjusting
4154 When @code{gtroff} reads text, it collects words from the input and fits
4155 as many of them together on one output line as it can.  This is known as
4156 @dfn{filling}.
4158 @cindex leading spaces
4159 @cindex spaces, leading and trailing
4160 @cindex extra spaces
4161 @cindex trailing spaces
4162 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
4163 it.  This means it widens the spacing between words until the text
4164 reaches the right margin (in the default adjustment mode).  Extra spaces
4165 between words are preserved, but spaces at the end of lines are ignored.
4166 Spaces at the front of a line cause a @dfn{break} (breaks are
4167 explained in @ref{Implicit Line Breaks}).
4169 @xref{Manipulating Filling and Adjusting}.
4171 @c ---------------------------------------------------------------------
4173 @node Hyphenation, Sentences, Filling and Adjusting, Text
4174 @subsection Hyphenation
4175 @cindex hyphenation
4177 Since the odds are not great for finding a set of words, for every
4178 output line, which fit nicely on a line without inserting excessive
4179 amounts of space between words, @code{gtroff} hyphenates words so
4180 that it can justify lines without inserting too much space between
4181 words.  It uses an internal hyphenation algorithm (a simplified version
4182 of the algorithm used within @TeX{}) to indicate which words can be
4183 hyphenated and how to do so.  When a word is hyphenated, the first part
4184 of the word is added to the current filled line being output (with
4185 an attached hyphen), and the other portion is added to the next
4186 line to be filled.
4188 @xref{Manipulating Hyphenation}.
4190 @c ---------------------------------------------------------------------
4192 @node Sentences, Tab Stops, Hyphenation, Text
4193 @subsection Sentences
4194 @cindex sentences
4196 Although it is often debated, some typesetting rules say there should be
4197 different amounts of space after various punctuation marks.  For
4198 example, the @cite{Chicago typsetting manual} says that a period at the
4199 end of a sentence should have twice as much space following it as would
4200 a comma or a period as part of an abbreviation.
4202 @c XXX exact citation of Chicago manual
4204 @cindex sentence space
4205 @cindex space between sentences
4206 @cindex french-spacing
4207 @code{gtroff} does this by flagging certain characters (normally
4208 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4209 When @code{gtroff} encounters one of these characters at the end of a
4210 line, it appends a normal space followed by a @dfn{sentence space} in
4211 the formatted output.  (This justifies one of the conventions mentioned
4212 in @ref{Input Conventions}.)
4214 @cindex transparent characters
4215 @cindex character, transparent
4216 @cindex @code{dg} glyph, at end of sentence
4217 @cindex @code{rq} glyph, at end of sentence
4218 @cindex @code{"}, at end of sentence
4219 @cindex @code{'}, at end of sentence
4220 @cindex @code{)}, at end of sentence
4221 @cindex @code{]}, at end of sentence
4222 @cindex @code{*}, at end of sentence
4223 In addition, the following characters or glyphs are treated
4224 transparently while handling end-of-sentence characters: @samp{"},
4225 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{dg}, and @code{rq}.
4227 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4229 @cindex @code{\&}, at end of sentence
4230 To prevent the insertion of extra space after an end-of-sentence
4231 character (at the end of a line), append @code{\&}.
4233 @c ---------------------------------------------------------------------
4235 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4236 @subsection Tab Stops
4237 @cindex tab stops
4238 @cindex stops, tabulator
4239 @cindex tab character
4240 @cindex character, tabulator
4242 @cindex @acronym{EBCDIC} encoding
4243 @cindex encoding, @acronym{EBCDIC}
4244 @code{gtroff} translates @dfn{tabulator characters}, also called
4245 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4246 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4247 tabulator stop.  These tab stops are initially located every half inch
4248 across the page.  Using this, simple tables can be made easily.
4249 However, it can often be deceptive as the appearance (and width) of the
4250 text on a terminal and the results from @code{gtroff} can vary greatly.
4252 Also, a possible sticking point is that lines beginning with tab
4253 characters are still filled, again producing unexpected results.
4254 For example, the following input
4256 @multitable {12345678} {12345678} {12345678} {12345678}
4257 @item
4258 @tab 1 @tab 2 @tab 3
4259 @item
4260 @tab   @tab 4 @tab 5
4261 @end multitable
4263 @noindent
4264 produces
4266 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4267 @item
4268 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
4269 @end multitable
4271 @xref{Tabs and Fields}.
4273 @c ---------------------------------------------------------------------
4275 @node Implicit Line Breaks,  , Tab Stops, Text
4276 @subsection Implicit Line Breaks
4277 @cindex implicit line breaks
4278 @cindex implicit breaks of lines
4279 @cindex line, implicit breaks
4280 @cindex break, implicit
4281 @cindex line break
4283 An important concept in @code{gtroff} is the @dfn{break}.  When a break
4284 occurs, @code{gtroff} outputs the partially filled line
4285 (unjustified), and resumes collecting and filling text on the next output
4286 line.
4288 @cindex blank line
4289 @cindex empty line
4290 @cindex line, blank
4291 @cindex blank line macro (@code{blm})
4292 There are several ways to cause a break in @code{gtroff}.  A blank
4293 line not only causes a break, but it also outputs a one-line vertical
4294 space (effectively a blank line).  Note that this behaviour can be
4295 modified with the blank line macro request @code{blm}.
4296 @xref{Blank Line Traps}.
4298 @cindex fill mode
4299 @cindex mode, fill
4300 A line that begins with a space causes a break and the space is
4301 output at the beginning of the next line.  Note that this space isn't
4302 adjusted, even in fill mode.
4304 The end of file also causes a break -- otherwise the last line of
4305 the document may vanish!
4307 Certain requests also cause breaks, implicitly or explicitly.  This is
4308 discussed in @ref{Manipulating Filling and Adjusting}.
4311 @c =====================================================================
4313 @node Input Conventions, Measurements, Text, gtroff Reference
4314 @section Input Conventions
4315 @cindex input conventions
4316 @cindex conventions for input
4318 Since @code{gtroff} does filling automatically, it is traditional in
4319 @code{groff} not to try and type things in as nicely formatted
4320 paragraphs.  These are some conventions commonly used when typing
4321 @code{gtroff} text:
4323 @itemize @bullet
4324 @item
4325 Break lines after punctuation, particularly at the end of a sentence
4326 and in other logical places.  Keep separate phrases on lines by
4327 themselves, as entire phrases are often added or deleted when editing.
4329 @item
4330 Try to keep lines less than 40-60@w{ }characters, to allow space for
4331 inserting more text.
4333 @item
4334 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4335 don't try using spaces to get proper indentation).
4336 @end itemize
4339 @c =====================================================================
4341 @node Measurements, Expressions, Input Conventions, gtroff Reference
4342 @section Measurements
4343 @cindex measurements
4345 @cindex units of measurement
4346 @cindex basic unit (@code{u})
4347 @cindex machine unit (@code{u})
4348 @cindex measurement unit
4349 @cindex @code{u} unit
4350 @cindex unit, @code{u}
4351 @code{gtroff} (like many other programs) requires numeric parameters to
4352 specify various measurements.  Most numeric parameters@footnote{those
4353 that specify vertical or horizontal motion or a type size} may have a
4354 @dfn{measurement unit} attached.  These units are specified as a single
4355 character which immediately follows the number or expression.  Each of
4356 these units are understood, by @code{gtroff}, to be a multiple of its
4357 @dfn{basic unit}.  So, whenever a different measurement unit is
4358 specified @code{gtroff} converts this into its @dfn{basic units}.  This
4359 basic unit, represented by a @samp{u}, is a device dependent measurement
4360 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4361 inch.  The values may be given as fractional numbers; however,
4362 fractional basic units are always rounded to integers.
4364 Some of the measurement units are completely independent of any of the
4365 current settings (e.g.@: type size) of @code{gtroff}.
4367 @table @code
4368 @item i
4369 @cindex inch unit (@code{i})
4370 @cindex @code{i} unit
4371 @cindex unit, @code{i}
4372 Inches.  An antiquated measurement unit still in use in certain
4373 backwards countries with incredibly low-cost computer equipment.  One
4374 inch is equal to@w{ }2.54@dmn{cm}.
4376 @item c
4377 @cindex centimeter unit (@code{c})
4378 @cindex @code{c} unit
4379 @cindex unit, @code{c}
4380 Centimeters.  One centimeter is equal to@w{ }0.3937@dmn{in}.
4382 @item p
4383 @cindex point unit (@code{p})
4384 @cindex @code{p} unit
4385 @cindex unit, @code{p}
4386 Points.  This is a typesetter's measurement used for measure type size.
4387 It is 72@w{ }points to an inch.
4389 @item P
4390 @cindex pica unit (@code{P})
4391 @cindex @code{P} unit
4392 @cindex unit, @code{P}
4393 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
4394 12@w{ }points to a pica).
4396 @item s
4397 @itemx z
4398 @cindex @code{s} unit
4399 @cindex unit, @code{s}
4400 @cindex @code{z} unit
4401 @cindex unit, @code{z}
4402 @xref{Fractional Type Sizes}, for a discussion of these units.
4404 @item f
4405 @cindex @code{f} unit
4406 @cindex unit, @code{f}
4407 Fractions. Value is 65536.
4408 @xref{Colors}, for usage.
4409 @end table
4411 The other measurements understood by @code{gtroff} depend on
4412 settings currently in effect in @code{gtroff}.  These are very useful
4413 for specifying measurements which should look proper with any size of
4414 text.
4416 @table @code
4417 @item m
4418 @cindex em unit (@code{m})
4419 @cindex @code{m} unit
4420 @cindex unit, @code{m}
4421 Ems.  This unit is equal to the current font size in points.  So called
4422 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
4423 in the current font.
4425 @item n
4426 @cindex en unit (@code{n})
4427 @cindex @code{n} unit
4428 @cindex unit, @code{n}
4429 Ens.  In @code{groff}, this is half of an em.
4431 @item v
4432 @cindex vertical space unit (@code{v})
4433 @cindex space, vertical, unit (@code{v})
4434 @cindex @code{v} unit
4435 @cindex unit, @code{v}
4436 Vertical space.  This is equivalent to the current line spacing.
4437 @xref{Sizes}, for more information about this.
4439 @item M
4440 @cindex @code{M} unit
4441 @cindex unit, @code{M}
4442 100ths of an em.
4443 @end table
4445 @menu
4446 * Default Units::
4447 @end menu
4449 @c ---------------------------------------------------------------------
4451 @node Default Units,  , Measurements, Measurements
4452 @subsection Default Units
4453 @cindex default units
4454 @cindex units, default
4456 Many requests take a default unit.  While this can be helpful at times,
4457 it can cause strange errors in some expressions.  For example, the line
4458 length request expects em units.  Here are several attempts to get a
4459 line length of 3.5@w{ }inches and their results:
4461 @Example
4462 3.5i      @result{}   3.5i
4463 7/2       @result{}   0i
4464 7/2i      @result{}   0i
4465 (7 / 2)u  @result{}   0i
4466 7i/2      @result{}   0.1i
4467 7i/2u     @result{}   3.5i
4468 @endExample
4470 @noindent
4471 Everything is converted to basic units first.  In the above example it
4472 is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m} equals@w{
4473 }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}).  The value 7@dmn{i}/2
4474 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4475 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4476 0.1@dmn{i}.  As can be seen, a scaling indicator after a closing
4477 parenthesis is simply ignored.
4479 @cindex measurements, specifying safely
4480 Thus, the safest way to specify measurements is to always
4481 attach a scaling indicator.  If you want to multiply or divide by a
4482 certain scalar value, use @samp{u} as the unit for that value.
4485 @c =====================================================================
4487 @node Expressions, Identifiers, Measurements, gtroff Reference
4488 @section Expressions
4489 @cindex expressions
4491 @code{gtroff} has most arithmetic operators common to other languages:
4493 @c XXX more details; examples
4495 @itemize @bullet
4496 @item
4497 @cindex arithmetic operators
4498 @cindex operators, arithmetic
4499 @opindex +
4500 @opindex -
4501 @opindex /
4502 @opindex *
4503 @opindex %
4504 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4505 (division), @samp{*} (multiplication), @samp{%} (modulo).
4507 @code{gtroff} only provides integer arithmetic.  The internal type used
4508 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4509 signed integer.
4511 @item
4512 @cindex comparison operators
4513 @cindex operators, comparison
4514 @opindex <
4515 @opindex >
4516 @opindex >=
4517 @opindex <=
4518 @opindex =
4519 @opindex ==
4520 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4521 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4522 (equal), @samp{==} (the same as @samp{=}).
4524 @item
4525 @cindex logical operators
4526 @cindex operators, logical
4527 @opindex &
4528 @ifnotinfo
4529 @opindex :
4530 @end ifnotinfo
4531 @ifinfo
4532 @opindex @r{<colon>}
4533 @end ifinfo
4534 Logical: @samp{&} (logical and), @samp{:} (logical or).
4536 @item
4537 @cindex unary operators
4538 @cindex operators, unary
4539 @opindex -
4540 @opindex +
4541 @opindex !
4542 @cindex @code{if} request, and the @samp{!} operator
4543 @cindex @code{while} request, and the @samp{!} operator
4544 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4545 (just for completeness; does nothing in expressions), @samp{!} (logical
4546 not; this works only within @code{if} and @code{while} requests).  See
4547 below for the use of unary operators in motion requests.
4549 @item
4550 @cindex extremum operators
4551 @cindex operators, extremum
4552 @opindex >?
4553 @opindex <?
4554 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).  For example,
4555 @samp{5>?3} yields@w{ }@samp{5}.
4557 @c XXX add examples
4559 @item
4560 @cindex scaling operator
4561 @cindex operator, scaling
4562 Scaling: @code{(@var{c};@var{e})}.  Evaluate@w{ }@var{e} using@w{ }@var{c}
4563 as the default scaling indicator.  If @var{c} is missing, ignore scaling
4564 indicators in the evaluation of@w{ }@var{e}.
4565 @end itemize
4567 @cindex parentheses
4568 @cindex order of evaluation in expressions
4569 @cindex expression, order of evaluation
4570 @opindex (
4571 @opindex )
4572 Parentheses may be used as in any other language.  However, in
4573 @code{gtroff} they are necessary to ensure order of evaluation.
4574 @code{gtroff} has no operator precedence; expressions are evaluated left
4575 to right.  This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4576 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4577 expected.
4579 @cindex @code{+}, and page motion
4580 @cindex @code{-}, and page motion
4581 @cindex motion operators
4582 @cindex operators, motion
4583 For many requests which cause a motion on the page, the unary operators
4584 @samp{+} and @samp{-} work differently if leading an expression.  They
4585 then indicate a motion relative to the current position (down or up,
4586 respectively).
4588 @cindex @code{|}, and page motion
4589 @cindex absolute position operator (@code{|})
4590 @cindex position, absolute, operator (@code{|})
4591 Similarly, a leading @samp{|} operator indicates an absolute position.
4592 For vertical movements, it specifies the distance from the top of the
4593 page; for horizontal movements, it gives the distance from the beginning
4594 of the @emph{input} line.
4596 @c XXX xref
4597 @samp{+} and @samp{-} are also treated differently by the following
4598 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4599 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4600 @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4601 Here, leading plus and minus signs indicate increments and decrements.
4603 @c XXX add more xref
4604 @xref{Setting Registers}.
4606 @cindex numeric expression, valid
4607 @cindex valid numeric expression
4608 @Defesc {\\B, ', anything, '}
4609 Return@w{ }1 if @var{anything} is a valid numeric expression;
4610 or@w{ }0 if @var{anything} is empty or not a valid numeric expression.
4611 @endDefesc
4613 @cindex space characters in expressions
4614 @cindex expressions and space characters
4615 Due to the way arguments are parsed, spaces are not allowed in
4616 expressions, unless the entire expression is surrounded by parentheses.
4618 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4621 @c =====================================================================
4623 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4624 @section Identifiers
4625 @cindex identifiers
4627 Like any other language, @code{gtroff} has rules for properly formed
4628 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
4629 almost any printable character, with the exception of the following
4630 characters:
4632 @itemize @bullet
4633 @item
4634 @cindex whitespace characters
4635 @cindex newline character
4636 @cindex character, whitespace
4637 Whitespace characters (spaces, tabs, and newlines).
4639 @item
4640 @cindex character, backspace
4641 @cindex backspace character
4642 @cindex @acronym{EBCDIC} encoding of backspace
4643 Backspace (@acronym{ASCII}@w{ }@code{0x08} or @acronym{EBCDIC}@w{
4644 }@code{0x16}) and character code @code{0x01}.
4646 @item
4647 @cindex invalid input characters
4648 @cindex input characters, invalid
4649 @cindex characters, invalid input
4650 @cindex Unicode
4651 The following input characters are invalid and are ignored if
4652 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4653 warning message of type @samp{input} (see @ref{Debugging}, for more
4654 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4655 @code{0x80}-@code{0x9F}.
4657 And here are the invalid input characters if @code{groff} runs on an
4658 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4659 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4660 @code{0x30}-@code{0x3F}.
4662 Currently, some of these reserved codepoints are used internally, thus
4663 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4664 character sets and encodings which use characters of these ranges.
4666 Note that invalid characters are removed before parsing; an
4667 identifier @code{foo}, followed by an invalid character, followed by
4668 @code{bar} is treated as @code{foobar}.
4669 @end itemize
4671 For example, any of the following is valid.
4673 @Example
4677 end-list
4679 @endExample
4681 @cindex @code{]}, as part of an identifier
4682 @noindent
4683 Note that identifiers longer than two characters with a closing bracket
4684 (@samp{]}) in its name can't be accessed with escape sequences which
4685 expect an identifier as a parameter.  For example, @samp{\[foo]]}
4686 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4687 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4689 @c XXX xref
4691 @Defesc {\\A, ', ident, '}
4692 Test whether an identifier @var{ident} is valid in @code{gtroff}.  It
4693 expands to the character@w{ }1 or@w{ }0 according to whether its
4694 argument (usually delimited by quotes) is or is not acceptable as the
4695 name of a string, macro, diversion, number register, environment, or
4696 font.  It returns@w{ }0 if no argument is given.  This is useful for
4697 looking up user input in some sort of associative table.
4699 @Example
4700 \A'end-list'
4701     @result{} 1
4702 @endExample
4703 @endDefesc
4705 @xref{Escapes}, for details on parameter delimiting characters.
4707 @c XXX add xrefs above
4709 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4710 @code{gtroff} needs to be told where identifiers end and text begins
4711 (and in different ways depending on their length):
4713 @itemize @bullet
4714 @item
4715 Single character.
4717 @cindex @code{(}, starting a two-character identifier
4718 @item
4719 Two characters.  Must be prefixed with @samp{(} in some situations.
4721 @cindex @code{[}, starting an identifier
4722 @cindex @code{]}, ending an identifier
4723 @item
4724 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
4725 and@w{ }@samp{]} in some situations.  Any length identifier can be put
4726 in brackets.
4727 @end itemize
4729 @cindex undefined identifiers
4730 @cindex identifiers, undefined
4731 Unlike many other programming languages, undefined identifiers are
4732 silently ignored or expanded to nothing.
4733 When @code{gtroff} finds an undefined identifier, it emits a
4734 warning then:
4736 @itemize @bullet
4737 @item
4738 If the identifier is a string, macro, or diversion,
4739 @code{gtroff} defines it as empty.
4741 @item
4742 If the identifier is a number register, @code{gtroff}
4743 defines it with a value of@w{ }0.
4744 @end itemize
4746 @xref{Warnings}.
4748 @c XXX info about common identifier pool for strings and macros.
4750 @xref{Interpolating Registers}, and @ref{Strings}.
4753 @c =====================================================================
4755 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4756 @section Embedded Commands
4757 @cindex embedded commands
4758 @cindex commands, embedded
4760 Most documents need more functionality beyond filling, adjusting and
4761 implicit line breaking.  In order to gain further functionality,
4762 @code{gtroff} allows commands to be embedded into the text, in two ways.
4764 The first is a @dfn{request} which takes up an entire line, and does
4765 some large-scale operation (e.g.@: break lines, start new pages).
4767 The other is an @dfn{escape} which can be embedded anywhere in the text,
4768 or even as an argument to a request.
4769 @c XXX (Not always?)
4770 Escapes generally do more minor operations like sub- and superscripts,
4771 print a symbol, etc.
4773 @menu
4774 * Requests::
4775 * Macros::
4776 * Escapes::
4777 @end menu
4779 @c ---------------------------------------------------------------------
4781 @node Requests, Macros, Embedded Commands, Embedded Commands
4782 @subsection Requests
4783 @cindex requests
4785 @cindex control character (@code{.})
4786 @cindex character, control (@code{.})
4787 @cindex no-break control character (@code{'})
4788 @cindex character, no-break control (@code{'})
4789 @cindex control character, no-break (@code{'})
4790 A request line begins with a control character, which is either a single
4791 quote (@samp{'}, the @dfn{no-break control character}) or a period
4792 (@samp{.}, the normal @dfn{control character}).  These can be changed;
4793 see @ref{Character Translations}, for details.  After this there may be
4794 optional tabs or spaces followed by an identifier which is the name of
4795 the request.  This may be followed by any number of space-separated
4796 arguments (@emph{no} tabs here).
4798 @cindex structuring source code of documents or macro packages
4799 @cindex documents, structuring the source code
4800 @cindex macro packages, strucuring the source code
4801 Since a control character followed by whitespace only is ignored, it
4802 is common practice to use this feature for structuring the source code
4803 of documents or macro packages.
4805 @Example
4806 .de foo
4807 .  tm This is foo.
4811 .de bar
4812 .  tm This is bar.
4814 @endExample
4816 @cindex blank line
4817 @cindex blank line macro (@code{blm})
4818 Another possibility is to use the blank line macro request @code{blm}
4819 by assigning an empty macro to it.
4821 @Example
4822 .de do-nothing
4824 .blm do-nothing  \" activate blank line macro
4826 .de foo
4827 .  tm This is foo.
4831 .de bar
4832 .  tm This is bar.
4835 .blm             \" deactivate blank line macro
4836 @endExample
4838 @xref{Blank Line Traps}.
4840 @cindex zero width space character (@code{\&})
4841 @cindex character, zero width space (@code{\&})
4842 @cindex space character, zero width (@code{\&})
4843 @cindex @code{\&}, escaping control characters
4844 To begin a line with a control character without it being interpreted,
4845 precede it with @code{\&}.  This represents a zero width space, which
4846 means it does not affect the output.
4848 In most cases the period is used as a control character.  Several
4849 requests cause a break implicitly; using the single quote control
4850 character prevents this.
4852 @menu
4853 * Request Arguments::
4854 @end menu
4856 @node Request Arguments,  , Requests, Requests
4857 @subsubsection Request Arguments
4858 @cindex request arguments
4859 @cindex arguments to requests
4861 Arguments to requests (and macros) are processed much like the shell:
4862 The line is split into arguments according to spaces.  An argument
4863 which is intended to contain spaces can either be enclosed in double
4864 quotes, or have the spaces @dfn{escaped} with backslashes.
4866 Here are a few examples:
4868 @Example
4869 .uh The Mouse Problem
4870 .uh "The Mouse Problem"
4871 .uh The\ Mouse\ Problem
4872 @endExample
4874 @cindex @code{\~}, difference to @code{\@key{SP}}
4875 @cindex @code{\@key{SP}}, difference to @code{\~}
4876 @noindent
4877 The first line is the @code{uh} macro being called with 3 arguments,
4878 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
4879 same effect of calling the @code{uh} macro with one argument, @samp{The
4880 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4881 is ``classical'' in the sense that it can be found in most @code{troff}
4882 documents.  Nevertheless, it is not optimal in all situations, since
4883 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4884 can't stretch.  @code{gtroff} provides a different command @code{\~} to
4885 insert a stretchable, non-breaking space.}
4887 @cindex @code{"}, in a macro argument
4888 @cindex double quote, in a macro argument
4889 A double quote which isn't preceded by a space doesn't start a macro
4890 argument.  If not closing a string, it is printed literally.
4892 For example,
4894 @Example
4895 .xxx a" "b c" "de"fg"
4896 @endExample
4898 @noindent
4899 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4900 Don't rely on this obscure behaviour!
4902 There are two possibilities to get a double quote reliably.
4904 @itemize @bullet
4905 @item
4906 Enclose the whole argument with double quotes and use two consecutive double
4907 quotes to represent a single one.  This traditional solution has the
4908 disadvantage that double quotes don't survive argument expansion again if
4909 called in compatibility mode (using the @option{-C} option of @code{groff}):
4911 @Example
4912 .de xx
4913 .  tm xx: `\\$1' `\\$2' `\\$3'
4915 .  yy "\\$1" "\\$2" "\\$3"
4917 .de yy
4918 .  tm yy: `\\$1' `\\$2' `\\$3'
4920 .xx A "test with ""quotes""" .
4921     @result{} xx: `A' `test with "quotes"' `.'
4922     @result{} yy: `A' `test with ' `quotes""'
4923 @endExample
4925 @noindent
4926 If not in compatibility mode, you get the expected result
4928 @Example
4929 xx: `A' `test with "quotes"' `.'
4930 yy: `A' `test with "quotes"' `.'
4931 @endExample
4933 @noindent
4934 since @code{gtroff} preserves the input level.
4936 @item
4937 Use the double quote glyph @code{\(dq}.  This works with and without
4938 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
4939 back to a double quote input character.
4941 Not that this method won't work with @acronym{UNIX} @code{troff} in general
4942 since the glyph `dq' isn't defined normally.
4943 @end itemize
4945 @cindex @code{ds} request, and double quotes
4946 Double quotes in the @code{ds} request are handled differently.
4947 @xref{Strings}, for more details.
4949 @c ---------------------------------------------------------------------
4951 @node Macros, Escapes, Requests, Embedded Commands
4952 @subsection Macros
4953 @cindex macros
4955 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
4956 which can be invoked by name.  They are called in the same manner as
4957 requests -- arguments also may be passed in the same manner.
4959 @xref{Writing Macros}, and @ref{Request Arguments}.
4961 @c ---------------------------------------------------------------------
4963 @node Escapes,  , Macros, Embedded Commands
4964 @subsection Escapes
4965 @cindex escapes
4967 Escapes may occur anywhere in the input to @code{gtroff}.  They usually
4968 begin with a backslash and are followed by a single character which
4969 indicates the function to be performed.  The escape character can be
4970 changed; see @ref{Character Translations}.
4972 Escape sequences which require an identifier as a parameter accept three
4973 possible syntax forms.
4975 @itemize @bullet
4976 @item
4977 The next single character is the identifier.
4979 @cindex @code{(}, starting a two-character identifier
4980 @item
4981 If this single character is an opening parenthesis, take the following
4982 two characters as the identifier.  Note that there is no closing
4983 parenthesis after the identifier.
4985 @cindex @code{[}, starting an identifier
4986 @cindex @code{]}, ending an identifier
4987 @item
4988 If this single character is an opening bracket, take all characters
4989 until a closing bracket as the identifier.
4990 @end itemize
4992 @noindent
4993 Examples:
4995 @Example
4997 \n(XX
4998 \*[TeX]
4999 @endExample
5001 @cindex @code{'}, delimiting arguments
5002 @cindex argument delimiting characters
5003 @cindex characters, argument delimiting
5004 @cindex delimiting characters for arguments
5005 Other escapes may require several arguments and/or some special format.
5006 In such cases the argument is traditionally enclosed in single quotes
5007 (and quotes are always used in this manual for the definitions of escape
5008 sequences).  The enclosed text is then processed according to what that
5009 escape expects.  Example:
5011 @Example
5012 \l'1.5i\(bu'
5013 @endExample
5015 @cindex @code{\o}, possible quote characters
5016 @cindex @code{\b}, possible quote characters
5017 @cindex @code{\X}, possible quote characters
5018 Note that the quote character can be replaced with any other character
5019 which does not occur in the argument (even a newline or a space
5020 character) in the following escapes: @code{\o}, @code{\b}, and
5021 @code{\X}.  This makes e.g.
5023 @Example
5024 A caf
5029 in Paris
5030   @result{} A caf@'e in Paris
5031 @endExample
5033 @noindent
5034 possible, but it is better not to use this feature to avoid confusion.
5036 @cindex @code{\%}, used as delimiter
5037 @cindex @code{\@key{SP}}, used as delimiter
5038 @cindex @code{\|}, used as delimiter
5039 @cindex @code{\^}, used as delimiter
5040 @cindex @code{\@{}, used as delimiter
5041 @cindex @code{\@}}, used as delimiter
5042 @cindex @code{\'}, used as delimiter
5043 @cindex @code{\`}, used as delimiter
5044 @cindex @code{\-}, used as delimiter
5045 @cindex @code{\_}, used as delimiter
5046 @cindex @code{\!}, used as delimiter
5047 @cindex @code{\?}, used as delimiter
5048 @cindex @code{\@@}, used as delimiter
5049 @cindex @code{\)}, used as delimiter
5050 @cindex @code{\/}, used as delimiter
5051 @cindex @code{\,}, used as delimiter
5052 @cindex @code{\&}, used as delimiter
5053 @ifnotinfo
5054 @cindex @code{\:}, used as delimiter
5055 @end ifnotinfo
5056 @ifinfo
5057 @cindex @code{\@r{<colon>}}, used as delimiter
5058 @end ifinfo
5059 @cindex @code{\~}, used as delimiter
5060 @cindex @code{\0}, used as delimiter
5061 @cindex @code{\a}, used as delimiter
5062 @cindex @code{\c}, used as delimiter
5063 @cindex @code{\d}, used as delimiter
5064 @cindex @code{\e}, used as delimiter
5065 @cindex @code{\E}, used as delimiter
5066 @cindex @code{\p}, used as delimiter
5067 @cindex @code{\r}, used as delimiter
5068 @cindex @code{\t}, used as delimiter
5069 @cindex @code{\u}, used as delimiter
5070 The following escapes sequences (which are handled similarly to
5071 characters since they don't take a parameter) are also allowed as
5072 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5073 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5074 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
5075 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
5076 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
5077 Again, don't use these if possible.
5079 @cindex @code{\A}, allowed delimiters
5080 @cindex @code{\B}, allowed delimiters
5081 @cindex @code{\Z}, allowed delimiters
5082 @cindex @code{\C}, allowed delimiters
5083 @cindex @code{\w}, allowed delimiters
5084 No newline characters as delimiters are allowed in the following
5085 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5087 @cindex @code{\D}, allowed delimiters
5088 @cindex @code{\h}, allowed delimiters
5089 @cindex @code{\H}, allowed delimiters
5090 @cindex @code{\l}, allowed delimiters
5091 @cindex @code{\L}, allowed delimiters
5092 @cindex @code{\N}, allowed delimiters
5093 @cindex @code{\R}, allowed delimiters
5094 @cindex @code{\s}, allowed delimiters
5095 @cindex @code{\S}, allowed delimiters
5096 @cindex @code{\v}, allowed delimiters
5097 @cindex @code{\x}, allowed delimiters
5098 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5099 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
5100 and @code{\x} can't use the following characters as delimiters:
5102 @itemize @bullet
5103 @item
5104 @cindex numbers, and delimiters
5105 @cindex digits, and delimiters
5106 The digits @code{0}-@code{9}.
5108 @item
5109 @cindex operators, as delimiters
5110 @cindex @code{+}, as delimiter
5111 @cindex @code{-}, as delimiter
5112 @cindex @code{/}, as delimiter
5113 @cindex @code{*}, as delimiter
5114 @cindex @code{%}, as delimiter
5115 @cindex @code{<}, as delimiter
5116 @cindex @code{>}, as delimiter
5117 @cindex @code{=}, as delimiter
5118 @cindex @code{&}, as delimiter
5119 @ifnotinfo
5120 @cindex @code{:}, as delimiter
5121 @end ifnotinfo
5122 @ifinfo
5123 @cindex <colon>, as delimiter
5124 @end ifinfo
5125 @cindex @code{(}, as delimiter
5126 @cindex @code{)}, as delimiter
5127 @cindex @code{.}, as delimiter
5128 The (single-character) operators @samp{+-/*%<>=&:().}.
5130 @item
5131 @cindex space character
5132 @cindex character, space
5133 @cindex tab character
5134 @cindex character, tab
5135 @cindex newline character
5136 @cindex character, newline
5137 The space, tab, and newline characters.
5139 @item
5140 @cindex @code{\%}, used as delimiter
5141 @ifnotinfo
5142 @cindex @code{\:}, used as delimiter
5143 @end ifnotinfo
5144 @ifinfo
5145 @cindex @code{\@r{<colon>}}, used as delimiter
5146 @end ifinfo
5147 @cindex @code{\@{}, used as delimiter
5148 @cindex @code{\@}}, used as delimiter
5149 @cindex @code{\'}, used as delimiter
5150 @cindex @code{\`}, used as delimiter
5151 @cindex @code{\-}, used as delimiter
5152 @cindex @code{\_}, used as delimiter
5153 @cindex @code{\!}, used as delimiter
5154 @cindex @code{\@@}, used as delimiter
5155 @cindex @code{\/}, used as delimiter
5156 @cindex @code{\c}, used as delimiter
5157 @cindex @code{\e}, used as delimiter
5158 @cindex @code{\p}, used as delimiter
5159 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
5160 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
5161 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5162 @end itemize
5164 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
5165 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
5166 To have a backslash (actually, the current escape character) appear in the
5167 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
5168 These are very similar, and only differ with respect to being used in
5169 macros or diversions.  @xref{Character Translations}, for an exact
5170 description of those escapes.
5172 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
5173 @ref{Identifiers}, for more information.
5175 @menu
5176 * Comments::
5177 @end menu
5179 @node Comments,  , Escapes, Escapes
5180 @subsubsection Comments
5181 @cindex comments
5183 Probably one of the most@footnote{Unfortunately, this is a lie.  But
5184 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5185 common forms of escapes is the comment.
5187 @Defesc {\\", , , }
5188 Start a comment.  Everything to the end of the input line is ignored.
5190 This may sound simple, but it can be tricky to keep the comments from
5191 interfering with the appearance of the final output.
5193 @cindex @code{ds} request, and comments
5194 @cindex @code{ds1} request, and comments
5195 @cindex @code{as} request, and comments
5196 @cindex @code{as1} request, and comments
5197 If the escape is to the right of some text or a request, that portion
5198 of the line is ignored, but the space leading up to it is noticed by
5199 @code{gtroff}.  This only affects the @code{.ds} and @code{.as}
5200 request and its variants.
5202 @cindex tabs before comments
5203 @cindex comments, lining up with tabs
5204 One possibly irritating idiosyncracy is that tabs must not be used to
5205 line up comments.  Tabs are not treated as white space between the
5206 request and macro arguments.
5208 @cindex undefined request
5209 @cindex request, undefined
5210 A comment on a line by itself is treated as a blank line, because
5211 after eliminating the comment, that is all that remains:
5213 @Example
5214 Test
5215 \" comment
5216 Test
5217 @endExample
5219 @noindent
5220 produces
5222 @Example
5223 Test
5225 Test
5226 @endExample
5228 To avoid this, it is common to start the line with @code{.\"} which
5229 causes the line to be treated as an undefined request and thus ignored
5230 completely.
5232 @cindex @code{'}, as a comment
5233 Another commenting scheme seen sometimes is three consecutive single
5234 quotes (@code{'''}) at the beginning of a line.  This works, but
5235 @code{gtroff} gives a warning about an undefined macro (namely
5236 @code{''}), which is harmless, but irritating.
5237 @endDefesc
5239 @Defesc {\\#, , , }
5240 To avoid all this, @code{gtroff} has a new comment mechanism using the
5241 @code{\#} escape.  This escape works the same as @code{\"} except that
5242 the newline is also ignored:
5244 @Example
5245 Test
5246 \# comment
5247 Test
5248 @endExample
5250 @noindent
5251 produces
5253 @Example
5254 Test Test
5255 @endExample
5257 @noindent
5258 as expected.
5259 @endDefesc
5261 @Defreq {ig, yy}
5262 Ignore all input until @code{gtroff} encounters the macro named
5263 @code{.}@var{yy} on a line by itself (or @code{..} if @var{yy} is not
5264 specified).  This is useful for commenting out large blocks of text:
5266 @Example
5267 text text text...
5269 This is part of a large block
5270 of text that has been
5271 temporarily(?) commented out.
5273 We can restore it simply by removing
5274 the .ig request and the ".." at the
5275 end of the block.
5277 More text text text...
5278 @endExample
5280 @noindent
5281 produces
5283 @Example
5284 text text text@dots{}  More text text text@dots{}
5285 @endExample
5287 @noindent
5288 Note that the commented-out block of text does not
5289 cause a break.
5291 The input is read in copy-mode; auto-incremented registers @emph{are}
5292 affected (@pxref{Auto-increment}).
5293 @endDefreq
5296 @c =====================================================================
5298 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5299 @section Registers
5300 @cindex registers
5302 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
5303 are a number of built-in registers, supplying anything from the date to
5304 details of formatting parameters.
5306 @xref{Identifiers}, for details on register identifiers.
5308 @menu
5309 * Setting Registers::
5310 * Interpolating Registers::
5311 * Auto-increment::
5312 * Assigning Formats::
5313 * Built-in Registers::
5314 @end menu
5316 @c ---------------------------------------------------------------------
5318 @node Setting Registers, Interpolating Registers, Registers, Registers
5319 @subsection Setting Registers
5320 @cindex setting registers (@code{nr}, @code{\R})
5321 @cindex registers, setting (@code{nr}, @code{\R})
5323 Define or set registers using the @code{nr} request or the
5324 @code{\R} escape.
5326 @DefreqList {nr, ident value}
5327 @DefescListEnd {\\R, ', ident value, '}
5328 Set number register @var{ident} to @var{value}.  If @var{ident}
5329 doesn't exist, @code{gtroff} creates it.
5331 The argument to @code{\R} usually has to be enclosed in quotes.
5332 @xref{Escapes}, for details on parameter delimiting characters.
5334 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5335 with other words, it vanishes completely after @code{gtroff} has
5336 processed it.
5337 @endDefreq
5339 For example, the following two lines are equivalent:
5341 @Example
5342 .nr a 1
5343 \R'a 1'
5344 @endExample
5346 Both @code{nr} and @code{\R} have two additional special forms to
5347 increment or decrement a register.
5349 @DefreqList {nr, ident @t{+}@Var{value}}
5350 @DefreqItem {nr, ident @t{-}@Var{value}}
5351 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5352 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5353 Increment (decrement) register @var{ident} by @var{value}.
5355 @Example
5356 .nr a 1
5357 .nr a +1
5359     @result{} 2
5360 @endExample
5362 @cindex negating register values
5363 To assign the negated value of a register to another register, some care
5364 must be taken to get the desired result:
5366 @Example
5367 .nr a 7
5368 .nr b 3
5369 .nr a -\nb
5371     @result{} 4
5372 .nr a (-\nb)
5374     @result{} -3
5375 @endExample
5377 @noindent
5378 The surrounding parentheses prevent the interpretation of the minus sign
5379 as a decrementing operator.  An alternative is to start the assignment
5380 with a @samp{0}:
5382 @Example
5383 .nr a 7
5384 .nr b -3
5385 .nr a \nb
5387     @result{} 4
5388 .nr a 0\nb
5390     @result{} -3
5391 @endExample
5392 @endDefreq
5394 @Defreq {rr, ident}
5395 Remove number register @var{ident}.  If @var{ident} doesn't exist, the
5396 request is ignored.
5397 @endDefreq
5399 @Defreq {rnn, ident1 ident2}
5400 Rename number register @var{ident1} to @var{ident2}.  If either
5401 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5402 @endDefreq
5404 @Defreq {aln, ident1 ident2}
5405 Create an alias @var{ident1} for a number register @var{ident2}.  The
5406 new name and the old name are exactly equivalent.  If @var{ident1} is
5407 undefined, a warning of type @samp{reg} is generated, and the request
5408 is ignored.  @xref{Debugging}, for information about warnings.
5409 @endDefreq
5411 @c ---------------------------------------------------------------------
5413 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5414 @subsection Interpolating Registers
5415 @cindex interpolating registers (@code{\n})
5416 @cindex registers, interpolating (@code{\n})
5418 Numeric registers can be accessed via the @code{\n} escape.
5420 @cindex nested assignments
5421 @cindex assignments, nested
5422 @cindex indirect assignments
5423 @cindex assignments, indirect
5424 @DefescList {\\n, , i, }
5425 @DefescItem {\\n, @lparen{}, id, }
5426 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5427 Interpolate number register with name @var{ident} (one-character name@w{
5428 }@var{i}, two-character name @var{id}). This means that the value of the
5429 register is expanded in-place while @code{gtroff} is parsing the input line.
5430 Nested assignments (also called indirect assignments) are possible.
5432 @Example
5433 .nr a 5
5434 .nr as \na+\na
5435 \n(as
5436     @result{} 10
5437 @endExample
5439 @Example
5440 .nr a1 5
5441 .nr ab 6
5442 .ds str b
5443 .ds num 1
5444 \n[a\n[num]]
5445     @result{} 5
5446 \n[a\*[str]]
5447     @result{} 6
5448 @endExample
5449 @endDefesc
5451 @c ---------------------------------------------------------------------
5453 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5454 @subsection Auto-increment
5455 @cindex auto-increment
5456 @cindex increment, automatic
5458 Number registers can also be auto-incremented and auto-decremented.
5459 The increment or decrement value can be specified with a third
5460 argument to the @code{nr} request or @code{\R} escape.
5462 @cindex @code{\R}, difference to @code{nr}
5463 @Defreq {nr, ident value incr}
5464 Set number register @var{ident} to @var{value}; the increment for
5465 auto-incrementing is set to @var{incr}.  Note that the @code{\R}
5466 escape doesn't support this notation.
5467 @endDefreq
5469 To activate auto-incrementing, the escape @code{\n} has a special
5470 syntax form.
5472 @DefescList {\\n, +, i, }
5473 @DefescItem {\\n, -, i, }
5474 @DefescItem {\\n, @lparen{}+, id, }
5475 @DefescItem {\\n, @lparen{}-, id, }
5476 @DefescItem {\\n, +@lparen{}, id, }
5477 @DefescItem {\\n, -@lparen{}, id, }
5478 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5479 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5480 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5481 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5482 Before interpolating, increment or decrement @var{ident}
5483 (one-character name@w{ }@var{i}, two-character name @var{id}) by the
5484 auto-increment value as specified with the @code{nr} request (or the
5485 @code{\R} escape).  If no auto-increment value has been specified,
5486 these syntax forms are identical to @code{\n}.
5487 @endDefesc
5489 For example,
5491 @Example
5492 .nr a 0 1
5493 .nr xx 0 5
5494 .nr foo 0 -2
5495 \n+a, \n+a, \n+a, \n+a, \n+a
5497 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5499 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5500 @endExample
5502 @noindent
5503 produces
5505 @Example
5506 1, 2, 3, 4, 5
5507 -5, -10, -15, -20, -25
5508 -2, -4, -6, -8, -10
5509 @endExample
5511 @cindex increment value without changing the register
5512 @cindex value, incrementing without changing the register
5513 To change the increment value without changing the value of a register
5514 (@var{a} in the example), the following can be used:
5516 @Example
5517 .nr a \na 10
5518 @endExample
5520 @c ---------------------------------------------------------------------
5522 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5523 @subsection Assigning Formats
5524 @cindex assigning formats (@code{af})
5525 @cindex formats, assigning (@code{af})
5527 When a register is used in the text of an input file (as opposed to
5528 part of an expression), it is textually replaced (or interpolated)
5529 with a representation of that number.  This output format can be
5530 changed to a variety of formats (numbers, Roman numerals, etc.).  This
5531 is done using the @code{af} request.
5533 @Defreq {af, ident format}
5534 Change the output format of a number register.  The first argument
5535 @var{ident} is the name of the number register to be changed, and the
5536 second argument @var{format} is the output format.  The following
5537 output formats are available:
5539 @table @code
5540 @item 1
5541 Decimal arabic numbers.  This is the default format: 0, 1, 2, 3,@w{
5542 }@enddots{}
5544 @item 0@dots{}0
5545 Decimal numbers with as many digits as specified.  So, @samp{00} would
5546 result in printing numbers as 01, 02, 03,@w{ }@enddots{}
5548 In fact, any digit instead of zero will do; @code{gtroff} only counts
5549 how many digits are specified.  As a consequence, @code{af}'s default
5550 format @samp{1} could be specified as @samp{0} also (and exactly this is
5551 returned by the @code{\g} escape, see below).
5553 @item I
5554 @cindex Roman numerals
5555 @cindex numerals, Roman
5556 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@enddots{}
5558 @item i
5559 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@enddots{}
5561 @item A
5562 Upper-case letters: 0, A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@enddots{}
5564 @item a
5565 Lower-case letters: 0, a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@enddots{}
5566 @end table
5568 Omitting the number register format causes a warning of type
5569 @samp{missing}.  @xref{Debugging}, for more details.  Specifying a
5570 nonexistent format causes an error.
5572 The following example produces @samp{10, X, j, 010}:
5574 @Example
5575 .nr a 10
5576 .af a 1           \" the default format
5577 \na,
5578 .af a I
5579 \na,
5580 .af a a
5581 \na,
5582 .af a 001
5584 @endExample
5586 @cindex Roman numerals, maximum and minimum
5587 @cindex maximum values of Roman numerals
5588 @cindex minimum values of Roman numerals
5589 The largest number representable for the @samp{i} and @samp{I} formats
5590 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5591 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5592 @code{gtroff}.  Currently, the correct glyphs of Roman numeral five
5593 thousand and Roman numeral ten thousand (Unicode code points
5594 @code{U+2182} and @code{U+2181}, respectively) are not available.
5596 If @var{ident} doesn't exist, it is created.
5598 @cindex read-only register, changing format
5599 @cindex changing format, read-only register
5600 Changing the output format of a read-only register causes an error.  It
5601 is necessary to first copy the register's value to a writeable register,
5602 then apply the @code{af} request to this other register.
5603 @endDefreq
5605 @cindex format of register (@code{\g})
5606 @cindex register, format (@code{\g})
5607 @DefescList {\\g, , i, }
5608 @DefescItem {\\g, @lparen{}, id, }
5609 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5610 Return the current format of the specified register @var{ident}
5611 (one-character name@w{ }@var{i}, two-character name @var{id}).  For
5612 example, @samp{\ga} after the previous example would produce the
5613 string @samp{000}.  If the register hasn't been defined yet, nothing
5614 is returned.
5615 @endDefesc
5617 @c ---------------------------------------------------------------------
5619 @node Built-in Registers,  , Assigning Formats, Registers
5620 @subsection Built-in Registers
5621 @cindex built-in registers
5622 @cindex registers, built-in
5624 The following lists some built-in registers which are not described
5625 elsewhere in this manual.  Any register which begins with a @samp{.} is
5626 read-only.  A complete listing of all built-in registers can be found in
5627 @ref{Register Index}.
5629 @table @code
5630 @item .H
5631 @cindex horizontal resolution register (@code{.H})
5632 @cindex resolution, horizontal, register (@code{.H})
5633 @vindex .H
5634 Horizontal resolution in basic units.
5636 @item .V
5637 @cindex vertical resolution register (@code{.V})
5638 @cindex resolution, vertical, register (@code{.V})
5639 @vindex .V
5640 Vertical resolution in basic units.
5642 @item dw
5643 @cindex day of the week register (@code{dw})
5644 @cindex date, day of the week register (@code{dw})
5645 @vindex dw
5646 Day of the week (1-7).
5648 @item dy
5649 @cindex day of the month register (@code{dy})
5650 @cindex date, day of the month register (@code{dy})
5651 @vindex dy
5652 Day of the month (1-31).
5654 @item mo
5655 @cindex month of the year register (@code{mo})
5656 @cindex date, month of the year register (@code{mo})
5657 @vindex mo
5658 Current month (1-12).
5660 @item year
5661 @cindex date, year register (@code{year}, @code{yr})
5662 @cindex year, current, register (@code{year}, @code{yr})
5663 @vindex year
5664 The current year.
5666 @item yr
5667 @vindex yr
5668 The current year minus@w{ }1900.  Unfortunately, the documentation of
5669 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5670 incorrectly claimed that @code{yr} contains the last two digits of the
5671 year.  That claim has never been true of either traditional @code{troff}
5672 or GNU @code{troff}.  Old @code{troff} input that looks like this:
5674 @Example
5675 '\" The following line stopped working after 1999
5676 This document was formatted in 19\n(yr.
5677 @endExample
5679 @noindent
5680 can be corrected as follows:
5682 @Example
5683 This document was formatted in \n[year].
5684 @endExample
5686 @noindent
5687 or, to be portable to older @code{troff} versions, as follows:
5689 @Example
5690 .nr y4 1900+\n(yr
5691 This document was formatted in \n(y4.
5692 @endExample
5694 @item .c
5695 @vindex .c
5696 @itemx c.
5697 @vindex c.
5698 @cindex input line number register (@code{.c}, @code{c.})
5699 @cindex line number, input, register (@code{.c}, @code{c.})
5700 The current @emph{input} line number.  Register @samp{.c} is read-only,
5701 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5702 affecting both @samp{.c} and @samp{c.}.
5704 @item ln
5705 @vindex ln
5706 @cindex output line number register (@code{ln})
5707 @cindex line number, output, register (@code{ln})
5708 The current @emph{output} line number after a call to the @code{nm}
5709 request to activate line numbering.
5711 @xref{Miscellaneous}, for more information about line numbering.
5713 @item .x
5714 @vindex .x
5715 @cindex major version number register (@code{.x})
5716 @cindex version number, major, register (@code{.x})
5717 The major version number.  For example, if the version number is@w{
5718 }1.03 then @code{.x} contains@w{ }@samp{1}.
5720 @item .y
5721 @vindex .y
5722 @cindex minor version number register (@code{.y})
5723 @cindex version number, minor, register (@code{.y})
5724 The minor version number.  For example, if the version number is@w{
5725 }1.03 then @code{.y} contains@w{ }@samp{03}.
5727 @item .Y
5728 @vindex .Y
5729 @cindex revision number register (@code{.Y})
5730 The revision number of @code{groff}.
5732 @item $$
5733 @vindex $$
5734 @cindex process ID of @code{gtroff} register (@code{$$})
5735 @cindex @code{gtroff}, process ID register (@code{$$})
5736 The process ID of @code{gtroff}.
5738 @item .g
5739 @vindex .g
5740 @cindex @code{gtroff} identification register (@code{.g})
5741 @cindex GNU-specific register (@code{.g})
5742 Always@w{ }1.  Macros should use this to determine whether they are
5743 running under GNU @code{troff}.
5745 @item .A
5746 @vindex .A
5747 @cindex @acronym{ASCII} approximation output register (@code{.A})
5748 If the command line option @option{-a} is used to produce an
5749 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5750 otherwise.  @xref{Groff Options}.
5752 @item .P
5753 @vindex .P
5754 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5755 page is actually being printed, i.e., if the @option{-o} option is being
5756 used to only print selected pages.  @xref{Groff Options}, for more
5757 information.
5759 @item .T
5760 @vindex .T
5761 If @code{gtroff} is called with the @option{-T} command line option, the
5762 number register @code{.T} is set to@w{ }1, and zero otherwise.
5763 @xref{Groff Options}.
5765 @stindex .T
5766 @cindex output device name string register (@code{.T})
5767 Additionally, @code{gtroff} predefines a single read-write string
5768 register @code{.T} which contains the current output device (for
5769 example, @samp{latin1} or @samp{ps}).
5770 @end table
5773 @c =====================================================================
5775 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5776 @section Manipulating Filling and Adjusting
5777 @cindex manipulating filling and adjusting
5778 @cindex filling and adjusting, manipulating
5779 @cindex adjusting and filling, manipulating
5780 @cindex justifying text
5781 @cindex text, justifying
5783 @cindex break
5784 @cindex line break
5785 @cindex @code{bp} request, causing implicit linebreak
5786 @cindex @code{ce} request, causing implicit linebreak
5787 @cindex @code{cf} request, causing implicit linebreak
5788 @cindex @code{fi} request, causing implicit linebreak
5789 @cindex @code{fl} request, causing implicit linebreak
5790 @cindex @code{in} request, causing implicit linebreak
5791 @cindex @code{nf} request, causing implicit linebreak
5792 @cindex @code{rj} request, causing implicit linebreak
5793 @cindex @code{sp} request, causing implicit linebreak
5794 @cindex @code{ti} request, causing implicit linebreak
5795 @cindex @code{trf} request, causing implicit linebreak
5796 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5797 Breaks}.  The @code{br} request likewise causes a break.  Several
5798 other requests also cause breaks, but implicitly.  These are
5799 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5800 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5802 @Defreq {br, }
5803 Break the current line, i.e., the input collected so far is emitted
5804 without adjustment.
5806 If the no-break control character is used, @code{gtroff} suppresses
5807 the break:
5809 @Example
5813     @result{} a b
5814 @endExample
5815 @endDefreq
5817 Initially, @code{gtroff} fills and adjusts text to both margins.
5818 Filling can be disabled via the @code{nf} request and re-enabled with
5819 the @code{fi} request.
5821 @cindex fill mode (@code{fi})
5822 @cindex mode, fill (@code{fi})
5823 @DefreqList {fi, }
5824 @DefregListEnd {.u}
5825 Activate fill mode (which is the default).  This request implicitly
5826 enables adjusting; it also inserts a break in the text currently being
5827 filled.  The read-only number register @code{.u} is set to@w{ }1.
5829 The fill mode status is associated with the current environment
5830 (@pxref{Environments}).
5832 See @ref{Line Control}, for interaction with the @code{\c} escape.
5833 @endDefreq
5835 @cindex no-fill mode (@code{nf})
5836 @cindex mode, no-fill (@code{nf})
5837 @Defreq {nf, }
5838 Activate no-fill mode.  Input lines are output as-is, retaining line
5839 breaks and ignoring the current line length.  This command implicitly
5840 disables adjusting; it also causes a break.  The number register
5841 @code{.u} is set to@w{ }0.
5843 The fill mode status is associated with the current environment
5844 (@pxref{Environments}).
5846 See @ref{Line Control}, for interaction with the @code{\c} escape.
5847 @endDefreq
5849 @DefreqList {ad, [@Var{mode}]}
5850 @DefregListEnd {.j}
5851 Set adjusting mode.
5853 Activation and deactivation of adjusting is done implicitly with
5854 calls to the @code{fi} or @code{nf} requests.
5856 @var{mode} can have one of the following values:
5858 @table @code
5859 @item l
5860 @cindex ragged-right
5861 Adjust text to the left margin.  This produces what is traditionally
5862 called ragged-right text.
5864 @item r
5865 @cindex ragged-left
5866 Adjust text to the right margin, producing ragged-left text.
5868 @item c
5869 @cindex centered text
5870 @cindex @code{ce} request, difference to @code{ad@w{ }c}
5871 Center filled text.  This is different to the @code{ce} request which
5872 only centers text without filling.
5874 @item b
5875 @itemx n
5876 Justify to both margins.  This is the default used by @code{gtroff}.
5877 @end table
5879 With no argument, @code{gtroff} adjusts lines in the same way it did
5880 before adjusting was deactivated (with a call to @code{na}, for
5881 example).
5883 @Example
5884 text
5885 .ad r
5886 text
5887 .ad c
5888 text
5890 text
5891 .ad  \" back to centering
5892 text
5893 @endExample
5895 @cindex adjustment mode register (@code{.j})
5896 The current adjustment mode is available in the read-only number
5897 register @code{.j}; it can be stored and subsequently used to set
5898 adjustment.
5900 The adjustment mode status is associated with the current environment
5901 (@pxref{Environments}).
5902 @endDefreq
5904 @Defreq {na, }
5905 Disable adjusting.  This request won't change the current adjustment
5906 mode: A subsequent call to @code{ad} uses the previous adjustment
5907 setting.
5909 The adjustment mode status is associated with the current environment
5910 (@pxref{Environments}).
5911 @endDefreq
5913 @DefreqList {brp, }
5914 @DefescListEnd {\\p, , , }
5915 Adjust the current line and cause a break.
5917 In most cases this produces very ugly results since @code{gtroff}
5918 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5919 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5920 line by line:
5922 @Example
5923   This is an uninteresting sentence.
5924   This is an uninteresting sentence.\p
5925   This is an uninteresting sentence.
5926 @endExample
5928 @noindent
5929 is formatted as
5931 @Example
5932   This is  an uninteresting  sentence.   This  is an
5933   uninteresting                            sentence.
5934   This is an uninteresting sentence.
5935 @endExample
5936 @endDefreq
5938 @cindex word space size register (@code{.ss})
5939 @cindex size of word space register (@code{.ss})
5940 @cindex space between words register (@code{.ss})
5941 @cindex sentence space size register (@code{.sss})
5942 @cindex size of sentence space register (@code{.sss})
5943 @cindex space between sentences register (@code{.sss})
5944 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5945 @DefregItem {.ss}
5946 @DefregListEnd {.sss}
5947 Change the minimum size of a space between filled words.  It takes its
5948 units as one twelfth of the space width parameter for the current
5949 font.  Initially both the @var{word_space_size} and
5950 @var{sentence_space_size} are@w{ }12.
5952 @cindex fill mode
5953 @cindex mode, fill
5954 If two arguments are given to the @code{ss} request, the second
5955 argument sets the sentence space size.  If the second argument is not
5956 given, sentence space size is set to @var{word_space_size}.  The
5957 sentence space size is used in two circumstances: If the end of a
5958 sentence occurs at the end of a line in fill mode, then both an
5959 inter-word space and a sentence space are added; if two spaces follow
5960 the end of a sentence in the middle of a line, then the second space
5961 is a sentence space.  If a second argument is never given to the
5962 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
5963 same as that exhibited by GNU @code{troff}.  In GNU @code{troff}, as
5964 in @acronym{UNIX} @code{troff}, a sentence should always be followed
5965 by either a newline or two spaces.
5967 The read-only number registers @code{.ss} and @code{.sss} hold the
5968 values of the parameters set by the first and second arguments of the
5969 @code{ss} request.
5971 The word space and sentence space values are associated with the current
5972 environment (@pxref{Environments}).
5974 Contrary to traditional Unix @code{troff}, this request is @emph{not}
5975 ignored if a tty output device is used; the given values are then
5976 rounded down to a multiple of@w{ }12.
5978 @c XXX xref implementation differences
5980 The request is ignored if there is no parameter.
5981 @endDefreq
5983 @cindex centering lines (@code{ce})
5984 @cindex lines, centering (@code{ce})
5985 @DefreqList {ce, [@Var{nnn}]}
5986 @DefregListEnd {.ce}
5987 Center text.  While the @w{@samp{.ad c}} request also centers text,
5988 it fills the text as well.  @code{ce} does not fill the
5989 text it affects.  This request causes a break.  The number of lines
5990 still to be centered is associated with the current environment
5991 (@pxref{Environments}).
5993 The following example demonstrates the differences.
5994 Here the input:
5996 @Example
5997 .ll 4i
5998 .ce 1000
5999 This is a small text fragment which shows the differences
6000 between the `.ce' and the `.ad c' request.
6001 .ce 0
6003 .ad c
6004 This is a small text fragment which shows the differences
6005 between the `.ce' and the `.ad c' request.
6006 @endExample
6008 @noindent
6009 And here the result:
6011 @Example
6012   This is a small text fragment which
6013          shows the differences
6014 between the `.ce' and the `.ad c' request.
6016   This is a small text fragment which
6017 shows the differences between the `.ce'
6018         and the `.ad c' request.
6019 @endExample
6021 With no arguments, @code{ce} centers the next line of text.  @var{nnn}
6022 specifies the number of lines to be centered.  If the argument is zero
6023 or negative, centering is disabled.
6025 The basic length for centering text is the line length (as set with the
6026 @code{ll} request) minus the indentation (as set with the @code{in}
6027 request).  Temporary indentation is ignored.
6029 As can be seen in the previous example, it is a common idiom to turn
6030 on centering for a large number of lines, and to turn off centering
6031 after text to be centered.  This is useful for any request which takes
6032 a number of lines as an argument.
6034 The @code{.ce} read-only number register contains the number of lines
6035 remaining to be centered, as set by the @code{ce} request.
6036 @endDefreq
6038 @cindex justifying text (@code{rj})
6039 @cindex text, justifying (@code{rj})
6040 @cindex right-justifying (@code{rj})
6041 @DefreqList {rj, [@Var{nnn}]}
6042 @DefregListEnd {.rj}
6043 Justify unfilled text to the right margin.  Arguments are identical to
6044 the @code{ce} request.  The @code{.rj} read-only number register is
6045 the number of lines to be right-justified as set by the @code{rj}
6046 request.  This request causes a break.  The number of lines still to be
6047 right-justified is associated with the current environment
6048 (@pxref{Environments}).
6049 @endDefreq
6052 @c =====================================================================
6054 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6055 @section Manipulating Hyphenation
6056 @cindex manipulating hyphenation
6057 @cindex hyphenation, manipulating
6059 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
6060 There are a number of ways to influence hyphenation.
6062 @DefreqList {hy, [@Var{mode}]}
6063 @DefregListEnd {.hy}
6064 Enable hyphenation.  The request has an optional numeric argument,
6065 @var{mode}, to restrict hyphenation if necessary:
6067 @table @code
6068 @item 1
6069 The default argument if @var{mode} is omitted.  Hyphenate without
6070 restrictions.  This is also the start-up value of @code{gtroff}.
6072 @item 2
6073 Do not hyphenate the last word on a page or column.
6075 @item 4
6076 Do not hyphenate the last two characters of a word.
6078 @item 8
6079 Do not hyphenate the first two characters of a word.
6080 @end table
6082 Values in the previous table are additive.  For example, the value@w{
6083 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
6084 two characters of a word.
6086 @cindex hyphenation restrictions register (@code{.hy})
6087 The current hyphenation restrictions can be found in the read-only
6088 number register @samp{.hy}.
6090 The hyphenation mode is associated with the current environment
6091 (@pxref{Environments}).
6092 @endDefreq
6094 @Defreq {nh, }
6095 Disable hyphenation (i.e., set the hyphenation mode to zero).  Note
6096 that the hyphenation mode of the last call to @code{hy} is not
6097 remembered.
6099 The hyphenation mode is associated with the current environment
6100 (@pxref{Environments}).
6101 @endDefreq
6103 @cindex explicit hyphen (@code{\%})
6104 @cindex hyphen, explicit (@code{\%})
6105 @cindex consecutive hyphenated lines (@code{hlm})
6106 @cindex lines, consecutive hyphenated (@code{hlm})
6107 @cindex hyphenated lines, consecutive (@code{hlm})
6108 @DefreqList {hlm, [@Var{nnn}]}
6109 @DefregItem {.hlm}
6110 @DefregListEnd {.hlc}
6111 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
6112 If this number is negative, there is no maximum.  The default value
6113 is@w{ }@minus{}1 if @var{nnn} is omitted.  This value is associated
6114 with the current environment (@pxref{Environments}).  Only lines
6115 output from a given environment count towards the maximum associated
6116 with that environment.  Hyphens resulting from @code{\%} are counted;
6117 explicit hyphens are not.
6119 The current setting of @code{hlm} is available in the @code{.hlm}
6120 read-only number register.  Also the number of immediately preceding
6121 consecutive hyphenated lines are available in the read-only number
6122 register @samp{.hlc}.
6123 @endDefreq
6125 @Defreq {hw, word1 word2 @dots{}}
6126 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated.  The
6127 words must be given with hyphens at the hyphenation points.  For
6128 example:
6130 @Example
6131 .hw in-sa-lub-rious
6132 @endExample
6134 @noindent
6135 Besides the space character, any character whose hyphenation code value
6136 is zero can be used to separate the arguments of @code{hw} (see the
6137 documentation for the @code{hcode} request below for more information).
6138 In addition, this request can be used more than once.
6140 Hyphenation exceptions specified with the @code{hw} request are
6141 associated with the current hyphenation language; it causes an error
6142 if there is no current hyphenation language.
6144 This request is ignored if there is no parameter.
6146 In old versions of @code{troff} there was a limited amount of space to
6147 store such information; fortunately, with @code{gtroff}, this is no
6148 longer a restriction.
6149 @endDefreq
6151 @cindex hyphenation character (@code{\%})
6152 @cindex character, hyphenation (@code{\%})
6153 @cindex disabling hyphenation (@code{\%})
6154 @cindex hyphenation, disabling (@code{\%})
6155 @DefescList {\\%, , , }
6156 @deffnx Escape @t{\:}
6157 @ifnotinfo
6158 @esindex \:
6159 @end ifnotinfo
6160 @ifinfo
6161 @esindex @r{<colon>}
6162 @end ifinfo
6163 To tell @code{gtroff} how to hyphenate words on the fly, use the
6164 @code{\%} escape, also known as the @dfn{hyphenation character}.
6165 Preceding a word with this character prevents it from being
6166 hyphenated; putting it inside a word indicates to @code{gtroff} that
6167 the word may be hyphenated at that point.  Note that this mechanism
6168 only affects that one occurrence of the word; to change the
6169 hyphenation of a word for the entire document, use the @code{hw}
6170 request.
6172 The @code{\:} escape inserts a zero-width break point
6173 (that is, the word breaks but without adding a hyphen).
6175 @Example
6176 ... check the /var/log/\:httpd/\:access_log file ...
6177 @endExample
6178 @endDefesc
6180 @Defreq {hc, [@Var{char}]}
6181 Change the hyphenation character to @var{char}.  This character then
6182 works the same as the @code{\%} escape, and thus, no longer appears in
6183 the output.  Without an argument, @code{hc} resets the hyphenation
6184 character to be @code{\%} (the default) only.
6186 The hyphenation character is associated with the current environment
6187 (@pxref{Environments}).
6188 @endDefreq
6190 @cindex hyphenation patterns (@code{hpf})
6191 @cindex patterns for hyphenation (@code{hpf})
6192 @DefreqList {hpf, pattern_file}
6193 @DefreqItem {hpfa, pattern_file}
6194 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6195 Read in a file of hyphenation patterns.  This file is searched for in
6196 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6197 searched for if the @option{-m@var{name}} option is specified.
6199 It should have the same format as (simple) @TeX{} patterns files.
6200 More specifically, the following scanning rules are implemented.
6202 @itemize @bullet
6203 @item
6204 A percent sign starts a comment (up to the end of the line)
6205 even if preceded by a backslash.
6207 @item
6208 No support for `digraphs' like @code{\$}.
6210 @item
6211 The only multi-character construction recognized is @code{^^@var{xx}}
6212 (@var{x} is 0-9 or a-f);  other use of @code{^} causes an error.
6214 @item
6215 No macro expansion.
6217 @item
6218 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6219 (possibly with whitespace before and after the braces).
6220 Everything between the braces is taken as hyphenation patterns.
6221 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6223 @item
6224 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6225 exceptions.
6227 @item
6228 @code{\endinput} is recognized also.
6230 @item
6231 For backwards compatibility, if @code{\patterns} is missing,
6232 the whole file is treated as a list of hyphenation patterns
6233 (only recognizing the @code{%} character as the start of a comment).
6234 @end itemize
6236 If no @code{hpf} request is specified (either in the document or in a
6237 macro package), @code{gtroff} won't hyphenate at all.
6239 The @code{hpfa} request appends a file of patterns to the current list.
6241 The @code{hpfcode} request defines mapping values for character codes in
6242 hyphenation patterns.  @code{hpf} or @code{hpfa} then apply the mapping
6243 (after reading the patterns) before replacing or appending them to
6244 the current list of patterns.  Its arguments are pairs of character codes
6245 -- integers from 0 to@w{ }255.  The request maps character code@w{ }@var{a}
6246 to code@w{ }@var{b}, code@w{ }@var{c} to code@w{ }@var{d}, and so on.  You
6247 can use character codes which would be invalid otherwise.
6249 @pindex troffrc
6250 @pindex troffrc-end
6251 @pindex hyphen.us
6252 The set of hyphenation patterns is associated with the current language
6253 set by the @code{hla} request.  The @code{hpf} request is usually
6254 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6255 @file{troffrc} loads hyphenation patterns for American English (in file
6256 @file{hyphen.us}).
6258 A second call to @code{hpf} (for the same language) will replace the
6259 hyphenation patterns with the new ones.
6261 Invoking @code{hpf} causes an error if there is no current hyphenation
6262 language.
6263 @endDefreq
6265 @cindex hyphenation code (@code{hcode})
6266 @cindex code, hyphenation (@code{hcode})
6267 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6268 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6269 @var{c2} to @var{code2}, etc.  A hyphenation code must be a single
6270 input character (not a special character) other than a digit or a
6271 space.  Initially each lower-case letter (@samp{a}-@samp{z}) has its
6272 hyphenation code set to itself, and each upper-case letter
6273 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6274 version of itself.
6276 This request is ignored if it has no parameter.
6277 @endDefreq
6279 @cindex hyphenation margin (@code{hym})
6280 @cindex margin for hyphenation (@code{hym})
6281 @cindex @code{ad} request, and hyphenation margin
6282 @DefreqList {hym, [@Var{length}]}
6283 @DefregListEnd {.hym}
6284 Set the (right) hyphenation margin to @var{length}.  If the current
6285 adjustment mode is not @samp{b} or @samp{n}, the line is not
6286 hyphenated if it is shorter than @var{length}.  Without an argument,
6287 the hyphenation margin is reset to its default value, which is@w{ }0.
6288 The default scaling indicator for this request is @samp{m}.  The
6289 hyphenation margin is associated with the current environment
6290 (@pxref{Environments}).
6292 A negative argument resets the hyphenation margin to zero, emitting
6293 a warning of type @samp{range}.
6295 @cindex hyphenation margin register (@code{.hym})
6296 The current hyphenation margin is available in the @code{.hym} read-only
6297 number register.
6298 @endDefreq
6300 @cindex hyphenation space (@code{hys})
6301 @cindex @code{ad} request, and hyphenation space
6302 @DefreqList {hys, [@Var{hyphenation_space}]}
6303 @DefregListEnd {.hys}
6304 Set the hyphenation space to @var{hyphenation_space}.  If the current
6305 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6306 if it can be justified by adding no more than @var{hyphenation_space}
6307 extra space to each word space.  Without argument, the hyphenation
6308 space is set to its default value, which is@w{ }0.  The default
6309 scaling indicator for this request is @samp{m}.  The hyphenation
6310 space is associated with the current environment
6311 (@pxref{Environments}).
6313 A negative argument resets the hyphenation space to zero, emitting a
6314 warning of type @samp{range}.
6316 @cindex hyphenation space register (@code{.hys})
6317 The current hyphenation space is available in the @code{.hys} read-only
6318 number register.
6319 @endDefreq
6321 @cindex soft hyphen character, setting (@code{shc})
6322 @cindex character, soft hyphen, setting (@code{shc})
6323 @cindex glyph, soft hyphen (@code{hy})
6324 @cindex soft hyphen glyph (@code{hy})
6325 @cindex @code{char} request, and soft hyphen character
6326 @cindex @code{tr} request, and soft hyphen character
6327 @Defreq {shc, [@Var{char}]}
6328 Set the soft hyphen character to @var{char}.  If the argument is
6329 omitted, the soft hyphen character is set to the default character
6330 @code{\(hy} (this is the start-up value of @code{gtroff} also).  The
6331 soft hyphen character is the character that is inserted when a word is
6332 hyphenated at a line break.  If the soft hyphen character does not
6333 exist in the font of the character immediately preceding a potential
6334 break point, then the line is not broken at that point.  Neither
6335 definitions (specified with the @code{char} request) nor translations
6336 (specified with the @code{tr} request) are considered when finding the
6337 soft hyphen character.
6338 @endDefreq
6340 @cindex @code{hpf} request, and hyphenation language
6341 @cindex @code{hw} request, and hyphenation language
6342 @pindex troffrc
6343 @pindex troffrc-end
6344 @DefreqList {hla, language}
6345 @DefregListEnd {.hla}
6346 Set the current hyphenation language to the string @var{language}.
6347 Hyphenation exceptions specified with the @code{hw} request and
6348 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6349 requests are both associated with the current hyphenation language.
6350 The @code{hla} request is usually invoked by the @file{troffrc} or the
6351 @file{troffrc-end} files; @file{troffrc} sets the default language to
6352 @samp{us}.
6354 @cindex hyphenation language register (@code{.hla})
6355 The current hyphenation language is available as a string in the
6356 read-only number register @samp{.hla}.
6358 @Example
6359 .ds curr_language \n[.hla]
6360 \*[curr_language]
6361     @result{} us
6362 @endExample
6363 @endDefreq
6366 @c =====================================================================
6368 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6369 @section Manipulating Spacing
6370 @cindex manipulating spacing
6371 @cindex spacing, manipulating
6373 @Defreq {sp, [@Var{distance}]}
6374 Space downwards @var{distance}.  With no argument it advances 1@w{
6375 }line.  A negative argument causes @code{gtroff} to move up the page
6376 the specified distance.  If the argument is preceded by a @samp{|}
6377 then @code{gtroff} moves that distance from the top of the page.  This
6378 request causes a line break.  The default scaling indicator is @samp{v}.
6379 @endDefreq
6381 @cindex double spacing (@code{ls})
6382 @DefreqList {ls, [@Var{nnn}]}
6383 @DefregListEnd {.L}
6384 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6385 With no argument, @code{gtroff} uses the previous value before the
6386 last @code{ls} call.
6388 @Example
6389 .ls 2    \" This causes double-spaced output
6390 .ls 3    \" This causes triple-spaced output
6391 .ls      \" Again double spaced
6392 @endExample
6394 The line spacing is associated with the current environment
6395 (@pxref{Environments}).
6397 @cindex line spacing register (@code{.L})
6398 The read-only number register @code{.L} contains the current line
6399 spacing setting.
6400 @endDefreq
6402 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6403 as alternatives to @code{ls}.
6405 @c XXX document \n[nl]
6406 @c XXX document \n[nl] == -1 if vertical position is zero
6408 @DefescList {\\x, ', spacing, '}
6409 @DefregListEnd {.a}
6410 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6411 to allow space for a tall construct (like an equation).  The @code{\x}
6412 escape does this.  The escape is given a numerical argument, usually
6413 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6414 is @samp{v}.  If this number is positive extra vertical space is
6415 inserted below the current line.  A negative number adds space above.
6416 If this escape is used multiple times on the same line, the maximum of
6417 the values is used.
6419 @xref{Escapes}, for details on parameter delimiting characters.
6421 @cindex extra post-vertical line space register (@code{.a})
6422 The @code{.a} read-only number register contains the most recent
6423 (nonnegative) extra vertical line space.
6425 @c XXX
6426 @ignore
6427 @Example
6428 ... example of inline equation ...
6429 @endExample
6430 @end ignore
6431 @endDefesc
6433 @cindex @code{sp} request, and no-space mode
6434 @cindex no-space mode (@code{ns})
6435 @cindex mode, no-space (@code{ns})
6436 @cindex blank lines, disabling
6437 @cindex lines, blank, disabling
6438 @DefreqList {ns, }
6439 @DefregListEnd {.ns}
6440 Enable @dfn{no-space mode}.  In this mode, spacing (either via
6441 @code{sp} or via blank lines) is disabled.  The @code{bp} request to
6442 advance to the next page is also disabled, except if it is accompanied
6443 by a page number (see @ref{Page Control}, for more information).  This
6444 mode ends when actual text is output or the @code{rs} request is
6445 encountered.  The read-only number register @code{.ns} is set to@w{ }1.
6447 This request is useful for macros that conditionally
6448 insert vertical space before the text starts
6449 (for example, a paragraph macro could insert some space
6450 except when it is the first paragraph after a section header).
6452 @c XXX xref
6453 @endDefreq
6455 @Defreq {rs, }
6456 Disable no-space mode.
6458 @c XXX xref
6459 @endDefreq
6462 @c =====================================================================
6464 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6465 @section Tabs and Fields
6466 @cindex tabs and fields
6467 @cindex fields and tabs
6469 @cindex @acronym{EBCDIC} encoding of a tab
6470 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6471 }5) causes a horizontal movement to the next tab stop (much
6472 like it did on a typewriter).
6474 @cindex tab character, non-interpreted (@code{\t})
6475 @Defesc {\\t, , , }
6476 This escape is a non-interpreted tab character.  In copy mode
6477 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6478 @endDefesc
6480 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6481 @DefregListEnd {.tabs}
6482 Change tab stop positions.  This request takes a series of tab
6483 specifiers as arguments (optionally divided into two groups with the
6484 letter @samp{T}) which indicate where each tab stop is to be
6485 (overriding any previous settings).
6487 Tab stops can be specified absolutely, i.e., as the distance from the
6488 left margin.  For example, the following sets 6@w{ }tab stops every
6489 one inch.
6491 @Example
6492 .ta 1i 2i 3i 4i 5i 6i
6493 @endExample
6495 Tab stops can also be specified using a leading @samp{+}
6496 which means that the specified tab stop is set relative to
6497 the previous tab stop.  For example, the following is equivalent to the
6498 previous example.
6500 @Example
6501 .ta 1i +1i +1i +1i +1i +1i
6502 @endExample
6504 @code{gtroff} supports an extended syntax to specify repeat values after
6505 the @samp{T} mark (these values are always taken as relative) -- this is
6506 the usual way to specify tabs set at equal intervals.  The following is,
6507 yet again, the same as the previous examples.  It does even more since
6508 it defines an infinite number of tab stops separated by one inch.
6510 @Example
6511 .ta T 1i
6512 @endExample
6514 Now we are ready to interpret the full syntax given at the beginning:
6515 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6516 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6517 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6518 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6520 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6521 20c 23c 28c 30c @dots{}}.
6523 The material in each tab column (i.e., the column between two tab stops)
6524 may be justified to the right or left or centered in the column.  This
6525 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6526 specifier.  The default justification is @samp{L}.  Example:
6528 @Example
6529 .ta 1i 2iC 3iR
6530 @endExample
6532 Some notes:
6534 @itemize @bullet
6535 @item
6536 The default unit of the @code{ta} request is @samp{m}.
6538 @item
6539 A tab stop is converted into a non-breakable horizontal movement which
6540 can be neither stretched nor squeezed.  For example,
6542 @Example
6543 .ds foo a\tb\tc
6544 .ta T 5i
6545 \*[foo]
6546 @endExample
6548 @noindent
6549 creates a single line which is a bit longer than 10@w{ }inches (a string
6550 is used to show exactly where the tab characters are).  Now consider the
6551 following:
6553 @Example
6554 .ds bar a\tb b\tc
6555 .ta T 5i
6556 \*[bar]
6557 @endExample
6559 @noindent
6560 @code{gtroff} first converts the tab stops of the line into unbreakable
6561 horizontal movements, then splits the line after the second @samp{b}
6562 (assuming a sufficiently short line length).  Usually, this isn't what
6563 the user wants.
6565 @item
6566 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6567 stop) are ignored except the first one which delimits the characters
6568 belonging to the last tab stop for right-justifying or centering.
6569 Consider the following example
6571 @Example
6572 .ds Z   foo\tbar\tfoo
6573 .ds ZZ  foo\tbar\tfoobar
6574 .ds ZZZ foo\tbar\tfoo\tbar
6575 .ta 2i 4iR
6576 \*[Z]
6578 \*[ZZ]
6580 \*[ZZZ]
6582 @endExample
6584 @noindent
6585 which produces the following output:
6587 @Example
6588 foo                 bar              foo
6589 foo                 bar           foobar
6590 foo                 bar              foobar
6591 @endExample
6593 @noindent
6594 The first line right-justifies the second `foo' relative to the tab
6595 stop.  The second line right-justifies `foobar'.  The third line finally
6596 right-justifies only `foo' because of the additional tab character which
6597 marks the end of the string belonging to the last defined tab stop.
6599 @item
6600 Tab stops are associated with the current environment
6601 (@pxref{Environments}).
6603 @item
6604 Calling @code{ta} without an argument removes all tab stops.
6606 @item
6607 @cindex tab stops, for tty output devices
6608 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}}.  This value
6609 is used even for tty output devices (contrary to @acronym{UNIX}
6610 @code{nroff} which has tab stops preset every 0.8@dmn{i}).
6612 @c XXX xref implementation differences
6613 @end itemize
6615 @cindex tab settings register (@code{.tabs})
6616 The read-only number register @code{.tabs} contains a string
6617 representation of the current tab settings suitable for use as an
6618 argument to the @code{ta} request.
6620 @Example
6621 .ds tab-string \n[.tabs]
6622 \*[tab-string]
6623     @result{} T120u
6624 @endExample
6625 @endDefreq
6627 @cindex tab repetition character (@code{tc})
6628 @cindex character, tab repetition (@code{tc})
6629 @Defreq {tc, [@Var{fill-char}]}
6630 Normally @code{gtroff} fills the space to the next tab stop with
6631 whitespace.  This can be changed with the @code{tc} request.  With no
6632 argument @code{gtroff} reverts to using whitespace, which is the
6633 default.  The value of this @dfn{tab repetition} character is
6634 associated with the current environment (@pxref{Environments}).
6635 @endDefreq
6637 @cindex tab, line-tabs mode
6638 @cindex line-tabs mode
6639 @DefreqList {linetabs, n}
6640 @DefregListEnd {.linetabs}
6641 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6642 or disable it otherwise (the default).
6643 In line-tabs mode, @code{gtroff} computes tab distances
6644 relative to the (current) output line instead of the input line.
6646 For example, the following code:
6648 @Example
6649 .ds x a\t\c
6650 .ds y b\t\c
6651 .ds z c
6652 .ta 1i 3i
6656 @endExample
6658 @noindent
6659 in normal mode, results in the output
6661 @Example
6662 a         b         c
6663 @endExample
6665 @noindent
6666 in line-tabs mode, the same code outputs
6668 @Example
6669 a         b                   c
6670 @endExample
6672 Line-tabs mode is associated with the current environment.
6673 The read-only register @code{.linetabs} is set to@w{ }1 if in line-tabs
6674 mode, and 0 in normal mode.
6675 @endDefreq
6677 @menu
6678 * Leaders::
6679 * Fields::
6680 @end menu
6682 @c ---------------------------------------------------------------------
6684 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6685 @subsection Leaders
6686 @cindex leaders
6688 Sometimes it may may be desirable to use the @code{tc} request to fill a
6689 particular tab stop with a given character (for example dots in a table
6690 of contents), but also normal tab stops on the rest of the line.  For
6691 this @code{gtroff} provides an alternate tab mechanism, called
6692 @dfn{leaders} which does just that.
6694 @cindex leader character
6695 A leader character (character code@w{ }1) behaves similarly to a tab
6696 character: It moves to the next tab stop.  The only difference is that
6697 for this movement, the fill character defaults to a period character and
6698 not to space.
6700 @cindex leader character, non-interpreted (@code{\a})
6701 @Defesc {\\a, , , }
6702 This escape is a non-interpreted leader character.  In copy mode
6703 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6704 character.
6705 @endDefesc
6707 @cindex leader repetition character (@code{lc})
6708 @cindex character, leader repetition (@code{lc})
6709 @Defreq {lc, [@Var{fill-char}]}
6710 Declare the leader character.  Without an argument, leaders act the
6711 same as tabs (i.e., using whitespace for filling).  @code{gtroff}'s
6712 start-up value is @samp{.}.  The value of this @dfn{leader repetition}
6713 character is associated with the current environment
6714 (@pxref{Environments}).
6715 @endDefreq
6717 @cindex table of contents
6718 @cindex contents, table of
6719 For a table of contents, to name an example, tab stops may be defined so
6720 that the section number is one tab stop, the title is the second with
6721 the remaining space being filled with a line of dots, and then the page
6722 number slightly separated from the dots.
6724 @Example
6725 .ds entry 1.1\tFoo\a\t12
6726 .lc .
6727 .ta 1i 5i +.25i
6728 \*[entry]
6729 @endExample
6731 @noindent
6732 This produces
6734 @Example
6735 1.1  Foo..........................................  12
6736 @endExample
6738 @c ---------------------------------------------------------------------
6740 @node Fields,  , Leaders, Tabs and Fields
6741 @subsection Fields
6742 @cindex fields
6744 @cindex field delimiting character (@code{fc})
6745 @cindex delimiting character for fields (@code{fc})
6746 @cindex character, field delimiting (@code{fc})
6747 @cindex field padding character (@code{fc})
6748 @cindex padding character for fields (@code{fc})
6749 @cindex character, field padding (@code{fc})
6750 @dfn{Fields} are a more general way of laying out tabular data.  A field
6751 is defined as the data between a pair of @dfn{delimiting characters}.
6752 It contains substrings which are separated by @dfn{padding characters}.
6753 The width of a field is the distance on the @emph{input} line from the
6754 position where the field starts to the next tab stop.  A padding
6755 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6756 command (thus it can even be negative) to make the sum of all substring
6757 lengths plus the stretchable space equal to the field width.  If more
6758 than one padding character is inserted, the available space is evenly
6759 distributed among them.
6761 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6762 Define a delimiting and a padding character for fields.  If the latter
6763 is missing, the padding character defaults to a space character.  If
6764 there is no argument at all, the field mechanism is disabled (which is
6765 the default).  Note that contrary to e.g.@: the tab repetition
6766 character, delimiting and padding characters are not associated to the
6767 current environment (@pxref{Environments}).
6769 Example:
6771 @Example
6772 .fc # ^
6773 .ta T 3i
6774 #foo^bar^smurf#
6776 #foo^^bar^smurf#
6777 @endExample
6779 @noindent
6780 and here the result:
6782 @Example
6783 foo         bar          smurf
6784 foo            bar       smurf
6785 @endExample
6786 @endDefreq
6789 @c =====================================================================
6791 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6792 @section Character Translations
6793 @cindex character translations
6794 @cindex translations of characters
6796 @cindex control character, changing (@code{cc})
6797 @cindex character, control, changing (@code{cc})
6798 @cindex no-break control character, changing (@code{c2})
6799 @cindex character, no-break control, changing (@code{c2})
6800 @cindex control character, no-break, changing (@code{c2})
6801 The control character (@samp{.}) and the no-break control character
6802 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6803 respectively.
6805 @Defreq {cc, [@Var{c}]}
6806 Set the control character to@w{ }@var{c}.  With no argument the default
6807 control character @samp{.} is restored.  The value of the control
6808 character is associated with the current environment
6809 (@pxref{Environments}).
6810 @endDefreq
6812 @Defreq {c2, [@Var{c}]}
6813 Set the no-break control character to@w{ }@var{c}.  With no argument the
6814 default control character @samp{'} is restored.  The value of the
6815 no-break control character is associated with the current environment
6816 (@pxref{Environments}).
6817 @endDefreq
6819 @cindex disabling @code{\} (@code{eo})
6820 @cindex @code{\}, disabling (@code{eo})
6821 @Defreq {eo, }
6822 Disable the escape mechanism completely.  After executing this
6823 request, the backslash character @samp{\} no longer starts an escape
6824 sequence.
6826 This request can be very helpful in writing macros since it is not
6827 necessary then to double the escape character.  Here an example:
6829 @Example
6830 .\" This is a simplified version of the
6831 .\" .BR request from the man macro package
6833 .de BR
6834 .  ds result \&
6835 .  while (\n[.$] >= 2) \@{\
6836 .    as result \fB\$1\fR\$2
6837 .    shift 2
6838 .  \@}
6839 .  if \n[.$] .as result \fB\$1
6840 \*[result]
6841 .  ft R
6844 @endExample
6845 @endDefreq
6847 @cindex escape character, changing (@code{ec})
6848 @cindex character, escape, changing (@code{ec})
6849 @Defreq {ec, [@Var{c}]}
6850 Set the escape character to@w{ }@var{c}.  With no argument the default
6851 escape character @samp{\} is restored.  It can be also used to
6852 re-enable the escape mechanism after an @code{eo} request.
6854 Note that changing the escape character globally will likely break
6855 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6856 i.e., to convert a macro definition into an internal form which is
6857 independent of its representation (@TeX{} has this mechanism).
6858 If a macro is called, it is executed literally.
6859 @endDefreq
6861 @DefreqList {ecs, }
6862 @DefreqListEnd {ecr, }
6863 The @code{ecs} request saves the current escape character
6864 in an internal register.
6865 Use this request in combination with the @code{ec} request to
6866 temporarily change the escape character.
6868 The @code{ecr} request restores the escape character
6869 saved with @code{ecs}.
6870 Without a previous call to @code{ecs}, this request
6871 sets the escape character to @code{\}.
6872 @endDefreq
6874 @DefescList {\\\\, , , }
6875 @DefescItem {\\e, , , }
6876 @DefescListEnd {\\E, , , }
6877 Print the current escape character (which is the backslash character
6878 @samp{\} by default).
6880 @code{\\} is a `delayed' backslash; more precisely, it is the default
6881 escape character followed by a backslash, which no longer has special
6882 meaning due to the leading escape character.  It is @emph{not} an escape
6883 sequence in the usual sense!  In any unknown escape sequence
6884 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6885 But if @var{X} is equal to the current escape character, no warning is
6886 emitted.
6888 As a consequence, only at top-level or in a diversion a backslash glyph is
6889 printed; in copy-in mode, it expands to a single backslash which then
6890 combines with the following character to an escape sequence.
6892 The @code{\E} escape differs from @code{\e} by printing an escape
6893 character that is not interpreted in copy mode.
6894 Use this to define strings with escapes that work
6895 when used in copy mode (for example, as a macro argument).
6896 The following example defines strings to begin and end
6897 a superscript:
6899 @Example
6900 .ds @{ \v'-.3m'\s'\Es[.s]*60/100'
6901 .ds @} \s0\v'.3m'
6902 @endExample
6904 Another example to demonstrate the differences between the various escape
6905 sequences, using a strange escape character, @samp{-}.
6907 @Example
6908 .ec -
6909 .de xxx
6910 --A'123'
6912 .xxx
6913     @result{} -A'foo'
6914 @endExample
6916 @noindent
6917 The result is surprising for most users, expecting @samp{1} since
6918 @samp{foo} is a valid identifier.  What has happened?  As mentioned
6919 above, the leading escape character makes the following character
6920 ordinary.  Written with the default escape character the sequence
6921 @samp{--} becomes @samp{\-} -- this is the minus sign.
6923 If the escape character followed by itself is a valid escape sequence,
6924 only @code{\E} yields the expected result:
6926 @Example
6927 .ec -
6928 .de xxx
6929 -EA'123'
6931 .xxx
6932     @result{} 1
6933 @endExample
6934 @endDefesc
6936 @Defesc {\\., , , }
6937 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
6938 As before, a warning message is suppressed if the escape character is
6939 followed by a dot, and the dot itself is printed.
6941 @Example
6942 .de foo
6943 .  nop foo
6945 .  de bar
6946 .    nop bar
6947 \\..
6950 .foo
6951 .bar
6952     @result{} foo bar
6953 @endExample
6955 @noindent
6956 The first backslash is consumed while the macro is read, and the second
6957 is swallowed while exexuting macro @code{foo}.
6958 @endDefesc
6960 A @dfn{translation} is a mapping of an input character to an output
6961 character.  The default mappings are given in the font definition files
6962 for the specific output device (@pxref{Font Files}); all mappings (both
6963 with @code{tr} and in the font definition files) occur at output time,
6964 i.e., the input character gets assigned the metric information of the
6965 mapped output character.
6967 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6968 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
6969 Translate character @var{a} to@w{ }@var{b}, character @var{c} to@w{
6970 }@var{d}, etc.  If there is an odd number of arguments, the last one is
6971 translated to the space character.
6973 The @code{trin} request is identical to @code{tr},
6974 but when you unformat a diversion with @code{asciify}
6975 it ignores the translation.
6976 @xref{Diversions}, for details about the @code{asciify} request.
6978 Some notes:
6980 @itemize @bullet
6981 @item
6982 @cindex @code{\(}, and translations
6983 @cindex @code{\[}, and translations
6984 @cindex @code{\'}, and translations
6985 @cindex @code{\`}, and translations
6986 @cindex @code{\-}, and translations
6987 @cindex @code{\_}, and translations
6988 @cindex @code{\C}, and translations
6989 @cindex @code{\N}, and translations
6990 @cindex @code{char} request, and translations
6991 @cindex special character
6992 @cindex character, special
6993 @cindex numbered character (@code{\N})
6994 @cindex character, numbered (@code{\N})
6995 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
6996 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
6997 characters defined with the @code{char} request, and numbered characters
6998 (@code{\N'@var{xxx}'}) can be translated also.
7000 @item
7001 @cindex @code{\e}, and translations
7002 The @code{\e} escape can be translated also.
7004 @item
7005 @cindex @code{\%}, and translations
7006 @cindex @code{\~}, and translations
7007 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
7008 @code{\%} and @code{\~} can't be mapped onto another character).
7010 @item
7011 @cindex backspace character and translations
7012 @cindex character, backspace, and translations
7013 @cindex leader character and translations
7014 @cindex character, leader, and translations
7015 @cindex newline character and translations
7016 @cindex character, newline, and translations
7017 @cindex tab character and translations
7018 @cindex character, tab, and translations
7019 @cindex @code{\a}, and translations
7020 @cindex @code{\t}, and translations
7021 The following characters can't be translated: space (with one exception,
7022 see below), backspace, newline, leader (and @code{\a}), tab (and
7023 @code{\t}).
7025 @item
7026 @cindex @code{shc} request, and translations
7027 Translations are not considered for finding the soft hyphen character
7028 set with the @code{shc} request.
7030 @item
7031 @cindex @code{\&}, and translations
7032 The character pair @samp{@var{c}\&} (this is an arbitrary character@w{
7033 }@var{c} followed by the zero width space character) maps this
7034 character to nothing.
7036 @Example
7037 .tr a\&
7038 foo bar
7039     @result{} foo br
7040 @endExample
7042 @noindent
7043 It is even possible to map the space character to nothing:
7045 @Example
7046 .tr aa \&
7047 foo bar
7048     @result{} foobar
7049 @endExample
7051 @noindent
7052 As shown in the example, the space character can't be the first
7053 character pair as an argument of @code{tr}.  Additionally, it is not
7054 possible to map the space character to any other character; requests
7055 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
7057 If justification is active, lines are justified in spite of the
7058 `empty' space character (but there is no minimal distance, i.e.@: the
7059 space character, between words).
7061 @item
7062 After an output character has been constructed (this happens at the
7063 moment immediately before the character is appended to an output
7064 character list, either by direct output, in a macro, diversion, or
7065 string), it is no longer affected by @code{tr}.
7067 @item
7068 Translating undefined characters is possible also; @code{tr} does not
7069 check whether the characters in its argument are defined.
7071 @c XXX xref
7073 @item
7074 Without an argument, the @code{tr} request is ignored.
7075 @end itemize
7076 @endDefreq
7078 @cindex @code{\!}, and @code{trnt}
7079 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7080 @code{trnt} is the same as the @code{tr} request except that the
7081 translations do not apply to text that is transparently throughput
7082 into a diversion with @code{\!}.  @xref{Diversions}, for more
7083 information.
7085 For example,
7087 @Example
7088 .tr ab
7089 .di x
7090 \!.tm a
7093 @endExample
7095 @noindent
7096 prints @samp{b} to the standard error stream; if @code{trnt} is used
7097 instead of @code{tr} it prints @samp{a}.
7098 @endDefreq
7101 @c =====================================================================
7103 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7104 @section Troff and Nroff Mode
7105 @cindex troff mode
7106 @cindex mode, troff
7107 @cindex nroff mode
7108 @cindex mode, nroff
7110 Originally, @code{nroff} and @code{troff} were two separate programs,
7111 the former for tty output, the latter for everything else.  With GNU
7112 @code{troff}, both programs are merged into one executable, sending
7113 its output to a device driver (@code{grotty} for tty devices,
7114 @code{grops} for @sc{PostScript}, etc.) which interprets the
7115 intermediate output of @code{gtroff}.  For @acronym{UNIX} @code{troff}
7116 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
7117 since the differences are hardcoded.  For GNU @code{troff}, this
7118 distinction is not appropriate because @code{gtroff} simply takes the
7119 information given in the font files for a particular device without
7120 handling requests specially if a tty output device is used.
7122 Usually, a macro package can be used with all output devices.
7123 Nevertheless, it is sometimes necessary to make a distinction between
7124 tty and non-tty devices: @code{gtroff} provides two built-in
7125 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
7126 @code{while} requests to decide whether @code{gtroff} shall behave
7127 like @code{nroff} or like @code{troff}.
7129 @pindex troffrc
7130 @pindex troffrc-end
7131 @Defreq {troff, }
7132 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7133 condition false) for @code{if}, @code{ie}, and @code{while}
7134 conditional requests.  This is the default if @code{gtroff}
7135 (@emph{not} @code{groff}) is started with the @option{-R} switch to
7136 avoid loading of the start-up files @file{troffrc} and
7137 @file{troffrc-end}.  Without @option{-R}, @code{gtroff} stays in troff
7138 mode if the output device is not a tty (e.g.@: `ps').
7139 @endDefreq
7141 @pindex tty.tmac
7142 @Defreq {nroff, }
7143 Make the @samp{n} built-in condition true (and the @samp{t} built-in
7144 condition false) for @code{if}, @code{ie}, and @code{while}
7145 conditional requests.  This is the default if @code{gtroff} uses a tty
7146 output device; the code for switching to nroff mode is in the file
7147 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
7148 @endDefreq
7150 @xref{Conditionals and Loops}, for more details on built-in
7151 conditions.
7154 @c =====================================================================
7156 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
7157 @section Line Layout
7158 @cindex line layout
7159 @cindex layout, line
7161 @cindex dimensions, line
7162 @cindex line dimensions
7163 The following drawing shows the dimensions which @code{gtroff} uses for
7164 placing a line of output onto the page.  They are labeled with the
7165 request which manipulates each dimension.
7167 @Example
7168                 -->| in |<--
7169                    |<-----------ll------------>|
7170               +----+----+----------------------+----+
7171               |    :    :                      :    |
7172               +----+----+----------------------+----+
7173            -->| po |<--
7174               |<--------paper width---------------->|
7175 @endExample
7177 @noindent
7178 These dimensions are:
7180 @ftable @code
7181 @item po
7182 @cindex left margin (@code{po})
7183 @cindex margin, left (@code{po})
7184 @cindex page offset (@code{po})
7185 @cindex offset, page (@code{po})
7186 @dfn{Page offset} -- this is the leftmost position of text on the final
7187 output, defining the @dfn{left margin}.
7189 @item in
7190 @cindex indentation (@code{in})
7191 @cindex line indentation (@code{in})
7192 @dfn{Indentation} -- this is the distance from the left margin where
7193 text is printed.
7195 @item ll
7196 @cindex line length (@code{ll})
7197 @cindex length of line (@code{ll})
7198 @dfn{Line length} -- this is the distance from the left margin to right
7199 margin.
7200 @end ftable
7202 @c XXX improve example
7204 @Example
7205 .in +.5i
7206 .ll -.5i
7207 A bunch of really boring text which should
7208 be indented from both margins.
7209 Replace me with a better (and more) example!
7210 .in -.5i
7211 .ll +.5i
7212 @endExample
7214 @pindex troffrc
7215 @DefreqList {po, [@Var{offset}]}
7216 @DefreqItem {po, @t{+}@Var{offset}}
7217 @DefreqItem {po, @t{-}@Var{offset}}
7218 @DefregListEnd {.o}
7219 Set horizontal page offset to @var{offset} (or increment or decrement
7220 the current value by @var{offset}).  Note that this request does not
7221 cause a break, so changing the page offset in the middle of text being
7222 filled may not yield the expected result.  The initial value is
7223 1@dmn{i}.  For tty output devices, it is set to 0 in the startup file
7224 @file{troffrc}; the default scaling indicator is @samp{m} (and
7225 not @samp{v} as incorrectly documented in the original
7226 @acronym{UNIX} troff manual).
7228 The current page offset can be found in the read-only number register
7229 @samp{.o}.
7231 If @code{po} is called without an argument, the page offset is reset to
7232 the previous value before the last call to @code{po}.
7234 @Example
7235 .po 3i
7236 \n[.o]
7237     @result{} 720
7238 .po -1i
7239 \n[.o]
7240     @result{} 480
7242 \n[.o]
7243     @result{} 720
7244 @endExample
7245 @endDefreq
7247 @DefreqList {in, [@Var{indent}]}
7248 @DefreqItem {in, @t{+}@Var{indent}}
7249 @DefreqItem {in, @t{-}@Var{indent}}
7250 @DefregListEnd {.i}
7251 Set indentation to @var{indent} (or increment or decrement the
7252 current value by @var{indent}).  This request causes a break.
7253 Initially, there is no indentation.
7255 If @code{in} is called without an argument, the indentation is reset to
7256 the previous value before the last call to @code{in}.  The default
7257 scaling indicator is @samp{m}.
7259 The indentation is associated with the current environment
7260 (@pxref{Environments}).
7262 If a negative indentation value is specified (which is not allowed),
7263 @code{gtroff} emits a warning of type @samp{range} and sets the
7264 indentation to zero.
7266 The effect of @code{in} is delayed until a partially collected line (if
7267 it exists) is output.  A temporary indent value is reset to zero also.
7269 The current indentation (as set by @code{in}) can be found in the
7270 read-only number register @samp{.i}.
7271 @endDefreq
7273 @DefreqList {ti, offset}
7274 @DefreqItem {ti, @t{+}@Var{offset}}
7275 @DefreqItem {ti, @t{-}@Var{offset}}
7276 @DefregListEnd {.in}
7277 Temporarily indent the next output line by @var{offset}.  If an
7278 increment or decrement value is specified, adjust the temporary
7279 indentation relative to the value set by the @code{in} request.
7281 This request causes a break; its value is associated with the current
7282 environment (@pxref{Environments}).  The default scaling indicator
7283 is @samp{m}.  A call of @code{ti} without an argument is ignored.
7285 If the total indentation value is negative (which is not allowed),
7286 @code{gtroff} emits a warning of type @samp{range} and sets the
7287 temporary indentation to zero.  `Total indentation' is either
7288 @var{offset} if specified as an absolute value, or the temporary plus
7289 normal indentation, if @var{offset} is given as a relative value.
7291 The effect of @code{ti} is delayed until a partially collected line (if
7292 it exists) is output.
7294 The read-only number register @code{.in} is the indentation that applies
7295 to the current output line.
7297 The difference between @code{.i} and @code{.in} is that the latter takes
7298 into account whether a partially collected line still uses the old
7299 indentation value or a temporary indentation value is active.
7300 @endDefreq
7302 @DefreqList {ll, [@Var{length}]}
7303 @DefreqItem {ll, @t{+}@Var{length}}
7304 @DefreqItem {ll, @t{-}@Var{length}}
7305 @DefregItem {.l}
7306 @DefregListEnd {.ll}
7307 Set the line length to @var{length} (or increment or decrement the
7308 current value by @var{length}).  Initially, the line length is set to
7309 6.5@dmn{i}.  The effect of @code{ll} is delayed until a partially
7310 collected line (if it exists) is output.  The default scaling
7311 indicator is @samp{m}.
7313 If @code{ll} is called without an argument, the line length is reset to
7314 the previous value before the last call to @code{ll}.  If a negative
7315 line length is specified (which is not allowed), @code{gtroff} emits a
7316 warning of type @samp{range} and sets the line length to zero.
7318 The line length is associated with the current environment
7319 (@pxref{Environments}).
7321 @cindex line length register (@code{.l})
7322 The current line length (as set by @code{ll}) can be found in the
7323 read-only number register @samp{.l}.  The read-only number register
7324 @code{.ll} is the line length that applies to the current output line.
7326 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7327 and @code{.ll} is that the latter takes into account whether a partially
7328 collected line still uses the old line length value.
7329 @endDefreq
7332 @c =====================================================================
7334 @node Line Control, Page Layout, Line Layout, gtroff Reference
7335 @section Line Control
7336 @cindex line control
7337 @cindex control, line
7339 It is important to understand how @code{gtroff} handles input and output
7340 lines.
7342 Many escapes use positioning relative to the input line.  For example,
7343 this
7345 @Example
7346 This is a \h'|1.2i'test.
7348 This is a
7349 \h'|1.2i'test.
7350 @endExample
7352 @noindent
7353 produces
7355 @Example
7356 This is a   test.
7358 This is a             test.
7359 @endExample
7361 The main usage of this feature is to define macros which act exactly
7362 at the place where called.
7364 @Example
7365 .\" A simple macro to underline a word
7366 .de underline
7367 .  nop \\$1\l'|0\[ul]'
7369 @endExample
7371 @noindent
7372 In the above example, @samp{|0} specifies a negative distance from the
7373 current position (at the end of the just emitted argument @code{\$1}) back
7374 to the beginning of the input line.  Thus, the @samp{\l} escape draws a
7375 line from right to left.
7377 @cindex input line continuation
7378 @cindex line, input, continuation
7379 @cindex continuation, input line
7380 @cindex output line continuation
7381 @cindex line, output, continuation
7382 @cindex continuation, output line
7383 @cindex interrupted line
7384 @cindex line, interrupted
7385 @code{gtroff} makes a difference between input and output line
7386 continuation; the latter is also called @dfn{interrupting} a line.
7388 @DefescList {\\@key{RET}, , ,}
7389 @DefescItem {\\c, , ,}
7390 @DefregListEnd{.int}
7391 Continue a line.  @code{\@key{RET}} (this is a backslash at the end
7392 of a line immediately followed by a newline) works on the input level,
7393 suppressing the effects of the following newline in the input.
7395 @Example
7396 This is a \
7397 .test
7398     @result{} This is a .test
7399 @endExample
7401 The @samp{|} operator is also affected.
7403 @cindex @code{\R} escape, after @code{\c}
7404 @code{\c} works on the output level.  Anything after this escape on the
7405 same line is ignored, except @code{\R} which works as usual.  Anything
7406 before @code{\c} on the same line will be appended to the current partial
7407 output line.  The next non-command line after an interrupted line counts
7408 as a new input line.
7410 The visual results depend on whether no-fill mode is active.
7412 @itemize @bullet
7413 @item
7414 @cindex @code{\c} escape, and no-fill mode
7415 @cindex no-fill mode, and @code{\c}
7416 @cindex mode, no-fill, and @code{\c}
7417 If no-fill mode is active (using the @code{nf} request), the next input
7418 text line after @code{\c} will be handled as a continuation of the same
7419 input text line.
7421 @Example
7423 This is a \c
7424 test.
7425     @result{} This is a test.
7426 @endExample
7428 @item
7429 @cindex @code{\c} escape, and fill mode
7430 @cindex fill mode, and @code{\c}
7431 @cindex mode, fill, and @code{\c}
7432 If fill mode is active (using the @code{fi} request), a word interrupted
7433 with @code{\c} will be continued with the text on the next input text line,
7434 without an intervening space.
7436 @Example
7437 This is a te\c
7439     @result{} This is a test.
7440 @endExample
7441 @end itemize
7443 Note that an intervening control line which causes a break is stronger
7444 than @code{\c}, flushing out the current partial line in the usual way.
7446 @cindex interrupted line register (@code{.int})
7447 The @code{.int} register contains a positive value
7448 if the last output line was interrupted with @code{\c}; this is
7449 associated with the current environment (@pxref{Environments}).
7451 @endDefesc
7453 @c =====================================================================
7455 @node Page Layout, Page Control, Line Control, gtroff Reference
7456 @section Page Layout
7457 @cindex page layout
7458 @cindex layout, page
7460 @code{gtroff} provides some very primitive operations for controlling
7461 page layout.
7463 @cindex page length (@code{pl})
7464 @cindex length of page (@code{pl})
7465 @DefreqList {pl, [@Var{length}]}
7466 @DefreqItem {pl, @t{+}@Var{length}}
7467 @DefreqItem {pl, @t{-}@Var{length}}
7468 @DefregListEnd {.p}
7469 Set the @dfn{page length} to @var{length} (or increment or decrement
7470 the current value by @var{length}).  This is the length of the
7471 physical output page.  The default scaling indicator is @samp{v}.
7473 @cindex page length register (@code{.p})
7474 The current setting can be found in the read-only number register
7475 @samp{.p}.
7477 @cindex top margin
7478 @cindex margin, top
7479 @cindex bottom margin
7480 @cindex margin, bottom
7481 Note that this only specifies the size of the page, not the top and
7482 bottom margins.  Those are not set by @code{gtroff} directly.
7483 @xref{Traps}, for further information on how to do this.
7485 Negative @code{pl} values are possible also, but not very useful: No
7486 trap is sprung, and each line is output on a single page (thus
7487 suppressing all vertical spacing).
7489 If no argument or an invalid argument is given, @code{pl} sets the page
7490 length to 11@dmn{i}.
7491 @endDefreq
7493 @cindex headers
7494 @cindex footers
7495 @cindex titles
7496 @code{gtroff} provides several operations which help in setting up top
7497 and bottom titles (or headers and footers).
7499 @cindex title line (@code{tl})
7500 @cindex three-part title (@code{tl})
7501 @cindex page number character (@code{%})
7502 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7503 Print a @dfn{title line}.  It consists of three parts: a left
7504 justified portion, a centered portion, and a right justified portion.
7505 The argument separator @samp{'} can be replaced with any character not
7506 occurring in the title line.  The @samp{%} character is replaced with
7507 the current page number.  This character can be changed with the
7508 @code{pc} request (see below).
7510 Without argument, @code{tl} is ignored.
7512 Some notes:
7514 @itemize @bullet
7515 @item
7516 A title line is not restricted to the top or bottom of a page.
7518 @item
7519 @code{tl} prints the title line immediately, ignoring a partially filled
7520 line (which stays untouched).
7522 @item
7523 It is not an error to omit closing delimiters.  For example,
7524 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7525 title line with the left justified word @samp{foo}; the centered and
7526 right justfied parts are empty.
7528 @item
7529 Any modifications to the current environment within @code{tl} (e.g.@:
7530 changing the font or font size) are undone after processing @code{tl}.
7532 @item
7533 @code{tl} accepts the same parameter delimiting characters as the
7534 @code{\A} escape; see @ref{Escapes}.
7535 @end itemize
7536 @endDefreq
7538 @cindex length of title line (@code{lt})
7539 @cindex title line, length (@code{lt})
7540 @cindex title line length register (@code{.lt})
7541 @DefreqList {lt, [@Var{length}]}
7542 @DefreqItem {lt, @t{+}@Var{length}}
7543 @DefreqItem {lt, @t{-}@Var{length}}
7544 @DefregListEnd {.lt}
7545 The title line is printed using its own line length, which is
7546 specified (or incremented or decremented) with the @code{lt} request.
7547 Initially, the title line length is set to 6.5@dmn{i}.  If a negative
7548 line length is specified (which is not allowed), @code{gtroff} emits a
7549 warning of type @samp{range} and sets the title line length to zero.
7550 The default scaling indicator is @samp{m}.  If @code{lt} is called
7551 without an argument, the title length is reset to the previous value
7552 before the last call to @code{lt}.
7554 The current setting of this is available in the @code{.lt} read-only
7555 number register; it is associated with the current environment
7556 (@pxref{Environments}).
7558 @endDefreq
7560 @cindex page number (@code{pn})
7561 @cindex number, page (@code{pn})
7562 @DefreqList {pn, page}
7563 @DefreqItem {pn, @t{+}@Var{page}}
7564 @DefreqItem {pn, @t{-}@Var{page}}
7565 @DefregListEnd {.pn}
7566 Change (increase or decrease) the page number of the @emph{next} page.
7567 The only argument is the page number; the request is ignored without a
7568 parameter.
7570 The read-only number register @code{.pn} contains the number of the next
7571 page: either the value set by a @code{pn} request, or the number of the
7572 current page plus@w{ }1.
7573 @endDefreq
7575 @cindex page number register (@code{%})
7576 @Defreg {%}
7577 A read-write register holding the current page number.
7578 @endDefreg
7580 @cindex changing the page number character (@code{pc})
7581 @cindex page number character, changing (@code{pc})
7582 @vindex %
7583 @Defreq {pc, [@Var{char}]}
7584 Change the page number character (used by the @code{tl} request) to a
7585 different character.  With no argument, this mechanism is disabled.
7586 Note that this doesn't affect the number register@w{ }@code{%}.
7587 @endDefreq
7589 @xref{Traps}.
7592 @c =====================================================================
7594 @node Page Control, Fonts, Page Layout, gtroff Reference
7595 @section Page Control
7596 @cindex page control
7597 @cindex control, page
7599 @cindex new page (@code{bp})
7600 @cindex page, new (@code{bp})
7601 @DefreqList {bp, [@Var{page}]}
7602 @DefreqItem {bp, @t{+}@Var{page}}
7603 @DefreqListEnd {bp, @t{-}@Var{page}}
7604 Stop processing the current page and move to the next page.  This
7605 request causes a break.  It can also take an argument to set
7606 (increase, decrease) the page number of the next page.  The only
7607 difference between @code{bp} and @code{pn} is that @code{pn} does not
7608 cause a break or actually eject a page.
7610 @Example
7611 .de newpage                         \" define macro
7612 'bp                                 \" begin page
7613 'sp .5i                             \" vertical space
7614 .tl 'left top'center top'right top' \" title
7615 'sp .3i                             \" vertical space
7616 ..                                  \" end macro
7617 @endExample
7619 @cindex @code{bp} request, and top-level diversion
7620 @cindex top-level diversion and @code{bp}
7621 @cindex diversion, top-level, and @code{bp}
7622 @code{bp} has no effect if not called within the top-level diversion
7623 (@pxref{Diversions}).
7624 @endDefreq
7626 @cindex orphan lines, preventing with @code{ne}
7627 @cindex conditional page break (@code{ne})
7628 @cindex page break, conditional (@code{ne})
7629 @Defreq {ne, [@Var{space}]}
7630 It is often necessary to force a certain amount of space before a new
7631 page occurs.  This is most useful to make sure that there is not a
7632 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
7633 request ensures that there is a certain distance, specified by the
7634 first argument, before the next page is triggered (see @ref{Traps},
7635 for further information).  The default unit for @code{ne} is @samp{v};
7636 the default value of @var{space} is@w{ }1@dmn{v} if no argument is
7637 given.
7639 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7640 do the following before each paragraph:
7642 @Example
7643 .ne 2
7644 text text text
7645 @endExample
7647 @code{ne} will then automatically cause a page break if there is space
7648 for one line only.
7649 @endDefreq
7651 @cindex @code{ne} request, comparison with @code{sv}
7652 @Defreq {sv, [@Var{space}]}
7653 @code{sv} is similar to the @code{ne} request; it reserves the
7654 specified amount of vertical space.  If the desired amount of space
7655 exists before the next trap (or the bottom page boundary if no trap is
7656 set), the space is output immediately (ignoring a partially filled line
7657 which stays untouched).  If there is not enough space, it is stored for
7658 later output via the @code{os} request.  The default value is@w{ }1@dmn{v}
7659 if no argument is given; the default unit is @samp{v}.
7660 @endDefreq
7663 @c =====================================================================
7665 @node Fonts, Sizes, Page Control, gtroff Reference
7666 @section Fonts
7667 @cindex fonts
7669 @code{gtroff} can switch fonts at any point in the text.
7671 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7672 These are Times Roman, Italic, Bold, and Bold Italic.  For non-tty
7673 devices, there is also at least one symbol font which contains various
7674 special symbols (Greek, mathematics).
7676 @menu
7677 * Changing Fonts::
7678 * Font Families::
7679 * Font Positions::
7680 * Using Symbols::
7681 * Special Fonts::
7682 * Artificial Fonts::
7683 * Ligatures and Kerning::
7684 @end menu
7686 @c ---------------------------------------------------------------------
7688 @node Changing Fonts, Font Families, Fonts, Fonts
7689 @subsection Changing Fonts
7690 @cindex fonts
7692 @cindex changing fonts (@code{ft}, @code{\f})
7693 @cindex fonts, changing (@code{ft}, @code{\f})
7694 @cindex @code{sty} request, and changing fonts
7695 @cindex @code{fam} request, and changing fonts
7696 @cindex @code{\F} escape, and changing fonts
7697 @kindex styles
7698 @kindex family
7699 @pindex DESC
7700 @DefreqList {ft, [@Var{font}]}
7701 @DefescItem {\\f, , f, }
7702 @DefescItem {\\f, @lparen{}, fn, }
7703 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7704 The @code{ft} request and the @code{\f} escape change the current font
7705 to @var{font} (one-character name@w{ }@var{f}, two-character name
7706 @var{fn}).
7708 If @var{font} is a style name (as set with the @code{sty} request or
7709 with the @code{styles} command in the @file{DESC} file), use it within
7710 the current font family (as set with the @code{fam} request, @code{\F}
7711 escape, or with the @code{family} command in the @file{DESC} file).
7713 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7714 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7715 With no argument or using @samp{P} as an argument, @code{.ft} switches
7716 to the previous font.  Use @code{\f[]} to do this with the escape.  The
7717 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7719 Fonts are generally specified as upper-case strings, which are usually
7720 1@w{ }to 4 characters representing an abbreviation or acronym of the
7721 font name.  This is no limitation, just a convention.
7723 The example below produces two identical lines.
7725 @Example
7726 eggs, bacon,
7727 .ft B
7728 spam
7730 and sausage.
7732 eggs, bacon, \fBspam\fP and sausage.
7733 @endExample
7735 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7736 As a consequence, it can be used in requests like @code{mc} (which
7737 expects a single character as an argument) to change the font on
7738 the fly:
7740 @Example
7741 .mc \f[I]x\f[]
7742 @endExample
7744 @xref{Font Positions}, for an alternative syntax.
7745 @endDefreq
7747 @cindex @code{ft} request, and font translations
7748 @cindex @code{ul} request, and font translations
7749 @cindex @code{bd} request, and font translations
7750 @cindex @code{\f}, and font translations
7751 @cindex @code{cs} request, and font translations
7752 @cindex @code{tkf} request, and font translations
7753 @cindex @code{special} request, and font translations
7754 @cindex @code{fspecial} request, and font translations
7755 @cindex @code{fp} request, and font translations
7756 @cindex @code{sty} request, and font translations
7757 @Defreq {ftr, f [@Var{g}]}
7758 Translate font@w{ }@var{f} to font@w{ }@var{g}.  Whenever a font named@w{
7759 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7760 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7761 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7762 font@w{ }@var{g} is used.  If @var{g} is missing or equal to@w{ }@var{f}
7763 the translation is undone.
7764 @endDefreq
7766 @c ---------------------------------------------------------------------
7768 @node Font Families, Font Positions, Changing Fonts, Fonts
7769 @subsection Font Families
7770 @cindex font families
7771 @cindex families, font
7772 @cindex font styles
7773 @cindex styles, font
7775 Due to the variety of fonts available, @code{gtroff} has added the
7776 concept of @dfn{font families} and @dfn{font styles}.  The fonts are
7777 specified as the concatenation of the font family and style.  Specifying
7778 a font without the family part causes @code{gtroff} to use that style of
7779 the current family.
7781 @cindex postscript fonts
7782 @cindex fonts, postscript
7783 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7784 @option{-Tlbp} are set up to this mechanism.
7785 By default, @code{gtroff} uses the Times family with the four styles
7786 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7788 This way, it is possible to use the basic four fonts and to select a
7789 different font family on the command line (@pxref{Groff Options}).
7791 @cindex changing font family (@code{fam}, @code{\F})
7792 @cindex font family, changing (@code{fam}, @code{\F})
7793 @DefreqList {fam, [@Var{family}]}
7794 @DefregItem {.fam}
7795 @DefescItem {\\F, , f, }
7796 @DefescItem {\\F, @lparen{}, fm, }
7797 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7798 @DefregListEnd {.fn}
7799 Switch font family to @var{family} (one-character name@w{ }@var{f},
7800 two-character name @var{fm}).  If no argument is given, switch
7801 back to the previous font family.  Use @code{\F[]} to do this with the
7802 escape.  Note that @code{\FP} doesn't work; it selects font family
7803 @samp{P} instead.
7805 The value at start-up is @samp{T}.
7806 The current font family is available in the read-only number register
7807 @samp{.fam} (this is a string-valued register); it is associated with
7808 the current environment.
7810 @Example
7811 spam,
7812 .fam H    \" helvetica family
7813 spam,     \" used font is family H + style R = HR
7814 .ft B     \" family H + style B = font HB
7815 spam,
7816 .fam T    \" times family
7817 spam,     \" used font is family T + style B = TB
7818 .ft AR    \" font AR (not a style)
7819 baked beans,
7820 .ft R     \" family T + style R = font TR
7821 and spam.
7822 @endExample
7824 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7825 As a consequence, it can be used in requests like @code{mc} (which
7826 expects a single character as an argument) to change the font family on
7827 the fly:
7829 @Example
7830 .mc \F[P]x\F[]
7831 @endExample
7833 The @samp{.fn} register contains the current @dfn{real font name}
7834 of the current font.
7835 This is a string-valued register.
7836 If the current font is a style, the value of @code{\n[.fn]}
7837 is the proper concatenation of family and style name.
7838 @endDefreq
7840 @cindex changing font style (@code{sty})
7841 @cindex font style, changing (@code{sty})
7842 @cindex @code{cs} request, and font styles
7843 @cindex @code{bd} request, and font styles
7844 @cindex @code{tkf} request, and font styles
7845 @cindex @code{uf} request, and font styles
7846 @cindex @code{fspecial} request, and font styles
7847 @Defreq {sty, n style}
7848 Associate @var{style} with font position@w{ }@var{n}.  A font position
7849 can be associated either with a font or with a style.  The current
7850 font is the index of a font position and so is also either a font or a
7851 style.  If it is a style, the font that is actually used is the font
7852 which name is the concatenation of the name of the current
7853 family and the name of the current style.  For example, if the current
7854 font is@w{ }1 and font position@w{ }1 is associated with style
7855 @samp{R} and the current font family is @samp{T}, then font
7856 @samp{TR} will be used.  If the current font is not a style, then the
7857 current family is ignored.  If the requests @code{cs}, @code{bd},
7858 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
7859 they will instead be applied to the member of the current family
7860 corresponding to that style.
7862 @var{n}@w{ }must be a non-negative integer value.
7864 @pindex DESC
7865 @kindex styles
7866 The default family can be set with the @option{-f} option
7867 (@pxref{Groff Options}).  The @code{styles} command in the @file{DESC}
7868 file controls which font positions (if any) are initially associated
7869 with styles rather than fonts.  For example, the default setting for
7870 @sc{PostScript} fonts
7872 @Example
7873 styles R I B BI
7874 @endExample
7876 @noindent
7877 is equivalent to
7879 @Example
7880 .sty 1 R
7881 .sty 2 I
7882 .sty 3 B
7883 .sty 4 BI
7884 @endExample
7886 @code{fam} and @code{\F} always check whether the current font position
7887 is valid; this can give surprising results if the current font position is
7888 associated with a style.
7890 In the following example, we want to access the @sc{PostScript} font
7891 @code{FooBar} from the font family @code{Foo}:
7893 @Example
7894 .sty \n[.fp] Bar
7895 .fam Foo
7896     @result{} warning: can't find font `FooR'
7897 @endExample
7899 @noindent
7900 The default font position at start-up is@w{ }1; for the
7901 @sc{PostScript} device, this is associated with style @samp{R}, so
7902 @code{gtroff} tries to open @code{FooR}.
7904 A solution to this problem is to use a dummy font like the following:
7906 @Example
7907 .fp 0 dummy TR    \" set up dummy font at position 0
7908 .sty \n[.fp] Bar  \" register style `Bar'
7909 .ft 0             \" switch to font at position 0
7910 .fam Foo          \" activate family `Foo'
7911 .ft Bar           \" switch to font `FooBar'
7912 @endExample
7914 @xref{Font Positions}.
7915 @endDefreq
7917 @c ---------------------------------------------------------------------
7919 @node Font Positions, Using Symbols, Font Families, Fonts
7920 @subsection Font Positions
7921 @cindex font positions
7922 @cindex positions, font
7924 For the sake of old phototypesetters and compatibility with old versions
7925 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
7926 on which various fonts are mounted.
7928 @cindex mounting font (@code{fp})
7929 @cindex font, mounting (@code{fp})
7930 @DefreqList {fp, pos font [@Var{external-name}]}
7931 @DefregItem {.f}
7932 @DefregListEnd {.fp}
7933 Mount font @var{font} at position @var{pos} (which must be a
7934 non-negative integer).  This numeric position can then be referred to
7935 with font changing commands.  When @code{gtroff} starts it is using
7936 font position@w{ }1 (which must exist; position@w{ }0 is unused
7937 usually at start-up).
7939 @cindex font position register (@code{.f})
7940 The current font in use, as a font position, is available in the
7941 read-only number register @samp{.f}.  This can be useful to remember the
7942 current font for later recall.  It is associated with the current
7943 environment (@pxref{Environments}).
7945 @Example
7946 .nr save-font \n[.f]
7947 .ft B
7948 ... text text text ...
7949 .ft \n[save-font]
7950 @endExample
7952 @cindex next free font position register (@code{.fp})
7953 The number of the next free font position is available in the read-only
7954 number register @samp{.fp}.  This is useful when mounting a new font,
7955 like so:
7957 @Example
7958 .fp \n[.fp] NEATOFONT
7959 @endExample
7961 @pindex DESC@r{, and font mounting}
7962 Fonts not listed in the @file{DESC} file are automatically mounted on
7963 the next available font position when they are referenced.  If a font
7964 is to be mounted explicitly with the @code{fp} request on an unused
7965 font position, it should be mounted on the first unused font position,
7966 which can be found in the @code{.fp} register.  Although @code{gtroff}
7967 does not enforce this strictly, it is not allowed to mount a font at a
7968 position whose number is much greater (approx.@: 1000 positions) than
7969 that of any currently used position.
7971 The @code{fp} request has an optional third argument.  This argument
7972 gives the external name of the font, which is used for finding the font
7973 description file.  The second argument gives the internal name of the
7974 font which is used to refer to the font in @code{gtroff} after it has
7975 been mounted.  If there is no third argument then the internal name is
7976 used as the external name.  This feature makes it possible to use
7977 fonts with long names in compatibility mode.
7978 @endDefreq
7980 Both the @code{ft} request and the @code{\f} escape have alternative
7981 syntax forms to access font positions.
7983 @cindex changing font position (@code{\f})
7984 @cindex font position, changing (@code{\f})
7985 @cindex @code{sty} request, and font positions
7986 @cindex @code{fam} request, and font positions
7987 @cindex @code{\F} escape, and font positions
7988 @kindex styles
7989 @kindex family
7990 @pindex DESC
7991 @DefreqList {ft, nnn}
7992 @DefescItem {\\f, , n, }
7993 @DefescItem {\\f, @lparen{}, nn, }
7994 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
7995 Change the current font position to @var{nnn} (one-digit position@w{
7996 }@var{n}, two-digit position @var{nn}), which must be a non-negative
7997 integer.
7999 If @var{nnn} is associated with a style (as set with the @code{sty}
8000 request or with the @code{styles} command in the @file{DESC} file), use
8001 it within the current font family (as set with the @code{fam} request,
8002 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
8003 file).
8005 @Example
8006 this is font 1
8007 .ft 2
8008 this is font 2
8009 .ft                   \" switch back to font 1
8010 .ft 3
8011 this is font 3
8013 this is font 1 again
8014 @endExample
8016 @xref{Changing Fonts}, for the standard syntax form.
8017 @endDefreq
8019 @c ---------------------------------------------------------------------
8021 @node Using Symbols, Special Fonts, Font Positions, Fonts
8022 @subsection Using Symbols
8023 @cindex using symbols
8024 @cindex symbols, using
8026 @cindex glyph
8027 @cindex character
8028 @cindex ligature
8029 A @dfn{glyph} is a graphical representation of a @dfn{character}.
8030 While a character is an abstract entity containing semantic
8031 information, a glyph is something which can be actually seen on screen
8032 or paper.  It is possible that a character has multiple glyph
8033 representation forms (for example, the character `A' can be either
8034 written in a roman or an italic font, yielding two different glyphs);
8035 sometimes more than one character maps to a single glyph (this is a
8036 @dfn{ligature} -- the most common is `fi').
8038 @c XXX
8040 Please note that currently the distinction between glyphs and
8041 characters in this reference is not clearly carried out.  This will be
8042 improved eventually in the next revision.
8044 @cindex symbol
8045 @cindex special fonts
8046 @kindex fonts
8047 @pindex DESC
8048 A @dfn{symbol} is simply a named glyph.  Within @code{gtroff}, all
8049 glyph names of a particular font are defined in its font file.  If the
8050 user requests a glyph not available in this font, @code{gtroff} looks
8051 up an ordered list of @dfn{special fonts}.  By default, the
8052 @sc{PostScript} output device supports the two special fonts @samp{SS}
8053 (slanted symbols) and @samp{S} (symbols) (the former is looked up
8054 before the latter).  Other output devices use different names for
8055 special fonts.  Fonts mounted with the @code{fonts} keyword in the
8056 @file{DESC} file are globally available.  To install additional
8057 special fonts locally (i.e.@: for a particular font), use the
8058 @code{fspecial} request.
8060 In summary, @code{gtroff} tries the following to find a given symbol:
8062 @itemize @bullet
8063 @item
8064 If the symbol has been defined with the @code{char} request, use it.
8065 This hides a symbol with the same name in the current font.
8067 @item
8068 Check the current font.
8070 @item
8071 If the symbol has been defined with the @code{fchar} request, use it.
8073 @item
8074 Check all fonts given with the @code{fspecial} request, in the order
8075 of appearance in @code{fspecial} calls.
8077 @item
8078 Check all fonts given with the @code{special} request, in the order
8079 of appearance in @code{special} calls (inclusively the special fonts
8080 defined in the @file{DESC} file, which come first).
8082 @item
8083 As a last resort, consult all fonts loaded up to now (in the order they
8084 have been called the first time) for special fonts and check them.
8085 @end itemize
8087 @xref{Font Files}, and @ref{Special Fonts}, for more details.
8089 @DefescList {\\, @lparen{}, nm, }
8090 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
8091 Insert a symbol @var{name} (two-character name @var{nm}).  There is no
8092 special syntax for one-character names -- the natural form
8093 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
8094 one-character symbol is not the same as an input character, i.e., the
8095 character @code{a} is not the same as @code{\[a]}.  By default,
8096 @code{groff} defines only a single one-character symbol, @code{\[-]};
8097 it is usually accessed as @code{\-}.  On the other hand, @code{gtroff}
8098 has the special feature that @code{\[char@var{XXX}]} is the same as the
8099 input character with character code @var{XXX}.  For example,
8100 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8101 encoding is active.}
8103 If @var{name} is undefined, a warning of type @samp{char} is generated,
8104 and the escape is ignored.  @xref{Debugging}, for information about
8105 warnings.
8107 The list of available symbols is device dependent; see @ref{Glyph Name
8108 Index} for some of them discussed in this reference.
8110 @c XXX list of common symbols
8111 @endDefesc
8113 @cindex named character (@code{\C})
8114 @cindex character, named (@code{\C})
8115 @Defesc {\\C, ', xxx, '}
8116 Typeset the character named @var{xxx}.  Normally it is more convenient
8117 to use @code{\[@var{xxx}]}, but @code{\C} has the advantage that it is
8118 compatible with newer versions of @code{ditroff} and is available in
8119 compatibility mode.
8120 @endDefesc
8122 @cindex numbered character (@code{\N})
8123 @cindex character, numbered (@code{\N})
8124 @cindex @code{char} request, used with @code{\N}
8125 @cindex Unicode
8126 @Defesc {\\N, ', n, '}
8127 Typeset the character with code@w{ }@var{n} in the current font (this
8128 is @strong{not} the input character code).  @var{n}@w{ }can be any
8129 integer.  Most devices only have characters with codes between 0
8130 and@w{ }255; the Unicode output device uses codes in the range
8131 0--65535.  If the current font does not contain a character with that
8132 code, special fonts are @emph{not} searched.  The @code{\N} escape
8133 sequence can be conveniently used in conjunction with the @code{char}
8134 request:
8136 @Example
8137 .char \[phone] \f[ZD]\N'37'
8138 @endExample
8140 @noindent
8141 @pindex DESC
8142 @cindex unnamed characters
8143 @cindex characters, unnamed
8144 The code of each character is given in the fourth column in the font
8145 description file after the @code{charset} command.  It is possible to
8146 include unnamed characters in the font description file by using a
8147 name of @samp{---}; the @code{\N} escape sequence is the only way to
8148 use these.
8149 @endDefesc
8151 @c XXX should be `glyph', not `character'
8153 @cindex character properties (@code{cflags})
8154 @cindex properties of characters (@code{cflags})
8155 @Defreq {cflags, n c1 c2 @dots{}}
8156 Each character has certain properties associated with it.  These
8157 properties can be modified with the @code{cflags} request.  The first
8158 argument is the sum of the desired flags and the remaining
8159 arguments are the characters to have those properties.  It is possible
8160 to omit the spaces between the characters.
8162 @table @code
8163 @item 1
8164 @cindex end-of-sentence characters
8165 @cindex characters, end-of-sentence
8166 the character ends sentences (initially characters @samp{.?!} have this
8167 property)
8169 @item 2
8170 @cindex hyphenating characters
8171 @cindex characters, hyphenation
8172 lines can be broken before the character (initially no characters have
8173 this property)
8175 @item 4
8176 @cindex @code{hy} glyph, and @code{cflags}
8177 @cindex @code{em} glyph, and @code{cflags}
8178 lines can be broken after the character (initially the characters
8179 @samp{-\(hy\(em} have this property)
8181 @item 8
8182 @cindex overlapping characters
8183 @cindex characters, overlapping
8184 @cindex @code{ul} glyph, and @code{cflags}
8185 @cindex @code{rn} glyph, and @code{cflags}
8186 @cindex @code{ru} glyph, and @code{cflags}
8187 the character overlaps horizontally (initially the characters
8188 @samp{\(ul\(rn\(ru} have this property)
8190 @item 16
8191 @cindex @code{br} glyph, and @code{cflags}
8192 the character overlaps vertically (initially character @samp{\(br} has
8193 this property)
8195 @item 32
8196 @cindex transparent characters
8197 @cindex character, transparent
8198 @cindex @code{"}, at end of sentence
8199 @cindex @code{'}, at end of sentence
8200 @cindex @code{)}, at end of sentence
8201 @cindex @code{]}, at end of sentence
8202 @cindex @code{*}, at end of sentence
8203 @cindex @code{dg} glyph, at end of sentence
8204 @cindex @code{rq} glyph, at end of sentence
8205 an end-of-sentence character followed by any number of characters with
8206 this property is treated as the end of a sentence if followed by a
8207 newline or two spaces; in other words the character is
8208 @dfn{transparent} for the purposes of end-of-sentence recognition --
8209 this is the same as having a zero space factor in @TeX{} (initially
8210 characters @samp{"')]*\(dg\(rq} have this property).
8211 @end table
8212 @endDefreq
8214 @cindex defining character (@code{char})
8215 @cindex character, defining (@code{char})
8216 @cindex creating new characters (@code{char})
8217 @cindex escape character, while defining character
8218 @cindex character, escape, while defining character
8219 @cindex @code{tr} request, and character definitions
8220 @cindex @code{cp} request, and character definitions
8221 @cindex @code{rc} request, and character definitions
8222 @cindex @code{lc} request, and character definitions
8223 @cindex @code{\l}, and character definitions
8224 @cindex @code{\L}, and character definitions
8225 @cindex @code{\&}, and character definitions
8226 @cindex @code{\e}, and character definitions
8227 @cindex @code{hcode} request, and character definitions
8228 @DefreqList {char, c [@Var{string}]}
8229 @DefreqListEnd {fchar, c [@Var{string}]}
8230 Define a new character@w{ }@var{c} to be @var{string} (which can be
8231 empty).  Every time character@w{ }@var{c} needs to be printed,
8232 @var{string} is processed in a temporary environment and the result is
8233 wrapped up into a single object.  Compatibility mode is turned off and
8234 the escape character is set to @samp{\} while @var{string} is being
8235 processed.  Any emboldening, constant spacing or track kerning is
8236 applied to this object rather than to individual characters in
8237 @var{string}.
8239 A character defined by this request can be used just
8240 like a normal character provided by the output device.  In particular,
8241 other characters can be translated to it with the @code{tr} or
8242 @code{trin} requests; it can be made the leader character by the
8243 @code{lc} request; repeated patterns can be drawn with the character
8244 using the @code{\l} and @code{\L} escape sequences; words containing
8245 the character can be hyphenated correctly if the @code{hcode} request
8246 is used to give the character a hyphenation code.
8248 There is a special anti-recursion
8249 feature: Use of character within the character's definition is handled
8250 like normal characters not defined with @code{char}.
8252 Note that the @code{tr} and @code{trin} requests take precedence if
8253 @code{char} accesses the same character.
8255 @Example
8256 .tr XY
8258     @result{} Y
8259 .char X Z
8261     @result{} Y
8262 .tr XX
8264     @result{} Z
8265 @endExample
8267 The @code{fchar} request defines a fallback character:
8268 @code{gtroff} only checks for characters defined with @code{fchar}
8269 if it cannot find the glyph in the current font.
8270 @code{gtroff} carries out this test before checking special fonts.
8271 @endDefreq
8273 @cindex removing character definition (@code{rchar})
8274 @cindex character, removing definition (@code{rchar})
8275 @Defreq {rchar, c1 c2 @dots{}}
8276 Remove the definitions of characters @var{c1}, @var{c2},@w{
8277 }@enddots{} This undoes the effect of a @code{char} or @code{fchar}
8278 request.
8280 It is possible to omit the whitespace between arguments.
8281 @endDefreq
8283 @xref{Special Characters}.
8285 @c ---------------------------------------------------------------------
8287 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8288 @subsection Special Fonts
8289 @cindex special fonts
8290 @cindex fonts, special
8292 @c XXX Add some more wrapper text up here.
8293 Special fonts are those that @code{gtroff} searches
8294 when it cannot find the requested character in the current font.
8295 The Symbol font is usually a special font.
8297 @DefreqList {special, s1 s2 @dots{}}
8298 @DefreqListEnd {fspecial, f s1 s2 @dots{}}
8299 Use the @code{special} request to define special fonts.
8301 Use the @code{fspecial} request to designate special fonts
8302 only when font@w{ }@var{f} font is active.
8303 @endDefreq
8305 @c ---------------------------------------------------------------------
8307 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8308 @subsection Artificial Fonts
8309 @cindex artificial fonts
8310 @cindex fonts, artificial
8312 There are a number of requests and escapes for artificially creating
8313 fonts.  These are largely vestiges of the days when output devices
8314 did not have a wide variety of fonts, and when @code{nroff} and
8315 @code{troff} were separate programs.  Most of them are no longer
8316 necessary in GNU @code{troff}.  Nevertheless, they are supported.
8318 @cindex changing the font height (@code{\H})
8319 @cindex font height, changing (@code{\H})
8320 @cindex height, font, changing (@code{\H})
8321 @DefescList {\\H, ', height, '}
8322 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8323 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8324 Change (increment, decrement) the height of the current font, but not
8325 the width.  If @var{height} is zero, restore the original height.
8326 Default unit is @samp{z}.
8328 Currently, only the @option{-Tps} device supports this feature.
8330 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8331 As a consequence, it can be used in requests like @code{mc} (which
8332 expects a single character as an argument) to change the font on
8333 the fly:
8335 @Example
8336 .mc \H'+5z'x\H'0'
8337 @endExample
8339 In compatibility mode, @code{gtroff} behaves differently:  If an
8340 increment or decrement is used, it is always taken relative to the
8341 current point size and not relative to the previously selected font
8342 height.  Thus,
8344 @Example
8345 .cp 1
8346 \H'+5'test \H'+5'test
8347 @endExample
8349 @noindent
8350 prints the word @samp{test} twice with the same font height (five
8351 points larger than the current font size).
8352 @endDefesc
8354 @cindex changing the font slant (@code{\S})
8355 @cindex font slant, changing (@code{\S})
8356 @cindex slant, font, changing (@code{\S})
8357 @DefescList {\\S, ', slant, '}
8358 Slant the current font by @var{slant} degrees.  Positive values slant
8359 to the right.
8361 Currently, only the @option{-Tps} device supports this feature.
8363 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8364 As a consequence, it can be used in requests like @code{mc} (which
8365 expects a single character as an argument) to change the font on
8366 the fly:
8368 @Example
8369 .mc \S'20'x\S'0'
8370 @endExample
8372 This request is incorrectly documented in the original @acronym{UNIX}
8373 troff manual; the slant is always set to an absolute value.
8374 @endDefesc
8376 @cindex underlining (@code{ul})
8377 @Defreq {ul, [@Var{lines}]}
8378 The @code{ul} request normally underlines subsequent lines if a tty
8379 output device is used.  Otherwise, the lines are printed in italics
8380 (only the term `underlined' is used in the following).  The single
8381 argument is the number of input lines to be underlined; with no
8382 argument, the next line is underlined.  If @var{lines} is zero or
8383 negative, stop the effects of @code{ul} (if it was active).  Requests
8384 and empty lines do not count for computing the number of underlined
8385 input lines, even if they produce some output like @code{tl}.  Lines
8386 inserted by macros (e.g.@: invoked by a trap) do count.
8388 At the beginning of @code{ul}, the current font is stored and the
8389 underline font is activated.  Within the span of a @code{ul} request,
8390 it is possible to change fonts, but after the last line affected by
8391 @code{ul} the saved font is restored.
8393 This number of lines still to be underlined is associated with the
8394 current environment (@pxref{Environments}).  The underline font can be
8395 changed with the @code{uf} request.
8397 @c XXX @xref should be changed to grotty
8399 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8400 @c implemented in for tty output devices, and which problems can arise.
8402 The @code{ul} request does not underline spaces.
8403 @endDefreq
8405 @cindex continuous underlining (@code{cu})
8406 @cindex underlining, continuous (@code{cu})
8407 @Defreq {cu, [@Var{lines}]}
8408 The @code{cu} request is similar to @code{ul} but underlines spaces as
8409 well (if a tty output device is used).
8410 @endDefreq
8412 @cindex underline font (@code{uf})
8413 @cindex font for underlining (@code{uf})
8414 @Defreq {uf, font}
8415 Set the underline font (globally) used by @code{ul} and @code{cu}.  By
8416 default, this is the font at position@w{ }2.  @var{font} can be either
8417 a non-negative font position or the name of a font.
8418 @endDefreq
8420 @cindex imitating bold face (@code{bd})
8421 @cindex bold face, imitating (@code{bd})
8422 @DefreqList {bd, font [@Var{offset}]}
8423 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8424 @DefregListEnd {.b}
8425 Artificially create a bold font by printing each character twice,
8426 slightly offset.
8428 Two syntax forms are available.
8430 @itemize @bullet
8431 @item
8432 Imitate a bold font unconditionally.  The first argument specifies the
8433 font to embolden, and the second is the number of basic units, minus
8434 one, by which the two characters is offset.  If the second argument is
8435 missing, emboldening is turned off.
8437 @var{font} can be either a non-negative font position or the name of a
8438 font.
8440 @var{offset} is available in the @code{.b} read-only register if a
8441 special font is active; in the @code{bd} request, its default unit is
8442 @samp{u}.
8444 @cindex @code{fspecial} request, and imitating bold
8445 @kindex special
8446 @cindex embolding of special fonts
8447 @cindex special fonts, emboldening
8448 @item
8449 Imitate a bold form conditionally.  Embolden @var{font1} by
8450 @var{offset} only if font @var{font2} is the current font.  This
8451 command can be issued repeatedly to set up different emboldening
8452 values for different current fonts.  If the second argument is
8453 missing, emboldening is turned off for this particular current font.
8455 This affects special fonts only (either set up with the @code{special}
8456 command in font files or with the @code{fspecial} request).
8457 @end itemize
8458 @endDefreq
8460 @cindex constant character space mode (@code{cs})
8461 @cindex mode for constant character space (@code{cs})
8462 @cindex character, constant space
8463 @cindex @code{ps} request, and constant character space mode
8464 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8465 Switch to and from constant character space mode.  If activated, the
8466 width of every character is @math{@var{width}/36} ems.  The em size is
8467 given absolutely by @var{em-size}; if this argument is missing, the em
8468 value is taken from the current font size (as set with the @code{ps}
8469 request) when the font is effectively in use.  Without second and
8470 third argument, constant character space mode is deactivated.
8472 Default unit for @var{em-size} is @samp{z}; @var{width} is an integer.
8473 @endDefreq
8475 @c ---------------------------------------------------------------------
8477 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
8478 @subsection Ligatures and Kerning
8479 @cindex ligatures and kerning
8480 @cindex kerning and ligatures
8482 Ligatures are groups of characters that are run together.  For
8483 example, the letters `f' and `i' can form a ligature `fi' as in the
8484 word `file'.  This produces a cleaner look (albeit subtle) to the
8485 printed output.  Usually, ligatures are not available in fonts for tty
8486 output devices.
8488 Most @sc{PostScript} fonts support the fi and fl ligatures.  The C/A/T
8489 typesetter that was the target of AT&T @code{troff} also supported
8490 `ff', `ffi', and `ffl' ligatures.  Advanced typesetters or `expert'
8491 fonts may include ligatures for `ft' and `ct', although GNU
8492 @code{troff} does not support these (yet).
8494 @cindex activating ligatures (@code{lg})
8495 @cindex ligatures, activating (@code{lg})
8496 @cindex ligatures enabled register (@code{.lg})
8497 @DefreqList {lg, [@Var{flag}]}
8498 @DefregListEnd {.lg}
8499 Switch the ligature mechanism on or off; if the parameter is non-zero
8500 or missing, ligatures are enabled, otherwise disabled.  Default is on.
8501 The current ligature mode can be found in the read-only number register
8502 @code{.lg} (set to 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
8504 Setting the ligature mode to@w{ }2 enables the two-character ligatures
8505 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8506 ffl).
8507 @endDefreq
8509 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8510 modifies the distance between a character pair to improve readability.
8511 In most cases (but not always) the distance is decreased.
8512 @ifnotinfo
8513 For example, compare the combination of the letters `V' and `A'.  With
8514 kerning, `VA' is printed.  Without kerning it appears as `V@w{}A'.
8515 @end ifnotinfo
8516 Typewriter-like fonts and fonts for terminals where all characters
8517 have the same width don't use kerning.
8519 @cindex activating kerning (@code{kern})
8520 @cindex kerning, activating (@code{kern})
8521 @cindex kerning enabled register (@code{.kern})
8522 @DefreqList {kern, [@Var{flag}]}
8523 @DefregListEnd {.kern}
8524 Switch kerning on or off.  If the parameter is non-zero or missing,
8525 enable pairwise kerning, otherwise disable it.  The read-only number
8526 register @code{.kern} is set to@w{ }1 if pairwise kerning is enabled,
8527 0@w{ }otherwise.
8529 @cindex zero width space character (@code{\&})
8530 @cindex character, zero width space (@code{\&})
8531 @cindex space character, zero width (@code{\&})
8532 If the font description file contains pairwise kerning information,
8533 characters from that font are kerned.  Kerning between two characters
8534 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8536 @xref{Font File Format}.
8537 @endDefreq
8539 @cindex track kerning
8540 @cindex kerning, track
8541 @dfn{Track kerning} expands or reduces the space between characters.
8542 This can be handy, for example, if you need to squeeze a long word
8543 onto a single line or spread some text to fill a narrow column.  It
8544 must be used with great care since it is usually considered bad
8545 typography if the reader notices the effect.
8547 @cindex activating track kerning (@code{tkf})
8548 @cindex track kerning, activating (@code{tkf})
8549 @Defreq {tkf, f s1 n1 s2 n2}
8550 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
8551 }@var{f} the width of every character is increased by an amount
8552 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8553 the current point size is less than or equal to @var{s1} the width is
8554 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8555 width is increased by @var{n2}; if the point size is greater than or
8556 equal to @var{s1} and less than or equal to @var{s2} the increase in
8557 width is a linear function of the point size.
8559 The default unit is @samp{z} for @var{s1} and @var{s2}, @samp{p} for
8560 @var{n1} and @var{n2}.
8562 Note that the track kerning amount is added even to the rightmost character
8563 in a line; for large values it is thus recommended to increase the line
8564 length by the same amount to compensate it.
8565 @endDefreq
8567 Sometimes, when typesetting letters of different fonts, more or less
8568 space at such boundaries are needed.  There are two escapes to help
8569 with this.
8571 @cindex italic correction (@code{\/})
8572 @cindex correction, italic (@code{\/})
8573 @cindex correction between italic and roman character (@code{\/})
8574 @cindex roman character, correction after italic character (@code{\/})
8575 @cindex italic character, correction before roman character (@code{\/})
8576 @Defesc {\\/, , , }
8577 Increase the width of the preceding character so that the spacing
8578 between that character and the following character is correct if the
8579 following character is a roman character.  For example, if an
8580 italic@w{ }@code{f} is immediately followed by a roman right
8581 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8582 overlaps the top left of the right parenthesis.  Use this escape
8583 sequence whenever an italic character is immediately followed by a
8584 roman character without any intervening space.  This small amount of
8585 space is also called @dfn{italic correction}.
8587 @iftex
8588 @example
8589 @group
8590 \f[I]f\f[R])
8591     @result{} {@it f}@r{)}
8592 \f[I]f\/\f[R])
8593     @result{} @i{f}@r{)}
8594 @end group
8595 @end example
8596 @end iftex
8597 @endDefesc
8599 @cindex left italic correction (@code{\,})
8600 @cindex correction, left italic (@code{\,})
8601 @cindex roman character, correction before italic character (@code{\,})
8602 @cindex italic character, correction after roman character (@code{\,})
8603 @Defesc {\\\,, , , }
8604 Modify the spacing of the following character so that the spacing
8605 between that character and the preceding character is correct if the
8606 preceding character is a roman character.  Use this escape sequence
8607 whenever a roman character is immediately followed by an italic
8608 character without any intervening space.  In analogy to above, this
8609 space could be called @dfn{left italic correction}, but this term
8610 isn't used widely.
8612 @iftex
8613 @example
8614 @group
8615 q\f[I]f
8616     @result{} @r{q}@i{f}
8617 q\,\f[I]f
8618     @result{} @r{q}@math{@ptexcomma}@i{f}
8619 @end group
8620 @end example
8621 @end iftex
8622 @endDefesc
8624 @Defesc {\\&, , , }
8625 Insert a zero-width character, which is invisible.  Its intended use
8626 is to stop interaction of a character with its surrounding.
8628 @itemize @bullet
8629 @item
8630 It prevents the insertion of extra space after an end-of-sentence
8631 character.
8633 @Example
8634 Test.
8635 Test.
8636     @result{} Test.  Test.
8637 Test.\&
8638 Test.
8639     @result{} Test. Test.
8640 @endExample
8642 @item
8643 It prevents interpretation of a control character at the beginning of
8644 an input line.
8646 @Example
8647 .Test
8648     @result{} warning: `Test' not defined
8649 \&.Test
8650     @result{} .Test
8651 @endExample
8653 @item
8654 It prevents kerning between two characters.
8656 @ifnotinfo
8657 @example
8658 @group
8660     @result{} @r{VA}
8661 V\&A
8662     @result{} @r{V@w{}A}
8663 @end group
8664 @end example
8665 @end ifnotinfo
8667 @item
8668 It is needed to map an arbitrary character to nothing in the @code{tr}
8669 request (@pxref{Character Translations}).
8670 @end itemize
8671 @endDefesc
8673 @Defesc {\\), , , }
8674 This escape is similar to @code{\&} except that it behaves like a
8675 character declared with the @code{cflags} request to be transparent
8676 for the purposes of an end-of-sentence character.
8678 Its main usage is in macro definitions to protect against arguments
8679 starting with a control character.
8681 @Example
8682 .de xxx
8683 \)\\$1
8685 .de yyy
8686 \&\\$1
8688 This is a test.\c
8689 .xxx '
8690 This is a test.
8691     @result{}This is a test.'  This is a test.
8692 This is a test.\c
8693 .yyy '
8694 This is a test.
8695     @result{}This is a test.' This is a test.
8696 @endExample
8697 @endDefesc
8700 @c =====================================================================
8702 @node Sizes, Strings, Fonts, gtroff Reference
8703 @section Sizes
8704 @cindex sizes
8706 @cindex baseline
8707 @cindex type size
8708 @cindex size of type
8709 @cindex vertical spacing
8710 @cindex spacing, vertical
8711 @code{gtroff} uses two dimensions with each line of text, type size
8712 and vertical spacing.  The @dfn{type size} is approximately the height
8713 of the tallest character.@footnote{This is usually the parenthesis.
8714 Note that in most cases the real dimensions of the glyphs in a font
8715 are @emph{not} related to its type size!  For example, the standard
8716 @sc{PostScript} font families `Times Roman', `Helvetica', and
8717 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8718 output, the size of `Helvetica' has to be reduced by one point, and
8719 the size of `Courier' must be increased by one point.}  @dfn{Vertical
8720 spacing} is the amount of space @code{gtroff} allows for a line of
8721 text; normally, this is about 20%@w{ }larger than the current type
8722 size.  Ratios smaller than this can result in hard-to-read text;
8723 larger than this, it spreads the text out more vertically (useful for
8724 term papers).  By default, @code{gtroff} uses 10@w{ }point type on
8725 12@w{ }point spacing.
8727 @cindex leading
8728 The difference between type size and vertical spacing is known, by
8729 typesetters, as @dfn{leading} (this is pronounced `ledding').
8731 @menu
8732 * Changing Type Sizes::
8733 * Fractional Type Sizes::
8734 @end menu
8736 @c ---------------------------------------------------------------------
8738 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8739 @subsection Changing Type Sizes
8741 @cindex changing type sizes (@code{ps}, @code{\s})
8742 @cindex type sizes, changing (@code{ps}, @code{\s})
8743 @cindex point sizes, changing (@code{ps}, @code{\s})
8744 @DefreqList {ps, [@Var{size}]}
8745 @DefreqItem {ps, @t{+}@Var{size}}
8746 @DefreqItem {ps, @t{-}@Var{size}}
8747 @DefescItem {\\s, , size, }
8748 @DefregListEnd {.s}
8749 Use the @code{ps} request or the @code{\s} escape to change (increase,
8750 decrease) the type size (in points).  Specify @var{size} as either an
8751 absolute point size, or as a relative change from the current size.
8752 The size@w{ }0, or no argument, goes back to the previous size.
8754 Default unit of @code{size} is @samp{z}.  If @code{size} is zero or
8755 negative, it is set to 1@dmn{u}.
8757 @cindex type size registers (@code{.s}, @code{.ps})
8758 @cindex point size registers (@code{.s}, @code{.ps})
8759 The read-only number register @code{.s} returns the point size in
8760 points as a decimal fraction.  This is a string.  To get the point
8761 size in scaled points, use the @code{.ps} register instead.
8763 @code{.s} is associated with the current environment
8764 (@pxref{Environments}).
8766 @Example
8767 snap, snap,
8768 .ps +2
8769 grin, grin,
8770 .ps +2
8771 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8772 .ps 10
8773 @endExample
8775 The @code{\s} escape may be called in a variety of ways.  Much like
8776 other escapes there must be a way to determine where the argument ends
8777 and the text begins.  Any of the following forms are valid:
8779 @table @code
8780 @item \s@var{n}
8781 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either
8782 0 or in the range 4 to@w{ }39.
8784 @item \s+@var{n}
8785 @itemx \s-@var{n}
8786 Increase or decrease the point size by @var{n}@w{ }points.  @var{n}@w{
8787 }must be exactly one digit.
8789 @item \s(@var{nn}
8790 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly
8791 two digits.
8793 @item \s+(@var{nn}
8794 @itemx \s-(@var{nn}
8795 @itemx \s(+@var{nn}
8796 @itemx \s(-@var{nn}
8797 Increase or decrease the point size by @var{nn}@w{ }points.  @var{nn}
8798 must be exactly two digits.
8799 @end table
8801 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8802 As a consequence, it can be used in requests like @code{mc} (which
8803 expects a single character as an argument) to change the font on
8804 the fly:
8806 @Example
8807 .mc \s[20]x\s[0]
8808 @endExample
8810 @xref{Fractional Type Sizes}, for yet another syntactical form of
8811 using the @code{\s} escape.
8812 @endDefreq
8814 @Defreq {sizes, s1 s2 @dots{} sn [0]}
8815 Some devices may only have certain permissible sizes, in which case
8816 @code{gtroff} rounds to the nearest permissible size.
8817 The @file{DESC} file specifies which sizes are permissible for the device.
8819 Use the @code{sizes} request to change the permissible sizes
8820 for the current output device.
8821 Arguments are in scaled points;
8822 the @code{sizescale} line in the
8823 @file{DESC} file for the output device
8824 provides the scaling factor.
8825 For example, if the scaling factor is 1000,
8826 then the value 12000 is 12@w{ }points.
8828 Each argument can be a single point size (such as 12000),
8829 or a range of sizes (such as 4000-72000).
8830 You can optionally end the list with a zero.
8831 @endDefreq
8833 @cindex changing vertical line spacing (@code{vs})
8834 @cindex vertical line spacing, changing (@code{vs})
8835 @cindex vertical line spacing register (@code{.v})
8836 @DefreqList {vs, [@Var{space}]}
8837 @DefreqItem {vs, @t{+}@Var{space}}
8838 @DefreqItem {vs, @t{-}@Var{space}}
8839 @DefregListEnd {.v}
8840 Change (increase, decrease) the vertical spacing by @var{space}.  The
8841 default unit is @samp{p}.
8843 If @code{vs} is called without an argument, the vertical spacing is
8844 reset to the previous value before the last call to @code{vs}.
8846 @cindex @code{.V} register, and @code{vs}
8847 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8848 zero or negative; the vertical spacing is then set to the vertical
8849 resolution (as given in the @code{.V} register).
8851 The read-only number register @code{.v} contains the current vertical
8852 spacing; it is associated with the current environment
8853 (@pxref{Environments}).
8854 @endDefreq
8856 @cindex vertical line spacing, effective value
8857 The effective vertical line spacing consists of four components.
8859 @itemize @bullet
8860 @item
8861 The vertical line spacing as set with the @code{vs} request.
8863 @cindex post-vertical line spacing
8864 @cindex line spacing, post-vertical (@code{pvs})
8865 @item
8866 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
8867 This is vertical space which will be added after a line has been
8868 output.
8870 @cindex extra pre-vertical line space (@code{\x})
8871 @cindex line space, extra pre-vertical (@code{\x})
8872 @item
8873 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
8874 using a negative value.  This is vertical space which will be added once
8875 before the current line has been output.
8877 @cindex extra post-vertical line space (@code{\x})
8878 @cindex line space, extra post-vertical (@code{\x})
8879 @item
8880 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
8881 using a positive value.  This is vertical space which will be added once
8882 after the current line has been output.
8883 @end itemize
8885 @cindex double spacing (@code{vs}, @code{pvs})
8886 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
8887 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
8888 granularity for the inserted vertical space compared to @code{ls};
8889 furthermore, certain preprocessors assume single spacing.
8891 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
8892 and the @code{ls} request.
8894 @cindex @code{ls} request, alternative to (@code{pvs})
8895 @cindex post-vertical line spacing, changing (@code{pvs})
8896 @cindex post-vertical line spacing register (@code{.pvs})
8897 @DefreqList {pvs, [@Var{space}]}
8898 @DefreqItem {pvs, @t{+}@Var{space}}
8899 @DefreqItem {pvs, @t{-}@Var{space}}
8900 @DefregListEnd {.pvs}
8901 Change (increase, decrease) the post-vertical spacing by
8902 @var{space}.  The default unit is @samp{p}.
8904 If @code{pvs} is called without an argument, the post-vertical spacing is
8905 reset to the previous value before the last call to @code{pvs}.
8907 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
8908 zero or negative; the vertical spacing is then set to zero.
8910 The read-only number register @code{.pvs} contains the current
8911 post-vertical spacing; it is associated with the current environment
8912 (@pxref{Environments}).
8913 @endDefreq
8915 @c XXX example
8917 @ignore
8918 @Example
8919 ... .sz macro example?? ...
8920 @endExample
8921 @end ignore
8923 @c ---------------------------------------------------------------------
8925 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
8926 @subsection Fractional Type Sizes
8927 @cindex fractional type sizes
8928 @cindex type sizes, fractional
8930 @cindex @code{s} unit
8931 @cindex unit, @code{s}
8932 @cindex @code{z} unit
8933 @cindex unit, @code{z}
8934 @cindex @code{ps} request, with fractional type sizes
8935 @cindex @code{cs} request, with fractional type sizes
8936 @cindex @code{tkf} request, with fractional type sizes
8937 @cindex @code{\H}, with fractional type sizes
8938 @cindex @code{\s}, with fractional type sizes
8939 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
8940 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
8941 default).  There is a new scale indicator @samp{z} which has the
8942 effect of multiplying by @var{sizescale}.  Requests and escape
8943 sequences in @code{gtroff} interpret arguments that represent a point
8944 size as being in units of scaled points, but they evaluate each such
8945 argument using a default scale indicator of @samp{z}.  Arguments
8946 treated in this way are the argument to the @code{ps} request, the
8947 third argument to the @code{cs} request, the second and fourth
8948 arguments to the @code{tkf} request, the argument to the @code{\H}
8949 escape sequence, and those variants of the @code{\s} escape sequence
8950 that take a numeric expression as their argument (see below).
8952 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
8953 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
8954 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
8955 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
8957 @code{gtroff} disallows the use of the @samp{z} scale indicator in
8958 instances where it would make no sense, such as a numeric
8959 expression whose default scale indicator was neither @samp{u} nor
8960 @samp{z}.  Similarly it would make
8961 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
8962 numeric expression whose default scale indicator was @samp{z}, and so
8963 @code{gtroff} disallows this as well.
8965 There is also new scale indicator @samp{s} which multiplies by the
8966 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
8967 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
8968 scale indicators.
8970 @Defreg {.ps}
8971 A read-only number register returning the point size in scaled points.
8973 @code{.ps} is associated with the current environment
8974 (@pxref{Environments}).
8975 @endDefreg
8977 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
8978 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
8979 @cindex @code{.ps} register, in comparison with @code{.psr}
8980 @cindex @code{.s} register, in comparison with @code{.sr}
8981 @DefregList {.psr}
8982 @DefregListEnd {.sr}
8983 The last-requested point size in scaled points is contained in the
8984 @code{.psr} read-only number register.  The last requested point size
8985 in points as a decimal fraction can be found in @code{.sr}.  This is a
8986 string-valued read-only number register.
8988 Note that the requested point sizes are device-independent, whereas
8989 the values returned by the @code{.ps} and @code{.s} registers are not.
8990 For example, if a point size of 11@dmn{pt} is requested, and a
8991 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
8992 specifies 10.95@dmn{pt} instead, this value is actually used.
8994 Both registers are associated with the current environment
8995 (@pxref{Environments}).
8996 @endDefreg
8998 The @code{\s} escape has the following syntax for working with
8999 fractional type sizes:
9001 @table @code
9002 @item \s[@var{n}]
9003 @itemx \s'@var{n}'
9004 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
9005 expression with a default scale indicator of @samp{z}.
9007 @item \s[+@var{n}]
9008 @itemx \s[-@var{n}]
9009 @itemx \s+[@var{n}]
9010 @itemx \s-[@var{n}]
9011 @itemx \s'+@var{n}'
9012 @itemx \s'-@var{n}'
9013 @itemx \s+'@var{n}'
9014 @itemx \s-'@var{n}'
9015 Increase or or decrease the point size by @var{n}@w{ }scaled points;
9016 @var{n}@w{ }is a numeric expression with a default scale indicator of
9017 @samp{z}.
9018 @end table
9020 @xref{Font Files}.
9023 @c =====================================================================
9025 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
9026 @section Strings
9027 @cindex strings
9029 @code{gtroff} has string variables, which are entirely for user
9030 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
9031 even this is a read-write string variable).
9033 @cindex string interpolation (@code{\*})
9034 @cindex string expansion (@code{\*})
9035 @cindex interpolation of strings (@code{\*})
9036 @cindex expansion of strings (@code{\*})
9037 @DefreqList {ds, name [@Var{string}]}
9038 @DefreqItem {ds1, name [@Var{string}]}
9039 @DefescItem {\\*, , n, }
9040 @DefescItem {\\*, @lparen{}, nm, }
9041 @DefescListEnd {\\*, @lbrack{}, name, @rbrack{}}
9042 Define and access a string variable @var{name} (one-character name@w{
9043 }@var{n}, two-character name @var{nm}).  If @var{name} already exists,
9044 @code{ds} overwrites the previous definition.
9046 Example:
9048 @Example
9049 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
9051 The \*(UX Operating System
9052 @endExample
9054 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9055 previously-defined string variable.  To be more precise, the stored
9056 string is pushed onto the input stack which is then parsed by
9057 @code{gtroff}.  Similar to number registers, it is possible to nest
9058 strings, i.e. string variables can be called within string variables.
9060 If the string named by the @code{\*} escape does not exist, it is
9061 defined as empty, and a warning of type @samp{mac} is emitted (see
9062 @ref{Debugging}, for more details).
9064 @cindex comments, with @code{ds}
9065 @cindex @code{ds} request, and comments
9066 @strong{Caution:} Unlike other requests, the second argument to the
9067 @code{ds} request takes up the entire line including trailing spaces.
9068 This means that comments on a line with such a request can introduce
9069 unwanted space into a string.
9071 @Example
9072 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9073 @endExample
9075 @noindent
9076 Instead the comment should be put on another line or have the comment
9077 escape adjacent with the end of the string.
9079 @Example
9080 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
9081 @endExample
9083 @cindex trailing quotes
9084 @cindex quotes, trailing
9085 @cindex leading spaces with @code{ds}
9086 @cindex spaces with @code{ds}
9087 @cindex @code{ds} request, and leading spaces
9088 To produce leading space the string can be started with a double
9089 quote.  No trailing quote is needed; in fact, any trailing quote is
9090 included in your string.
9092 @Example
9093 .ds sign "           Yours in a white wine sauce,
9094 @endExample
9096 @cindex multi-line strings
9097 @cindex strings, multi-line
9098 @cindex newline character in strings, escaping
9099 @cindex escaping newline characters in strings
9100 Strings are not limited to a single line of text.  A string can span
9101 several lines by escaping the newlines with a backslash.  The
9102 resulting string is stored @emph{without} the newlines.
9104 @Example
9105 .ds foo lots and lots \
9106 of text are on these \
9107 next several lines
9108 @endExample
9110 It is not possible to have real newlines in a string.  To put a single
9111 double quote character into a string, use two consecutive double quote
9112 characters.
9114 The @code{ds1} request turns off compatibility mode
9115 while interpreting a string.  To be more precise, a @dfn{compatibility
9116 save} input token is inserted at the beginning of  the string, and a
9117 @dfn{compatibility restore} input token at the end.
9119 @Example
9120 .nr xxx 12345
9121 .ds aa The value of xxx is \\n[xxx].
9122 .ds1 bb The value of xxx ix \\n[xxx].
9124 .cp 1
9126 \*(aa
9127     @result{} warning: number register `[' not defined
9128     @result{} The value of xxx is 0xxx].
9129 \*(bb
9130     @result{} The value of xxx ix 12345.
9131 @endExample
9133 @cindex name space of macros and strings
9134 @cindex macros, shared name space with strings
9135 @cindex strings, shared name space with macros
9136 Strings, macros, and diversions (and boxes) share the same name space.
9137 Internally, even the same mechanism is used to store them.  This has
9138 some interesting consequences.  For example, it is possible to call a
9139 macro with string syntax and vice versa.
9141 @Example
9142 .de xxx
9143 a funny test.
9145 This is \*[xxx]
9146     @result{} This is a funny test.
9148 .ds yyy a funny test
9149 This is
9150 .yyy
9151     @result{} This is a funny test.
9152 @endExample
9154 Diversions and boxes can be also called with string syntax.  It is not
9155 possible to pass arguments to a macro if called with @code{\*}.
9157 Another consequence is that you can copy one-line diversions or boxes
9158 to a string.
9160 @Example
9161 .di xxx
9162 a \fItest\fR
9165 .ds yyy This is \*[xxx]\c
9166 \*[yyy].
9167     @result{} @r{This is a }@i{test}.
9168 @endExample
9170 @noindent
9171 As the previous example shows, it is possible to store formatted
9172 output in strings.  The @code{\c} escape prevents the insertion of an
9173 additional blank line in the output.
9175 Copying diversions longer than a single output line produces
9176 unexpected results.
9178 @Example
9179 .di xxx
9180 a funny
9182 test
9185 .ds yyy This is \*[xxx]\c
9186 \*[yyy].
9187     @result{} test This is a funny.
9188 @endExample
9190 Usually, it is not predictable whether a diversion contains one or
9191 more output lines, so this mechanism should be avoided.  With
9192 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9193 final newline from a diversion.  Another disadvantage is that the
9194 spaces in the copied string are already formatted, making them
9195 unstretchable.  This can cause ugly results.
9197 @cindex stripping final newline in diversions
9198 @cindex diversions, stripping final newline
9199 @cindex final newline, stripping in diversions
9200 @cindex newline, final, stripping in diversions
9201 @cindex horizontal space, unformatting
9202 @cindex space, horizontal, unformatting
9203 @cindex unformatting horizontal space
9204 A clean solution to this problem is available in GNU @code{troff},
9205 using the requests @code{chop} to remove the final newline of a
9206 diversion, and @code{unformat} to make the horizontal spaces
9207 stretchable again.
9209 @Example
9210 .box xxx
9211 a funny
9213 test
9215 .box
9216 .chop xxx
9217 .unformat xxx
9218 This is \*[xxx].
9219     @result{} This is a funny test.
9220 @endExample
9222 @xref{Gtroff Internals}, for more information.
9223 @endDefreq
9225 @cindex appending to strings (@code{as})
9226 @cindex strings, appending (@code{as})
9227 @DefreqList {as, name [@Var{string}]}
9228 @DefreqListEnd {as1, name [@Var{string}]}
9229 The @code{as} request is similar to @code{ds} but appends @var{string}
9230 to the string stored as @var{name} instead of redefining it.  If
9231 @var{name} doesn't exist yet, it is created.
9233 @Example
9234 .as sign " with shallots, onions and garlic,
9235 @endExample
9237 The @code{as1} request is similar to @code{as}, but compatibility mode
9238 is switched off while the appended string is interpreted.  To be more
9239 precise, a @dfn{compatibility save} input token is inserted at the
9240 beginning of the appended string, and a @dfn{compatibility restore}
9241 input token at the end.
9242 @endDefreq
9244 Rudimentary string manipulation routines are given with the next two
9245 requests.
9247 @cindex substring (@code{substring})
9248 @Defreq {substring, str n1 [@Var{n2}]}
9249 Replace the string in register@w{ }@var{str} with the substring
9250 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
9251 in the string has index one.  If @var{n2} is omitted, it is taken to
9252 be equal to the string's length.  If the index value @var{n1} or
9253 @var{n2} is negative or zero, it is counted from the end of the
9254 string, going backwards: The last character has index@w{ }0, the
9255 character before the last character has index@w{ }@minus{}1, etc.
9257 @Example
9258 .ds xxx abcdefgh
9259 .substring xxx 2 -3
9260 \*[xxx]
9261     @result{} bcde
9262 @endExample
9263 @endDefreq
9265 @cindex length of a string (@code{length})
9266 @cindex string, length of (@code{length})
9267 @Defreq {length, reg str}
9268 Compute the length of @var{str} and returns it in the number
9269 register@w{ }@var{reg}.  If @var{reg} doesn't exist, it is created.
9271 @Example
9272 .ds xxx abcdefgh
9273 .length yyy xxx
9274 \n[yyy]
9275     @result{} 8
9276 @endExample
9277 @endDefreq
9279 @cindex rename request (@code{rn})
9280 @cindex rename macro (@code{rn})
9281 @cindex rename string (@code{rn})
9282 @Defreq {rn, xx yy}
9283 Rename the request, macro, or string @var{xx} to @var{yy}.
9284 @endDefreq
9286 @cindex remove request (@code{rm})
9287 @cindex remove macro (@code{rm})
9288 @cindex remove string (@code{rm})
9289 @Defreq {rm, xx}
9290 Remove the request, macro, or string @var{xx}.  @code{gtroff} treats
9291 subsequent invocations as if the object had never been defined.
9292 @endDefreq
9294 @cindex alias, creating (@code{als})
9295 @cindex creating alias (@code{als})
9296 @Defreq {als, new old}
9297 Create an alias named @var{new} for the request, string, macro, or
9298 diversion object named @var{old}.  The new name and the old name are
9299 exactly equivalent (it is similar to a hard rather than a soft
9300 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9301 type @samp{mac} and ignores the request.
9302 @endDefreq
9304 @Defreq {chop, xx}
9305 Remove (chop) the last character from the macro, string, or diversion
9306 named @var{xx}. This is useful for removing the newline from the end
9307 of diversions that are to be interpolated as strings.  This command
9308 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9309 nodes inserted by @code{gtroff} automatically.
9310 @endDefreq
9312 @xref{Identifiers}, and @ref{Comments}.
9315 @c =====================================================================
9317 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9318 @section Conditionals and Loops
9319 @cindex conditionals and loops
9320 @cindex loops and conditionals
9322 @c XXX Introductory text
9324 @menu
9325 * Operators in Conditionals::
9326 * if-else::
9327 * while::
9328 @end menu
9330 @c ---------------------------------------------------------------------
9332 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9333 @subsection Operators in Conditionals
9335 @cindex @code{if} request, operators to use with it
9336 @cindex @code{while} request, operators to use with it
9337 In @code{if} and @code{while} requests, there are several more
9338 operators available:
9340 @table @code
9341 @item e
9342 @itemx o
9343 True if the current page is even or odd numbered (respectively).
9345 @item n
9346 True if the document is being processed in nroff mode (i.e., the
9347 @code{.nroff} command has been issued).
9349 @item t
9350 True if the document is being processed in troff mode (i.e., the
9351 @code{.troff} command has been issued).
9353 @item v
9354 Always false.  This condition is for compatibility with other
9355 @code{troff} versions only.
9357 @item '@var{xxx}'@var{yyy}'
9358 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
9359 characters can be used in place of the single quotes; the same set of
9360 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9361 @code{gtroff} formats the strings before being compared:
9363 @Example
9364 .ie "|"\fR|\fP" \
9365 true
9366 .el \
9367 false
9368     @result{} true
9369 @endExample
9371 @noindent
9372 The resulting motions, character sizes, and fonts have to
9373 match,@footnote{The created output nodes must be identical.
9374 @xref{Gtroff Internals}.} and not the individual motion, size, and
9375 font requests.  In the previous example, @samp{|} and @samp{\fR|\fP}
9376 both result in a roman @samp{|} character with the same point size and
9377 at the same location on the page, so the strings are equal.  If
9378 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
9379 would be ``false'' because (the first) @samp{|} produces an italic
9380 @samp{|} rather than a roman one.
9382 @item r @var{xxx}
9383 True if there is a number register named @var{xxx}.
9385 @item d @var{xxx}
9386 True if there is a string, macro, diversion, or request named @var{xxx}.
9388 @item m @var{xxx}
9389 True if there is a color named @var{xxx}.
9391 @item c @var{ch}
9392 True if there is a character @var{ch} available; @var{ch} is either an
9393 @acronym{ASCII} character or a special character (@code{\(@var{ch}} or
9394 @code{\[@var{ch}]}); the condition is also true if @var{ch} has been
9395 defined by the @code{char} request.
9396 @end table
9398 Note that these operators can't be combined with other operators like
9399 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9400 between the exclamation mark and the operator) can be used to negate
9401 the result.
9403 @Example
9404 .nr xxx 1
9405 .ie !r xxx \
9406 true
9407 .el \
9408 false
9409     @result{} false
9410 @endExample
9412 A whitespace after @samp{!} always evaluates to zero (this bizarre
9413 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9415 @Example
9416 .nr xxx 1
9417 .ie ! r xxx \
9418 true
9419 .el \
9420 false
9421     @result{} r xxx true
9422 @endExample
9424 It is possible to omit the whitespace before the argument to the
9425 @samp{r}, @samp{d}, and @samp{c} operators.
9427 @xref{Expressions}.
9429 @c ---------------------------------------------------------------------
9431 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9432 @subsection if-else
9433 @cindex if-else
9435 @code{gtroff} has if-then-else constructs like other languages, although
9436 the formatting can be painful.
9438 @Defreq {if, expr anything}
9439 Evaluate the expression @var{expr}, and executes @var{anything} (the
9440 remainder of the line) if @var{expr} evaluates to non-zero (true).
9441 @var{anything} is interpreted as though it was on a line by itself
9442 (except that leading spaces are swallowed).  @xref{Expressions}, for
9443 more info.
9445 @Example
9446 .nr xxx 1
9447 .nr yyy 2
9448 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9449     @result{} true
9450 @endExample
9451 @endDefreq
9453 @Defreq{nop, anything}
9454 Executes @var{anything}.
9455 This is similar to @code{.if@w{ }1}.
9456 @endDefreq
9458 @DefreqList {ie, expr anything}
9459 @DefreqListEnd {el, anything}
9460 Use the @code{ie} and @code{el} requests to write an if-then-else.
9461 The first request is the `if' part and the latter is the `else' part.
9463 @Example
9464 .ie n .ls 2 \" double spacing in nroff
9465 .el   .ls 1 \" single spacing in troff
9466 @endExample
9467 @endDefreq
9469 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9470 @c to @deffn
9472 @c and in 4.2 you still can't use @{ in macros.
9474 @cindex begin of conditional block (@code{\@{})
9475 @cindex end of conditional block (@code{\@}})
9476 @cindex conditional block, begin (@code{\@{})
9477 @cindex conditional block, end (@code{\@}})
9478 @cindex block, conditional, begin (@code{\@{})
9479 @cindex block, condititional, end (@code{\@}})
9480 @c @DefescList {\@{, , , }
9481 @c @DefescListEnd {\@}, , , }
9482 @deffn Escape @t{\@{}
9483 @deffnx Escape @t{\@}}
9484 @esindex \@{
9485 @esindex \@}
9486 In many cases, an if (or if-else) construct needs to execute more than
9487 one request.  This can be done using the @code{\@{} and @code{\@}}
9488 escapes.  The following example shows the possible ways to use these
9489 escapes (note the position of the opening and closing braces).
9491 @Example
9492 .ie t \@{\
9493 .    ds lq ``
9494 .    ds rq ''
9495 .\@}
9496 .el \
9497 .\@{\
9498 .    ds lq "
9499 .    ds rq "\@}
9500 @endExample
9501 @c @endDefesc
9502 @end deffn
9504 @xref{Expressions}.
9506 @c ---------------------------------------------------------------------
9508 @node while,  , if-else, Conditionals and Loops
9509 @subsection while
9510 @cindex while
9512 @code{gtroff} provides a looping construct using the @code{while}
9513 request, which is used much like the @code{if} (and related) requests.
9515 @Defreq {while, expr anything}
9516 Evaluate the expression @var{expr}, and repeatedly execute
9517 @var{anything} (the remainder of the line) until @var{expr} evaluates
9518 to@w{ }0.
9520 @Example
9521 .nr a 0 1
9522 .while (\na < 9) \@{\
9523 \n+a,
9524 .\@}
9525 \n+a
9526     @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9527 @endExample
9529 Some remarks.
9531 @cindex @code{de} request, and @code{while}
9532 @itemize @bullet
9533 @item
9534 The body of a @code{while} request is treated like the body of a
9535 @code{de} request: @code{gtroff} temporarily stores it in a macro
9536 which is deleted after the loop has been exited.  It can considerably
9537 slow down a macro if the body of the @code{while} request (within the
9538 macro) is large.  Each time the macro is executed, the @code{while}
9539 body is parsed and stored again as a temporary macro.
9541 @Example
9542 .de xxx
9543 .  nr num 10
9544 .  while (\\n[num] > 0) \@{\
9545 .    \" many lines of code
9546 .    nr num -1
9547 .  \@}
9549 @endExample
9551 @cindex recursive macros
9552 @cindex macros, recursive
9553 @noindent
9554 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9555 doesn't have the @code{while} request) is to use a recursive macro
9556 instead which is parsed only once during its definition.
9558 @Example
9559 .de yyy
9560 .  if (\\n[num] > 0) \@{\
9561 .    \" many lines of code
9562 .    nr num -1
9563 .    yyy
9564 .  \@}
9567 .de xxx
9568 .  nr num 10
9569 .  yyy
9571 @endExample
9573 @noindent
9574 Note that the number of available recursion levels is set to@w{ }1000
9575 (this is a compile-time constant value of @code{gtroff}).
9577 @item
9578 The closing brace of a @code{while} body must end a line.
9580 @Example
9581 .if 1 \@{\
9582 .  nr a 0 1
9583 .  while (\n[a] < 10) \@{\
9584 .    nop \n+[a]
9585 .\@}\@}
9586     @result{} unbalanced \@{ \@}
9587 @endExample
9588 @end itemize
9589 @endDefreq
9591 @cindex @code{while} request, confusing with @code{br}
9592 @cindex @code{break} request, in a @code{while} loop
9593 @cindex @code{continue} request, in a @code{while} loop
9594 @Defreq {break, }
9595 Break out of a @code{while} loop.  Be sure not to confuse this with
9596 the @code{br} request (causing a line break).
9597 @endDefreq
9599 @Defreq {continue, }
9600 Finish the current iteration of a @code{while} loop, immediately
9601 restarting the next iteration.
9602 @endDefreq
9604 @xref{Expressions}.
9607 @c =====================================================================
9609 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9610 @section Writing Macros
9611 @cindex writing macros
9612 @cindex macros, writing
9614 A @dfn{macro} is a collection of text and embedded commands which can
9615 be invoked multiple times.  Use macros to define common operations.
9617 @DefreqList {de, name [@Var{end}]}
9618 @DefreqItem {de1, name [@Var{end}]}
9619 @DefreqListEnd {dei, name [@Var{end}]}
9620 Define a new macro named @var{name}.  @code{gtroff} copies subsequent
9621 lines (starting with the next one) into an internal buffer until it
9622 encounters the line @samp{..} (two dots).  The optional second
9623 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9625 There can be whitespace after the first dot in the line containing the
9626 ending token (either @samp{.} or macro @samp{@var{end}}).
9628 Here a small example macro called @samp{P} which causes a break and
9629 inserts some vertical space.  It could be used to separate paragraphs.
9631 @Example
9632 .de P
9633 .  br
9634 .  sp .8v
9636 @endExample
9638 @c XXX add info about macro definitions in macros.
9640 @c XXX give example for end macro.
9642 The @code{de1} request turns off compatibility mode
9643 while executing the macro.  On entry, the current compatibility mode
9644 is saved and restored at exit.
9646 @Example
9647 .nr xxx 12345
9649 .de aa
9650 The value of xxx is \\n[xxx].
9652 .de1 bb
9653 The value of xxx ix \\n[xxx].
9656 .cp 1
9659     @result{} warning: number register \e' not defined
9660     @result{} The value of xxx is 0xxx].
9662     @result{} The value of xxx ix 12345.
9663 @endExample
9665 The @code{dei} request defines a macro indirectly.
9666 That is, it expands strings whose names
9667 are @var{name} or @var{end} before performing the append.
9669 This:
9671 @Example
9672 .ds xx aa
9673 .ds yy bb
9674 .dei xx yy
9675 @endExample
9677 @noindent
9678 is equivalent to:
9680 @Example
9681 .de aa bb
9682 @endExample
9684 @pindex trace.tmac
9685 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9687 @c XXX info about common identifier pool for strings, macros, and
9688 @c     diversions.
9689 @endDefreq
9691 @cindex appending, to a macro (@code{am})
9692 @cindex macro appending (@code{am})
9693 @DefreqList {am, xx}
9694 @DefreqItem {am1, xx}
9695 @DefreqListEnd {ami, xx yy}
9696 Works similarly to @code{de} except it appends onto the macro named
9697 @var{xx}.  So, to make the previously defined @samp{P} macro actually
9698 do indented instead of block paragraphs, add the necessary code to the
9699 existing macro like this:
9701 @Example
9702 .am P
9703 .ti +5n
9705 @endExample
9707 The @code{am1} request turns off compatibility mode
9708 while executing the appended macro piece.  To be more precise, a
9709 @dfn{compatibility save} input token is inserted at the beginning of
9710 the appended code, and a @dfn{compatibility restore} input token at
9711 the end.
9713 The @code{ami} request appends indirectly,
9714 meaning that @code{gtroff} expands strings whose names
9715 are @var{xx} or @var{yy} before performing the append.
9717 @pindex trace.tmac
9718 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9719 @endDefreq
9721 @cindex alias, creating (@code{als})
9722 @cindex creating alias (@code{als})
9723 @xref{Strings}, for the @code{als} request to rename a macro.
9725 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9726 @code{as} requests (together with its variants) only create a new object
9727 if the name of the macro, diversion or string diversion is currently
9728 undefined or if it is defined to be a request; normally they modify the
9729 value of an existing object.
9731 @Defreq {return, }
9732 Exit a macro, immediately returning to the caller.
9733 @endDefreq
9735 @menu
9736 * Copy-in Mode::
9737 * Parameters::
9738 @end menu
9740 @c ---------------------------------------------------------------------
9742 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9743 @subsection Copy-in Mode
9744 @cindex copy-in mode
9745 @cindex mode, copy-in
9747 @cindex @code{\n}, when reading text for a macro
9748 @cindex @code{\$}, when reading text for a macro
9749 @cindex @code{\*}, when reading text for a macro
9750 @cindex @code{\\}, when reading text for a macro
9751 @cindex \@key{RET}, when reading text for a macro
9752 When @code{gtroff} reads in the text for a macro or diversion, it copies
9753 the text (including request lines, but excluding escapes) into an
9754 internal buffer.  Escapes are converted into an internal form,
9755 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9756 @code{\@key{RET}} which are evaluated and inserted into the text where
9757 the escape was located.  This is known as @dfn{copy-in} mode or
9758 @dfn{copy} mode.
9760 What this means is that you can specify when these escapes are to be
9761 evaluated (either at copy-in time or at the time of use) by insulating
9762 the escapes with an extra backslash.  Compare this to the @code{\def}
9763 and @code{\edef} commands in @TeX{}.
9765 The following example prints the numbers 20 and@w{ }10:
9767 @Example
9768 .nr x 20
9769 .de y
9770 .nr x 10
9771 \&\nx
9772 \&\\nx
9775 @endExample
9777 @c ---------------------------------------------------------------------
9779 @node Parameters,  , Copy-in Mode, Writing Macros
9780 @subsection Parameters
9781 @cindex parameters
9783 The arguments to a macro can be examined using a variety of escapes.
9785 @cindex number of arguments register (@code{.$})
9786 @Defreg {.$}
9787 The number of arguments in a macro.  This is a read-only number register.
9788 @endDefreg
9790 Any individual argument can be retrieved with one of the following
9791 escapes:
9793 @cindex copy-in mode, and macro arguments
9794 @cindex macro arguments (@code{\$})
9795 @cindex arguments, macro (@code{\$})
9796 @DefescList {\\$, , n, }
9797 @DefescItem {\\$, @lparen{}, nn, }
9798 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
9799 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
9800 argument.  As usual, the first form only accepts a single number
9801 (larger than zero), the second a two-digit number (larger or equal
9802 to@w{ }10), and the third any positive integer value (larger
9803 than zero).  Macros can have an unlimited number of arguments.  Note
9804 that due to copy-in mode, use two backslashes on these in actual use to
9805 prevent interpolation until the macro is actually invoked.
9806 @endDefesc
9808 @Defreq {shift, [@Var{n}]}
9809 Shift the arguments 1@w{ }position, or as
9810 many positions as specified by its argument.  After executing this
9811 request, argument@w{ }@var{i} becomes argument @math{@var{i}-@var{n}};
9812 arguments 1 to@w{ }@var{n} are no longer available.  Shifting by
9813 negative amounts is currently undefined.
9814 @endDefreq
9816 @DefescList {\\$*, , , }
9817 @DefescListEnd {\\$@@, , , }
9818 In some cases it is convenient to use all of the arguments at once (for
9819 example, to pass the arguments along to another macro).  The @code{\$*}
9820 escape concatenates all the arguments separated by spaces.  A
9821 similar escape is @code{\$@@}, which concatenates all the
9822 arguments with each surrounded by double quotes, and separated by
9823 spaces.  If not in compatibility mode, the input level of double quotes
9824 is preserved (see @ref{Request Arguments}).
9825 @endDefesc
9827 @cindex macro name register (@code{\$0})
9828 @cindex @code{als} request, and @code{\$0}
9829 @cindex @code{als} request, use with @code{\$0}
9830 @Defesc {\\$0, , , }
9831 The name used to invoke the current macro.
9832 The @code{als} request can make a macro have more than one name.
9834 @Example
9835 .de generic-macro
9836 .  ...
9837 .  if \\n[error] \@{\
9838 .    tm \\$0: Houston, we have a problem.
9839 .    return
9840 .  \@}
9843 .als foo generic-macro
9844 .als bar generic-macro
9845 @endExample
9846 @endDefesc
9848 @xref{Request Arguments}.
9851 @c =====================================================================
9853 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
9854 @section Page Motions
9855 @cindex page motions
9856 @cindex motions, page
9858 @xref{Manipulating Spacing}, for a discussion of the main request for
9859 vertical motion, @code{sp}.
9861 @cindex marking vertical page location (@code{mk})
9862 @cindex page location, vertical, marking (@code{mk})
9863 @cindex location, vertical, page, marking (@code{mk})
9864 @cindex vertical page location, marking (@code{mk})
9865 @cindex returning to marked vertical page location (@code{rt})
9866 @cindex page location, vertical, returning to marked (@code{rt})
9867 @cindex location, vertical, page, returning to marked (@code{rt})
9868 @cindex vertical page location, returning to marked (@code{rt})
9869 @DefreqList {mk, [@Var{reg}]}
9870 @DefreqListEnd {rt, [@Var{dist}]}
9871 The request @code{mk} can be used to mark a location on a page, for
9872 movement to later.  This request takes a register name as an argument
9873 in which to store the current page location.  With no argument it
9874 stores the location in an internal register.  The results of this can
9875 be used later by the @code{rt} or the @code{sp} request (or the
9876 @code{\v} escape).
9878 The @code{rt} request returns @emph{upwards} to the location marked
9879 with the last @code{mk} request.  If used with an argument, return to
9880 a position which distance from the top of the page is @var{dist} (no
9881 previous call to @code{mk} is necessary in this case).
9883 @c XXX example
9884 @ignore
9885 @Example
9886 ... dual column example ...
9887 @endExample
9888 @end ignore
9889 @endDefreq
9891 The following escapes give fine control of movements about the page.
9893 @cindex vertical motion (@code{\v})
9894 @cindex motion, vertical (@code{\v})
9895 @Defesc {\\v, ', e, '}
9896 Move vertically, usually from the current location on the page (if no
9897 absolute position operator @samp{|} is used).  The
9898 argument@w{ }@var{e} specifies the distance to move; positive is
9899 downwards and negative upwards.  The default unit for this escape
9900 @samp{v}.  Beware, however, that @code{gtroff} continues text
9901 processing at the point where the motion ends, so you should always
9902 balance motions to avoid interference with text processing.
9904 @code{\v} doesn't trigger a trap.  This can be quite useful; for example,
9905 consider a page bottom trap macro which prints a marker in the margin to
9906 indicate continuation of a footnote or something similar.
9907 @endDefesc
9909 There are some special-case escapes for vertical motion.
9911 @Defesc {\\r, , , }
9912 Move upwards@w{ }1@dmn{v}.
9913 @endDefesc
9915 @Defesc {\\u, , , }
9916 Move upwards@w{ }.5@dmn{v}.
9917 @endDefesc
9919 @Defesc {\\d, , , }
9920 Move down@w{ }.5@dmn{v}.
9921 @endDefesc
9923 @cindex inserting horizontal space (@code{\h})
9924 @cindex horizontal space (@code{\h})
9925 @cindex space, horizontal (@code{\h})
9926 @Defesc {\\h, ', e, '}
9927 Move horizontally, usually from the current location (if no absolute
9928 position operator @samp{|} is used).  The
9929 expression@w{ }@var{e} indicates how far to move: positive is rightwards
9930 and negative leftwards.
9931 @c XXX Is there a default unit for this?
9932 @endDefesc
9934 There are a number of special-case escapes for horizontal motion.
9936 @cindex space, unbreakable
9937 @cindex unbreakable space
9938 @Defesc {\\@key{SP}, , , }
9939 An unbreakable and unpaddable (i.e.@: not expanded during filling)
9940 space.  (Note: This is a backslash followed by a space.)
9941 @endDefesc
9943 @Defesc {\\~, , , }
9944 An unbreakable space that stretches like a normal inter-word space
9945 when a line is adjusted.
9946 @endDefesc
9948 @Defesc {\\|, , , }
9949 A 1/6@dmn{th} em space.  Ignored for tty output devices (rounded to
9950 zero).
9951 @endDefesc
9953 @Defesc {\\^, , , }
9954 A 1/12@dmn{th} em space.  Ignored for tty output devices (rounded to
9955 zero).
9956 @endDefesc
9958 @cindex space, width of a digit
9959 @cindex digit width space
9960 @Defesc {\\0, , , }
9961 A space the size of a digit.
9962 @endDefesc
9964 The following string sets the @TeX{} logo:
9966 @Example
9967 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
9968 @endExample
9970 @cindex width escape (@code{\w})
9971 @cindex escape, width (@code{\w})
9972 @DefescList {\\w, ', text, '}
9973 @DefregItem {st}
9974 @DefregItem {sb}
9975 @DefregItem {rst}
9976 @DefregItem {rsb}
9977 @DefregItem {ct}
9978 @DefregItem {ssc}
9979 @DefregListEnd {skw}
9980 Return the width of the specified @var{text} in basic units.
9981 This allows horizontal movement based on the width of some
9982 arbitrary text (e.g.@: given as an argument to a macro).
9984 @c XXX example
9986 @ignore
9987 @Example
9988 ... strlen example ...
9989 @endExample
9990 @end ignore
9992 Font changes may occur in @var{text} which don't affect current
9993 settings.
9995 After use, @code{\w} sets several registers:
9997 @table @code
9998 @item st
9999 @itemx sb
10000 The highest and lowest point of the baseline, respectively, in @var{text}.
10002 @item rst
10003 @itemx rsb
10004 Like the @code{st} and @code{sb} registers, but takes account of the
10005 heights and depths of characters.  With other words, this gives the
10006 highest and lowest point of @var{text}.
10008 @item ct
10009 Defines the kinds of characters occurring in @var{text}:
10011 @table @asis
10012 @item 0
10013 only short characters, no descenders or tall characters.
10015 @item 1
10016 at least one descender.
10018 @item 2
10019 at least one tall character.
10021 @item 3
10022 at least one each of a descender and a tall character.
10023 @end table
10025 @item ssc
10026 The amount of horizontal space (possibly negative) that should be added
10027 to the last character before a subscript.
10029 @item skw
10030 How far to right of the center of the last character in the @code{\w}
10031 argument, the center of an accent from a roman font should be placed
10032 over that character.
10033 @end table
10034 @endDefesc
10036 @cindex saving horizontal input line position (@code{\k})
10037 @cindex horizontal input line position, saving (@code{\k})
10038 @cindex input line position, horizontal, saving (@code{\k})
10039 @cindex position, horizontal input line, saving (@code{\k})
10040 @cindex line, input, horizontal position, saving (@code{\k})
10041 @DefescList {\\k, , p, }
10042 @DefescItem {\\k, @lparen{}, ps, }
10043 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10044 Store the current horizontal position in the @emph{input} line in
10045 number register with name @var{position} (one-character name@w{ }@var{p},
10046 two-character name @var{ps}).  Use this, for example, to return to the
10047 beginning of a string for highlighting or other decoration.
10048 @endDefesc
10050 @cindex horizontal input line position register (@code{hp})
10051 @cindex input line, horizontal position, register (@code{hp})
10052 @cindex position, horizontal, in input line, register (@code{hp})
10053 @cindex line, input, horizontal position, register (@code{hp})
10054 @Defreg {hp}
10055 The current horizontal position at the input line.
10056 @endDefreg
10058 @cindex horizontal output line position register (@code{.k})
10059 @cindex output line, horizontal position, register (@code{.k})
10060 @cindex position, horizontal, in output line, register (@code{.k})
10061 @cindex line, output, horizontal position, register (@code{.k})
10062 @Defreg {.k}
10063 A read-only number register containing the current horizontal output
10064 position.
10065 @endDefreg
10067 @Defesc {\\Z, ', anything, '}
10068 Print @var{anything}, then restore the horizontal and vertical position.
10069 The argument may not contain tabs or leaders.
10071 The following is an example of a strike-through macro:
10073 @Example
10074 .de ST
10075 .nr ww \w'\\$1'
10076 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10079 This is
10080 .ST "a test"
10081 an actual emergency!
10082 @endExample
10083 @endDefesc
10085 @c XXX documentation
10088 @c =====================================================================
10090 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10091 @section Drawing Requests
10092 @cindex drawing requests
10093 @cindex requests for drawing
10095 @code{gtroff} provides a number of ways to draw lines and other figures
10096 on the page.  Used in combination with the page motion commands (see
10097 @ref{Page Motions}, for more info), a wide variety of figures can be
10098 drawn.  However, for complex drawings these operations can be quite
10099 cumbersome, and it may be wise to use graphic preprocessors like
10100 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
10101 information.
10103 All drawing is done via escapes.
10105 @cindex drawing horizontal lines (@code{\l})
10106 @cindex horizontal line, drawing (@code{\l})
10107 @cindex line, horizontal, drawing (@code{\l})
10108 @DefescList {\\l, ', @Var{l}, '}
10109 @DefescListEnd {\\l, ', @Var{l}@Var{c}, '}
10110 Draw a line rightwards from the current location.
10111 @var{l} is the length of the line to be drawn, starting at the
10112 current location; positive numbers draw to the right, and negative
10113 numbers draw towards the left.  This can also be specified absolutely
10114 (i.e.@: with a leading @samp{|}) which draws back to the beginning
10115 of the input line.
10117 @cindex underscore character
10118 @cindex character, underscore
10119 @cindex line drawing character
10120 @cindex character for line drawing
10121 The optional second parameter@w{ }@var{c} is a character to draw the line
10122 with.  If this second argument is not specified, @code{gtroff} uses
10123 the underscore character.
10125 @cindex zero width space character (@code{\&})
10126 @cindex character, zero width space (@code{\&})
10127 @cindex space character, zero width (@code{\&})
10128 To separate the two arguments (to prevent @code{gtroff} from
10129 interpreting a drawing character as a scaling indicator) use @code{\&}.
10131 Here a small useful example:
10133 @Example
10134 .de box
10135 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10137 @endExample
10139 @noindent
10140 Note that this works by outputting a box rule (a vertical line), then
10141 the text given as an argument and then another box rule.  Then the line
10142 drawing escapes both draw from the current location to the beginning of
10143 the @emph{input} line.
10144 @endDefesc
10146 @cindex drawing vertical lines (@code{\L})
10147 @cindex vertical line drawing (@code{\L})
10148 @cindex line, vertical, drawing (@code{\L})
10149 @cindex line drawing character
10150 @cindex character for line drawing
10151 @cindex box rule character
10152 @cindex character, box rule
10153 @DefescList {\\L, ', @Var{l}, '}
10154 @DefescListEnd {\\L, ', @Var{l}@Var{c}, '}
10155 Draw vertical lines.  Its parameters are
10156 similar to the @code{\l} escape.  The
10157 movement is downwards for positive values,
10158 and upwards for negative values.  The
10159 default character is the box rule character.  As with the vertical
10160 motion escapes, text processing blindly continues where the line
10161 ends.
10163 @c XXX example
10165 @ignore
10166 @Example
10167 ... box macro ...
10168 @endExample
10169 @end ignore
10170 @endDefesc
10172 @Defesc {\\D, ', command arg @dots{}, '}
10173 The @code{\D} escape provides a variety of drawing functions.
10174 Note that on character devices, only vertical and horizontal lines are
10175 supported within @code{grotty}; other devices may only support a subset
10176 of the available drawing functions.
10178 @table @code
10179 @item \D'l @var{dx} @var{dy}'
10180 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10181 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10182 Draw a line from the current location to the relative point specified by
10183 (@var{dx},@var{dy}).
10185 @c XXX example
10187 @ignore
10188 @Example
10189 ... revised box macro ...
10190 @endExample
10191 @end ignore
10193 @item \D'c @var{d}'
10194 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10195 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10196 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
10197 current position.
10199 @item \D'C @var{d}'
10200 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10201 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10202 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10203 Draw a solid circle with the same parameters as an outlined circle.
10205 @item \D'e @var{x} @var{y}'
10206 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10207 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10208 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10209 diameter of @var{y} with the leftmost point at the current position.
10211 @item \D'E @var{x} @var{y}'
10212 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10213 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10214 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10215 Draw a solid ellipse with the same parameters as an outlined ellipse.
10217 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10218 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10219 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10220 Draw an arc clockwise from the current location through the two
10221 specified relative locations (@var{dx1},@var{dy1}) and
10222 (@var{dx2},@var{dy2}).  The coordinates of the first point are relative
10223 to the current position, and the coordinates of the second point are
10224 relative to the first point.
10226 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10227 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10228 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10229 Draw a spline from the current location to the relative point
10230 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10232 @item \D'f @var{n}'
10233 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10234 @cindex shading (@w{@code{\D'f @dots{}'}})
10235 @cindex shades for filling objects (@w{@code{\D'f @dots{}'}})
10236 Set the shade of gray to be used for filling solid objects to@w{
10237 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
10238 corresponds solid white and 1000 to solid black, and values in between
10239 correspond to intermediate shades of gray.  This applies only to solid
10240 circles, solid ellipses, and solid polygons.  By default, a level of
10241 1000 is used.
10243 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10244 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10245 @cindex polygon, drawing (@w{@code{\D''p @dots{}}})
10246 Draw a polygon from the current location to the relative position
10247 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10248 When the specified data points are exhausted, a line is drawn back
10249 to the starting point.
10251 @c XXX example
10253 @ignore
10254 @Example
10255 ... box example (yes, again) ...
10256 @endExample
10257 @end ignore
10259 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10260 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10261 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10262 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10263 Draw a solid polygon with the same parameters as an outlined polygon.
10265 @c XXX example
10267 @ignore
10268 @Example
10269 ... shaded box example ...
10270 @endExample
10271 @end ignore
10273 @item \D't @var{n}'
10274 @cindex line thickness (@w{@code{\D't @dots{}'}})
10275 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10276 Set the current line thickness to @var{n}@w{ }machine units.  A value of
10277 zero selects the smallest available line thickness.  A negative value
10278 makes the line thickness proportional to the current point size (this is
10279 the default behaviour of @code{ditroff}).
10280 @end table
10281 @endDefesc
10283 @xref{Drawing Functions}.
10285 @cindex pile, character (@code{\b})
10286 @cindex character pile (@code{\b})
10287 @cindex stacking characters (@code{\b})
10288 @Defesc {\\b, ', string, '}
10289 @dfn{Pile} a sequence of characters vertically, and center it vertically
10290 on the current line.  Use it to build large brackets and braces.
10292 @Example
10293 \b'\(lt\(bv\(lk\(bv\(lb'
10294 @endExample
10295 @endDefesc
10298 @c =====================================================================
10300 @node Traps, Diversions, Drawing Requests, gtroff Reference
10301 @section Traps
10302 @cindex traps
10304 @dfn{Traps} are locations, which, when reached, call a specified
10305 macro.  These traps can occur at a given location on the page, at a
10306 given location in the current diversion,
10307 at a blank line,
10308 after a certain number of input lines,
10309 or at the end of input.
10311 @cindex trap, springing
10312 @cindex springing a trap
10313 It is also said that a trap is @dfn{sprung} if the associated macro
10314 is executed.
10316 @menu
10317 * Page Location Traps::
10318 * Diversion Traps::
10319 * Input Line Traps::
10320 * Blank Line Traps::
10321 * End-of-input Traps::
10322 @end menu
10324 @c ---------------------------------------------------------------------
10326 @node Page Location Traps, Diversion Traps, Traps, Traps
10327 @subsection Page Location Traps
10328 @cindex page location traps
10329 @cindex traps, page location
10331 @dfn{Page location traps} perform an action when @code{gtroff}
10332 reaches or passes a certain vertical location on the page.  Page
10333 location traps have a variety of purposes, including:
10335 @itemize
10336 @item
10337 setting headers and footers
10339 @item
10340 setting body text in multiple columns
10342 @item
10343 setting footnotes
10344 @end itemize
10346 @cindex enabling vertical position traps (@code{vpt})
10347 @cindex vertical position traps, enabling (@code{vpt})
10348 @cindex vertical position trap enable register (@code{.vpt})
10349 @DefreqList {vpt, flag}
10350 @DefregListEnd {.vpt}
10351 Enable vertical position traps if @var{flag} is non-zero, or disables
10352 them otherwise.  Vertical position traps are traps set by the @code{wh}
10353 or @code{dt} requests.  Traps set by the @code{it} request are not
10354 vertical position traps.  The parameter that controls whether vertical
10355 position traps are enabled is global.  Initially vertical position traps
10356 are enabled.  The current setting of this is available in the
10357 @code{.vpt} read-only number register.
10358 @endDefreq
10360 @Defreq {wh, dist macro}
10361 Set a page location trap.  Positive values for @var{dist} set
10362 the trap relative to the top of the page; negative values set
10363 the trap relative to the bottom of the page.
10365 @var{macro} is the name of the macro to execute when the
10366 trap is sprung.
10368 @cindex page headers
10369 @cindex page footers
10370 @cindex headers
10371 @cindex footers
10372 The following is a simple example of how many macro packages
10373 set headers and footers.
10375 @Example
10376 .de hd                \" Page header
10377 '  sp .5i
10378 .  tl 'Title''date'
10379 '  sp .3i
10382 .de fo                \" Page footer
10383 '  sp 1v
10384 .  tl ''%''
10385 '  bp
10388 .wh 0   hd            \" trap at top of the page
10389 .wh -1i fo            \" trap one inch from bottom
10390 @endExample
10392 A trap at or below the bottom of the page is ignored; it can be made
10393 active by either moving it up or increasing the page length so that the
10394 trap is on the page.
10396 It is possible to have more than one trap at the same location; to do so,
10397 the traps must be defined at different locations, then moved together with
10398 the @code{ch} request; otherwise the second trap would replace the first
10399 one.  Earlier defined traps hide later defined traps if moved to the same
10400 position (the many empty lines caused by the @code{bp} request are omitted):
10402 @Example
10403 .de a
10404 .  nop a
10406 .de b
10407 .  nop b
10409 .de c
10410 .  nop c
10413 .wh 1i a
10414 .wh 2i b
10415 .wh 3i c
10417     @result{} a b c
10418 @endExample
10419 @Example
10420 .ch b 1i
10421 .ch c 1i
10423     @result{} a
10424 @endExample
10425 @Example
10426 .ch a 0.5i
10428     @result{} a b
10429 @endExample
10430 @endDefreq
10432 @cindex distance to next trap register (@code{.t})
10433 @cindex trap, distance, register (@code{.t})
10434 @Defreg {.t}
10435 A read-only number register holding the distance to the next trap.
10437 If there are no traps between the current position and the bottom of the
10438 page, it contains the distance to the page bottom.  In a diversion, the
10439 distance to the page bottom is infinite (the returned value is the biggest
10440 integer which can be represented in @code{groff}) if there are no diversion
10441 traps.
10442 @endDefreg
10444 @cindex changing trap location (@code{ch})
10445 @cindex trap, changing location (@code{ch})
10446 @Defreq {ch, macro dist}
10447 Change the location of a trap.
10448 The first argument is the name of the macro to be invoked at
10449 the trap, and the second argument is the new location for the trap
10450 (note that the parameters are specified the opposite of the @code{wh}
10451 request).  This is useful for building up footnotes in a diversion to
10452 allow more space at the bottom of the page for them.
10454 @c XXX
10456 @ignore
10457 @Example
10458 ... (simplified) footnote example ...
10459 @endExample
10460 @end ignore
10461 @endDefreq
10463 @Defreg {.ne}
10464 The read-only number register @code{.ne} contains the amount of space
10465 that was needed in the last @code{ne} request that caused a trap to be
10466 sprung.  Useful in conjunction with the @code{.trunc} register.
10467 @xref{Page Control}, for more information.
10468 @endDefreg
10470 @cindex @code{ne} request, and the @code{.trunc} register
10471 @cindex truncated vertical space register (@code{.trunc})
10472 @Defreg {.trunc}
10473 A read-only register containing the amount of vertical space truncated
10474 by the most recently sprung vertical position trap, or, if the trap was
10475 sprung by an @code{ne} request, minus the amount of vertical motion
10476 produced by the @code{ne} request.  In other words, at the point a trap
10477 is sprung, it represents the difference of what the vertical position
10478 would have been but for the trap, and what the vertical position
10479 actually is.
10480 @endDefreg
10482 @c ---------------------------------------------------------------------
10484 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10485 @subsection Diversion Traps
10486 @cindex diversion traps
10487 @cindex traps, diversion
10489 @cindex @code{.t} register, and diversions
10490 @cindex setting diversion trap (@code{dt})
10491 @cindex diversion trap, setting (@code{dt})
10492 @cindex trap, diversion, setting (@code{dt})
10493 @Defreq {dt, dist macro}
10494 Set a trap @emph{within} a diversion.
10495 @var{dist} is the location of the trap
10496 (identical to the @code{.wh} request)
10497 and @var{macro} is the name of the macro to be invoked.  The
10498 number register @code{.t} still works within diversions.
10499 @xref{Diversions}, for more information.
10500 @endDefreq
10502 @c ---------------------------------------------------------------------
10504 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10505 @subsection Input Line Traps
10506 @cindex input line traps
10507 @cindex traps, input line
10509 @cindex setting input line trap (@code{it})
10510 @cindex input line trap, setting (@code{it})
10511 @cindex trap, input line, setting (@code{it})
10512 @DefreqList {it, n macro}
10513 @DefreqItem {itc, n macro}
10514 Set an input line trap.
10515 @var{n}@w{ }is the number of lines of input which may be read before
10516 springing the trap, @var{macro} is the macro to be invoked.
10517 Request lines are not counted as input lines.
10519 For example, one possible use is to have a macro which prints the
10520 next @var{n}@w{ }lines in a bold font.
10522 @Example
10523 .de B
10524 .  it \\$1 B-end
10525 .  ft B
10528 .de B-end
10529 .  ft R
10531 @endExample
10533 @cindex input line traps and interrupted lines (@code{itc})
10534 @cindex interrupted lines and input line traps (@code{itc})
10535 @cindex traps, input line, and interrupted lines (@code{itc})
10536 @cindex lines, interrupted, and input line traps (@code{itc})
10537 The @code{itc} request is identical,
10538 except that a line interrupted with @code{\c}
10539 counts as one input line.
10541 Both requests are associated with the current environment
10542 (@pxref{Environments}); switching to another environment disables the
10543 current input trap, and going back reactivates it, restoring the number
10544 of already processed lines.
10545 @endDefreq
10547 @c ---------------------------------------------------------------------
10549 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10550 @subsection Blank Line Traps
10551 @cindex blank line traps
10552 @cindex traps, blank line
10553 @cindex blank line macro (@code{blm})
10554 @Defreq {blm, macro}
10555 Set a blank line trap.
10556 @code{gtroff} executes @var{macro} when it encounters a blank line in
10557 the input file.
10558 @endDefreq
10560 @c ---------------------------------------------------------------------
10562 @node End-of-input Traps,  , Blank Line Traps, Traps
10563 @subsection End-of-input Traps
10564 @cindex end-of-input traps
10565 @cindex traps, end-of-input
10567 @cindex setting end-of-input trap (@code{em})
10568 @cindex end-of-input trap, setting (@code{em})
10569 @cindex trap, end-of-input, setting (@code{em})
10570 @cindex end-of-input macro (@code{em})
10571 @cindex macro, end-of-input (@code{em})
10572 @Defreq {em, macro}
10573 Set a trap at the end of input.  @var{macro} is executed after the
10574 last line of the input file has been processed.
10576 For example, if the document had to have a section at the bottom of the
10577 last page for someone to approve it, the @code{em} request could be
10578 used.
10580 @Example
10581 .de approval
10582 .  ne 5v
10583 .  sp |(\\n[.t] - 6v)
10584 .  in +4i
10585 .  lc _
10586 .  br
10587 Approved:\t\a
10588 .  sp
10589 Date:\t\t\a
10592 .em approval
10593 @endExample
10594 @endDefreq
10597 @c =====================================================================
10599 @node Diversions, Environments, Traps, gtroff Reference
10600 @section Diversions
10601 @cindex diversions
10603 In @code{gtroff} it is possible to @dfn{divert} text into a named
10604 storage area.  Due to the similarity to defining macros it is sometimes
10605 said to be stored in a macro.  This is used for saving text for output
10606 at a later time, which is useful for keeping blocks of text on the same
10607 page, footnotes, tables of contents, and indices.
10609 @cindex top-level diversion
10610 @cindex diversion, top-level
10611 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
10612 diversion} if no diversion is active (i.e., the data is diverted to the
10613 output device).
10615 @cindex beginning diversion (@code{di})
10616 @cindex diversion, beginning (@code{di})
10617 @cindex ending diversion (@code{di})
10618 @cindex diversion, ending (@code{di})
10619 @cindex appending to diversion (@code{da})
10620 @cindex diversion, appending (@code{da})
10621 @DefreqList {di, macro}
10622 @DefreqListEnd {da, macro}
10623 Begin a diversion.  Like the @code{de}
10624 request, it takes an argument of a macro name to divert subsequent text
10625 into.  The @code{da} macro appends to an existing diversion.
10627 @code{di} or @code{da} without an argument ends the diversion.
10628 @endDefreq
10630 @DefreqList {box, macro}
10631 @DefreqListEnd {boxa, macro}
10632 Begin (or appends to) a diversion like the
10633 @code{di} and @code{da} requests.
10634 The difference is that @code{box} and @code{boxa}
10635 do not include a partially-filled line in the diversion.
10637 Compare this:
10639 @Example
10640 Before the box.
10641 .box xxx
10642 In the box.
10644 .box
10645 After the box.
10647     @result{} Before the box.  After the box.
10648 .xxx
10649     @result{} In the box.
10650 @endExample
10652 @noindent
10653 with this:
10655 @Example
10656 Before the diversion.
10657 .di yyy
10658 In the diversion.
10661 After the diversion.
10663     @result{} After the diversion.
10664 .yyy
10665     @result{} Before the diversion.  In the diversion.
10666 @endExample
10668 @code{box} or @code{boxa} without an argument ends the diversion.
10669 @endDefreq
10671 @cindex @code{nl} register, and @code{.d}
10672 @cindex nested diversions
10673 @cindex diversion, nested
10674 @cindex diversion name register (@code{.z})
10675 @cindex vertical position in diversion register (@code{.d})
10676 @cindex position, vertical, in diversion, register (@code{.d})
10677 @cindex diversion, vertical position in, register (@code{.d})
10678 @DefregList {.z}
10679 @DefregListEnd {.d}
10680 Diversions may be nested.  The read-only number register @code{.z}
10681 contains the name of the current diversion (this is a string-valued
10682 register).  The read-only number register @code{.d} contains the current
10683 vertical place in the diversion.  If not in a diversion it is the same
10684 as the register @code{nl}.
10685 @endDefreg
10687 @cindex high-water mark register (@code{.h})
10688 @cindex mark, high-water, register (@code{.h})
10689 @cindex position of lowest text line (@code{.h})
10690 @cindex text line, position of lowest (@code{.h})
10691 @Defreg {.h}
10692 The @dfn{high-water mark} on the current page.  It corresponds to the
10693 text baseline of the lowest line on the page.  This is a read-only
10694 register.
10696 @Example
10697 .tm .h==\n[.h], nl==\n[nl]
10698     @result{} .h==0, nl==-1
10699 This is a test.
10701 .sp 2
10702 .tm .h==\n[.h], nl==\n[nl]
10703     @result{} .h==40, nl==120
10704 @endExample
10706 @cindex @code{.h} register, difference to @code{nl}
10707 @cindex @code{nl} register, difference to @code{.h}
10708 @noindent
10709 As can be seen in the previous example, empty lines are not considered
10710 in the return value of the @code{.h} register.
10711 @endDefreg
10713 @DefregList {dn}
10714 @DefregListEnd {dl}
10715 After completing a diversion, the read-write number registers @code{dn}
10716 and @code{dl} contain the vertical and horizontal size of the diversion.
10718 @example
10719 @group
10720 .\" Center text both horizontally & vertically
10722 .\" Enclose macro definitions in .eo and .ec
10723 .\" to avoid the doubling of the backslash
10725 .\" macro .(c starts centering mode
10726 .de (c
10727 .  br
10728 .  ev (c
10729 .  evc 0
10730 .  in 0
10731 .  nf
10732 .  di @@c
10734 @end group
10735 @group
10736 .\" macro .)c terminates centering mode
10737 .de )c
10738 .  br
10739 .  ev
10740 .  di
10741 .  nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
10742 .  sp \n[@@s]u
10743 .  ce 1000
10744 .  @@c
10745 .  ce 0
10746 .  sp \n[@@s]u
10747 .  br
10748 .  fi
10749 .  rr @@s
10750 .  rm @@s
10751 .  rm @@c
10753 .\" End of macro definitions, restore escape mechanism
10755 @end group
10756 @end example
10757 @endDefreg
10759 @cindex transparent output (@code{\!}, @code{\?})
10760 @cindex output, transparent (@code{\!}, @code{\?})
10761 @DefescList {\\!, , , }
10762 @DefescListEnd {\\?, , @Var{anything}, \\?}
10763 Prevent requests, macros, and escapes from being
10764 interpreted when read into a diversion.  This takes the given text
10765 and @dfn{transparently} embeds it into the diversion.  This is useful for
10766 macros which shouldn't be invoked until the diverted text is actually
10767 output.
10769 @c XXX anything is read in copy mode. (what about \! ??)
10771 The @code{\!} escape transparently embeds text up to
10772 and including the end of the line.
10773 The @code{\?} escape transparently embeds text until the next
10774 occurrence of the @code{\?} escape.  For example:
10776 @Example
10777 \?@var{anything}\?
10778 @endExample
10780 @noindent
10781 @var{anything} may not contain newlines; use @code{\!}  to embed
10782 newlines in a diversion.  The escape sequence @code{\?} is also
10783 recognized in copy mode and turned into a single internal code; it is
10784 this code that terminates @var{anything}.  Thus the following example
10785 prints@w{ }4.
10787 @Example
10788 .nr x 1
10790 .di d
10791 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
10793 .nr x 2
10794 .di e
10797 .nr x 3
10798 .di f
10801 .nr x 4
10803 @endExample
10804 @endDefesc
10806 @cindex unformatting diversions (@code{asciify})
10807 @cindex diversion, unformatting (@code{asciify})
10808 @cindex @code{trin} and @code{asciify} request
10809 @Defreq {asciify, div}
10810 @dfn{Unformat} the diversion specified by @var{div}
10811 in such a way that @acronym{ASCII} characters, characters translated with
10812 the @code{trin} request, space characters, and some escape sequences that
10813 were formatted and diverted are treated like ordinary input
10814 characters when the diversion is reread.  It can be also used for gross
10815 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
10817 @Example
10818 .tr @@.
10819 .di x
10820 @@nr n 1
10823 .tr @@@@
10824 .asciify x
10826 @endExample
10828 @xref{Copy-in Mode}.
10829 @endDefreq
10831 @Defreq {unformat, div}
10832 Like @code{asciify}, unformat the specified diversion.
10833 However, @code{unformat} only unformats spaces and tabs
10834 between words.
10835 Unformatted tabs are treated as input tokens,
10836 and spaces are stretchable again.
10838 The vertical size of lines is not preserved; glyph information (font,
10839 font size, space width, etc.)@: is retained.
10840 @endDefreq
10843 @c =====================================================================
10845 @node Environments, Suppressing output, Diversions, gtroff Reference
10846 @section Environments
10847 @cindex environments
10849 It happens frequently that some text should be printed in a certain
10850 format regardless of what may be in effect at the time, for example, in
10851 a trap invoked macro to print headers and footers.  To solve this
10852 @code{gtroff} processes text in @dfn{environments}.  An
10853 environment contains most of the parameters that control text
10854 processing.  It is possible to switch amongst these environments; by
10855 default @code{gtroff} processes text in environment@w{ }0.  The
10856 following is the information kept in an environment.
10858 @itemize @bullet
10859 @item
10860 font parameters (size, family, style, character height and slant, space
10861 and sentence space size)
10863 @item
10864 page parameters (line length, title length, vertical spacing,
10865 line spacing, indentation, line numbering, centering, right-justifying,
10866 underlining, hyphenation data)
10868 @item
10869 fill and adjust mode
10871 @item
10872 tab stops, tab and leader characters, escape character,
10873 no-break and hyphen indicators, margin character data
10875 @item
10876 partially collected lines
10878 @item
10879 input traps
10881 @item
10882 drawing and fill colours
10883 @end itemize
10885 These environments may be given arbitrary names (see @ref{Identifiers},
10886 for more info).  Old versions of @code{troff} only had environments
10887 named @samp{0}, @samp{1}, and @samp{2}.
10889 @cindex switching environment (@code{ev})
10890 @cindex environment, switching (@code{ev})
10891 @cindex environment number/name register (@code{.ev})
10892 @DefreqList {ev, env}
10893 @DefregListEnd {.ev}
10894 Switch to another environment.  The argument @var{env} is the name of
10895 the environment to switch to.  With no argument, @code{gtroff} switches
10896 back to the previous environment.  There is no limit on the number of
10897 named environments; they are created the first time that they are
10898 referenced.  The @code{.ev} read-only register contains the name or
10899 number of the current environment.  This is a string-valued register.
10901 Note that a call to @code{ev} (with argument) pushes the previously
10902 active environment onto a stack.  If, say, environments @samp{foo},
10903 @samp{bar}, and @samp{zap} are called (in that order), the first
10904 @code{ev} request without parameter switches back to environment
10905 @samp{bar} (which is popped off the stack), and a second call
10906 switches back to environment @samp{foo}.
10908 @c XXX example
10910 @ignore
10911 @Example
10912 ... page break macro, revised ...
10913 @endExample
10914 @end ignore
10916 Here is an example:
10918 @Example
10919 .ev footnote-env
10920 .fam N
10921 .ps 6
10922 .vs 8
10923 .ll -.5i
10928 .ev footnote-env
10929 \(dg Note the large, friendly letters.
10931 @endExample
10932 @endDefreq
10934 @cindex copying environment (@code{evc})
10935 @cindex environment, copying (@code{evc})
10936 @Defreq {evc, env}
10937 Copy the environment @var{env} into the current environment.
10939 The following environment data is not copied:
10941 @itemize @bullet
10942 @item
10943 Partially filled lines.
10945 @item
10946 The status whether the previous line was interrupted.
10948 @item
10949 The number of lines still to center, or to right-justify, or to underline
10950 (with or without underlined spaces); they are set to zero.
10952 @item
10953 The status whether a temporary indent is active.
10955 @item
10956 Input traps and its associated data.
10958 @item
10959 Line numbering mode is disabled; it can be reactivated with
10960 @w{@samp{.nm +0}}.
10962 @item
10963 The number of consecutive hyphenated lines (set to zero).
10964 @end itemize
10965 @endDefreq
10967 @cindex environment, last character
10968 @DefregList {.cht}
10969 @DefregItem {.cdp}
10970 @DefregListEnd {.csk}
10971 The @code{\n[.cht]} register contains the
10972 maximum extent (above the baseline)
10973 of the last character added to the current environment.
10975 The @code{\n[.cdp]} register contains the
10976 maximum extent (below the baseline)
10977 of the last character added to the current environment.
10979 The @code{\n[.csk]} register contains the
10980 @dfn{skew} (how far to the right of the character's center
10981 that @code{gtroff} shold place an accent)
10982 of the last character added to the current environment.
10983 @endDefreg
10986 @c =====================================================================
10988 @node Suppressing output, Colors, Environments, gtroff Reference
10989 @section Suppressing output
10991 @cindex suppressing output (@code{\O})
10992 @cindex output, suppressing (@code{\O})
10993 @Defesc {\\O, , num, }
10994 Disable or enable output depending on the value of @var{num}:
10996 @table @samp
10997 @item \O0
10998 Disable any ditroff glyphs from being emitted to the device driver,
10999 provided that the escape occurs at the outer level (see @code{\O3} and
11000 @code{\O4}).
11002 @item \O1
11003 Enable output of glyphs, provided that the escape occurs at the outer
11004 level.
11005 @end table
11007 @vindex opminx
11008 @vindex opminy
11009 @vindex opmaxx
11010 @vindex opmaxy
11011 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11012 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11013 @xref{Register Index}.  These four registers mark the top left and
11014 bottom right hand corners of a box which encompasses all written glyphs.
11016 @table @samp
11017 @item \O2
11018 Provided that the escape occurs at the outer level, enable output of
11019 glyphs and also write out to @code{stderr} the page number and four
11020 registers encompassing the glyphs previously written since the last call
11021 to @code{\O}.
11023 @item \O3
11024 Begin a nesting level.  This is really an internal mechanism for
11025 @code{grohtml} while producing images.  They are generated by running
11026 the troff source through troff to the PostScript device and GhostScript
11027 to produce images in PNG format.  The @code{\O3} escape will start a new
11028 page if the device is not html (to reduce the possibility of images
11029 crossing a page boundary).
11031 @item \O4
11032 End a nesting level.
11034 @item \O[5Pfilename]
11035 This escape is @code{grohtml} specific.  Provided that this escape
11036 occurs at the outer nesting level write the @code{filename} to
11037 @code{stderr}.  The position of the image, @var{P}, must be specified
11038 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
11039 right, centered, inline).  @var{filename} will be associated with the
11040 production of the next inline image.
11041 @end table
11042 @endDefesc
11045 @c =====================================================================
11047 @node Colors, I/O, Suppressing output, gtroff Reference
11048 @section Colors
11050 @Defreq {defcolor, ident scheme color_components}
11051 Define color with name @var{ident}.  @var{scheme} can be one of  the
11052 following values: @code{rgb} (three components), @code{cym} (three
11053 components), @code{cmyk} (four components), and @code{gray} or
11054 @code{grey} (one component).
11056 @cindex default color
11057 @cindex color, default
11058 Color components can be given either as a hexadecimal string or as
11059 positive decimal integers in the range 0--65535.  A hexadecimal string
11060 contains all color components concatenated.  It must start with either
11061 @code{#} or @code{##}; the former specifies hex values in the range
11062 0--255 (which are internally multiplied by@w{ }257), the latter in the
11063 range 0--65535.  Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11064 (magenta).  The default color name @c{default} can't be redefined; its
11065 value is device-specific (usually black).  It is possible that the
11066 default color for @code{\m} and @code{\M} is not identical.
11068 @cindex @code{f} unit, and colors
11069 @cindex unit, @code{f}, and colors
11070 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
11071 its value by 65536; this makes it convenient to specify color components
11072 as fractions in the range 0 to@w{ }1 (1f equals 65536u).  Example:
11074 @Example
11075 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11076 @endExample
11078 Note that @code{f} is the default scaling indicator for the
11079 @code{defcolor} request, thus the above statement is equivalent to
11081 @Example
11082 .defcolor darkgreen rgb 0.1 0.5 0.2
11083 @endExample
11084 @endDefreq
11086 @DefescList {\\m, , c, }
11087 @DefescItem {\\m, @lparen{}, co, }
11088 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11089 Set drawing color.  The following example shows how to turn the next four
11090 words red.
11092 @Example
11093 \m[red]these are in red\m[] and these words are in black.
11094 @endExample
11096 The escape @code{\m[]} returns to the previous color.
11098 The drawing color is associated with the current environment
11099 (@pxref{Environments}).
11100 @endDefesc
11102 @DefescList {\\M, , c, }
11103 @DefescItem {\\M, @lparen{}, co, }
11104 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11105 Set background color for filled objects drawn with the
11106 @code{\D'@dots{}'} commands.
11108 A red ellipse can be created with the following code:
11110 @Example
11111 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11112 @endExample
11114 The escape @code{\M[]} returns to the previous fill color.
11116 The fill color is associated with the current environment
11117 (@pxref{Environments}).
11118 @endDefesc
11121 @c =====================================================================
11123 @node I/O, Postprocessor Access, Colors, gtroff Reference
11124 @section I/O
11125 @cindex i/o
11126 @cindex input and output requests
11127 @cindex requests for input and output
11128 @cindex output and input requests
11130 @code{gtroff} has several requests for including files:
11132 @cindex including a file (@code{so})
11133 @cindex file inclusion (@code{so})
11134 @Defreq {so, file}
11135 Read in the specified @var{file} and
11136 includes it in place of the @code{so} request.  This is quite useful for
11137 large documents, e.g.@: keeping each chapter in a separate file.
11138 @xref{gsoelim}, for more information.
11139 @endDefreq
11141 @Defreq {pso, command}
11142 Read the standard output from the specified @var{command}
11143 and includes it in place of the @code{pso} request.
11145 This request causes an error if used in safer mode (which is the default).
11146 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11147 mode.
11148 @endDefreq
11150 @Defreq {mso, file}
11151 Identical to the @code{so} request except that @code{gtroff}
11152 searches for the specified
11153 @var{file} in the same directories as macro files for the
11154 the @option{-m} command line option.  If the file name to be included
11155 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11156 to include @file{tmac.@var{name}} and vice versa.
11157 @endDefreq
11159 @cindex transparent output (@code{cf}, @code{trf})
11160 @cindex output, transparent (@code{cf}, @code{trf})
11161 @DefreqList {trf, file}
11162 @DefreqListEnd {cf, file}
11163 Transparently output the contents of @var{file}.  Each line is output
11164 as if it were preceded by @code{\!}; however, the lines are not subject
11165 to copy mode interpretation.  If the file does not end with a newline,
11166 then a newline is added (@code{trf} only).  For example, to define a
11167 macro@w{ }@code{x} containing the contents of file@w{ }@file{f}, use
11169 @Example
11170 .di x
11171 .trf f
11173 @endExample
11175 Both @code{trf} and @code{cf}, when used in a diversion,
11176 embeds an object in the diversion which, when reread, causes the
11177 contents of @var{file} to be transparently copied through to the
11178 output.  In @acronym{UNIX} @code{troff}, the contents of @var{file}
11179 is immediately copied through to the output regardless of whether there
11180 is a current diversion; this behaviour is so anomalous that it must be
11181 considered a bug.
11183 @cindex @code{trf} request, and invalid characters
11184 @cindex characters, invalid for @code{trf} request
11185 @cindex invalid characters for @code{trf} request
11186 While @code{cf} copies the contents of @var{file} completely unprocessed,
11187 @code{trf} disallows characters such as NUL that are not valid
11188 @code{gtroff} input characters (@pxref{Identifiers}).
11190 Both requests cause a line break.
11191 @endDefreq
11193 @cindex processing next file (@code{nx})
11194 @cindex file, processing next (@code{nx})
11195 @cindex next file, processing (@code{nx})
11196 @Defreq {nx, [@Var{file}]}
11197 Force @code{gtroff} to continue processing of
11198 the file specified as an argument.  If no argument is given, immediately
11199 jump to the end of file.
11200 @endDefreq
11202 @cindex reading from standard input (@code{rd})
11203 @cindex standard input, reading from (@code{rd})
11204 @cindex input, standard, reading from (@code{rd})
11205 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11206 Read from standard input, and include what is read as though it
11207 were part of the input file.  Text is read until a blank line
11208 is encountered.
11210 If standard input is a TTY input device (keyboard), write @var{prompt}
11211 to standard error, followed by a colon (or send BEL for a beep if no
11212 argument is given).
11214 Arguments after @var{prompt} are available for the input.  For example,
11215 the line
11217 @Example
11218 .rd data foo bar
11219 @endExample
11221 with the input @w{@samp{This is \$2.}} prints
11223 @Example
11224 This is bar.
11225 @endExample
11226 @endDefreq
11228 @cindex form letters
11229 @cindex letters, form
11230 Using the @code{nx} and @code{rd} requests,
11231 it is easy to set up form letters.  The form
11232 letter template is constructed like this, putting the following lines
11233 into a file called @file{repeat.let}:
11235 @Example
11237 \*(td
11238 .sp 2
11244 Body of letter.
11246 .nx repeat.let
11247 @endExample
11249 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11250 @noindent
11251 When this is run, a file containing the following lines should be
11252 redirected in.  Note that requests included in this file are executed
11253 as though they were part of the form letter.  The last block of input
11254 is the @code{ex} request which tells groff to stop processing.  If
11255 this was not there, groff would not know when to stop.
11257 @Example
11258 Trent A. Fisher
11259 708 NW 19th Av., #202
11260 Portland, OR  97209
11262 Dear Trent,
11264 Len Adollar
11265 4315 Sierra Vista
11266 San Diego, CA  92103
11268 Dear Mr. Adollar,
11271 @endExample
11273 @Defreq {pi, pipe}
11274 Pipe the output of @code{gtroff} to the shell command(s)
11275 specified by @var{pipe}.  This request must occur before
11276 @code{gtroff} has a chance to print anything.
11278 @code{pi} causes an error if used in safer mode (which is the default).
11279 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11280 mode.
11281 @endDefreq
11283 @DefreqList {sy, cmds}
11284 @DefregListEnd {systat}
11285 Execute the shell command(s) specified by @var{cmds}.  The output is not
11286 saved anyplace, so it is up to the user to do so.
11288 This request causes an error if used in safer mode (which is the default).
11289 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11290 mode.
11292 For example, the following example introduces the current time
11293 into a document:
11295 @cindex time, current
11296 @cindex current time
11297 @pindex perl
11298 @Example
11299 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11300              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11301 .so /tmp/x\n[$$]
11302 .sy rm /tmp/x\n[$$]
11303 \nH:\nM:\nS
11304 @endExample
11306 @noindent
11307 Note that this works by having the @code{perl} script (run by @code{sy})
11308 print out the @code{nr} requests which set the number registers
11309 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in with
11310 the @code{so} request.
11312 @cindex @code{system()} return value register (@code{systat})
11313 The @code{systat} read-write number register contains the return value
11314 of the @code{system()} function executed by the last @code{sy} request.
11315 @endDefreq
11317 @cindex opening file (@code{open})
11318 @cindex file, opening (@code{open})
11319 @cindex appending to file (@code{opena})
11320 @cindex file, appending to (@code{opena})
11321 @DefreqList {open, stream file}
11322 @DefreqListEnd {opena, stream file}
11323 Open the specified @var{file} for writing and
11324 associates the specified @var{stream} with it.
11326 The @code{opena} request is like @code{open}, but if the file exists,
11327 append to it instead of truncating it.
11329 Both @code{open} and @code{opena} cause an error if used in safer mode
11330 (which is the default).  Use @code{groff}'s or @code{troff}'s @option{-U}
11331 option to activate unsafe mode.
11332 @endDefreq
11334 @cindex copy-in mode, and @code{write} requests
11335 @cindex mode, copy-in, and @code{write} requests
11336 @cindex writing to file (@code{write})
11337 @cindex file, writing to (@code{write})
11338 @DefreqList {write, stream data}
11339 @DefreqListEnd {writec, stream data}
11340 Write to the file associated with the specified @var{stream}.
11341 The stream must previously have
11342 been the subject of an open request.  The remainder of the line is
11343 interpreted as the @code{ds} request reads its second argument: A
11344 leading @samp{"} is stripped, and it is read in copy-in mode.
11346 The @code{writec} request is like @code{write}, but only
11347 @code{write} appends a newline to the data.
11348 @endDefreq
11350 @cindex @code{asciify} and @code{writem}
11351 @Defreq {writem, stream xx}
11352 Write the contents of the macro or string @var{xx}
11353 to the file associated with the specified @var{stream}.
11355 @var{xx} is read in copy mode, i.e., already formatted elements are
11356 ignored.  Consequently, diversions must be unformatted with the
11357 @code{asciify} request before calling @code{writem}.  Usually, this
11358 means a loss of information.
11359 @endDefreq
11361 @cindex closing file (@code{close})
11362 @cindex file, closing (@code{close})
11363 @Defreq {close, stream}
11364 Close the specified @var{stream};
11365 the stream is no longer an acceptable argument to the
11366 @code{write} request.
11368 @c XXX example
11370 @ignore
11371 @Example
11372 ... example of open write &c ...
11373 @endExample
11374 @end ignore
11375 @endDefreq
11377 @DefescList {\\V, , e, }
11378 @DefescItem {\\V, @lparen{}, ev, }
11379 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11380 Interpolate the contents of the specified environment variable
11381 @var{env} (one-character name@w{ }@var{e}, two-character name @var{ev})
11382 as returned by the function @code{getenv}.  @code{\V} is interpreted
11383 in copy-in mode.
11384 @endDefesc
11387 @c =====================================================================
11389 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11390 @section Postprocessor Access
11391 @cindex postprocessor access
11392 @cindex access of postprocessor
11394 There are two escapes which give information directly to the
11395 postprocessor.  This is particularly useful for embedding
11396 @sc{PostScript} into the final document.
11398 @Defesc {\\X, ', xxx, '}
11399 Embeds its argument into the @code{gtroff}
11400 output preceded with @w{@samp{x X}}.
11402 @cindex @code{\&}, in @code{\X}
11403 @cindex @code{\)}, in @code{\X}
11404 @cindex @code{\%}, in @code{\X}
11405 @ifnotinfo
11406 @cindex @code{\:}, in @code{\X}
11407 @end ifnotinfo
11408 @ifinfo
11409 @cindex @code{\@r{<colon>}}, in @code{\X}
11410 @end ifinfo
11411 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11412 within @code{\X}; all other escapes (except @code{\\} which produces a
11413 backslash) cause an error.
11415 @kindex use_charnames_in_special
11416 @pindex DESC@r{, and @code{use_charnames_in_special}}
11417 @cindex @code{\X} and special characters
11418 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11419 file, special characters no longer cause an error; the name @var{xx} is
11420 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11421 Additionally, the backslash is represented as @code{\\}.
11423 This mechanism is currently used by @code{grohtml} only.
11424 @endDefesc
11426 @DefescList {\\Y, , n, }
11427 @DefescItem {\\Y, @lparen{}, nm, }
11428 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11429 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11430 (one-character name@w{ }@var{n}, two-character name @var{nm}).
11431 However, the contents of the string or macro @var{name} are not
11432 interpreted; also it is permitted for @var{name} to have been defined
11433 as a macro and thus contain newlines (it is not permitted for the
11434 argument to @code{\X} to contain newlines).  The inclusion of
11435 newlines requires an extension to the @acronym{UNIX} @code{troff}
11436 output format, and confuses drivers that do not know about this
11437 extension (@pxref{Line Continuation}).
11438 @endDefesc
11440 @xref{Output Devices}.
11443 @c =====================================================================
11445 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11446 @section Miscellaneous
11447 @cindex miscellaneous
11449 This section documents parts of @code{gtroff} which cannot (yet) be
11450 categorized elsewhere in this manual.
11452 @cindex printing line numbers (@code{nm})
11453 @cindex line numbers, printing (@code{nm})
11454 @cindex numbers, line, printing (@code{nm})
11455 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11456 Print line numbers.
11457 @var{start} is the line number of the @emph{next}
11458 output line.  @var{inc} indicates which line numbers are printed.
11459 For example, the value@w{ }5 means to emit only line numbers which
11460 are multiples of@w{ }5; this defaults to@w{ }1.  @var{space} is the
11461 space to be left between the number and the text; this defaults to
11462 one digit space.  The fourth argument is the indentation of the line
11463 numbers, defaulting to zero.  Both @var{space} and @var{indent} are
11464 given as multiples of digit spaces; they can be negative also.
11465 Without any arguments, line numbers are turned off.
11467 @code{gtroff} reserves three digit spaces for the line number (which is
11468 printed right-justified) plus the amount given by @var{indent}; the
11469 output lines are concatenated to the line numbers, separated by
11470 @var{space}, and @emph{without} reducing the line length.  Depending
11471 on the value of the horizontal page offset (as set with the
11472 @code{po} request), line numbers which are longer than the reserved
11473 space stick out to the left, or the whole line is moved to the right.
11475 Parameters corresponding to missing arguments are not changed; any
11476 non-digit argument (to be more precise, any argument starting with a
11477 character valid as a delimiter for identifiers) is also treated as
11478 missing.
11480 If line numbering has been disabled with a call to @code{nm} without
11481 an argument, it can be reactivated with @samp{.nm +0}, using the
11482 previously active line numbering parameters.
11484 The parameters of @code{nm} are associated with the current environment
11485 (@pxref{Environments}).
11487 @Example
11488 .po 1m
11489 .ll 2i
11490 This test shows how line numbering works with groff.
11491 .nm 999
11492 This test shows how line numbering works with groff.
11494 .nm xxx 3 2
11495 .ll -\w'0'u
11496 This test shows how line numbering works with groff.
11497 .nn 2
11498 This test shows how line numbering works with groff.
11499 @endExample
11501 @noindent
11502 And here the result:
11504 @Example
11505  This  test shows how
11506  line numbering works
11507  999 with   groff.   This
11508 1000 test shows how  line
11509 1001 numbering works with
11510 1002 groff.
11511       This test shows how
11512       line      numbering
11513  works  with  groff.
11514  This test shows how
11515 1005  line      numbering
11516       works with groff.
11517 @endExample
11518 @endDefreq
11520 @c XXX xref ln register
11522 @Defreq {nn, [@Var{skip}]}
11523 Temporarily turn off line numbering.  The argument is the number
11524 of lines not to be numbered; this defaults to@w{ }1.
11525 @endDefreq
11527 @cindex margin character (@code{mc})
11528 @cindex character, for margins (@code{mc})
11529 @Defreq {mc, char [@Var{dist}]}
11530 Print margin character to the right of the text.
11531 The first argument is the character to be
11532 printed.  The second argument is the distance away from the right
11533 margin.  If missing, the previously set value is used; default is
11534 10@dmn{pt}).  For text lines that are too long (that is, longer than
11535 the text length plus @var{dist}), the margin character is directly
11536 appended to the lines.
11538 With no arguments the margin character is turned off.
11539 If this occurs before a break, no margin character is printed.
11541 @cindex @code{tl} request, and @code{mc}
11542 For empty lines and lines produced by the @code{tl} request no margin
11543 character is emitted.
11545 The margin character is associated with the current environment
11546 (@pxref{Environments}).
11548 @pindex nrchbar
11549 @pindex changebar
11550 This is quite useful for indicating text that has changed, and, in fact,
11551 there are programs available for doing this (they are called
11552 @code{nrchbar} and @code{changebar} and can be found in any
11553 @samp{comp.sources.unix} archive.
11555 @c XXX example
11557 @ignore
11558 @Example
11559 ... margin char example ...
11560 @endExample
11561 @end ignore
11562 @endDefreq
11564 @cindex PostScript, bounding box
11565 @cindex bounding box
11566 @DefreqList {psbb, filename}
11567 @DefregItem {llx}
11568 @DefregItem {lly}
11569 @DefregItem {urx}
11570 @DefregListEnd {ury}
11571 Retrieve the bounding box of the PostScript image
11572 found in @var{filename}.
11573 The file must conform to
11574 Adobe's @dfn{Document Structuring Conventions} (DSC);
11575 the command searches for a @code{%%BoundingBox} comment
11576 and extracts the bounding box values into the number registers
11577 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
11578 If an error occurs (for example, @code{psbb} cannot find
11579 the @code{%%BoundingBox} comment),
11580 it sets the four number registers to zero.
11581 @endDefreq
11584 @c =====================================================================
11586 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
11587 @section @code{gtroff} Internals
11589 @cindex input token
11590 @cindex token, input
11591 @cindex output node
11592 @cindex node, output
11593 @code{gtroff} processes input in three steps.  One or more input
11594 characters are converted to an @dfn{input token}.@footnote{Except the
11595 escapes @code{\f}, @code{\F}, @code{\H}, @code{\R}, @code{\s}, and
11596 @code{\S} which are processed immediately if not in copy-in mode.}
11597 Then, one or more input tokens are converted to an @dfn{output node}.
11598 Finally, output nodes are converted to the intermediate output language
11599 understood by all output devices.
11601 Actually, before step one happens, @code{gtroff} converts certain
11602 escape sequences into reserved input characters (not accessible by
11603 the user); such reserved characters are used for other internal
11604 processing also -- this is the very reason why not all characters
11605 are valid input.  @xref{Identifiers}, for more on this topic.
11607 For example, the input string @samp{fi\[:u]} is converted into a
11608 character token @samp{f}, a character token @samp{i}, and a special
11609 token @samp{:u} (representing u@w{ }umlaut).  Later on, the character
11610 tokens @samp{f} and @samp{i} are merged to a single output node
11611 representing the ligature glyph @samp{fi} (provided the current font
11612 has a glyph for this ligature); the same happens with @samp{:u}.  All
11613 output glyph nodes are `processed' which means that they are invariably
11614 associated with a given font, font size, advance width, etc.  During
11615 the formatting process, @code{gtroff} itself adds various nodes to
11616 control the data flow.
11618 Macros, diversions, and strings collect elements in two chained lists:
11619 a list of input tokens which have been passed unprocessed, and a list
11620 of output nodes.  Consider the following the diversion.
11622 @Example
11623 .di xxx
11629 @endExample
11631 @noindent
11632 It contains these elements.
11634 @multitable {@i{vertical size node}} {token list} {element number}
11635 @item node list               @tab token list @tab element number
11637 @item @i{line start node}     @tab ---        @tab 1
11638 @item @i{glyph node @code{a}} @tab ---        @tab 2
11639 @item @i{word space node}     @tab ---        @tab 3
11640 @item ---                     @tab @code{b}   @tab 4
11641 @item ---                     @tab @code{\n}  @tab 5
11642 @item @i{glyph node @code{c}} @tab ---        @tab 6
11643 @item @i{vertical size node}  @tab ---        @tab 7
11644 @item @i{vertical size node}  @tab ---        @tab 8
11645 @item ---                     @tab @code{\n}  @tab 9
11646 @end multitable
11648 @cindex @code{\v}, internal representation
11649 @noindent
11650 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
11651 (which are always present) specify the vertical extent of the last
11652 line, possibly modified by @code{\x}.  The @code{br} request finishes
11653 the current partial line, inserting a newline input token which is
11654 subsequently converted to a space when the diversion is reread.  Note
11655 that the word space node has a fixed width which isn't stretchable
11656 anymore.  To convert horizontal space nodes back to input tokens, use
11657 the @code{unformat} request.
11659 Macros only contain elements in the token list (and the node list is
11660 empty); diversions and strings can contain elements in both lists.
11663 @c =====================================================================
11665 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
11666 @section Debugging
11667 @cindex debugging
11669 @code{gtroff} is not easy to debug, but there are some useful features
11670 and strategies for debugging.
11672 @pindex soelim
11673 @cindex multi-file documents
11674 @cindex documents, multi-file
11675 @cindex setting input line number (@code{lf})
11676 @cindex input line number, setting (@code{lf})
11677 @cindex number, input line, setting (@code{lf})
11678 @Defreq {lf, line filename}
11679 Change the line number and the file name @code{gtroff} shall use for
11680 error and warning messages.  @var{line} is the input line number of the
11681 @emph{next} line.
11683 Without argument, the request is ignored.
11685 This is a debugging aid for documents which are split into many files,
11686 then put together with @code{soelim} and other preprocessors.  Usually,
11687 it isn't invoked manually.
11689 @c XXX example
11691 @ignore
11692 @Example
11693 ... example of soelim'ed doc ...
11694 @endExample
11695 @end ignore
11696 @endDefreq
11698 @cindex printing to stderr (@code{tm})
11699 @cindex stderr, printing to (@code{tm})
11700 @DefreqList {tm, string}
11701 @DefreqItem {tm1, string}
11702 @DefreqListEnd {tmc, string}
11703 Send @var{string} to the standard error output;
11704 this is very useful for printing debugging messages among other things.
11706 @var{string} is read in copy mode.
11708 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
11709 handles its argument similar to the @code{ds} request: a leading double
11710 quote in @var{string} is stripped to allow initial blanks.
11712 The @code{tmc} request is similar to @code{tm1} but does
11713 not append a newline (as is done in @code{tm} and @code{tm1}).
11714 @endDefreq
11716 @cindex aborting (@code{ab})
11717 @Defreq {ab, [@Var{string}]}
11718 Similar to the @code{tm} request, except that
11719 it causes @code{gtroff} to stop processing.  With no argument it
11720 prints @samp{User Abort.} to standard error.
11721 @endDefreq
11723 @cindex @code{ex} request, use in debugging
11724 @cindex exiting (@code{ex})
11725 @Defreq {ex, }
11726 The @code{ex} request also causes @code{gtroff} to stop processing;
11727 see also @ref{I/O}.
11728 @endDefreq
11730 When doing something involved it is useful to leave the debugging
11731 statements in the code and have them turned on by a command line flag.
11733 @Example
11734 .if \n(DB .tm debugging output
11735 @endExample
11737 @noindent
11738 To activate these statements say
11740 @Example
11741 groff -rDB=1 file
11742 @endExample
11744 If it is known in advance that there will be many errors and no useful
11745 output, @code{gtroff} can be forced to suppress formatted output with
11746 the @option{-z} flag.
11748 @cindex dumping symbol table (@code{pm})
11749 @cindex symbol table, dumping (@code{pm})
11750 @Defreq {pm, }
11751 Print the entire symbol table on @code{stderr}.  Names of all defined
11752 macros, strings, and diversions are print together with their size in
11753 bytes.  Since @code{gtroff} sometimes adds nodes by itself, the
11754 returned size can be larger than expected.
11756 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
11757 reports the sizes of diversions, ignores an additional argument to
11758 print only the total of the sizes, and the size isn't returned in
11759 blocks of 128 characters.
11760 @endDefreq
11762 @cindex dumping number registers (@code{pnr})
11763 @cindex number registers, dumping (@code{pnr})
11764 @Defreq {pnr, }
11765 Print the names and contents of all
11766 currently defined number registers on @code{stderr}.
11767 @endDefreq
11769 @cindex dumping traps (@code{ptr})
11770 @cindex traps, dumping (@code{ptr})
11771 @Defreq {ptr, }
11772 Print the names and positions of all traps
11773 (not including input line traps and diversion traps) on @code{stderr}.
11774 Empty slots in the page trap list are printed as well, because they can
11775 affect the priority of subsequently planted traps.
11776 @endDefreq
11778 @cindex flush output (@code{fl})
11779 @cindex output, flush (@code{fl})
11780 @cindex interactive use of @code{gtroff}
11781 @cindex @code{gtroff}, interactive use
11782 @Defreq {fl, }
11783 Instruct @code{gtroff} to flush its output immediately.  The intent
11784 is for interactive use, but this behaviour is currently not
11785 implemented in @code{gtroff}.  Contrary to @acronym{UNIX} @code{troff},
11786 TTY output is sent to a device driver also (@code{grotty}), making it
11787 non-trivial to communicate interactively.
11789 This request causes a line break.
11790 @endDefreq
11792 @cindex backtrace of input stack (@code{backtrace})
11793 @cindex input stack, backtrace (@code{backtrace})
11794 @Defreq {backtrace, }
11795 Print a backtrace of the input stack to the standard error stream.
11797 Consider the following in file @file{test}:
11799 @Example
11800 .de xxx
11801 .  backtrace
11803 .de yyy
11804 .  xxx
11807 .yyy
11808 @endExample
11810 @noindent
11811 On execution, @code{gtroff} prints the following:
11813 @Example
11814 test:2: backtrace: macro `xxx'
11815 test:5: backtrace: macro `yyy'
11816 test:8: backtrace: file `test'
11817 @endExample
11819 The option @option{-b} of @code{gtroff} internally calls a variant of
11820 this request on each error and warning.
11821 @endDefreq
11823 @cindex input stack, setting limit
11824 @Defreg {slimit}
11825 Use the @code{slimit} number register
11826 to set the maximum number of objects on the input stack.
11827 If @code{slimit} is less than or equal to@w{ }0,
11828 there is no limit set.
11829 With no limit, a buggy recursive macro can exhaust virtual memory.
11830 @endDefreg
11832 @cindex warnings
11833 @code{gtroff} has command line options for printing out more warnings
11834 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
11835 or an error occurs.  The most verbose level of warnings is @option{-ww}.
11837 @cindex level of warnings (@code{warn})
11838 @cindex warnings, level (@code{warn})
11839 @DefreqList {warn, [@Var{flags}]}
11840 @DefregListEnd {.warn}
11841 Control the level of warnings checked for.  The @var{flags} are the sum
11842 of the numbers associated with each warning that is to be enabled; all
11843 other warnings are disabled.  The number associated with each warning is
11844 listed below.  For example, @w{@code{.warn 0}} disables all warnings,
11845 and @w{@code{.warn 1}} disables all warnings except that about missing
11846 characters.  If no argument is given, all warnings are enabled.
11848 The read-only number register @code{.warn} contains the current warning
11849 level.
11850 @endDefreq
11852 @menu
11853 * Warnings::
11854 @end menu
11856 @c ---------------------------------------------------------------------
11858 @node Warnings,  , Debugging, Debugging
11859 @subsection Warnings
11860 @cindex warnings
11862 The warnings that can be given to @code{gtroff} are divided into the
11863 following categories.  The name associated with each warning is used by
11864 the @option{-w} and @option{-W} options; the number is used by the
11865 @code{warn} request and by the @code{.warn} register.
11867 @table @samp
11868 @item char
11869 @itemx 1
11870 Non-existent characters.  This is enabled by default.
11872 @item number
11873 @itemx 2
11874 Invalid numeric expressions.  This is enabled by default.
11875 @xref{Expressions}.
11877 @item break
11878 @itemx 4
11879 @cindex fill mode
11880 @cindex mode, fill
11881 In fill mode, lines which could not be broken so that their length was
11882 less than the line length.  This is enabled by default.
11884 @item delim
11885 @itemx 8
11886 Missing or mismatched closing delimiters.
11888 @item el
11889 @itemx 16
11890 @cindex @code{ie} request, and warnings
11891 @cindex @code{el} request, and warnings
11892 Use of the @code{el} request with no matching @code{ie} request.
11893 @xref{if-else}.
11895 @item scale
11896 @itemx 32
11897 Meaningless scaling indicators.
11899 @item range
11900 @itemx 64
11901 Out of range arguments.
11903 @item syntax
11904 @itemx 128
11905 Dubious syntax in numeric expressions.
11907 @item di
11908 @itemx 256
11909 @cindex @code{di} request, and warnings
11910 @cindex @code{da} request, and warnings
11911 Use of @code{di} or @code{da} without an argument when there is no
11912 current diversion.
11914 @item mac
11915 @itemx 512
11916 @cindex @code{de} request, and warnings
11917 @c XXX more index entries
11918 Use of undefined strings, macros and diversions.  When an undefined
11919 string, macro, or diversion is used, that string is automatically
11920 defined as empty.  So, in most cases, at most one warning is given
11921 for each name.
11923 @item reg
11924 @itemx 1024
11925 @cindex @code{nr} request, and warnings
11926 @c XXX more index entries
11927 Use of undefined number registers.  When an undefined number register is
11928 used, that register is automatically defined to have a value of@w{ }0.
11929 So, in most cases, at most one warning is given for use of a particular
11930 name.
11932 @item tab
11933 @itemx 2048
11934 Use of a tab character where a number was expected.
11936 @item right-brace
11937 @itemx 4096
11938 @cindex @code{\@}}, debugging
11939 Use of @code{\@}} where a number was expected.
11941 @item missing
11942 @itemx 8192
11943 Requests that are missing non-optional arguments.
11945 @item input
11946 @itemx 16384
11947 Invalid input characters.
11949 @item escape
11950 @itemx 32768
11951 Unrecognized escape sequences.  When an unrecognized escape sequence is
11952 encountered, the escape character is ignored.
11954 @item space
11955 @itemx 65536
11956 @cindex compatibility mode
11957 Missing space between a request or macro and its argument.  This warning
11958 is given when an undefined name longer than two characters is
11959 encountered, and the first two characters of the name make a defined
11960 name.  The request or macro is not invoked.  When this warning is
11961 given, no macro is automatically defined.  This is enabled by default.
11962 This warning never occurs in compatibility mode.
11964 @item font
11965 @itemx 131072
11966 Non-existent fonts.  This is enabled by default.
11968 @item ig
11969 @itemx 262144
11970 Invalid escapes in text ignored with the @code{ig} request.  These are
11971 conditions that are errors when they do not occur in ignored text.
11973 @item color
11974 @itemx 524288
11975 Color related warnings.
11977 @item all
11978 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
11979 intended that this covers all warnings that are useful with traditional
11980 macro packages.
11982 @item w
11983 All warnings.
11984 @end table
11987 @c =====================================================================
11989 @node Implementation Differences, Summary, Debugging, gtroff Reference
11990 @section Implementation Differences
11991 @cindex implementation differences
11992 @cindex differences in implementation
11993 @cindex incompatibilities with Unix @code{troff}
11994 @cindex compatibility mode
11995 @cindex mode, compatibility
11997 GNU @code{troff} has a number of features which cause incompatibilities
11998 with documents written with old versions of @code{troff}.
12000 @cindex long names
12001 @cindex names, long
12002 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
12003 interprets
12005 @Example
12006 .dsabcd
12007 @endExample
12009 @cindex @code{\*}, incompatibilities with Unix @code{troff}
12010 @cindex @code{\n}, incompatibilities with Unix @code{troff}
12011 @noindent
12012 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
12013 @code{troff} interprets this as a call of a macro named
12014 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} interprets
12015 @code{\*[} or @code{\n[} as references to a string or number register
12016 called @samp{[}.  In GNU @code{troff}, however, this is normally
12017 interpreted as the start of a long name.  In compatibility mode GNU
12018 @code{troff} interprets long names in the traditional way
12019 (which means that they are not recognized as names).
12021 @DefreqList {cp, [@Var{n}]}
12022 @DefreqItem {do, cmd}
12023 @DefregListEnd {.C}
12024 If @var{n} is missing or non-zero, turn on compatibility mode;
12025 otherwise, turn it off.
12027 The number
12028 register @code{.C} is@w{ }1 if compatibility mode is on, 0@w{
12029 }otherwise.
12031 Compatibility mode can be turned on with the
12032 @option{-C} command line option.
12034 The @code{do} request turns off compatibility mode
12035 while executing its arguments as a @code{gtroff} command.
12037 @Example
12038 .do fam T
12039 @endExample
12041 @noindent
12042 executes the @code{fam} request when compatibility mode
12043 is enabled.
12045 @code{gtroff} restores the previous compatibility setting
12046 before interpreting any files sourced by the @var{cmd}.
12047 @endDefreq
12049 @cindex input level in delimited arguments
12050 @cindex delimited arguments, incompatibilities with Unix @code{troff}
12051 Two other features are controlled by @option{-C}.  If not in
12052 compatibility mode, GNU @code{troff} preserves the input level in
12053 delimited arguments:
12055 @Example
12056 .ds xx '
12057 \w'abc\*(xxdef'
12058 @endExample
12060 @noindent
12061 In compatibility mode, the string @samp{72def'} is returned; without
12062 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12063 device).
12065 @cindex @code{\f}, incompatibilities with Unix @code{troff}
12066 @cindex @code{\H}, incompatibilities with Unix @code{troff}
12067 @cindex @code{\R}, incompatibilities with Unix @code{troff}
12068 @cindex @code{\s}, incompatibilities with Unix @code{troff}
12069 @cindex @code{\S}, incompatibilities with Unix @code{troff}
12070 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
12071 @code{\S} are transparent for recognizing the beginning of a line only
12072 in compatibility mode (this is a rather obscure feature).  For example,
12073 the code
12075 @Example
12076 .de xx
12077 Hallo!
12079 \fB.xx\fP
12080 @endExample
12082 prints @samp{Hallo!} in bold face if in compatibility mode, and
12083 @samp{.xx} in bold face otherwise.
12085 @cindex @code{\A}, incompatibilities with Unix @code{troff}
12086 @cindex @code{\|}, incompatibilities with Unix @code{troff}
12087 @cindex @code{\^}, incompatibilities with Unix @code{troff}
12088 @cindex @code{\&}, incompatibilities with Unix @code{troff}
12089 @cindex @code{\@{}, incompatibilities with Unix @code{troff}
12090 @cindex @code{\@}}, incompatibilities with Unix @code{troff}
12091 @cindex @code{\@key{SP}}, incompatibilities with Unix @code{troff}
12092 @cindex @code{\'}, incompatibilities with Unix @code{troff}
12093 @cindex @code{\`}, incompatibilities with Unix @code{troff}
12094 @cindex @code{\-}, incompatibilities with Unix @code{troff}
12095 @cindex @code{\_}, incompatibilities with Unix @code{troff}
12096 @cindex @code{\!}, incompatibilities with Unix @code{troff}
12097 @cindex @code{\%}, incompatibilities with Unix @code{troff}
12098 @cindex @code{\c}, incompatibilities with Unix @code{troff}
12099 GNU @code{troff} does not allow the use of the escape sequences
12100 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12101 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12102 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12103 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
12104 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12105 avoiding use of these escape sequences in names.
12107 @cindex fractional point sizes
12108 @cindex point sizes, fractional
12109 @cindex @code{ps} request, incompatibilities with Unix @code{troff}
12110 Fractional point sizes cause one noteworthy incompatibility.  In
12111 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12112 indicators and thus
12114 @Example
12115 .ps 10u
12116 @endExample
12118 @noindent
12119 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
12120 sets the point size to 10@w{ }scaled points.  @xref{Fractional Type
12121 Sizes}, for more information.
12123 @cindex @code{bd} request, incompatibilities with Unix @code{troff}
12124 @cindex @code{cs} request, incompatibilities with Unix @code{troff}
12125 @cindex @code{tkf} request, incompatibilities with Unix @code{troff}
12126 @cindex @code{tr} request, incompatibilities with Unix @code{troff}
12127 @cindex @code{fp} request, incompatibilities with Unix @code{troff}
12128 @cindex input and output characters, compatibility with Unix
12129 @cindex output characters, compatibility with Unix
12130 @cindex characters, input and output, compatibility with Unix
12131 In GNU @code{troff} there is a fundamental difference between
12132 unformatted, input characters, and formatted, output characters.
12133 Everything that affects how an output character is output is stored
12134 with the character; once an output character has been constructed it is
12135 unaffected by any subsequent requests that are executed, including
12136 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12137 Normally output characters are constructed from input characters at the
12138 moment immediately before the character is added to the current output
12139 line.  Macros, diversions and strings are all, in fact, the same type of
12140 object; they contain lists of input characters and output characters in
12141 any combination.  An output character does not behave like an input
12142 character for the purposes of macro processing; it does not inherit any
12143 of the special properties that the input character from which it was
12144 constructed might have had.  For example,
12146 @Example
12147 .di x
12148 \\\\
12152 @endExample
12154 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
12155 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\(rs})
12156 @cindex @code{\e}, incompatibilities with Unix @code{troff}
12157 @cindex @code{\!}, incompatibilities with Unix @code{troff}
12158 @cindex @code{\?}, incompatibilities with Unix @code{troff}
12159 @cindex transparent output, incompatibilities with Unix @code{troff}
12160 @cindex output, transparent, incompatibilities with Unix @code{troff}
12161 @noindent
12162 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12163 is turned into one output backslash and the resulting output backslashes
12164 are not interpreted as escape characters when they are reread.
12165 @acronym{UNIX} @code{troff} would interpret them as escape characters
12166 when they were reread and would end up printing one @samp{\}.  The
12167 correct way to obtain a printable backslash is to use the @code{\e}
12168 escape sequence: This always prints a single instance of the current
12169 escape character, regardless of whether or not it is used in a
12170 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12171 @code{troff}.@footnote{To be completely independent of the current
12172 escape character, use @code{\(rs} which represents a reverse solidus
12173 (backslash) glyph.}  To store, for some reason, an escape sequence in a
12174 diversion that will be interpreted when the diversion is reread, either
12175 use the traditional @code{\!} transparent output facility, or, if this
12176 is unsuitable, the new @code{\?} escape sequence.
12178 @xref{Diversions}, for more information.
12181 @c =====================================================================
12183 @node Summary,  , Implementation Differences, gtroff Reference
12184 @section Summary
12185 @cindex summary
12187 @c XXX documentation
12191 @c =====================================================================
12192 @c =====================================================================
12194 @node Preprocessors, Output Devices, gtroff Reference, Top
12195 @chapter Preprocessors
12196 @cindex preprocessors
12198 This chapter describes all preprocessors that come with @code{groff} or
12199 which are freely available.
12201 @menu
12202 * geqn::
12203 * gtbl::
12204 * gpic::
12205 * ggrn::
12206 * grap::
12207 * grefer::
12208 * gsoelim::
12209 @end menu
12212 @c =====================================================================
12214 @node geqn, gtbl, Preprocessors, Preprocessors
12215 @section @code{geqn}
12216 @cindex @code{eqn}, the program
12217 @cindex @code{geqn}, the program
12219 @c XXX
12221 @menu
12222 * Invoking geqn::
12223 @end menu
12225 @c ---------------------------------------------------------------------
12227 @node Invoking geqn,  , geqn, geqn
12228 @subsection Invoking @code{geqn}
12229 @cindex invoking @code{geqn}
12230 @cindex @code{geqn}, invoking
12232 @c XXX
12235 @c =====================================================================
12237 @node gtbl, gpic, geqn, Preprocessors
12238 @section @code{gtbl}
12239 @cindex @code{tbl}, the program
12240 @cindex @code{gtbl}, the program
12242 @c XXX
12244 @menu
12245 * Invoking gtbl::
12246 @end menu
12248 @c ---------------------------------------------------------------------
12250 @node Invoking gtbl,  , gtbl, gtbl
12251 @subsection Invoking @code{gtbl}
12252 @cindex invoking @code{gtbl}
12253 @cindex @code{gtbl}, invoking
12255 @c XXX
12258 @c =====================================================================
12260 @node gpic, ggrn, gtbl, Preprocessors
12261 @section @code{gpic}
12262 @cindex @code{pic}, the program
12263 @cindex @code{gpic}, the program
12265 @c XXX
12267 @menu
12268 * Invoking gpic::
12269 @end menu
12271 @c ---------------------------------------------------------------------
12273 @node Invoking gpic,  , gpic, gpic
12274 @subsection Invoking @code{gpic}
12275 @cindex invoking @code{gpic}
12276 @cindex @code{gpic}, invoking
12278 @c XXX
12281 @c =====================================================================
12283 @node ggrn, grap, gpic, Preprocessors
12284 @section @code{ggrn}
12285 @cindex @code{grn}, the program
12286 @cindex @code{ggrn}, the program
12288 @c XXX
12290 @menu
12291 * Invoking ggrn::
12292 @end menu
12294 @c ---------------------------------------------------------------------
12296 @node Invoking ggrn,  , ggrn, ggrn
12297 @subsection Invoking @code{ggrn}
12298 @cindex invoking @code{ggrn}
12299 @cindex @code{ggrn}, invoking
12301 @c XXX
12304 @c =====================================================================
12306 @node grap, grefer, ggrn, Preprocessors
12307 @section @code{grap}
12308 @cindex @code{grap}, the program
12310 A free implementation of @code{grap}, written by Ted Faber,
12311 is available as an extra package from the following address:
12313 @display
12314 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12315 @end display
12318 @c =====================================================================
12320 @node grefer, gsoelim, grap, Preprocessors
12321 @section @code{grefer}
12322 @cindex @code{refer}, the program
12323 @cindex @code{grefer}, the program
12325 @c XXX
12327 @menu
12328 * Invoking grefer::
12329 @end menu
12331 @c ---------------------------------------------------------------------
12333 @node Invoking grefer,  , grefer, grefer
12334 @subsection Invoking @code{grefer}
12335 @cindex invoking @code{grefer}
12336 @cindex @code{grefer}, invoking
12338 @c XXX
12341 @c =====================================================================
12343 @node gsoelim,  , grefer, Preprocessors
12344 @section @code{gsoelim}
12345 @cindex @code{soelim}, the program
12346 @cindex @code{gsoelim}, the program
12348 @c XXX
12350 @menu
12351 * Invoking gsoelim::
12352 @end menu
12354 @c ---------------------------------------------------------------------
12356 @node Invoking gsoelim,  , gsoelim, gsoelim
12357 @subsection Invoking @code{gsoelim}
12358 @cindex invoking @code{gsoelim}
12359 @cindex @code{gsoelim}, invoking
12361 @c XXX
12365 @c =====================================================================
12366 @c =====================================================================
12368 @node Output Devices, File formats, Preprocessors, Top
12369 @chapter Output Devices
12370 @cindex output devices
12371 @cindex devices for output
12373 @c XXX
12375 @menu
12376 * Special Characters::
12377 * grotty::
12378 * grops::
12379 * grodvi::
12380 * grolj4::
12381 * grolbp::
12382 * grohtml::
12383 * gxditview::
12384 @end menu
12387 @c =====================================================================
12389 @node Special Characters, grotty, Output Devices, Output Devices
12390 @section Special Characters
12391 @cindex special characters
12392 @cindex characters, special
12394 @c XXX
12396 @xref{Font Files}.
12399 @c =====================================================================
12401 @node grotty, grops, Special Characters, Output Devices
12402 @section @code{grotty}
12403 @cindex @code{grotty}, the program
12405 @c XXX
12407 @menu
12408 * Invoking grotty::
12409 @end menu
12411 @c ---------------------------------------------------------------------
12413 @node Invoking grotty,  , grotty, grotty
12414 @subsection Invoking @code{grotty}
12415 @cindex invoking @code{grotty}
12416 @cindex @code{grotty}, invoking
12418 @c XXX
12420 @c The following is no longer true; fix and extend it.
12422 @c @pindex less
12423 @c @cindex Teletype
12424 @c @cindex ISO 6249 SGR
12425 @c @cindex terminal control sequences
12426 @c @cindex control sequences, for terminals
12427 @c For tty output devices, underlining is done by emitting sequences of
12428 @c @samp{_} and @samp{\b} (the backspace character) before the actual
12429 @c character.  Literally, this is printing an underline character, then
12430 @c moving back one character position, and printing the actual character
12431 @c at the same position as the underline character (similar to a
12432 @c typewriter).  Usually, a modern terminal can't interpret this (and the
12433 @c original Teletype machines for which this sequence was appropriate are
12434 @c no longer in use).  You need a pager program like @code{less} which
12435 @c translates this into ISO 6429 SGR sequences to control terminals.
12438 @c =====================================================================
12440 @node grops, grodvi, grotty, Output Devices
12441 @section @code{grops}
12442 @cindex @code{grops}, the program
12444 @c XXX
12446 @menu
12447 * Invoking grops::
12448 * Embedding PostScript::
12449 @end menu
12451 @c ---------------------------------------------------------------------
12453 @node Invoking grops, Embedding PostScript, grops, grops
12454 @subsection Invoking @code{grops}
12455 @cindex invoking @code{grops}
12456 @cindex @code{grops}, invoking
12458 @c XXX
12460 @c ---------------------------------------------------------------------
12462 @node Embedding PostScript,  , Invoking grops, grops
12463 @subsection Embedding @sc{PostScript}
12464 @cindex embedding postscript
12465 @cindex postscript, embedding
12467 @c XXX
12470 @c =====================================================================
12472 @node grodvi, grolj4, grops, Output Devices
12473 @section @code{grodvi}
12474 @cindex @code{grodvi}, the program
12476 @c XXX
12478 @menu
12479 * Invoking grodvi::
12480 @end menu
12482 @c ---------------------------------------------------------------------
12484 @node Invoking grodvi,  , grodvi, grodvi
12485 @subsection Invoking @code{grodvi}
12486 @cindex invoking @code{grodvi}
12487 @cindex @code{grodvi}, invoking
12489 @c XXX
12492 @c =====================================================================
12494 @node grolj4, grolbp, grodvi, Output Devices
12495 @section @code{grolj4}
12496 @cindex @code{grolj4}, the program
12498 @c XXX
12500 @menu
12501 * Invoking grolj4::
12502 @end menu
12504 @c ---------------------------------------------------------------------
12506 @node Invoking grolj4,  , grolj4, grolj4
12507 @subsection Invoking @code{grolj4}
12508 @cindex invoking @code{grolj4}
12509 @cindex @code{grolj4}, invoking
12511 @c XXX
12514 @c =====================================================================
12516 @node grolbp, grohtml, grolj4, Output Devices
12517 @section @code{grolbp}
12518 @cindex @code{grolbp}, the program
12520 @c XXX
12522 @menu
12523 * Invoking grolbp::
12524 @end menu
12526 @c ---------------------------------------------------------------------
12528 @node Invoking grolbp,  , grolbp, grolbp
12529 @subsection Invoking @code{grolbp}
12530 @cindex invoking @code{grolbp}
12531 @cindex @code{grolbp}, invoking
12533 @c XXX
12536 @c =====================================================================
12538 @node grohtml, gxditview, grolbp, Output Devices
12539 @section @code{grohtml}
12540 @cindex @code{grohtml}, the program
12542 @c XXX
12544 @menu
12545 * Invoking grohtml::
12546 * grohtml specific registers and strings::
12547 @end menu
12549 @c ---------------------------------------------------------------------
12551 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
12552 @subsection Invoking @code{grohtml}
12553 @cindex invoking @code{grohtml}
12554 @cindex @code{grohtml}, invoking
12556 @c XXX
12558 @c ---------------------------------------------------------------------
12560 @node grohtml specific registers and strings,  , Invoking grohtml, grohtml
12561 @subsection @code{grohtml} specific registers and strings
12562 @cindex registers specific to @code{grohtml}
12563 @cindex strings specific to @code{grohtml}
12564 @cindex @code{grohtml}, registers and strings
12566 @DefmpregList {ps4html, grohtml}
12567 @DefstrListEnd {www-image-template, grohtml}
12568 The registers @code{ps4html} and @code{www-image-template} are defined
12569 by the @code{pre-grohtml} preprocessor.  @code{pre-grohtml} reads in
12570 the @code{troff} input, marks up the inline equations and passes the
12571 result firstly to
12573 @example
12574 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
12575 @end example
12577 @noindent
12578 and secondly to
12580 @example
12581 troff -Thtml
12582 @end example
12584 The postscript device is used to create all the image files, and the
12585 register @code{ps4html} enables the macro sets to ignore floating
12586 keeps, footers, and headings.
12588 The register @code{www-image-template} is set to the user specified
12589 template name or the default name.
12590 @endDefmpreg
12593 @c =====================================================================
12595 @node gxditview,  , grohtml, Output Devices
12596 @section @code{gxditview}
12597 @cindex @code{gxditview}, the program
12599 @c XXX
12601 @menu
12602 * Invoking gxditview::
12603 @end menu
12605 @c ---------------------------------------------------------------------
12607 @node Invoking gxditview,  , gxditview, gxditview
12608 @subsection Invoking @code{gxditview}
12609 @cindex invoking @code{gxditview}
12610 @cindex @code{gxditview}, invoking
12612 @c XXX
12613 @c X11's xditview
12617 @c =====================================================================
12618 @c =====================================================================
12620 @node File formats, Installation, Output Devices, Top
12621 @chapter File formats
12622 @cindex file formats
12623 @cindex formats, file
12625 @c XXX
12627 @menu
12628 * gtroff Output::
12629 * Font Files::
12630 @end menu
12633 @c =====================================================================
12635 @node gtroff Output, Font Files, File formats, File formats
12636 @section @code{gtroff} Output
12637 @cindex @code{gtroff} output
12638 @cindex output, @code{gtroff}
12640 This section describes the format output of GNU @code{troff}.  The
12641 output format used by GNU @code{troff} is very similar -- but
12642 not identical -- to that used by
12643 @acronym{UNIX} device-independent @code{troff} (@code{ditroff}).
12645 @menu
12646 * Output Format::
12647 * Device Control::
12648 * Drawing Functions::
12649 * Line Continuation::
12650 @end menu
12652 @c ---------------------------------------------------------------------
12654 @node Output Format, Device Control, gtroff Output, gtroff Output
12655 @subsection Output Format
12656 @cindex output format
12657 @cindex format of output
12659 @cindex 8-bit input
12660 @cindex input, 8-bit
12661 The output format is text based, as opposed to a binary format (like
12662 @TeX{} DVI).  The output format is @w{8-bit} clean, thus single
12663 characters can have the eighth bit set, as can the names of fonts and
12664 special characters.
12666 The output format consists of single command characters with attached
12667 parameters which are separated from subsequent text by whitespace or a
12668 newline.
12670 The names of characters and fonts can be of arbitrary length; drivers
12671 should not assume that they are only two characters long (as
12672 @code{ditroff} does).
12674 When a character is to be printed, that character is always in the
12675 current font.  Unlike @code{ditroff}, it is not necessary for drivers to
12676 search special fonts to find a character.
12678 @table @code
12679 @item H@var{n}
12680 @c XXX
12682 @item V@var{n}
12683 @c XXX
12685 @item h@var{n}
12686 @c XXX
12688 @item v@var{n}
12689 @c XXX
12691 @item c@var{n}
12692 @c XXX
12694 @item C@var{n}
12695 @c XXX
12697 @item @var{nn}@var{c}
12698 @c XXX
12700 @item t@var{xxx}
12701 @var{xxx} is any sequence of characters terminated by a space or a
12702 newline; the first character should be printed at the current position,
12703 the the current horizontal position should be increased by the width of
12704 the first character, and so on for each character.  The width of the
12705 character is that given in the font file, appropriately scaled for the
12706 current point size, and rounded so that it is a multiple of the
12707 horizontal resolution.  Special characters cannot be printed using this
12708 command.
12710 @kindex tcommand
12711 @pindex DESC@r{, and @code{tcommand}}
12712 This command is only allowed if the @samp{tcommand} line is present in
12713 the @file{DESC} file.
12715 @item u@var{n} @var{xxx}
12716 This is same as the @samp{t} command except that after printing each
12717 character, the current horizontal position is increased by the sum of
12718 the width of that character and@w{ }@var{n}.
12720 This command is only allowed if the @samp{tcommand} line is present in
12721 the @file{DESC} file.
12723 @item n@var{a}@var{b}
12724 @c XXX
12726 @item p@var{n}
12727 @c XXX
12729 @item s@var{n}
12730 @kindex sizescale
12731 @pindex DESC@r{, and @code{sizescale}}
12732 The argument to the @samp{s} command is in scaled points (units of
12733 points/@var{n}, where @var{n} is the argument to the @samp{sizescale}
12734 command in the @file{DESC} file).
12736 @item f@var{n}
12737 @item x @dots{} \n
12738 Device control.
12739 @c XXX more info
12741 @item D@var{c} @var{x}@dots{}\n
12742 @c XXX
12743 @end table
12745 @c ---------------------------------------------------------------------
12747 @node Device Control, Drawing Functions, Output Format, gtroff Output
12748 @subsection Device Control
12749 @cindex device control
12750 @cindex control of devices
12752 The @samp{x} command is normally followed by a letter or word indicating
12753 the function to perform, followed by white space separated arguments.
12755 The first argument can be abbreviated to the first letter.
12757 @table @code
12758 @item x init
12759 @c XXX
12761 @item x T
12762 @c XXX
12764 @item x res @var{n} @var{h} @var{v}
12765 @c XXX
12767 @item x H
12768 @c XXX more info
12769 The argument to the @w{@samp{x Height}} command is also in scaled
12770 points.
12771 @end table
12773 The first three output commands are guaranteed to be:
12775 @Example
12776 x T device
12777 x res n h v
12778 x init
12779 @endExample
12781 @noindent
12782 For example, the input
12784 @Example
12785 crunchy \fH\s+2frog\s0\fP!?
12786 @endExample
12788 @noindent
12789 produces
12791 @c XXX example
12793 @ignore
12794 @Example
12795 ... sample output here ...
12796 @endExample
12797 @end ignore
12799 @c ---------------------------------------------------------------------
12801 @node Drawing Functions, Line Continuation, Device Control, gtroff Output
12802 @subsection Drawing Functions
12803 @cindex drawing functions
12804 @cindex functions for drawing
12806 @pindex gpic
12807 The @samp{D} drawing command has been extended.  These extensions are
12808 used by GNU @code{pic} only if the @option{-x} option is given.
12810 @xref{Drawing Requests}.
12812 @table @code
12813 @c XXX ...
12814 @item Df @var{n}
12815 Set the shade of gray to be used for filling solid objects to@w{
12816 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
12817 corresponds solid white and 1000 to solid black, and values in between
12818 correspond to intermediate shades of gray.  This applies only to solid
12819 circles, solid ellipses and solid polygons.  By default, a level of@w{
12820 }1000 is used.  Whatever color a solid object has, it should
12821 completely obscure everything beneath it.  A value greater than@w{ }1000
12822 or less than@w{ }0 can also be used: this means fill with the shade of
12823 gray that is currently being used for lines and text.  Normally this
12824 is black, but some drivers may provide a way of changing this.
12826 @item DC @var{d}
12827 Draw a solid circle with a diameter of@w{ }@var{d} with the leftmost
12828 point at the current position.
12830 @item DE @var{dx} @var{dy}
12831 Draw a solid ellipse with a horizontal diameter of@w{ }@var{dx} and a
12832 vertical diameter of@w{ }@var{dy} with the leftmost point at the current
12833 position.
12835 @item Dp @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
12836 Draw a polygon with automatic closure.  The first vertex is at the
12837 current position, the second vertex at an offset (@var{dx1},@var{dy1})
12838 from the current position, the second vertex at an offset
12839 (@var{dx2},@var{dy2}) from the first vertex, and so on up to the
12840 @var{n}@dmn{th} vertex.  At the moment, GNU @code{pic} only uses this
12841 command to generate triangles and rectangles.
12843 @item DP @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
12844 Like @code{Dp} but draw a solid rather than outlined polygon.
12846 @item Dt @var{n}
12847 @cindex line thickness
12848 @cindex thickness of lines
12849 Set the current line thickness to @var{n}@w{ }machine units.
12850 Traditionally, @acronym{UNIX} @code{troff} drivers use a line thickness
12851 proportional to the current point size; drivers should continue to do
12852 this if no @code{Dt} command has been given, or if a @code{Dt} command
12853 has been given with a negative value of@w{ }@var{n}.  A zero value of@w{
12854 }@var{n} selects the smallest available line thickness.
12855 @end table
12857 A difficulty arises in how the current position should be changed after
12858 the execution of these commands.  This is not of great importance since
12859 the code generated by GNU @code{pic} does not depend on this.  Given a
12860 drawing command of the form
12862 @Example
12863 \D'@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}'
12864 @endExample
12866 @cindex @code{\w}, and drawing commands
12867 @cindex @code{st} register, and drawing commands
12868 @cindex @code{sb} register, and drawing commands
12869 @noindent
12870 where @var{c} is not one of @samp{c}, @samp{e}, @samp{l}, @samp{a} or
12871 @samp{~}, @acronym{UNIX} @code{troff} treats each x@w{ }value
12872 as a horizontal quantity, and each y@w{ }value as a vertical
12873 quantity; it assumes that the width of the drawn object is the sum of
12874 all x@w{ }values, and that the height is the sum of all y@w{ }values.
12875 (The assumption about the height can be seen by examining the @code{st}
12876 and @code{sb} registers after using such a @code{D}@w{ }command in a
12877 @code{\w} escape sequence.)  This rule also holds for all the original
12878 drawing commands with the exception of @code{De}.  For the sake of
12879 compatibility GNU @code{troff} also follows this rule, even though it
12880 produces an ugly result in the case of the @code{Df}, @code{Dt}, and, to
12881 a lesser extent, @code{DE}@w{ }commands.  Thus after executing a
12882 @code{D}@w{ }command of the form
12884 @Example
12885 D@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}
12886 @endExample
12888 @noindent
12889 the current position should be increased horizontally by the sum of all
12890 x@w{ }values and vertically by the sum of all y@w{ }values.
12892 @c ---------------------------------------------------------------------
12894 @node Line Continuation,  , Drawing Functions, gtroff Output
12895 @subsection Line Continuation
12896 @cindex line continuation in output commands
12897 @cindex output commands, line continuation
12899 There is a continuation convention which permits the argument to the
12900 @w{@samp{x X}} command to contain newlines: When outputting the argument
12901 to the @w{@samp{x X}} command, GNU @code{troff} follows each newline
12902 in the argument with a @samp{+} character (as usual, it terminates
12903 the entire argument with a newline); thus if the line after the line
12904 containing the @w{@samp{x X}} command starts with @samp{+}, then the
12905 newline ending the line containing the @w{@samp{x X}} command should be
12906 treated as part of the argument to the @w{@samp{x X}} command, the
12907 @samp{+} should be ignored, and the part of the line following the
12908 @samp{+} should be treated like the part of the line following the
12909 @w{@samp{x X}} command.
12912 @c =====================================================================
12914 @node Font Files,  , gtroff Output, File formats
12915 @section Font Files
12916 @cindex font files
12917 @cindex files, font
12919 The @code{gtroff} font format is roughly a superset of the
12920 @code{ditroff} font format.  Unlike the @code{ditroff} font format,
12921 there is no associated binary format; all files are text files.  The
12922 font files for device @var{name} are stored in a directory
12923 @file{dev@var{name}}.  There are two types of file: a device description
12924 file called @file{DESC} and for each font@w{ }@var{f} a font file
12925 called@w{ }@file{@var{f}}.
12927 @menu
12928 * DESC File Format::
12929 * Font File Format::
12930 @end menu
12932 @c ---------------------------------------------------------------------
12934 @node DESC File Format, Font File Format, Font Files, Font Files
12935 @subsection @file{DESC} File Format
12936 @cindex @file{DESC} file format
12937 @cindex font description file format
12938 @cindex format of font description file
12939 @pindex DESC@r{ file format}
12941 The @file{DESC} file can contain the following types of line:
12943 @table @code
12944 @item res @var{n}
12945 @kindex res
12946 There are @var{n}@w{ }machine units per inch.
12948 @item hor @var{n}
12949 @kindex hor
12950 The horizontal resolution is @var{n}@w{ }machine units.
12952 @item vert @var{n}
12953 @kindex vert
12954 The vertical resolution is @var{n}@w{ }machine units.
12956 @item sizescale @var{n}
12957 @kindex sizescale
12958 The scale factor for point sizes.  By default this has a value of@w{ }1.
12959 One scaled point is equal to one point/@var{n}.  The arguments to the
12960 @code{unitwidth} and @code{sizes} commands are given in scaled points.
12961 @xref{Fractional Type Sizes}, for more information.
12963 @item unitwidth @var{n}
12964 @kindex unitwidth
12965 Quantities in the font files are given in machine units for fonts whose
12966 point size is @var{n}@w{ }scaled points.
12968 @item tcommand
12969 @kindex tcommand
12970 This means that the postprocessor can handle the @samp{t} and @samp{u}
12971 output commands.
12973 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
12974 @kindex sizes
12975 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
12976 @var{sn} scaled points.  The list of sizes must be terminated by a@w{
12977 }0.  Each @var{si} can also be a range of sizes @var{m}-@var{n}.  The
12978 list can extend over more than one line.
12980 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
12981 @kindex styles
12982 The first @var{m}@w{ }font positions are associated with styles
12983 @var{S1} @dots{} @var{Sm}.
12985 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
12986 @kindex fonts
12987 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
12988 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
12989 styles.  This command may extend over more than one line.  A font name
12990 of@var{ }0 means no font is mounted on the corresponding font position.
12992 @item family @var{fam}
12993 @kindex family
12994 The default font family is @var{fam}.
12996 @item charset
12997 @kindex charset
12998 This line and everything following in the file are ignored.  It is
12999 allowed for the sake of backwards compatibility.
13000 @end table
13002 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
13003 are mandatory.  Other commands are ignored by @code{gtroff} but may be
13004 used by postprocessors to store arbitrary information about the device
13005 in the @file{DESC} file.
13007 @c XXX add other commands resp. xrefs to output devices
13008 @c XXX add obsolete commands
13010 @c ---------------------------------------------------------------------
13012 @node Font File Format,  , DESC File Format, Font Files
13013 @subsection Font File Format
13014 @cindex font file format
13015 @cindex format of font files
13017 A font file has two sections.  The first section is a sequence of lines
13018 each containing a sequence of blank delimited words; the first word in
13019 the line is a key, and subsequent words give a value for that key.
13021 @table @code
13022 @item name @var{f}
13023 @kindex name
13024 The name of the font is@w{ }@var{f}.
13026 @item spacewidth @var{n}
13027 @kindex spacewidth
13028 The normal width of a space is@w{ }@var{n}.
13030 @item slant @var{n}
13031 @kindex slant
13032 The characters of the font have a slant of @var{n}@w{ }degrees.
13033 (Positive means forward.)
13035 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
13036 @kindex ligatures
13037 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
13038 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
13039 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
13040 terminated with a@w{ }0.  The list of ligatures may not extend over more
13041 than one line.
13043 @item special
13044 @kindex special
13045 The font is special; this means that when a character is requested that
13046 is not present in the current font, it is searched for in any
13047 special fonts that are mounted.
13048 @end table
13050 Other commands are ignored by @code{gtroff} but may be used by
13051 postprocessors to store arbitrary information about the font in the font
13052 file.
13054 @cindex comments in font files
13055 @cindex font files, comments
13056 @kindex #
13057 The first section can contain comments which start with the @samp{#}
13058 character and extend to the end of a line.
13060 The second section contains one or two subsections.  It must contain a
13061 @code{charset} subsection and it may also contain a @code{kernpairs}
13062 subsection.  These subsections can appear in any order.  Each
13063 subsection starts with a word on a line by itself.
13065 @kindex charset
13066 The word @code{charset} starts the character set subsection.  The
13067 @code{charset} line is followed by a sequence of lines.  Each line gives
13068 information for one character.  A line comprises a number of fields
13069 separated by blanks or tabs.  The format is
13071 @c XXX fix it for new HTML additions
13073 @Example
13074 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
13075 @endExample
13077 @cindex 8-bit input
13078 @cindex input, 8-bit
13079 @cindex accessing unnamed characters with @code{\N}
13080 @cindex unnamed characters, accessing with @code{\N}
13081 @cindex characters, unnamed, accessing with @code{\N}
13082 @kindex ---
13083 @noindent
13084 @var{name} identifies the character: If @var{name} is a single
13085 character@w{ }@var{c} then it corresponds to the @code{gtroff} input
13086 character@w{ }@var{c}; if it is of the form @samp{\@var{c}} where @var{c}
13087 is a single character, then it corresponds to the @code{gtroff} input
13088 character@w{ }\@var{c}; otherwise it corresponds to the groff input
13089 character @samp{\[@var{name}]}.  (If it is exactly two characters
13090 @var{xx} it can be entered as @samp{\(@var{xx}}.)  @code{gtroff}
13091 supports 8-bit characters; however some utilities have difficulties with
13092 eight-bit characters.  For this reason, there is a convention that the
13093 name @samp{char@var{n}} is equivalent to the single character whose code
13094 is@w{ }@var{n}.  For example, @samp{char163} would be equivalent to the
13095 character with code@w{ }163 which is the pounds sterling sign in @w{ISO
13096 Latin-1} character set.  The name @samp{---} is special and indicates
13097 that the character is unnamed; such characters can only be used by means
13098 of the @code{\N} escape sequence in @code{gtroff}.
13100 @c XXX input encodings vs. output encodings
13102 The @var{type} field gives the character type:
13104 @table @code
13105 @item 1
13106 the character has an descender, for example, `p';
13108 @item 2
13109 the character has an ascender, for example, `b';
13111 @item 3
13112 the character has both an ascender and a descender, for example, `('.
13113 @end table
13115 The @var{code} field gives the code which the postprocessor uses to
13116 print the character.  The character can also be input to @code{gtroff}
13117 using this code by means of the @code{\N} escape sequence.  The code can
13118 be any integer.  If it starts with @samp{0} it is interpreted as
13119 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
13120 hexadecimal.
13122 Anything on the line after the @var{code} field is ignored.
13124 The @var{metrics} field has the form:
13126 @Example
13127 @var{width}[,@var{height}[,@var{depth}[,@var{italic_correction}
13128   [,@var{left_italic_correction}[,@var{subscript_correction}]]]]]
13129 @endExample
13131 @noindent
13132 There must not be any spaces between these subfields (it has been split
13133 here into two lines for better legibility only).  Missing subfields are
13134 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
13135 there is no associated binary format, these values are not required to
13136 fit into a variable of type @samp{char} as they are in @code{ditroff}.
13137 The @var{width} subfield gives the width of the character.  The
13138 @var{height} subfield gives the height of the character (upwards is
13139 positive); if a character does not extend above the baseline, it should
13140 be given a zero height, rather than a negative height.  The @var{depth}
13141 subfield gives the depth of the character, that is, the distance below
13142 the lowest point below the baseline to which the character extends
13143 (downwards is positive); if a character does not extend below above the
13144 baseline, it should be given a zero depth, rather than a negative depth.
13145 The @var{italic_correction} subfield gives the amount of space that
13146 should be added after the character when it is immediately to be
13147 followed by a character from a roman font.  The
13148 @var{left_italic_correction} subfield gives the amount of space that
13149 should be added before the character when it is immediately to be
13150 preceded by a character from a roman font.  The
13151 @var{subscript_correction} gives the amount of space that should be
13152 added after a character before adding a subscript.  This should be less
13153 than the italic correction.
13155 A line in the @code{charset} section can also have the format
13157 @Example
13158 @var{name} "
13159 @endExample
13161 @noindent
13162 This indicates that @var{name} is just another name for the character
13163 mentioned in the preceding line.
13165 @kindex kernpairs
13166 The word @code{kernpairs} starts the kernpairs section.  This contains a
13167 sequence of lines of the form:
13169 @Example
13170 @var{c1} @var{c2} @var{n}
13171 @endExample
13173 @noindent
13174 This means that when character @var{c1} appears next to character
13175 @var{c2} the space between them should be increased by@w{ }@var{n}.
13176 Most entries in the kernpairs section have a negative value for@w{
13177 }@var{n}.
13181 @c =====================================================================
13182 @c =====================================================================
13184 @node Installation, Request Index, File formats, Top
13185 @chapter Installation
13186 @cindex installation
13188 @c XXX
13192 @c =====================================================================
13193 @c =====================================================================
13195 @node Request Index, Escape Index, Installation, Top
13196 @chapter Request Index
13198 Requests appear without the leading control character (normally either
13199 @samp{.} or @samp{'}).
13201 @printindex rq
13205 @c =====================================================================
13206 @c =====================================================================
13208 @node Escape Index, Operator Index, Request Index, Top
13209 @chapter Escape Index
13211 @printindex es
13215 @c =====================================================================
13216 @c =====================================================================
13218 @node Operator Index, Register Index, Escape Index, Top
13219 @chapter Operator Index
13221 @printindex op
13225 @c =====================================================================
13226 @c =====================================================================
13228 @node Register Index, Macro Index, Operator Index, Top
13229 @chapter Register Index
13231 The macro package or program a specific register belongs to is appended in
13232 brackets.
13234 A register name@w{ }@code{x} consisting of exactly one character can be
13235 accessed as @samp{\nx}.  A register name @code{xx} consisting of exactly
13236 two characters can be accessed as @samp{\n(xx}.  Register names @code{xxx}
13237 of any length can be accessed as @samp{\n[xxx]}.
13239 @printindex vr
13243 @c =====================================================================
13244 @c =====================================================================
13246 @node Macro Index, String Index, Register Index, Top
13247 @chapter Macro Index
13249 The macro package a specific macro belongs to is appended in brackets.
13250 They appear without the leading control character (normally @samp{.}).
13252 @printindex ma
13256 @c =====================================================================
13257 @c =====================================================================
13259 @node String Index, Glyph Name Index, Macro Index, Top
13260 @chapter String Index
13262 The macro package or program a specific string belongs to is appended in
13263 brackets.
13265 A string name@w{ }@code{x} consisting of exactly one character can be
13266 accessed as @samp{\*x}.  A string name @code{xx} consisting of exactly
13267 two characters can be accessed as @samp{\*(xx}.  String names @code{xxx}
13268 of any length can be accessed as @samp{\*[xxx]}.
13271 @printindex st
13275 @c =====================================================================
13276 @c =====================================================================
13278 @node Glyph Name Index, Font File Keyword Index, String Index, Top
13279 @chapter Glyph Name Index
13281 A glyph name @code{xx} consisting of exactly two characters can be
13282 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
13283 accessed as @samp{\[xxx]}.
13285 @c XXX
13289 @c =====================================================================
13290 @c =====================================================================
13292 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
13293 @chapter Font File Keyword Index
13295 @printindex ky
13299 @c =====================================================================
13300 @c =====================================================================
13302 @node Program and File Index, Concept Index, Font File Keyword Index, Top
13303 @chapter Program  and File Index
13305 @printindex pg
13309 @c =====================================================================
13310 @c =====================================================================
13312 @node Concept Index,  , Program and File Index, Top
13313 @chapter Concept Index
13315 @printindex cp
13319 @summarycontents
13320 @contents
13321 @bye