1 \input texinfo @c -*-texinfo-*-
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.
7 @c You need texinfo 4.2 or newer to format this document!
10 @c %**start of header (This is for running Texinfo on a region.)
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:
24 @c kindex: commands in font files
25 @c pindex: programs and files
26 @c tindex: environment variables
31 @c tindex and cindex are merged.
41 @c to avoid uppercasing in @deffn while converting to info, we define
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
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:
81 @c The definition block must end with
85 @c The above is valid for texinfo 4.0f.
88 @c a dummy macro to assure the `@def...'
94 @c definition of requests
96 @macro Defreq{name, arg}
97 @deffn Request @t{.\name\} \arg\
101 @macro DefreqList{name, arg}
102 @deffn Request @t{.\name\} \arg\
107 @macro DefreqItem{name, arg}
108 @deffnx Request @t{.\name\} \arg\
113 @macro DefreqListEnd{name, arg}
114 @deffnx Request @t{.\name\} \arg\
123 @c definition of escapes
125 @macro Defesc{name, delimI, arg, delimII}
126 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
130 @macro DefescList{name, delimI, arg, delimII}
131 @deffn Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
136 @macro DefescItem{name, delimI, arg, delimII}
137 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
142 @macro DefescListEnd{name, delimI, arg, delimII}
143 @deffnx Escape @t{\name\\delimI\}@var{\arg\}@t{\delimII\}
152 @c definition of registers
155 @deffn Register @t{\\n[\name\]}
159 @macro DefregList{name}
160 @deffn Register @t{\\n[\name\]}
165 @macro DefregItem{name}
166 @deffnx Register @t{\\n[\name\]}
171 @macro DefregListEnd{name}
172 @deffnx Register @t{\\n[\name\]}
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{]}
188 @macro DefmpregList{name, package}
189 @deffn Register @t{\\n[\name\]}
191 @vindex \name\ @r{[}\package\@r{]}
194 @macro DefmpregItem{name, package}
195 @deffnx Register @t{\\n[\name\]}
197 @vindex \name\ @r{[}\package\@r{]}
200 @macro DefmpregListEnd{name, package}
201 @deffnx Register @t{\\n[\name\]}
202 @vindex \name\ @r{[}\package\@r{]}
210 @c definition of macros
212 @macro Defmac{name, arg, package}
213 @defmac @t{.\name\} \arg\
214 @maindex \name\ @r{[}\package\@r{]}
217 @macro DefmacList{name, arg, package}
218 @defmac @t{.\name\} \arg\
220 @maindex \name\ @r{[}\package\@r{]}
223 @macro DefmacItem{name, arg, package}
224 @defmacx @t{.\name\} \arg\
226 @maindex \name\ @r{[}\package\@r{]}
229 @macro DefmacListEnd{name, arg, package}
230 @defmacx @t{.\name\} \arg\
231 @maindex \name\ @r{[}\package\@r{]}
239 @c definition of strings
241 @macro Defstr{name, package}
242 @deffn String @t{\\*[\name\]}
243 @stindex \name\ @r{[}\package\@r{]}
246 @macro DefstrList{name, package}
247 @deffn String @t{\\*[\name\]}
249 @stindex \name\ @r{[}\package\@r{]}
252 @macro DefstrItem{name, package}
253 @deffnx String @t{\\*[\name\]}
255 @stindex \name\ @r{[}\package\@r{]}
258 @macro DefstrListEnd{name, package}
259 @deffnx String @t{\\*[\name\]}
260 @stindex \name\ @r{[}\package\@r{]}
281 @c We need special parentheses and brackets:
283 @c . Real parentheses in @deffn produce an error while compiling with
285 @c . Real brackets use the wrong font in @deffn, overriding @t{}.
287 @c This is true for texinfo 4.0.
320 @c Note: We say `Roman numerals' but `roman font'.
323 @c XXX comment all examples
326 @dircategory Miscellaneous
328 * Groff: (groff). The GNU troff document formatting system.
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.
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).
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
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.
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.
397 @vskip 0pt plus 1filll
398 Copyright @copyright@w{ }1994-2000, 2001, 2002 Free Software
401 Version 1.18 of @code{groff}, @*
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
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.
432 @node Top, Copying, (dir), (dir)
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.
446 * Tutorial for Macro Users::
460 * Font File Keyword Index::
461 * Program and File Index::
467 @node Copying, Introduction, Top, Top
469 @unnumbered GNU GENERAL PUBLIC LICENSE
470 @center Version 2, June 1991
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.
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
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
530 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
533 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
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.
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.
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:
574 You must cause the modified files to carry prominent notices stating
575 that you changed the files and the date of any change.
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
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.)
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.
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
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,
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
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.)
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
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.
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
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
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.
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
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
717 This section is intended to make thoroughly clear what is believed to be
718 a consequence of the rest of this License.
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.
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.
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.
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.
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.
783 @heading END OF TERMS AND CONDITIONS
786 @center END OF TERMS AND CONDITIONS
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
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.
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.
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:
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.
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:
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
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
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.
878 * groff Capabilities::
879 * Macro Package Intro::
880 * Preprocessor Intro::
881 * Output device intro::
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
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}:
912 They must be used on a graphics display to work on a document.
915 Most of the @acronym{WYSIWYG} systems are either non-free or are not
919 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
922 It is difficult to have a wide range of capabilities available within
923 the confines of a GUI/window system.
926 It is more difficult to make global changes to a document.
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})
936 @c =====================================================================
938 @node History, groff Capabilities, What Is groff?, Introduction
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 @acronym{AT&T} patents
960 division. This first formatting program was a reimplementation of
961 McIllroy's @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
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.
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:
1021 A replacement for @code{ditroff} with many extensions.
1024 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
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.
1033 A version of the @file{me} macros and an implementation of the
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}:
1069 text filling, adjusting, and centering
1078 font and character size control
1081 vertical spacing (i.e.@: double spacing)
1084 line length and indenting
1087 macros, strings, diversions, and traps
1093 tabs, leaders, and fields
1096 input and output conventions and character translation
1099 overstrike, bracket, line drawing, and zero-width functions
1102 local horizontal and vertical motions and the width function
1108 output line numbering
1111 conditional acceptance of input
1114 environment switching
1117 insertions from the standard input
1120 input/output file switching
1123 output and error messages
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}
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
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
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
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}.
1235 * Invocation Examples::
1239 @c =====================================================================
1241 @node Groff Options, Environment, Invoking groff, Invoking groff
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:
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{} ]
1279 The command line format for @code{gtroff} is as follows.
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{} ]
1289 Obviously, many of the options to @code{groff} are actually passed on to
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
1304 Print a help message.
1307 Preprocess with @code{geqn}.
1310 Preprocess with @code{gtbl}.
1313 Preprocess with @code{ggrn}.
1316 Preprocess with @code{grap}.
1319 Preprocess with @code{gpic}.
1322 Preprocess with @code{gsoelim}.
1325 Suppress color output.
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},
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.
1340 Make programs run by @code{groff} print out their version number.
1343 Print the pipeline on @code{stdout} instead of executing it.
1346 Suppress output from @code{gtroff}. Only error messages are printed.
1349 Do not postprocess the output of @code{gtroff}. Normally @code{groff}
1350 automatically runs the appropriate postprocessor.
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.
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
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.
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:
1377 For @sc{PostScript} printers and previewers.
1380 For @TeX{} DVI format.
1383 For a 75@dmn{dpi} X11 previewer.
1386 For a 75@dmn{dpi} X11 previewer with a 12@dmn{pt} base font.
1389 For a 100@dmn{dpi} X11 previewer.
1392 For a 100@dmn{dpi} X11 previewer with a 12@dmn{pt} base font.
1395 @cindex encoding, @acronym{ASCII}
1396 @cindex @acronym{ASCII}, encoding
1397 For typewriter-like devices.
1400 @cindex encoding, latin-1
1401 @cindex latin-1, encoding
1402 For typewriter-like devices that support the @w{Latin-1} (@w{ISO
1403 8859-1}) character set.
1406 @cindex encoding, utf-8
1407 @cindex utf-8, encoding
1408 For typewriter-like devices which use the Unicode (@w{ISO 10646})
1409 character set with @w{UTF-8} encoding.
1412 @cindex @acronym{EBCDIC} encoding
1413 @cindex encoding, @acronym{EBCDIC}
1414 @cindex encoding, cp1047
1417 For typewriter-like devices which use the @acronym{EBCDIC} encoding IBM
1421 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
1424 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1428 @pindex post-grohtml
1429 @cindex @code{grohtml}, the program
1431 To produce @acronym{HTML} output. Note that the @acronym{HTML} driver
1432 consists of two parts, a preprocessor (@code{pre-grohtml}) and a
1433 postprocessor (@code{post-grohtml}).
1436 @cindex output device name string register (@code{.T})
1437 @cindex output device usage number register (@code{.T})
1438 The predefined @code{gtroff} string register @code{.T} contains the
1439 current output device; the read-only number register @code{.T} is set
1440 to@w{ }1 if this option is used (which is always true if @code{groff} is
1441 used to call @code{gtroff}). @xref{Built-in Registers}.
1443 The postprocessor to be used for a device is specified by the
1444 @code{postpro} command in the device description file. (@xref{Font
1445 Files}, for more info.) This can be overridden with the @option{-X}
1449 Preview with @code{gxditview} instead of using the usual postprocessor.
1450 This is unlikely to produce good results except with @option{-Tps}.
1452 Note that this is not the same as using @option{-TX75} or
1453 @option{-TX100} to view a document with @code{gxditview}: The former
1454 uses the metrics of the specified device, whereas the latter uses
1455 X-specific fonts and metrics.
1458 Don't allow newlines with @code{eqn} delimiters. This is the same as
1459 the @option{-N} option in @code{geqn}.
1461 @cindex @code{open} request, and safer mode
1462 @cindex @code{opena} request, and safer mode
1463 @cindex @code{pso} request, and safer mode
1464 @cindex @code{sy} request, and safer mode
1465 @cindex @code{pi} request, and safer mode
1467 Safer mode. Pass the @option{-S} option to @code{gpic} and disable the
1468 @code{open}, @code{opena}, @code{pso}, @code{sy}, and @code{pi}
1469 requests. For security reasons, this is enabled by default.
1472 Unsafe mode. Reverts to the old unsafe behaviour.
1475 @cindex @acronym{ASCII} approximation output register (@code{.A})
1476 Generate an @acronym{ASCII} approximation of the typeset output. The
1477 read-only register @code{.A} is then set to@w{ }1. @xref{Built-in
1478 Registers}. A typical example is
1481 groff -a -man -Tdvi troff.man | less
1485 which shows how lines are broken for the DVI device. Note that this
1486 option is rather useless today since graphic output devices are
1487 available virtually everywhere.
1490 Print a backtrace with each warning or error message. This backtrace
1491 should help track down the cause of the error. The line numbers given
1492 in the backtrace may not always be correct: @code{gtroff} can get
1493 confused by @code{as} or @code{am} requests while counting line numbers.
1496 Read the standard input after all the named input files have been
1500 Enable warning @var{name}. Available warnings are described in
1501 @ref{Debugging}. Multiple @option{-w} options are allowed.
1504 Inhibit warning @var{name}. Multiple @option{-W} options are allowed.
1507 Inhibit all error messages.
1510 Enable compatibility mode. @xref{Implementation Differences}, for the
1511 list of incompatibilities between @code{groff} and traditional @acronym{AT&T}
1515 @itemx -d@var{name}=s
1516 Define @var{c} or @var{name} to be a string@w{ }@var{s}. @var{c}@w{ }must
1517 be a one-letter name; @var{name} can be of arbitrary length. All string
1518 assignments happen before loading any macro file (including the start-up
1522 Use @var{fam} as the default font family. @xref{Font Families}.
1525 Read in the file @file{@var{name}.tmac}. Normally @code{groff} searches
1526 for this in its macro directories. If it isn't found, it tries
1527 @file{tmac.@var{name}} (and searches in the same directories).
1529 @c XXX document local and system macro dirs
1532 Number the first page @var{num}.
1535 @cindex print current page register (@code{.P})
1536 Output only pages in @var{list}, which is a comma-separated list of page
1537 ranges; @samp{@var{n}} means print page@w{ }@var{n}, @samp{@var{m}-@var{n}}
1538 means print every page between @var{m} and@w{ }@var{n}, @samp{-@var{n}}
1539 means print every page up to@w{ }@var{n}, @samp{@var{n}-} means print every
1540 page beginning with@w{ }@var{n}. @code{gtroff} exits after printing the
1541 last page in the list. All the ranges are inclusive on both ends.
1543 Within @code{gtroff}, this information can be extracted with the
1544 @samp{.P} register. @xref{Built-in Registers}.
1546 If your document restarts page numbering at the beginning of each
1547 chapter, then @code{gtroff} prints the specified page range for each
1551 @itemx -r@var{name}=@var{n}
1552 Set number register@w{ }@var{c} or @var{name} to the value@w{ }@var{n}.
1553 @var{c}@w{ }must be a one-letter name; @var{name} can be of arbitrary
1554 length. @var{n}@w{ }can be any @code{gtroff} numeric expression. All
1555 register assignments happen before loading any macro file (including
1559 Search @file{@var{dir}} for subdirectories @file{dev@var{name}}
1560 (@var{name} is the name of the device), for the @file{DESC} file, and
1561 for font files before looking in the standard directories.
1564 Search directory @file{@var{dir}} for macro files before the standard
1568 This option is as described in @ref{gsoelim}. It implies the
1573 @c =====================================================================
1575 @node Environment, Invocation Examples, Groff Options, Invoking groff
1576 @section Environment
1577 @cindex environment variables
1578 @cindex variables in environment
1580 There are also several environment variables (of the operating system,
1581 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1584 @item GROFF_COMMAND_PREFIX
1585 @tindex GROFF_COMMAND_PREFIX@r{, environment variable}
1586 If this is set to@w{ }@var{X}, then @code{groff} runs @code{@var{X}troff}
1587 instead of @code{gtroff}. This also applies to @code{tbl}, @code{pic},
1588 @code{eqn}, @code{grn}, @code{refer}, and @code{soelim}. It does not
1589 apply to @code{grops}, @code{grodvi}, @code{grotty}, @code{pre-grohtml},
1590 @code{post-grohtml}, @code{grolj4}, and @code{gxditview}.
1592 @c XXX document default values
1594 @item GROFF_TMAC_PATH
1595 @tindex GROFF_TMAC_PATH@r{, environment variable}
1596 A colon-separated list of directories in which to search for macro files
1597 (before the default directories are tried).
1599 @c XXX document local and system macro dirs
1601 @item GROFF_TYPESETTER
1602 @tindex GROFF_TYPESETTER@r{, environment variable}
1603 The default output device.
1605 @item GROFF_FONT_PATH
1606 @tindex GROFF_FONT_PATH@r{, environment variable}
1607 A colon-separated list of directories in which to search for the
1608 @code{dev}@var{name} directory (before the default directories are
1611 @item GROFF_BIN_PATH
1612 @tindex GROFF_BIN_PATH@r{, environment variable}
1613 This search path, followed by @code{PATH}, is used for commands executed
1617 @tindex GROFF_TMPDIR@r{, environment variable}
1618 @tindex TMPDIR@r{, environment variable}
1619 The directory in which @code{groff} creates temporary files. If this is
1620 not set and @env{TMPDIR} is set, temporary files are created in that
1621 directory. Otherwise temporary files are created in a system-dependent
1622 default directory (on Unix and GNU/Linux systems, this is usually
1623 @file{/tmp}). @code{grops}, @code{grefer}, @code{pre-grohtml}, and
1624 @code{post-grohtml} can create temporary files in this directory.
1627 Note that MS-DOS and MS-Windows ports of @code{groff} use semi-colons,
1628 rather than colons, to separate the directories in the lists described
1632 @c =====================================================================
1634 @node Invocation Examples, , Environment, Invoking groff
1635 @section Invocation Examples
1636 @cindex invocation examples
1637 @cindex examples of invocation
1639 This section lists several common uses of @code{groff} and the
1640 corresponding command lines.
1647 This command processes @file{file} without a macro package or a
1648 preprocessor. The output device is the default, @samp{ps}, and the
1649 output is sent to @code{stdout}.
1652 groff -t -mandoc -Tascii file | less
1656 This is basically what a call to the @code{man} program does.
1657 @code{gtroff} processes the manual page @file{file} with the
1658 @file{mandoc} macro file (which in turn either calls the @file{man} or
1659 the @file{mdoc} macro package), using the @code{tbl} preprocessor and
1660 the @acronym{ASCII} output device. Finally, the @code{less} pager
1661 displays the result.
1668 Preview @file{file} with @code{gxditview}, using the @file{me} macro
1669 package. Since no @option{-T} option is specified, use the default
1670 device (@samp{ps}). Note that you can either say @w{@samp{-m me}} or
1671 @w{@samp{-me}}; the latter is an anachronism from the early days of
1672 @acronym{UNIX}.@footnote{The same is true for the other main macro
1673 packages that come with @code{groff}: @file{man}, @file{mdoc},
1674 @file{ms}, @file{mm}, and @file{mandoc}. This won't work in general;
1675 for example, to load @file{trace.tmac}, either @samp{-mtrace} or
1676 @w{@samp{-m trace}} must be used.}
1679 groff -man -rD1 -z file
1683 Check @file{file} with the @file{man} macro package, forcing
1684 double-sided printing -- don't produce any output.
1690 @c ---------------------------------------------------------------------
1692 @node grog, , Invocation Examples, Invocation Examples
1693 @subsection @code{grog}
1696 @code{grog} reads files, guesses which of the @code{groff} preprocessors
1697 and/or macro packages are required for formatting them, and prints the
1698 @code{groff} command including those options on the standard output. It
1699 generates one or more of the options @option{-e}, @option{-man},
1700 @option{-me}, @option{-mm}, @option{-ms}, @option{-mdoc},
1701 @option{-mdoc-old}, @option{-p}, @option{-R}, @option{-g}, @option{-G},
1702 @option{-s}, and @option{-t}.
1704 A special file name@w{ }@file{-} refers to the standard input. Specifying
1705 no files also means to read the standard input. Any specified options
1706 are included in the printed command. No space is allowed between
1707 options and their arguments. The only options recognized are
1708 @option{-C} (which is also passed on) to enable compatibility mode, and
1709 @option{-v} (if it is the only parameter) to print the version number.
1718 guesses the appropriate command to print @file{paper.ms} and then prints
1719 it to the command line after adding the @option{-Tdvi} option. For
1720 direct execution, enclose the call to @code{grog} in backquotes at the
1721 @acronym{UNIX} shell prompt:
1724 `grog -Tdvi paper.ms` > paper.dvi
1728 As seen in the example, it is still necessary to redirect the output to
1729 something meaningful (i.e.@: either a file or a pager program like
1734 @c =====================================================================
1735 @c =====================================================================
1737 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1738 @chapter Tutorial for Macro Users
1739 @cindex tutorial for macro users
1740 @cindex macros, tutorial for users
1741 @cindex user's tutorial for macros
1742 @cindex user's macro tutorial
1744 Most users tend to use a macro package to format their papers. This
1745 means that the whole breadth of @code{groff} is not necessary for most
1746 people. This chapter covers the material needed to efficiently use a
1755 @c =====================================================================
1757 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1759 @cindex basics of macros
1760 @cindex macro basics
1762 This section covers some of the basic concepts necessary to understand
1763 how to use a macro package.@footnote{This section is derived from
1764 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1765 References are made throughout to more detailed information, if desired.
1767 @code{gtroff} reads an input file prepared by the user and outputs a
1768 formatted document suitable for publication or framing. The input
1769 consists of text, or words to be printed, and embedded commands
1770 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1771 format the output. For more detail on this, see @ref{Embedded
1774 The word @dfn{argument} is used in this chapter to mean a word or number
1775 which appears on the same line as a request, and which modifies the
1776 meaning of that request. For example, the request
1783 spaces one line, but
1790 spaces four lines. The number@w{ }4 is an argument to the @code{sp}
1791 request which says to space four lines instead of one. Arguments are
1792 separated from the request and from each other by spaces (@emph{no}
1793 tabs). More details on this can be found in @ref{Request Arguments}.
1795 The primary function of @code{gtroff} is to collect words from input
1796 lines, fill output lines with those words, justify the right-hand margin
1797 by inserting extra spaces in the line, and output the result. For
1805 Four score and seven
1810 is read, packed onto output lines, and justified to produce:
1813 Now is the time for all good men to come to the aid of their party.
1814 Four score and seven years ago,@dots{}
1819 Sometimes a new output line should be started even though the current
1820 line is not yet full; for example, at the end of a paragraph. To do
1821 this it is possible to cause a @dfn{break}, which starts a new output
1822 line. Some requests cause a break automatically, as normally do blank
1823 input lines and input lines beginning with a space.
1825 Not all input lines are text to be formatted. Some input lines are
1826 requests which describe how to format the text. Requests always have a
1827 period (@samp{.}) or an apostrophe (@samp{'}) as the first character of
1830 The text formatter also does more complex things, such as automatically
1831 numbering pages, skipping over page boundaries, putting footnotes in the
1832 correct place, and so forth.
1834 Here are a few hints for preparing text for input to @code{gtroff}.
1838 First, keep the input lines short. Short input lines are easier to
1839 edit, and @code{gtroff} packs words onto longer lines anyhow.
1842 In keeping with this, it is helpful to begin a new line after every
1843 comma or phrase, since common corrections are to add or delete sentences
1847 End each sentence with two spaces -- or better, start each sentence on a
1848 new line. @code{gtroff} recognizes characters that usually end a
1849 sentence, and inserts sentence space accordingly.
1852 Do not hyphenate words at the end of lines -- @code{gtroff} is smart
1853 enough to hyphenate words as needed, but is not smart enough to take
1854 hyphens out and join a word back together. Also, words such as
1855 ``mother-in-law'' should not be broken over a line, since then a space
1856 can occur where not wanted, such as ``@w{mother- in}-law''.
1859 @cindex double spacing (@code{ls})
1861 @code{gtroff} double spaces output text automatically if you use the
1862 request @w{@samp{.ls 2}}. Reactivate single spaced mode by typing
1865 A number of requests allow to change the way the output looks,
1866 sometimes called the @dfn{layout} of the output page. Most of these
1867 requests adjust the placing of @dfn{whitespace} (blank lines or
1870 @cindex new page (@code{bp})
1871 The @samp{.bp} request starts a new page, causing a line break.
1873 @cindex blank line (@code{sp})
1874 @cindex empty line (@code{sp})
1875 @cindex line, empty (@code{sp})
1876 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1877 space. @var{N}@w{ }can be omitted (meaning skip a single line) or can
1878 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1879 @var{N}@w{ }centimeters). For example, the input:
1883 My thoughts on the subject
1888 leaves one and a half inches of space, followed by the line ``My
1889 thoughts on the subject'', followed by a single blank line (more
1890 measurement units are available, see @ref{Measurements}).
1892 @cindex centering lines (@code{ce})
1893 @cindex lines, centering (@code{ce})
1894 Text lines can be centered by using the @code{ce} request. The line
1895 after @code{ce} is centered (horizontally) on the page. To center more
1896 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1897 of lines to center), followed by the @var{N}@w{ }lines. To center many
1898 lines without counting them, type:
1907 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1908 lines, in other words, stop centering.
1910 @cindex line break (@code{br})
1911 @cindex break (@code{br})
1912 All of these requests cause a break; that is, they always start a new
1913 line. To start a new line without performing any other action, use
1917 @c =====================================================================
1919 @node Common Features, , Basics, Tutorial for Macro Users
1920 @section Common Features
1921 @cindex common features
1922 @cindex features, common
1924 @code{gtroff} provides very low-level operations for formatting a
1925 document. There are many common routine operations which are done in
1926 all documents. These common operations are written into @dfn{macros}
1927 and collected into a @dfn{macro package}.
1929 All macro packages provide certain common capabilities which fall into
1930 the following categories.
1934 * Sections and Chapters::
1935 * Headers and Footers::
1936 * Page Layout Adjustment::
1938 * Footnotes and Annotations::
1939 * Table of Contents::
1942 * Multiple Columns::
1943 * Font and Size Changes::
1944 * Predefined Strings::
1945 * Preprocessor Support::
1946 * Configuration and Customization::
1949 @c ---------------------------------------------------------------------
1951 @node Paragraphs, Sections and Chapters, Common Features, Common Features
1952 @subsection Paragraphs
1955 One of the most common and most used capability is starting a
1956 paragraph. There are a number of different types of paragraphs, any
1957 of which can be initiated with macros supplied by the macro package.
1958 Normally, paragraphs start with a blank line and the first line
1959 indented, like the text in this manual. There are also block style
1960 paragraphs, which omit the indentation:
1963 Some men look at constitutions with sanctimonious
1964 reverence, and deem them like the ark of the covenant, too
1965 sacred to be touched.
1969 And there are also indented paragraphs which begin with a tag or label
1970 at the margin and the remaining text indented.
1974 one This is the first paragraph. Notice how the first
1975 line of the resulting paragraph lines up with the
1976 other lines in the paragraph.
1980 This paragraph had a long label. The first
1981 character of text on the first line does not line up
1982 with the text on second and subsequent lines,
1983 although they line up with each other.
1987 A variation of this is a bulleted list.
1991 @c ---------------------------------------------------------------------
1993 @node Sections and Chapters, Headers and Footers, Paragraphs, Common Features
1994 @subsection Sections and Chapters
1996 Most macro packages supply some form of section headers. The simplest
1997 kind is simply the heading on a line by itself in bold type. Others
1998 supply automatically numbered section heading or different heading
1999 styles at different levels. Some, more sophisticated, macro packages
2000 supply macros for starting chapters and appendices.
2002 @c ---------------------------------------------------------------------
2004 @node Headers and Footers, Page Layout Adjustment, Sections and Chapters, Common Features
2005 @subsection Headers and Footers
2007 Every macro package gives some way to manipulate the headers and footers
2008 (or @dfn{titles}) on each page. Some packages allow for different ones
2009 on the even and odd pages (for material printed in a book form).
2011 The titles are called three-part titles, that is, there is a
2012 left-justified part, a centered part, and a right-justified part. An
2013 automatically generated page number may be put in any of these fields
2014 with the @samp{%} character (see @ref{Page Layout}, for more details).
2016 @c ---------------------------------------------------------------------
2018 @node Page Layout Adjustment, Displays, Headers and Footers, Common Features
2019 @subsection Page Layout
2021 Most macro packages let the user specify top and bottom margins and
2022 other details about the appearance of the printed pages.
2024 @c ---------------------------------------------------------------------
2026 @node Displays, Footnotes and Annotations, Page Layout Adjustment, Common Features
2027 @subsection Displays
2030 Displays are sections of text to be set off from the body of the paper.
2031 Major quotes, tables, and figures are types of displays, as are all the
2032 examples used in this document.
2034 @cindex quotes, major
2035 @cindex major quotes
2036 @dfn{Major quotes} are quotes which are several lines long, and hence
2037 are set in from the rest of the text without quote marks around them.
2040 A @dfn{list} is an indented, single spaced, unfilled display. Lists
2041 should be used when the material to be printed should not be filled and
2042 justified like normal text, such as columns of figures or the examples
2046 A @dfn{keep} is a display of lines which are kept on a single page if
2047 possible. An example for a keep might be a diagram. Keeps differ from
2048 lists in that lists may be broken over a page boundary whereas keeps are
2051 @cindex keep, floating
2052 @cindex floating keep
2053 Floating keeps move relative to the text. Hence, they are good for
2054 things which are referred to by name, such as ``See figure@w{ }3''. A
2055 floating keep appears at the bottom of the current page if it fits;
2056 otherwise, it appears at the top of the next page. Meanwhile, the
2057 surrounding text `flows' around the keep, thus leaving no blank areas.
2059 @c ---------------------------------------------------------------------
2061 @node Footnotes and Annotations, Table of Contents, Displays, Common Features
2062 @subsection Footnotes and Annotations
2066 There are a number of requests to save text for later printing.
2068 @dfn{Footnotes} are printed at the bottom of the current page.
2070 @cindex delayed text
2071 @dfn{Delayed text} is very similar to a footnote except that it is
2072 printed when called for explicitly. This allows a list of references to
2073 appear (for example) at the end of each chapter, as is the convention in
2076 Most macro packages which supply this functionality also supply a means
2077 of automatically numbering either type of annotation.
2079 @c ---------------------------------------------------------------------
2081 @node Table of Contents, Indices, Footnotes and Annotations, Common Features
2082 @subsection Table of Contents
2083 @cindex table of contents
2084 @cindex contents, table of
2086 @dfn{Tables of contents} are a type of delayed text having a tag
2087 (usually the page number) attached to each entry after a row of dots.
2088 The table accumulates throughout the paper until printed, usually after
2089 the paper has ended. Many macro packages provide the ability to have
2090 several tables of contents (e.g.@: a standard table of contents, a list
2093 @c ---------------------------------------------------------------------
2095 @node Indices, Paper Formats, Table of Contents, Common Features
2097 @cindex index, in macro package
2099 While some macro packages use the term @dfn{index}, none actually
2100 provide that functionality. The facilities they call indices are
2101 actually more appropriate for tables of contents.
2103 @c ---------------------------------------------------------------------
2105 @node Paper Formats, Multiple Columns, Indices, Common Features
2106 @subsection Paper Formats
2107 @cindex paper formats
2109 Some macro packages provide stock formats for various kinds of
2110 documents. Many of them provide a common format for the title and
2111 opening pages of a technical paper. The @file{mm} macros in particular
2112 provide formats for letters and memoranda.
2114 @c ---------------------------------------------------------------------
2116 @node Multiple Columns, Font and Size Changes, Paper Formats, Common Features
2117 @subsection Multiple Columns
2119 Some macro packages (but not @file{man}) provide the ability to have two
2120 or more columns on a page.
2122 @c ---------------------------------------------------------------------
2124 @node Font and Size Changes, Predefined Strings, Multiple Columns, Common Features
2125 @subsection Font and Size Changes
2127 The built-in font and size functions are not always intuitive, so all
2128 macro packages provide macros to make these operations simpler.
2130 @c ---------------------------------------------------------------------
2132 @node Predefined Strings, Preprocessor Support, Font and Size Changes, Common Features
2133 @subsection Predefined Strings
2135 Most macro packages provide various predefined strings for a variety of
2136 uses; examples are sub- and superscripts, printable dates, quotes and
2137 various special characters.
2139 @c ---------------------------------------------------------------------
2141 @node Preprocessor Support, Configuration and Customization, Predefined Strings, Common Features
2142 @subsection Preprocessor Support
2144 All macro packages provide support for the various preprocessors and may
2145 extend their functionality.
2147 For example, all macro packages mark tables (which are processed with
2148 @code{gtbl}) by placing them between @code{.TS} and @code{.TE} macros.
2149 The @file{ms} macro package has an option, @code{.TS@w{}H}, that prints
2150 a caption at the top of a new page (when the table is too long to fit on
2153 @c ---------------------------------------------------------------------
2155 @node Configuration and Customization, , Preprocessor Support, Common Features
2156 @subsection Configuration and Customization
2158 Some macro packages provide means of customizing many of the details of
2159 how the package behaves. This ranges from setting the default type size
2160 to changing the appearance of section headers.
2164 @c =====================================================================
2165 @c =====================================================================
2167 @node Macro Packages, gtroff Reference, Tutorial for Macro Users, Top
2168 @chapter Macro Packages
2169 @cindex macro packages
2170 @cindex packages, macros
2172 This chapter documents the main macro packages that come with
2184 @c =====================================================================
2186 @node man, mdoc, Macro Packages, Macro Packages
2188 @cindex manual pages
2192 @pindex man-old.tmac
2194 This is the most popular and probably the most important macro package
2195 of @code{groff}. It is easy to use, and a vast majority of manual pages
2202 * Miscellaneous man macros::
2203 * Predefined man strings::
2204 * Preprocessors in man pages::
2207 @c ---------------------------------------------------------------------
2209 @node Man options, Man usage, man, man
2212 The command line format for using the @file{man} macros with
2216 groff -m man [ -rcR=1 ] [ -rC1 ] [ -rD1 ] [ -rP@var{nnn} ]
2217 [ -rS@var{xx} ] [ -rX@var{nnn} ] [ @var{files}@dots{} ]
2221 It is possible to use @samp{-man} instead of @w{@samp{-m man}}.
2225 This option (the default if a TTY output device is used) creates a
2226 single, very long page instead of multiple pages. Use @code{-rcR=0}
2230 If more than one manual page is given on the command line, number the
2231 pages continuously, rather than starting each at@w{ }1.
2234 Double-sided printing. Footers for even and odd pages are formatted
2238 Page numbering starts with @var{nnn} rather than with@w{ }1.
2241 Use @var{xx} (which can be 10, 11, or@w{ }12@dmn{pt}) as the base
2242 document font size instead of the default value of@w{ }10@dmn{pt}.
2245 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
2246 @var{nnn}c, etc. For example, the option @option{-rX2} produces the
2247 following page numbers: 1, 2, 2a, 2b, 2c, etc.
2250 @c ---------------------------------------------------------------------
2252 @node Man usage, Man font macros, Man options, man
2254 @cindex @code{man} macros
2255 @cindex macros for manual pages [@code{man}]
2258 This section describes the available macros for manual pages. For
2259 further customization, put additional macros and requests into the file
2260 @file{man.local} which is loaded immediately after the @file{man}
2263 @Defmac {TH, title section [@Var{extra1}] [@Var{extra2}] [@Var{extra3}], man}
2264 Set the title of the man page to @var{title} and the section to
2265 @var{section}, which must have a value between 1 and@w{ }8. The value
2266 of @var{section} may also have a string appended, e.g.@: @samp{.pm},
2267 to indicate a specific subsection of the man pages.
2269 Both @var{title} and @var{section} are positioned at the left and right
2270 in the header line (with @var{section} in parentheses immediately
2271 appended to @var{title}. @var{extra1} is positioned in the middle of
2272 the footer line. @var{extra2} is positioned at the left in the footer
2273 line (or at the left on even pages and at the right on odd pages if
2274 double-sided printing is active). @var{extra3} is centered in the
2277 For @acronym{HTML} output, headers and footers are completely suppressed.
2279 Additionally, this macro starts a new page; the new line number is@w{ }1
2280 again (except if the @option{-rC1} option is given on the command line)
2281 -- this feature is intended only for formatting multiple man pages; a
2282 single man page should contain exactly one @code{TH} macro at the
2283 beginning of the file.
2286 @Defmac {SH, [@Var{heading}], man}
2287 Set up an unnumbered section heading sticking out to the left. Prints
2288 out all the text following @code{SH} up to the end of the line (or the
2289 text in the next line if there is no argument to @code{SH}) in bold
2290 face, one size larger than the base document size. Additionally, the
2291 left margin for the following text is reset to its default value.
2294 @Defmac {SS, [@Var{heading}], man}
2295 Set up an unnumbered (sub)section heading. Prints out all the text
2296 following @code{SS} up to the end of the line (or the text in the next
2297 line if there is no argument to @code{SS}) in bold face, at the same
2298 size as the base document size. Additionally, the left margin for the
2299 following text is reset to its default value.
2302 @Defmac {TP, [@Var{nnn}], man}
2303 Set up an indented paragraph with label. The indentation is set to
2304 @var{nnn} if that argument is supplied (the default unit is @samp{n}
2305 if omitted), otherwise it is set to the default indentation value.
2307 The first line of text following this macro is interpreted as a string
2308 to be printed flush-left, as it is appropriate for a label. It is not
2309 interpreted as part of a paragraph, so there is no attempt to fill the
2310 first line with text from the following input lines. Nevertheless, if
2311 the label is not as wide as the indentation, then the paragraph starts
2312 at the same line (but indented), continuing on the following lines.
2313 If the label is wider than the indentation, then the descriptive part
2314 of the paragraph begins on the line following the label, entirely
2315 indented. Note that neither font shape nor font size of the label is
2316 set to a default value; on the other hand, the rest of the text has
2317 default font settings.
2320 @DefmacList {LP, , man}
2321 @DefmacItem {PP, , man}
2322 @DefmacListEnd {P, , man}
2323 These macros are mutual aliases. Any of them causes a line break at
2324 the current position, followed by a vertical space downwards by the
2325 amount specified by the @code{PD} macro. The font size and shape are
2326 reset to the default value (10@dmn{pt} roman). Finally, the current
2327 left margin is restored.
2330 @Defmac {IP, [@Var{designator}] [@Var{nnn}], man}
2331 Set up an indented paragraph, using @var{designator} as a tag to mark
2332 its beginning. The indentation is set to @var{nnn} if that argument
2333 is supplied (default unit is @samp{n}), otherwise the default
2334 indentation value is used. Font size and face of the paragraph (but
2335 not the designator) are reset to their default values. To start an
2336 indented paragraph with a particular indentation but without a
2337 designator, use @samp{""} (two double quotes) as the first argument of
2340 For example, to start a paragraph with bullets as the designator and
2341 4@dmn{en} indentation, write
2348 @Defmac {HP, [@Var{nnn}], man}
2349 @cindex hanging indentation [@code{man}]
2350 @cindex @code{man} macros, hanging indentation
2351 Set up a paragraph with hanging left indentation. The indentation is
2352 set to @var{nnn} if that argument is supplied (default unit is
2353 @samp{n}), otherwise the default indentation value is used. Font size
2354 and face are reset to their default values.
2357 @Defmac {RS, [@Var{nnn}], man}
2358 @cindex left margin, how to move [@code{man}]
2359 @cindex @code{man} macros, moving left margin
2360 Move the left margin to the right by the value @var{nnn} if specified
2361 (default unit is @samp{n}); otherwise the default indentation value
2362 is used. Calls to the @code{RS} macro can be nested.
2365 @Defmac {RE, [@Var{nnn}], man}
2366 Move the left margin back to level @var{nnn}; if no argument is given,
2367 it moves one level back. The first level (i.e., no call to @code{RS}
2368 yet) has number@w{ }1, and each call to @code{RS} increases the level
2372 @cindex line breaks, with vertical space [@code{man}]
2373 @cindex @code{man} macros, line breaks with vertical space
2374 To summarize, the following macros cause a line break with the insertion
2375 of vertical space (which amount can be changed with the @code{PD}
2376 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
2377 @code{P}), @code{IP}, and @code{HP}.
2379 @cindex line breaks, without vertical space [@code{man}]
2380 @cindex @code{man} macros, line breaks without vertical space
2381 The macros @code{RS} and @code{RE} also cause a break but do not insert
2384 @c ---------------------------------------------------------------------
2386 @node Man font macros, Miscellaneous man macros, Man usage, man
2387 @subsection Macros to set fonts
2388 @cindex font selection [@code{man}]
2389 @cindex @code{man} macros, how to set fonts
2391 The standard font is roman; the default text size is 10@w{ }point.
2393 @Defmac {SM, [@Var{text}], man}
2394 Set the text on the same line or the text on the next line in a font
2395 that is one point size smaller than the default font.
2398 @Defmac {SB, [@Var{text}], man}
2399 @cindex bold face [@code{man}]
2400 @cindex @code{man} macros, bold face
2401 Set the text on the same line or the text on the next line in bold face
2402 font, one point size smaller than the default font.
2405 @Defmac {BI, text, man}
2406 Set its arguments alternately in bold face and italic. Thus,
2409 .BI this "word and" that
2413 would set ``this'' and ``that'' in bold face, and ``word and'' in
2417 @Defmac {IB, text, man}
2418 Set its arguments alternately in italic and bold face.
2421 @Defmac {RI, text, man}
2422 Set its arguments alternately in roman and italic.
2425 @Defmac {IR, text, man}
2426 Set its arguments alternately in italic and roman.
2429 @Defmac {BR, text, man}
2430 Set its arguments alternately in bold face and roman.
2433 @Defmac {RB, text, man}
2434 Set its arguments alternately in roman and bold face.
2437 @Defmac {B, [@Var{text}], man}
2438 Set @var{text} in bold face. If no text is present on the line where
2439 the macro is called, then the text of the next line appears in bold
2443 @Defmac {I, [@Var{text}], man}
2444 @cindex italic fonts [@code{man}]
2445 @cindex @code{man} macros, italic fonts
2446 Set @var{text} in italic. If no text is present on the line where the
2447 macro is called, then the text of the next line appears in italic.
2450 @c ---------------------------------------------------------------------
2452 @node Miscellaneous man macros, Predefined man strings, Man font macros, man
2453 @subsection Miscellaneous macros
2456 @cindex @code{man} macros, default indentation
2457 @cindex default indentation [@code{man}]
2458 The default indentation is 7.2@dmn{n} for all output devices except for
2459 @code{grohtml} which ignores indentation.
2462 @cindex tab stops [@code{man}]
2463 @cindex @code{man} macros, tab stops
2464 Set tabs every 0.5@w{ }inches. Since this macro is always called
2465 during a @code{TH} request, it makes sense to call it only if the tab
2466 positions have been changed.
2469 @Defmac {PD, [@Var{nnn}], man}
2470 @cindex empty space before a paragraph [@code{man}]
2471 @cindex @code{man} macros, empty space before a paragraph
2472 Adjust the empty space before a new paragraph (or section). The
2473 optional argument gives the amount of space (default unit is
2474 @samp{v}); without parameter, the value is reset to its default value
2475 (1@w{ }line for TTY devices, 0.4@dmn{v}@w{ }otherwise).
2478 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP} (as
2479 well as @code{PP} and @code{P}), @code{IP}, and @code{HP}.
2481 @c ---------------------------------------------------------------------
2483 @node Predefined man strings, Preprocessors in man pages, Miscellaneous man macros, man
2484 @subsection Predefined strings
2486 The following strings are defined:
2489 Switch back to the default font size.
2493 The `registered' sign.
2497 The `trademark' sign.
2500 @DefstrList {lq, man}
2501 @DefstrListEnd {rq, man}
2502 @cindex @code{lq} glyph, and @code{lq} string [@code{man}]
2503 @cindex @code{rq} glyph, and @code{rq} string [@code{man}]
2504 Left and right quote. This is equal to @code{\(lq} and @code{\(rq},
2508 @c ---------------------------------------------------------------------
2510 @node Preprocessors in man pages, , Predefined man strings, man
2511 @subsection Preprocessors in @file{man} pages
2513 @cindex preprocessor, calling convention
2514 @cindex calling convention of preprocessors
2515 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
2516 become common usage to make the first line of the man page look like
2523 @pindex geqn@r{, invocation in manual pages}
2524 @pindex grefer@r{, invocation in manual pages}
2525 @pindex gtbl@r{, invocation in manual pages}
2526 @pindex man@r{, invocation of preprocessors}
2528 Note the single space character after the double quote. @var{word}
2529 consists of letters for the needed preprocessors: @samp{e} for
2530 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
2531 Modern implementations of the @code{man} program read this first line
2532 and automatically call the right preprocessor(s).
2535 @c =====================================================================
2537 @node mdoc, ms, man, Macro Packages
2538 @section @file{mdoc}
2539 @cindex @code{mdoc} macros
2541 @c XXX documentation
2542 @c XXX this is a placeholder until we get stuff knocked into shape
2543 See the @cite{groff_mdoc(7)} man page (type @command{man groff_mdoc}
2544 at the command line).
2547 @c =====================================================================
2549 @node ms, me, mdoc, Macro Packages
2551 @cindex @code{ms} macros
2554 macros are suitable for reports, letters, books,
2555 user manuals, and so forth.
2556 The package provides macros for cover pages, section headings,
2557 paragraphs, lists, footnotes, pagination,
2558 and a table of contents.
2562 * General ms Structure::
2563 * ms Document Control Registers::
2564 * ms Cover Page Macros::
2567 * Differences from AT&T ms::
2570 @c ---------------------------------------------------------------------
2572 @node ms Intro, General ms Structure, ms, ms
2573 @subsection Introduction to @file{ms}
2575 The original @file{-ms} macros were included with
2576 @acronym{AT&T} @code{troff} as well as the
2578 While the @file{man} package is intended for brief documents
2579 that can be read on-line as well as printed, the @file{ms}
2580 macros are suitable for longer documents that are meant to be
2581 printed rather than read on-line.
2583 The @file{ms} macro package included with @code{groff}
2584 is a complete, bottom-up re-implementation.
2585 Several macros (specific to @acronym{AT&T}
2586 or Berkeley) are not included, while several new commands are.
2587 @xref{Differences from AT&T ms}, for more information.
2589 @c ---------------------------------------------------------------------
2591 @node General ms Structure, ms Document Control Registers, ms Intro, ms
2592 @subsection General structure of an @file{ms} document
2593 @cindex @code{ms} macros, general structure
2595 The @file{ms} macro package expects a certain amount of structure,
2596 but not as much as packages such as @file{man} or @file{mdoc}.
2598 The simplest documents can begin with a paragraph macro
2599 (such as @code{LP} or @code{PP}),
2600 and consist of text separated by paragraph macros
2601 or even blank lines.
2602 Longer documents have a structure as follows:
2606 If you invoke the @code{RP}
2607 (report) macro on the first line of the document,
2608 @code{groff} prints the cover page information on its own page;
2609 otherwise it prints the information on the
2610 first page with your document text immediately following.
2611 Other document formats found in @acronym{AT&T} @code{troff}
2612 are specific to @acronym{AT&T} or Berkeley, and are not supported in
2615 @item Format and layout
2616 By setting number registers,
2617 you can change your document's type (font and size),
2618 margins, spacing, headers and footers, and footnotes.
2619 @xref{ms Document Control Registers}, for more details.
2622 A cover page consists of a title, the author's name and institution,
2623 an abstract, and the date.
2624 @footnote{Actually, only the title is required.}
2625 @xref{ms Cover Page Macros}, for more details.
2628 Following the cover page is your document.
2629 You can use the @file{ms}
2630 macros to write reports, letters, books, and so forth.
2631 The package is designed for structured documents,
2632 consisting of paragraphs interspersed with headings
2633 and augmented by lists, footnotes, tables, and other
2635 @xref{ms Body Text}, for more details.
2637 @item Table of contents
2638 Longer documents usually include a table of contents,
2639 which you can invoke by placing the
2641 macro at the end of your document.
2643 macros have minimal indexing facilities, consisting of the
2644 @code{IX} macro, which prints an entry on standard error.
2645 Printing the table of contents at the end is necessary since
2646 @code{groff} is a single-pass text formatter,
2647 thus it cannot determine the page number of each section
2648 until that section has actually been set and printed.
2649 Since @file{ms} output is intended for hardcopy,
2650 you can manually relocate the pages containing
2651 the table of contents between the cover page and the
2652 body text after printing.
2655 @c ---------------------------------------------------------------------
2657 @node ms Document Control Registers, ms Cover Page Macros, General ms Structure, ms
2658 @subsection Document control registers
2659 @cindex @code{ms} macros, document control registers
2661 The following is a list of document control number registers.
2662 For the sake of consistency,
2663 set registers related to margins at the beginning of your document,
2664 or just after the @code{RP} macro.
2665 You can set other registers later in your document,
2666 but you should keep them together at the beginning
2667 to make them easy to find and edit as necessary.
2669 @unnumberedsubsubsec Margin Settings
2672 Defines the page offset (i.e.@: the left margin).
2673 There is no explicit right margin setting; the combination of
2674 the @code{PO} and @code{LL} registers implicitly define the
2677 Effective: next page.
2679 Default value: 1@dmn{i}.
2683 Defines the line length (i.e.@: the width of the body text).
2685 Effective: next paragraph.
2691 Defines the title length (i.e.@: the header and footer width).
2692 This is usually the same as @code{LL}, but not necessarily.
2694 Effective: next paragraph.
2700 Defines the header margin height at the top of the page.
2702 Effective: next page.
2708 Defines the footer margin height at the bottom of the page.
2710 Effective: next page.
2715 @unnumberedsubsubsec Text Settings
2718 Defines the point size of the body text.
2720 Effective: next paragraph.
2726 Defines the space between lines (line height plus leading).
2728 Effective: next paragraph.
2733 @unnumberedsubsubsec Paragraph Settings
2736 Defines the initial indent of a @code{.PP} paragraph.
2738 Effective: next paragraph.
2744 Defines the space between paragraphs.
2746 Effective: next paragraph.
2748 Default: 0.3@dmn{v}.
2752 Defines the indent on both sides of a quoted (@code{.QP}) paragraph.
2754 Effective: next paragraph.
2759 @unnumberedsubsubsec Footnote Settings
2762 Defines the length of a footnote.
2764 Effective: next footnote.
2766 Default: @math{@code{@\n[LL]} * 5 / 6}.
2770 Defines the footnote indent.
2772 Effective: next footnote.
2778 The footnote format:
2781 Prints the footnote number as a superscript; indents the footnote (default).
2784 Prints the number followed by a period (like 1.)
2785 and indents the footnote.
2788 Like 1, without an indent.
2791 Like 1, but prints the footnote number as a hanging paragraph.
2794 Effective: next footnote.
2799 @unnumberedsubsubsec Miscellaneous Number Registers
2801 @Defmpreg {MINGW, ms}
2802 Defines the minimum width between columns in a multi-column document.
2804 Effective: next page.
2809 @c ---------------------------------------------------------------------
2811 @node ms Cover Page Macros, ms Body Text, ms Document Control Registers, ms
2812 @subsection Cover page macros
2813 @cindex @code{ms} macros, cover page
2814 @cindex cover page macros, [@code{ms}]
2816 Use the following macros to create a cover page for your document
2819 @Defmac {RP, [@code{no}], ms}
2820 Specifies the report format for your document.
2821 The report format creates a separate cover page.
2822 The default action (no @code{.RP}
2823 macro) is to print a subset of the
2824 cover page on page 1 of your document.
2826 If you use the word @code{no} as an optional argument,
2827 @code{groff} prints a title page but
2828 does not repeat any of the title page information
2829 (title, author, abstract, etc.)
2830 on page 1 of the document.
2833 @Defmac {DA, [@dots{}], ms}
2834 (optional) Print the current date, or the arguments to the macro if any,
2835 on the title page (if specified) and in the footers.
2836 This is the default for @code{nroff}.
2839 @Defmac {ND, [@dots{}], ms}
2840 (optional) Print the current date, or the arguments to the macro if any,
2841 on the title page (if specified) but not in the footers.
2842 This is the default for @code{troff}.
2846 Specifies the document title.
2847 @code{groff} collects text following the @code{.TL}
2848 macro into the title, until reaching the author name or abstract.
2852 Specifies the author's name, which appears on the
2853 line (or lines) immediately following.
2854 You can specify multiple authors as follows:
2860 University of West Bumblefuzz
2864 Monolithic Corporation
2871 Specifies the author's institution.
2872 You can specify multiple institutions in the same way
2873 that you specify multiple authors.
2876 @Defmac {AB, [@code{no}], ms}
2877 Begins the abstract.
2878 The default is to print the word @acronym{ABSTRACT},
2879 centered and in italics, above the text of the abstract.
2880 The word @code{no} as an optional argument suppresses this heading.
2887 The following is example mark-up for a title page.
2888 @cindex title page, example markup
2889 @cindex example markup, title page
2895 The Inevitability of Code Bloat
2896 in Commercial and Free Software
2900 University of West Bumblefuzz
2902 This report examines the long-term growth
2903 of the code bases in two large, popular software
2904 packages; the free Emacs and the commercial
2906 While differences appear in the type or order
2907 of features added, due to the different
2908 methodologies used, the results are the same
2911 The free software approach is shown to be
2912 superior in that while free software can
2913 become as bloated as commercial offerings,
2914 free software tends to have fewer serious
2915 bugs and the added features are in line with
2919 ... the rest of the paper follows ...
2923 @c ---------------------------------------------------------------------
2925 @node ms Body Text, ms Page Layout, ms Cover Page Macros, ms
2926 @subsection Body text
2927 @cindex @code{ms} macros, body text
2929 This section describes macros used to mark up the body of your document.
2930 Examples include paragraphs, sections, and other groups.
2933 * Paragraphs in ms::
2935 * Highlighting in ms::
2939 * ms Displays and Keeps::
2941 * Example multi-page table::
2945 @c ---------------------------------------------------------------------
2947 @node Paragraphs in ms, Headings in ms, ms Body Text, ms Body Text
2948 @subsubsection Paragraphs
2949 @cindex @code{ms} macros, paragraph handling
2951 The following paragraph types are available.
2954 Sets a paragraph with an initial indent.
2958 Sets a paragraph with no initial indent.
2962 Sets a paragraph that is indented at both left and right margins.
2963 The effect is identical to the @acronym{HTML} @code{<BLOCKQUOTE>} element.
2964 The next paragraph or heading returns margins to normal.
2968 Sets a paragraph whose lines are indented,
2969 except for the first line.
2970 This is a Berkeley extension.
2973 The following markup uses all four paragraph macros.
2978 Cases used in the study
2980 The following software and versions were
2981 considered for this report.
2983 For commercial software, we chose
2984 .B "Microsoft Word for Windows" ,
2985 starting with version 1.0 through the
2986 current version (Word 2000).
2988 For free software, we chose
2990 from its first appearance as a standalone
2991 editor through the current version (v20).
2992 See [Bloggs 2002] for details.
2994 Franklin's Law applied to software:
2995 software expands to outgrow both
2996 RAM and disk space over time.
3001 .I "Everyone's a Critic" ,
3002 Underground Press, March 2002.
3003 A definitive work that answers all questions
3004 and criticisms about the quality and usability of
3010 @c ---------------------------------------------------------------------
3012 @node Headings in ms, Highlighting in ms, Paragraphs in ms, ms Body Text
3013 @subsubsection Headings
3014 @cindex @code{ms} macros, headings
3016 Use headings to create a hierarchical structure for your document.
3017 The @file{ms} macros print headings in @strong{bold},
3018 using the same font family and point size as the body text.
3020 The following describes the heading macros:
3022 @DefmacList {NH, @Var{curr-level}, ms}
3023 @DefmacListEnd {NH, @t{S} @Var{level0} @dots{}, ms}
3025 The argument is either a numeric argument to indicate the
3026 level of the heading, or the letter@w{ }@code{S} followed by numeric
3027 arguments to set the heading level explicitly.
3029 If you specify heading levels out of sequence, such as invoking
3030 @samp{.NH 3} after @samp{.NH 1}, @code{groff}
3031 prints a warning on standard error.
3035 Unnumbered subheading.
3038 @c ---------------------------------------------------------------------
3040 @node Highlighting in ms, Lists in ms, Headings in ms, ms Body Text
3041 @subsubsection Highlighting
3042 @cindex @code{ms} macros, highlighting
3044 The @file{ms} macros provide a variety of methods to highlight
3047 @Defmac {B, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3048 Sets its first argument in @strong{bold type}.
3049 If you specify a second argument, @code{groff} prints it in the
3050 previous font after the bold text, with no intervening space
3051 (this allows you to set punctuation after the highlighted text
3052 without highlighting the punctuation).
3053 Similarly, it prints the third argument (if any) in the previous
3054 font @strong{before} the first argument.
3061 prints (@strong{foo}).
3063 If you give this macro no arguments, @code{groff}
3064 prints all text following in bold until
3065 the next highlighting, paragraph, or heading macro.
3068 @Defmac {R, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3069 Sets its first argument in roman (or regular) type.
3070 It operates similarly to the @code{B}@w{ }macro otherwise.
3073 @Defmac {I, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3074 Sets its first argument in @emph{italic type}.
3075 It operates similarly to the @code{B}@w{ }macro otherwise.
3078 @Defmac {CW, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3079 Sets its first argument in a @code{constant width face}.
3080 It operates similarly to the @code{B}@w{ }macro otherwise.
3083 @Defmac {BI, [@Var{txt} [@Var{post} [@Var{pre}]]], ms}
3084 Sets its first argument in bold italic type.
3085 It operates similarly to the @code{B}@w{ }macro otherwise.
3088 @Defmac {BX, [@Var{txt}], ms}
3089 Prints its argument and draws a box around it.
3090 If you want to box a string that contains spaces,
3091 use a digit-width space (@code{\0}).
3094 @Defmac {UL, [@Var{txt} [@Var{post}]], ms}
3095 Prints its first argument with an underline.
3096 If you specify a second argument, @code{groff}
3097 prints it in the previous font after
3098 the underlined text, with no intervening space.
3102 Prints all text following in larger type
3103 (two points larger than the current point size) until
3104 the next font size, highlighting, paragraph, or heading macro.
3105 You can specify this macro multiple times
3106 to enlarge the point size as needed.
3110 Prints all text following in smaller type
3111 (two points smaller than the current point size) until
3112 the next type size, highlighting, paragraph, or heading macro.
3113 You can specify this macro multiple times
3114 to reduce the point size as needed.
3118 Prints all text following in the normal point size
3119 (that is, the value of the @code{PS} register).
3122 @c ---------------------------------------------------------------------
3124 @node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text
3125 @subsubsection Lists
3126 @cindex @code{ms} macros, lists
3128 The @code{.IP} macro handles duties for all lists.
3130 @Defmac {IP, [@Var{marker} [@Var{width}]], ms}
3131 The @var{marker} is usually a bullet character (@code{\[bu]})
3132 for unordered lists, a number (or auto-incrementing number
3133 register) for numbered lists, or a word or phrase for indented
3134 (glossary-style) lists.
3136 The @var{width} specifies the indent for the body of each list item;
3137 its default unit is @samp{n}.
3138 Once specified, the indent remains the same for all
3139 list items in the document until specified again.
3142 The following is an example of a bulleted list.
3143 @cindex example markup, bulleted list [@code{ms}]
3144 @cindex bulleted list, example markup [@code{ms}]
3170 The following is an example of a numbered list.
3171 @cindex example markup, numbered list [@code{ms}]
3172 @cindex numbered list, example markup [@code{ms}]
3197 Note the use of the auto-incrementing number
3198 register in this example.
3201 The following is an example of a glossary-style list.
3202 @cindex example markup, glossary-style list [@code{ms}]
3203 @cindex glossary-style list, example markup [@code{ms}]
3206 A glossary-style list:
3208 Two or more attorneys.
3210 Firearms, preferably
3220 A glossary-style list:
3223 Two or more attorneys.
3225 guns Firearms, preferably large-caliber.
3228 Gotta pay for those lawyers and guns!
3231 In the last example, the @code{IP} macro places the definition
3232 on the same line as the term if it has enough space; otherwise,
3233 it breaks to the next line and starts the definition below the
3235 This may or may not be the effect you want, especially if some
3236 of the definitions break and some do not.
3237 The following examples show two possible ways to force a break.
3239 The first workaround uses the @code{.br}
3240 request to force a break after printing the term or label.
3244 A glossary-style list:
3246 Two or more attorneys.
3249 Firearms, preferably large-caliber.
3251 Gotta pay for those lawyers and guns!
3256 The second workaround uses the @code{\p} escape to force the break.
3257 Note the space following the escape; this is important.
3258 If you omit the space, @code{groff} prints the first word on
3259 the same line as the term or label (if it fits) @strong{then}
3264 A glossary-style list:
3266 Two or more attorneys.
3268 \p Firearms, preferably large-caliber.
3270 Gotta pay for those lawyers and guns!
3275 To set nested lists, use the @code{RS} and @code{RE} macros.
3276 @xref{Indents in ms}, for more information.
3277 @cindex @code{ms} macros, nested lists
3278 @cindex nested lists [@code{ms}]
3313 @c ---------------------------------------------------------------------
3315 @node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text
3316 @subsubsection Indents
3319 you may need to indent a section of text
3320 while still wrapping and filling.
3322 for an example of nested lists.
3324 @DefmacList {RS, , ms}
3325 @DefmacListEnd {RE, , ms}
3326 These macros begin and end an indented section.
3327 The @code{PI} register controls the amount of indent,
3328 allowing the indented text to line up under hanging
3329 and indented paragraphs.
3332 @xref{ms Displays and Keeps},
3333 for macros to indent and turn off filling.
3335 @c ---------------------------------------------------------------------
3337 @node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text
3338 @subsubsection Tab Stops
3340 Use the @code{ta} request to define tab stops as needed.
3341 @xref{Tabs and Fields}.
3344 Use this macro to reset the tab stops to the default for @file{ms}
3346 You can redefine the @code{TA} macro to create a different set
3347 of default tab stops.
3350 @c ---------------------------------------------------------------------
3352 @node ms Displays and Keeps, ms Insertions, Tabstops in ms, ms Body Text
3353 @subsubsection Displays and keeps
3354 @cindex @code{ms} macros, displays
3355 @cindex @code{ms} macros, keeps
3356 @cindex keeps [@code{ms}]
3357 @cindex displays [@code{ms}]
3359 Use displays to show text-based examples or figures
3360 (such as code listings).
3362 Displays turn off filling, so lines of code are displayed
3363 as-is without inserting @code{br} requests in between each line.
3364 Displays can be @dfn{kept} on a single page, or allowed
3365 to break across pages.
3367 @DefmacList {DS, @t{L}, ms}
3368 @DefmacItem {LD, , ms}
3369 @DefmacListEnd {DE, , ms}
3370 Left-justified display.
3371 The @samp{.DS L} call generates a page break, if necessary,
3372 to keep the entire display on one page.
3373 The @code{LD} macro allows the display to break across pages.
3374 The @code{DE} macro ends the display.
3377 @DefmacList {DS, @t{I}, ms}
3378 @DefmacItem {ID, , ms}
3379 @DefmacListEnd {DE, , ms}
3380 Indents the display as defined by the @code{DI} register.
3381 The @samp{.DS I} call generates a page break, if necessary,
3382 to keep the entire display on one page.
3383 The @code{ID} macro allows the display to break across pages.
3384 The @code{DE} macro ends the display.
3387 @DefmacList {DS, @t{B}, ms}
3388 @DefmacItem {BD, , ms}
3389 @DefmacListEnd {DE, , ms}
3390 Sets a block-centered display: the entire display is left-justified,
3391 but indented so that the longest line in the display is centered
3393 The @samp{.DS B} call generates a page break, if necessary,
3394 to keep the entire display on one page.
3395 The @code{BD} macro allows the display to break across pages.
3396 The @code{DE} macro ends the display.
3399 @DefmacList {DS, @t{C}, ms}
3400 @DefmacItem {CD, , ms}
3401 @DefmacListEnd {DE, , ms}
3402 Sets a centered display: each line in the display is centered.
3403 The @samp{.DS C} call generates a page break, if necessary,
3404 to keep the entire display on one page.
3405 The @code{CD} macro allows the display to break across pages.
3406 The @code{DE} macro ends the display.
3409 @DefmacList {DS, @t{R}, ms}
3410 @DefmacItem {RD, , ms}
3411 @DefmacListEnd {DE, , ms}
3412 Right-justifies each line in the display.
3413 The @samp{.DS R} call generates a page break, if necessary,
3414 to keep the entire display on one page.
3415 The @code{RD} macro allows the display to break across pages.
3416 The @code{DE} macro ends the display.
3420 On occasion, you may want to @dfn{keep} other text together on a page.
3421 For example, you may want to keep two paragraphs together, or
3422 a paragraph that refers to a table (or list, or other item)
3423 immediately following.
3424 The @file{ms} macros provide the @code{KS} and @code{KE}
3425 macros for this purpose.
3427 @DefmacList {KS, , ms}
3428 @DefmacListEnd {KE, , ms}
3429 The @code{KS} macro begins a block of text to be kept on a
3430 single page, and the @code{KE} macro ends the block.
3433 @DefmacList {KF, , ms}
3434 @DefmacListEnd {KE, , ms}
3435 Specifies a @dfn{floating keep};
3436 if the keep cannot fit on the current page, @code{groff}
3437 holds the contents of the keep and allows text following
3438 the keep (in the source file) to fill in the remainder of
3440 When the page breaks, whether by an explicit @code{bp}
3441 request or by reaching the end of the page, @code{groff}
3442 prints the floating keep at the top of the new page.
3443 This is useful for printing large graphics or tables
3444 that do not need to appear exactly where specified.
3447 You can also use the @code{ne} request to force a page break if
3448 there is not enough vertical space remaining on the page.
3451 Use the following macros to draw a box around a section of
3452 text (such as a display).
3454 @DefmacList {B1, , ms}
3455 @DefmacListEnd {B2, , ms}
3456 Marks the beginning and ending of text that is to have a
3457 box drawn around it.
3458 The @code{B1} macro begins the box; the @code{B2} macro ends it.
3459 Text in the box is automatically placed in a diversion (keep).
3462 @c ---------------------------------------------------------------------
3464 @node ms Insertions, Example multi-page table, ms Displays and Keeps, ms Body Text
3465 @subsubsection Tables, figures, equations, and references
3466 @cindex @code{ms} macros, tables
3467 @cindex @code{ms} macros, figures
3468 @cindex @code{ms} macros, equations
3469 @cindex @code{ms} macros, references
3470 @cindex tables [@code{ms}]
3471 @cindex figures [@code{ms}]
3472 @cindex equations [@code{ms}]
3473 @cindex references [@code{ms}]
3475 The @file{ms} macros support the standard
3476 @code{groff} preprocessors:
3477 @code{tbl}, @code{pic}, @code{eqn}, and @code{refer}.
3482 You mark text meant for preprocessors by enclosing it
3483 in pairs of tags as follows.
3485 @DefmacList {TS, [@code{H}], ms}
3486 @DefmacListEnd {TE, , ms}
3487 Denotes a table, to be processed by the @code{tbl} preprocessor.
3488 The optional argument@w{ }@code{H} to @code{TS} instructs @code{groff}
3489 to create a running header with the information
3490 up to the @code{TH} macro.
3491 @code{groff} prints the header at the beginning of the
3492 table; if the table runs onto another page, @code{groff}
3493 prints the header on the next page as well.
3496 @DefmacList {PS, , ms}
3497 @DefmacListEnd {PE, , ms}
3498 Denotes a graphic, to be processed by the @code{pic} preprocessor.
3499 You can create a @code{pic} file by hand, using the @acronym{AT&T}
3500 @code{pic} manual available on the Web as a reference, or by using
3501 a graphics program such as @code{xfig}.
3504 @DefmacList {EQ, [@Var{align}], ms}
3505 @DefmacListEnd {EN, , ms}
3506 Denotes an equation, to be processed by the @code{eqn} preprocessor.
3507 The optional @var{align} argument can be @code{C}, @code{L}, or@w{
3508 }@code{I} to center (the default), left-justify, or indent the equation.
3511 @DefmacList {[, , ms}
3512 @DefmacListEnd {], , ms}
3513 Denotes a reference, to be processed by the @code{refer} preprocessor.
3514 The @acronym{GNU} @cite{refer(1)} man page provides a comprehensive
3515 reference to the preprocessor and the format of the bibliographic
3520 * Example multi-page table::
3523 @c ---------------------------------------------------------------------
3525 @node Example multi-page table, ms Footnotes, ms Insertions, ms Body Text
3526 @subsubsection An example multi-page table
3527 @cindex example markup, multi-page table [@code{ms}]
3528 @cindex multi-page table, example markup [@code{ms}]
3530 The following is an example of how to set up a
3531 table that may print across two or more pages.
3538 Text ...of heading...
3543 ... the rest of the table follows...
3549 @c ---------------------------------------------------------------------
3551 @node ms Footnotes, , Example multi-page table, ms Body Text
3552 @subsubsection Footnotes
3553 @cindex @code{ms} macros, footnotes
3554 @cindex footnotes [@code{ms}]
3556 The @file{ms} macro package has a flexible footnote system.
3557 You can specify either numbered footnotes or symbolic footnotes
3558 (that is, using a marker such as a dagger symbol).
3561 Specifies the location of a numbered footnote marker in the text.
3564 @DefmacList {FS, , ms}
3565 @DefmacListEnd {FE, , ms}
3566 Specifies the text of the footnote.
3567 The default action is to create a numbered footnote;
3568 you can create a symbolic footnote by specifying
3569 a @dfn{mark} character
3570 (such as @code{\[dg]} for the dagger character)
3571 in the body text and as an argument to the @code{FS} macro,
3572 followed by the text of the footnote
3573 and the @code{FE} macro.
3576 You can control how @code{groff}
3577 prints footnote numbers by changing the value of the
3578 @code{FF} register. @xref{ms Document Control Registers}.
3580 @c ---------------------------------------------------------------------
3582 @node ms Page Layout, Differences from AT&T ms, ms Body Text, ms
3583 @subsection Page layout
3584 @cindex @code{ms} macros, page layout
3585 @cindex page layout [@code{ms}]
3587 The default output from the @file{ms}
3588 macros provides a minimalist page layout:
3589 it prints a single column, with the page number centered at the top
3591 It prints no footers.
3593 You can change the layout by setting
3594 the proper number registers and strings.
3597 * ms Headers and Footers::
3599 * ms Multiple Columns::
3601 * ms Strings and Special Characters::
3604 @c ---------------------------------------------------------------------
3606 @node ms Headers and Footers, ms Margins, ms Page Layout, ms Page Layout
3607 @subsubsection Headers and footers
3608 @cindex @code{ms} macros, headers
3609 @cindex @code{ms} macros, footers
3610 @cindex headers [@code{ms}]
3611 @cindex footers [@code{ms}]
3613 For documents that do not distinguish between odd and even pages,
3614 set the following strings:
3616 @DefstrList {LH, ms}
3617 @DefstrItem {CH, ms}
3618 @DefstrListEnd {RH, ms}
3619 Sets the left, center, and right headers.
3622 @DefstrList {LF, ms}
3623 @DefstrItem {CF, ms}
3624 @DefstrListEnd {RF, ms}
3625 Sets the left, center, and right footers.
3629 For documents that need different information printed in the
3630 even and odd pages, use the following macros:
3632 @DefmacList {OH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3633 @DefmacItem {EH, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3634 @DefmacItem {OF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3635 @DefmacListEnd {EF, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}, ms}
3636 The @code{OH} and @code{EH} macros define headers for the odd and even pages;
3637 the @code{OF} and @code{EF} macros define footers for the odd and even pages.
3638 This is more flexible than defining the individual strings.
3640 You can replace the quote (@code{'}) marks with any character not
3641 appearing in the header or footer text.
3644 @c ---------------------------------------------------------------------
3646 @node ms Margins, ms Multiple Columns, ms Headers and Footers, ms Page Layout
3647 @subsubsection Margins
3648 @cindex @code{ms} macros, margins
3650 You control margins using a set of number registers.
3651 @xref{ms Document Control Registers}, for details.
3653 @c ---------------------------------------------------------------------
3655 @node ms Multiple Columns, ms TOC, ms Margins, ms Page Layout
3656 @subsubsection Multiple columns
3657 @cindex @code{ms} macros, multiple columns
3658 @cindex multiple columns [@code{ms}]
3660 The @file{ms} macros can set text in as many columns as will
3661 reasonably fit on the page.
3662 The following macros are available;
3663 all of them force a page break if a multi-column mode is already set.
3664 However, if the current mode is single-column, starting a multi-column
3665 mode does @strong{not} force a page break.
3675 @Defmac {MC, [@Var{width} [@Var{gutter}]], ms}
3677 If you specify no arguments, it is equivalent to the
3679 Otherwise, @var{width} is the width of each column and
3680 @var{gutter} is the space between columns.
3681 The @code{MINGW} number register controls the default gutter width.
3684 @c ---------------------------------------------------------------------
3686 @node ms TOC, ms Strings and Special Characters, ms Multiple Columns, ms Page Layout
3687 @subsubsection Creating a table of contents
3688 @cindex @code{ms} macros, creating table of contents
3689 @cindex table of contents, creating [@code{ms}]
3691 The facilities in the @file{ms} macro package for creating
3692 a table of contents are semi-automated at best.
3693 Assuming that you want the table of contents to consist of
3694 the document's headings, you need to repeat those headings
3695 wrapped in @code{XS} and @code{XE} macros.
3697 @DefmacList {XS, [@Var{page}], ms}
3698 @DefmacItem {XA, [@Var{page}], ms}
3699 @DefmacListEnd {XE, , ms}
3700 These macros define a table of contents
3701 or an individual entry in the table of contents,
3702 depending on their use.
3703 The macros are very simple; they cannot indent a heading based on its level.
3704 The easiest way to work around this is to add tabs
3705 to the table of contents string.
3706 The following is an example:
3728 You can manually create a table of contents
3729 by beginning with the @code{XS} macro for the first entry,
3730 specifying the page number for that entry as the argument to @code{XS}.
3731 Add subsequent entries using the @code{XA} macro,
3732 specifying the page number for that entry as the argument to @code{XA}.
3733 The following is an example:
3740 A Brief History of the Universe
3742 Details of Galactic Formation
3749 @Defmac {TC, [@code{no}], ms}
3750 Prints the table of contents on a new page,
3751 setting the page number to@w{ }@strong{i} (Roman numeral one).
3752 You should usually place this macro at the end of the
3753 file, since @code{groff} is a single-pass formatter and
3754 can only print what has been collected up to the point
3755 that the @code{TC} macro appears.
3757 The optional argument @code{no} suppresses printing
3758 the title specified by the string register @code{TOC}.
3761 @Defmac{PX, [@code{no}], ms}
3762 Prints the table of contents on a new page,
3763 using the current page numbering sequence.
3764 Use this macro to print a manually-generated table of contents
3765 at the beginning of your document.
3767 The optional argument @code{no} suppresses printing
3768 the title specified by the string register @code{TOC}.
3771 The @cite{Groff and Friends HOWTO}
3772 includes a @code{sed} script that automatically inserts
3773 @code{XS} and @code{XE} macro entries after each heading in a document.
3775 Altering the @code{NH} macro to automatically build the table
3776 of contents is perhaps initially more difficult, but would save
3777 a great deal of time in the long run if you use @file{ms} regularly.
3779 @c ---------------------------------------------------------------------
3781 @node ms Strings and Special Characters, , ms TOC, ms Page Layout
3782 @subsubsection Strings and Special Characters
3783 @cindex @code{ms} macros, strings
3784 @cindex @code{ms} macros, special characters
3785 @cindex @code{ms} macros, accent marks
3786 @cindex accent marks [@code{ms}]
3787 @cindex special characters [@code{ms}]
3788 @cindex strings [@code{ms}]
3790 The @file{ms} macros provide the following predefined strings.
3791 You can change the string definitions to help in creating
3792 documents in languages other than English.
3794 @Defstr {REFERENCES, ms}
3795 Contains the string printed at the beginning of the
3796 references (bibliography) page.
3797 The default is @samp{References}.
3800 @Defstr {ABSTRACT, ms}
3801 Contains the string printed at the beginning of the abstract.
3802 The default is @samp{ABSTRACT}.
3806 Contains the string printed at the beginning of the table of contents.
3809 @DefstrList {MONTH1, ms}
3810 @DefstrItem {MONTH2, ms}
3811 @DefstrItem {MONTH3, ms}
3812 @DefstrItem {MONTH4, ms}
3813 @DefstrItem {MONTH5, ms}
3814 @DefstrItem {MONTH6, ms}
3815 @DefstrItem {MONTH7, ms}
3816 @DefstrItem {MONTH8, ms}
3817 @DefstrItem {MONTH9, ms}
3818 @DefstrItem {MONTH10, ms}
3819 @DefstrItem {MONTH11, ms}
3820 @DefstrListEnd {MONTH12, ms}
3821 Prints the full name of the month in dates.
3822 The default is @samp{January}, @samp{February}, etc.
3825 The following special characters are available:
3831 @DefstrList {*Q, ms}
3832 @DefstrListEnd {*U, ms}
3833 Prints typographer's quotes in troff,
3834 plain quotes in nroff.
3835 @code{*Q} is the left quote and @code{*U} is the right quote.
3838 Improved accent marks are available in the @file{ms} macros.
3841 Specify this macro at the beginning of your document
3842 to enable extended accent marks and special characters.
3843 This is a Berkeley extension.
3845 To use the accent marks, place them @strong{after}
3846 the character being accented.
3849 The following accent marks are available
3850 after invoking the @code{AM} macro:
3872 @deffn String @t{\*[:]}
3874 @stindex : @r{[}ms@r{]}
3877 @stindex @r{<colon>} @r{[}ms@r{]}
3898 The following are standalone characters
3899 available after invoking the @code{AM} macro:
3902 Upside-down question mark.
3906 Upside-down exclamation point.
3910 German @ss{} ligature.
3938 Lowercase @ae{} ligature.
3942 Uppercase @AE{} ligature.
3945 @c ---------------------------------------------------------------------
3947 @node Differences from AT&T ms, , ms Page Layout, ms
3948 @subsection Differences from @acronym{AT&T} @file{ms}
3949 @cindex @code{ms} macros, differences from @acronym{AT&T}
3950 @cindex @acronym{AT&T} @code{troff}, @code{ms} macro package differences
3952 This section lists the (minor) differences between the
3953 @code{groff -ms} macros and @acronym{AT&T}
3954 @code{troff -ms} macros.
3957 * Missing ms Macros::
3958 * Additional ms Macros::
3961 @c ---------------------------------------------------------------------
3963 @node Missing ms Macros, Additional ms Macros, Differences from AT&T ms, Differences from AT&T ms
3964 @subsubsection @code{troff} macros not appearing in @code{groff}
3966 Macros missing from @code{groff -ms}
3967 are cover page macros specific to Bell Labs.
3968 The macros known to be missing are:
3972 Technical memorandum; a cover sheet style
3975 Internal memorandum; a cover sheet style
3978 Memo for record; a cover sheet style
3981 Memo for file; a cover sheet style
3984 Engineer's notes; a cover sheet style
3987 Computing Science Tech Report; a cover sheet style
3993 Cover sheet information
3999 @c ---------------------------------------------------------------------
4001 @node Additional ms Macros, , Missing ms Macros, Differences from AT&T ms
4002 @subsubsection @code{groff} macros not appearing in @acronym{AT&T} @code{troff}
4004 The @code{groff -ms} macros have a few minor extensions
4005 compared to the @acronym{AT&T} @code{troff -ms} macros.
4008 Improved accent marks.
4009 @xref{ms Strings and Special Characters}, for details.
4012 @Defmac {DS, @t{I}, ms}
4014 The default behavior of @acronym{AT&T} @code{troff -ms}
4015 was to indent; the @code{groff} default prints displays
4016 flush left with the body text.
4020 Print text in @code{constant width} (Courier) font.
4024 Indexing term (printed on standard error).
4025 You can write a script to capture and process an index
4026 generated in this manner.
4030 The following additional number registers
4031 appear in @code{groff -ms}:
4033 @Defmpreg {MINGW, ms}
4034 Specifies a minimum space
4035 between columns (for multi-column output); this takes the
4036 place of the @code{GW} register that was documented but apparently
4037 not implemented in @acronym{AT&T} @code{troff}.
4041 Several new string registers are available as well.
4042 You can change these to handle (for example) the local language.
4043 @xref{ms Strings and Special Characters}, for details.
4046 @c =====================================================================
4048 @node me, mm, ms, Macro Packages
4050 @cindex @code{me} macro package
4052 @c XXX documentation
4053 @c XXX this is a placeholder until we get stuff knocked into shape
4054 See the @file{meintro.me} and @file{meref.me} documents in
4055 groff's @file{doc} directory.
4058 @c =====================================================================
4060 @node mm, , me, Macro Packages
4062 @cindex @code{mm} macro package
4064 @c XXX documentation
4065 @c XXX this is a placeholder until we get stuff knocked into shape
4066 See the @cite{groff_mm(7)} man page (type @command{man groff_mm} at
4070 @c =====================================================================
4071 @c =====================================================================
4073 @node gtroff Reference, Preprocessors, Macro Packages, Top
4074 @chapter @code{gtroff} Reference
4075 @cindex reference, @code{gtroff}
4076 @cindex @code{gtroff}, reference
4078 This chapter covers @strong{all} of the facilities of @code{gtroff}.
4079 Users of macro packages may skip it if not interested in details.
4084 * Input Conventions::
4088 * Embedded Commands::
4090 * Manipulating Filling and Adjusting::
4091 * Manipulating Hyphenation::
4092 * Manipulating Spacing::
4094 * Character Translations::
4095 * Troff and Nroff Mode::
4103 * Conditionals and Loops::
4106 * Drawing Requests::
4110 * Suppressing output::
4113 * Postprocessor Access::
4115 * Gtroff Internals::
4117 * Implementation Differences::
4121 @c =====================================================================
4123 @node Text, Input Conventions, gtroff Reference, gtroff Reference
4125 @cindex text, @code{gtroff} processing
4127 @code{gtroff} input files contain text with control commands
4128 interspersed throughout. But, even without control codes, @code{gtroff}
4129 still does several things with the input text:
4133 filling and adjusting
4136 adding additional space after sentences
4142 inserting implicit line breaks
4146 * Filling and Adjusting::
4150 * Implicit Line Breaks::
4153 @c ---------------------------------------------------------------------
4155 @node Filling and Adjusting, Hyphenation, Text, Text
4156 @subsection Filling and Adjusting
4160 When @code{gtroff} reads text, it collects words from the input and fits
4161 as many of them together on one output line as it can. This is known as
4164 @cindex leading spaces
4165 @cindex spaces, leading and trailing
4166 @cindex extra spaces
4167 @cindex trailing spaces
4168 Once @code{gtroff} has a @dfn{filled} line, it tries to @dfn{adjust}
4169 it. This means it widens the spacing between words until the text
4170 reaches the right margin (in the default adjustment mode). Extra spaces
4171 between words are preserved, but spaces at the end of lines are ignored.
4172 Spaces at the front of a line cause a @dfn{break} (breaks are
4173 explained in @ref{Implicit Line Breaks}).
4175 @xref{Manipulating Filling and Adjusting}.
4177 @c ---------------------------------------------------------------------
4179 @node Hyphenation, Sentences, Filling and Adjusting, Text
4180 @subsection Hyphenation
4183 Since the odds are not great for finding a set of words, for every
4184 output line, which fit nicely on a line without inserting excessive
4185 amounts of space between words, @code{gtroff} hyphenates words so
4186 that it can justify lines without inserting too much space between
4187 words. It uses an internal hyphenation algorithm (a simplified version
4188 of the algorithm used within @TeX{}) to indicate which words can be
4189 hyphenated and how to do so. When a word is hyphenated, the first part
4190 of the word is added to the current filled line being output (with
4191 an attached hyphen), and the other portion is added to the next
4194 @xref{Manipulating Hyphenation}.
4196 @c ---------------------------------------------------------------------
4198 @node Sentences, Tab Stops, Hyphenation, Text
4199 @subsection Sentences
4202 Although it is often debated, some typesetting rules say there should be
4203 different amounts of space after various punctuation marks. For
4204 example, the @cite{Chicago typsetting manual} says that a period at the
4205 end of a sentence should have twice as much space following it as would
4206 a comma or a period as part of an abbreviation.
4208 @c XXX exact citation of Chicago manual
4210 @cindex sentence space
4211 @cindex space between sentences
4212 @cindex french-spacing
4213 @code{gtroff} does this by flagging certain characters (normally
4214 @samp{!}, @samp{?}, and @samp{.}) as @dfn{end-of-sentence} characters.
4215 When @code{gtroff} encounters one of these characters at the end of a
4216 line, it appends a normal space followed by a @dfn{sentence space} in
4217 the formatted output. (This justifies one of the conventions mentioned
4218 in @ref{Input Conventions}.)
4220 @cindex transparent characters
4221 @cindex character, transparent
4222 @cindex @code{dg} glyph, at end of sentence
4223 @cindex @code{rq} glyph, at end of sentence
4224 @cindex @code{"}, at end of sentence
4225 @cindex @code{'}, at end of sentence
4226 @cindex @code{)}, at end of sentence
4227 @cindex @code{]}, at end of sentence
4228 @cindex @code{*}, at end of sentence
4229 In addition, the following characters or glyphs are treated
4230 transparently while handling end-of-sentence characters: @samp{"},
4231 @samp{'}, @samp{)}, @samp{]}, @samp{*}, @code{dg}, and @code{rq}.
4233 See the @code{cflags} request in @ref{Using Symbols}, for more details.
4235 @cindex @code{\&}, at end of sentence
4236 To prevent the insertion of extra space after an end-of-sentence
4237 character (at the end of a line), append @code{\&}.
4239 @c ---------------------------------------------------------------------
4241 @node Tab Stops, Implicit Line Breaks, Sentences, Text
4242 @subsection Tab Stops
4244 @cindex stops, tabulator
4245 @cindex tab character
4246 @cindex character, tabulator
4248 @cindex @acronym{EBCDIC} encoding
4249 @cindex encoding, @acronym{EBCDIC}
4250 @code{gtroff} translates @dfn{tabulator characters}, also called
4251 @dfn{tabs} (normally code point @acronym{ASCII} @code{0x09} or
4252 @acronym{EBCDIC} @code{0x05}), in the input into movements to the next
4253 tabulator stop. These tab stops are initially located every half inch
4254 across the page. Using this, simple tables can be made easily.
4255 However, it can often be deceptive as the appearance (and width) of the
4256 text on a terminal and the results from @code{gtroff} can vary greatly.
4258 Also, a possible sticking point is that lines beginning with tab
4259 characters are still filled, again producing unexpected results.
4260 For example, the following input
4262 @multitable {12345678} {12345678} {12345678} {12345678}
4264 @tab 1 @tab 2 @tab 3
4272 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
4274 @tab 1 @tab 2 @tab 3 @tab @tab 4 @tab 5
4277 @xref{Tabs and Fields}.
4279 @c ---------------------------------------------------------------------
4281 @node Implicit Line Breaks, , Tab Stops, Text
4282 @subsection Implicit Line Breaks
4283 @cindex implicit line breaks
4284 @cindex implicit breaks of lines
4285 @cindex line, implicit breaks
4286 @cindex break, implicit
4289 An important concept in @code{gtroff} is the @dfn{break}. When a break
4290 occurs, @code{gtroff} outputs the partially filled line
4291 (unjustified), and resumes collecting and filling text on the next output
4297 @cindex blank line macro (@code{blm})
4298 There are several ways to cause a break in @code{gtroff}. A blank
4299 line not only causes a break, but it also outputs a one-line vertical
4300 space (effectively a blank line). Note that this behaviour can be
4301 modified with the blank line macro request @code{blm}.
4302 @xref{Blank Line Traps}.
4306 A line that begins with a space causes a break and the space is
4307 output at the beginning of the next line. Note that this space isn't
4308 adjusted, even in fill mode.
4310 The end of file also causes a break -- otherwise the last line of
4311 the document may vanish!
4313 Certain requests also cause breaks, implicitly or explicitly. This is
4314 discussed in @ref{Manipulating Filling and Adjusting}.
4317 @c =====================================================================
4319 @node Input Conventions, Measurements, Text, gtroff Reference
4320 @section Input Conventions
4321 @cindex input conventions
4322 @cindex conventions for input
4324 Since @code{gtroff} does filling automatically, it is traditional in
4325 @code{groff} not to try and type things in as nicely formatted
4326 paragraphs. These are some conventions commonly used when typing
4331 Break lines after punctuation, particularly at the end of a sentence
4332 and in other logical places. Keep separate phrases on lines by
4333 themselves, as entire phrases are often added or deleted when editing.
4336 Try to keep lines less than 40-60@w{ }characters, to allow space for
4337 inserting more text.
4340 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.,
4341 don't try using spaces to get proper indentation).
4345 @c =====================================================================
4347 @node Measurements, Expressions, Input Conventions, gtroff Reference
4348 @section Measurements
4349 @cindex measurements
4351 @cindex units of measurement
4352 @cindex basic unit (@code{u})
4353 @cindex machine unit (@code{u})
4354 @cindex measurement unit
4355 @cindex @code{u} unit
4356 @cindex unit, @code{u}
4357 @code{gtroff} (like many other programs) requires numeric parameters to
4358 specify various measurements. Most numeric parameters@footnote{those
4359 that specify vertical or horizontal motion or a type size} may have a
4360 @dfn{measurement unit} attached. These units are specified as a single
4361 character which immediately follows the number or expression. Each of
4362 these units are understood, by @code{gtroff}, to be a multiple of its
4363 @dfn{basic unit}. So, whenever a different measurement unit is
4364 specified @code{gtroff} converts this into its @dfn{basic units}. This
4365 basic unit, represented by a @samp{u}, is a device dependent measurement
4366 which is quite small, ranging from 1/75@dmn{th} to 1/72000@dmn{th} of an
4367 inch. The values may be given as fractional numbers; however,
4368 fractional basic units are always rounded to integers.
4370 Some of the measurement units are completely independent of any of the
4371 current settings (e.g.@: type size) of @code{gtroff}.
4375 @cindex inch unit (@code{i})
4376 @cindex @code{i} unit
4377 @cindex unit, @code{i}
4378 Inches. An antiquated measurement unit still in use in certain
4379 backwards countries with incredibly low-cost computer equipment. One
4380 inch is equal to@w{ }2.54@dmn{cm}.
4383 @cindex centimeter unit (@code{c})
4384 @cindex @code{c} unit
4385 @cindex unit, @code{c}
4386 Centimeters. One centimeter is equal to@w{ }0.3937@dmn{in}.
4389 @cindex point unit (@code{p})
4390 @cindex @code{p} unit
4391 @cindex unit, @code{p}
4392 Points. This is a typesetter's measurement used for measure type size.
4393 It is 72@w{ }points to an inch.
4396 @cindex pica unit (@code{P})
4397 @cindex @code{P} unit
4398 @cindex unit, @code{P}
4399 Pica. Another typesetting measurement. 6@w{ }Picas to an inch (and
4400 12@w{ }points to a pica).
4404 @cindex @code{s} unit
4405 @cindex unit, @code{s}
4406 @cindex @code{z} unit
4407 @cindex unit, @code{z}
4408 @xref{Fractional Type Sizes}, for a discussion of these units.
4411 @cindex @code{f} unit
4412 @cindex unit, @code{f}
4413 Fractions. Value is 65536.
4414 @xref{Colors}, for usage.
4417 The other measurements understood by @code{gtroff} depend on
4418 settings currently in effect in @code{gtroff}. These are very useful
4419 for specifying measurements which should look proper with any size of
4424 @cindex em unit (@code{m})
4425 @cindex @code{m} unit
4426 @cindex unit, @code{m}
4427 Ems. This unit is equal to the current font size in points. So called
4428 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
4429 in the current font.
4432 @cindex en unit (@code{n})
4433 @cindex @code{n} unit
4434 @cindex unit, @code{n}
4435 Ens. In @code{groff}, this is half of an em.
4438 @cindex vertical space unit (@code{v})
4439 @cindex space, vertical, unit (@code{v})
4440 @cindex @code{v} unit
4441 @cindex unit, @code{v}
4442 Vertical space. This is equivalent to the current line spacing.
4443 @xref{Sizes}, for more information about this.
4446 @cindex @code{M} unit
4447 @cindex unit, @code{M}
4455 @c ---------------------------------------------------------------------
4457 @node Default Units, , Measurements, Measurements
4458 @subsection Default Units
4459 @cindex default units
4460 @cindex units, default
4462 Many requests take a default unit. While this can be helpful at times,
4463 it can cause strange errors in some expressions. For example, the line
4464 length request expects em units. Here are several attempts to get a
4465 line length of 3.5@w{ }inches and their results:
4471 (7 / 2)u @result{} 0i
4473 7i/2u @result{} 3.5i
4477 Everything is converted to basic units first. In the above example it
4478 is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m} equals@w{
4479 }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}). The value 7@dmn{i}/2
4480 is first handled as 7@dmn{i}/2@dmn{m}, then converted to
4481 1680@dmn{u}/66@dmn{u} which is 25@dmn{u}, and this is approximately
4482 0.1@dmn{i}. As can be seen, a scaling indicator after a closing
4483 parenthesis is simply ignored.
4485 @cindex measurements, specifying safely
4486 Thus, the safest way to specify measurements is to always
4487 attach a scaling indicator. If you want to multiply or divide by a
4488 certain scalar value, use @samp{u} as the unit for that value.
4491 @c =====================================================================
4493 @node Expressions, Identifiers, Measurements, gtroff Reference
4494 @section Expressions
4497 @code{gtroff} has most arithmetic operators common to other languages:
4501 @cindex arithmetic operators
4502 @cindex operators, arithmetic
4508 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
4509 (division), @samp{*} (multiplication), @samp{%} (modulo).
4511 @code{gtroff} only provides integer arithmetic. The internal type used
4512 for computing results is @samp{int}, which is usually a 32@dmn{bit}
4516 @cindex comparison operators
4517 @cindex operators, comparison
4524 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
4525 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
4526 (equal), @samp{==} (the same as @samp{=}).
4529 @cindex logical operators
4530 @cindex operators, logical
4536 @opindex @r{<colon>}
4538 Logical: @samp{&} (logical and), @samp{:} (logical or).
4541 @cindex unary operators
4542 @cindex operators, unary
4546 @cindex @code{if} request, and the @samp{!} operator
4547 @cindex @code{while} request, and the @samp{!} operator
4548 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
4549 (just for completeness; does nothing in expressions), @samp{!} (logical
4550 not; this works only within @code{if} and @code{while} requests). See
4551 below for the use of unary operators in motion requests.
4554 @cindex extremum operators (@code{>?}, @code{<?})
4555 @cindex operators, extremum (@code{>?}, @code{<?})
4558 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).
4565 .nr z (\n[x] >? \n[y])
4569 The register@w{ }@code{z} now contains@w{ }5.
4572 @cindex scaling operator
4573 @cindex operator, scaling
4574 Scaling: @code{(@var{c};@var{e})}. Evaluate@w{ }@var{e} using@w{ }@var{c}
4575 as the default scaling indicator. If @var{c} is missing, ignore scaling
4576 indicators in the evaluation of@w{ }@var{e}.
4580 @cindex order of evaluation in expressions
4581 @cindex expression, order of evaluation
4584 Parentheses may be used as in any other language. However, in
4585 @code{gtroff} they are necessary to ensure order of evaluation.
4586 @code{gtroff} has no operator precedence; expressions are evaluated left
4587 to right. This means that @code{gtroff} evaluates @samp{3+5*4} as if it were
4588 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as might be
4591 @cindex @code{+}, and page motion
4592 @cindex @code{-}, and page motion
4593 @cindex motion operators
4594 @cindex operators, motion
4595 For many requests which cause a motion on the page, the unary operators
4596 @samp{+} and @samp{-} work differently if leading an expression. They
4597 then indicate a motion relative to the current position (down or up,
4600 @cindex @code{|}, and page motion
4601 @cindex absolute position operator (@code{|})
4602 @cindex position, absolute, operator (@code{|})
4603 Similarly, a leading @samp{|} operator indicates an absolute position.
4604 For vertical movements, it specifies the distance from the top of the
4605 page; for horizontal movements, it gives the distance from the beginning
4606 of the @emph{input} line.
4608 @cindex @code{bp} request, using @code{+} and@w{ }@code{-}
4609 @cindex @code{in} request, using @code{+} and@w{ }@code{-}
4610 @cindex @code{ll} request, using @code{+} and@w{ }@code{-}
4611 @cindex @code{lt} request, using @code{+} and@w{ }@code{-}
4612 @cindex @code{nm} request, using @code{+} and@w{ }@code{-}
4613 @cindex @code{nr} request, using @code{+} and@w{ }@code{-}
4614 @cindex @code{pl} request, using @code{+} and@w{ }@code{-}
4615 @cindex @code{pn} request, using @code{+} and@w{ }@code{-}
4616 @cindex @code{po} request, using @code{+} and@w{ }@code{-}
4617 @cindex @code{ps} request, using @code{+} and@w{ }@code{-}
4618 @cindex @code{pvs} request, using @code{+} and@w{ }@code{-}
4619 @cindex @code{rt} request, using @code{+} and@w{ }@code{-}
4620 @cindex @code{ti} request, using @code{+} and@w{ }@code{-}
4621 @cindex @code{\H}, using @code{+} and@w{ }@code{-}
4622 @cindex @code{\R}, using @code{+} and@w{ }@code{-}
4623 @cindex @code{\s}, using @code{+} and@w{ }@code{-}
4624 @samp{+} and @samp{-} are also treated differently by the following
4625 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
4626 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
4627 @code{pvs}, @code{rt}, @code{ti}, @code{\H}, @code{\R}, and @code{\s}.
4628 Here, leading plus and minus signs indicate increments and decrements.
4630 @xref{Setting Registers}, for some examples.
4632 @Defesc {\\B, ', anything, '}
4633 @cindex numeric expression, valid
4634 @cindex valid numeric expression
4635 Return@w{ }1 if @var{anything} is a valid numeric expression;
4636 or@w{ }0 if @var{anything} is empty or not a valid numeric expression.
4639 @cindex space characters, in expressions
4640 @cindex expressions, and space characters
4641 Due to the way arguments are parsed, spaces are not allowed in
4642 expressions, unless the entire expression is surrounded by parentheses.
4644 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
4647 @c =====================================================================
4649 @node Identifiers, Embedded Commands, Expressions, gtroff Reference
4650 @section Identifiers
4653 Like any other language, @code{gtroff} has rules for properly formed
4654 @dfn{identifiers}. In @code{gtroff}, an identifier can be made up of
4655 almost any printable character, with the exception of the following
4660 @cindex whitespace characters
4661 @cindex newline character
4662 @cindex character, whitespace
4663 Whitespace characters (spaces, tabs, and newlines).
4666 @cindex character, backspace
4667 @cindex backspace character
4668 @cindex @acronym{EBCDIC} encoding of backspace
4669 Backspace (@acronym{ASCII}@w{ }@code{0x08} or @acronym{EBCDIC}@w{
4670 }@code{0x16}) and character code @code{0x01}.
4673 @cindex invalid input characters
4674 @cindex input characters, invalid
4675 @cindex characters, invalid input
4677 The following input characters are invalid and are ignored if
4678 @code{groff} runs on a machine based on @acronym{ASCII}, causing a
4679 warning message of type @samp{input} (see @ref{Debugging}, for more
4680 details): @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
4681 @code{0x80}-@code{0x9F}.
4683 And here are the invalid input characters if @code{groff} runs on an
4684 @acronym{EBCDIC} host: @code{0x00}, @code{0x08}, @code{0x09},
4685 @code{0x0B}, @code{0x0D}-@code{0x14}, @code{0x17}-@code{0x1F},
4686 @code{0x30}-@code{0x3F}.
4688 Currently, some of these reserved codepoints are used internally, thus
4689 making it non-trivial to extend @code{gtroff} to cover Unicode or other
4690 character sets and encodings which use characters of these ranges.
4692 Note that invalid characters are removed before parsing; an
4693 identifier @code{foo}, followed by an invalid character, followed by
4694 @code{bar} is treated as @code{foobar}.
4697 For example, any of the following is valid.
4707 @cindex @code{]}, as part of an identifier
4709 Note that identifiers longer than two characters with a closing bracket
4710 (@samp{]}) in its name can't be accessed with escape sequences which
4711 expect an identifier as a parameter. For example, @samp{\[foo]]}
4712 accesses the glyph @samp{foo}, followed by @samp{]}, whereas
4713 @samp{\C'foo]'} really asks for glyph @samp{foo]}.
4715 @Defesc {\\A, ', ident, '}
4716 Test whether an identifier @var{ident} is valid in @code{gtroff}. It
4717 expands to the character@w{ }1 or@w{ }0 according to whether its
4718 argument (usually delimited by quotes) is or is not acceptable as the
4719 name of a string, macro, diversion, number register, environment, or
4720 font. It returns@w{ }0 if no argument is given. This is useful for
4721 looking up user input in some sort of associative table.
4729 @xref{Escapes}, for details on parameter delimiting characters.
4731 Identifiers in @code{gtroff} can be any length, but, in some contexts,
4732 @code{gtroff} needs to be told where identifiers end and text begins
4733 (and in different ways depending on their length):
4739 @cindex @code{(}, starting a two-character identifier
4741 Two characters. Must be prefixed with @samp{(} in some situations.
4743 @cindex @code{[}, starting an identifier
4744 @cindex @code{]}, ending an identifier
4746 Arbitrary length (@code{gtroff} only). Must be bracketed with @samp{[}
4747 and@w{ }@samp{]} in some situations. Any length identifier can be put
4751 @cindex undefined identifiers
4752 @cindex identifiers, undefined
4753 Unlike many other programming languages, undefined identifiers are
4754 silently ignored or expanded to nothing.
4755 When @code{gtroff} finds an undefined identifier, it emits a
4756 warning, doing the following:
4760 If the identifier is a string, macro, or diversion,
4761 @code{gtroff} defines it as empty.
4764 If the identifier is a number register, @code{gtroff}
4765 defines it with a value of@w{ }0.
4768 @xref{Warnings}., @ref{Interpolating Registers}, and @ref{Strings}.
4770 Note that macros, strings, and diversions share the same name space.
4787 As can be seen in the previous example, @code{gtroff} reuses the
4788 identifier @samp{xxx}, changing it from a macro to a diversion.
4789 No warning is emitted! The contents of the first macro definition is
4792 @xref{Interpolating Registers}, and @ref{Strings}.
4795 @c =====================================================================
4797 @node Embedded Commands, Registers, Identifiers, gtroff Reference
4798 @section Embedded Commands
4799 @cindex embedded commands
4800 @cindex commands, embedded
4802 Most documents need more functionality beyond filling, adjusting and
4803 implicit line breaking. In order to gain further functionality,
4804 @code{gtroff} allows commands to be embedded into the text, in two ways.
4806 The first is a @dfn{request} which takes up an entire line, and does
4807 some large-scale operation (e.g.@: break lines, start new pages).
4809 The other is an @dfn{escape} which can be usually embedded anywhere
4810 in the text; most requests can accept it even as an argument.
4811 Escapes generally do more minor operations like sub- and superscripts,
4812 print a symbol, etc.
4820 @c ---------------------------------------------------------------------
4822 @node Requests, Macros, Embedded Commands, Embedded Commands
4823 @subsection Requests
4826 @cindex control character (@code{.})
4827 @cindex character, control (@code{.})
4828 @cindex no-break control character (@code{'})
4829 @cindex character, no-break control (@code{'})
4830 @cindex control character, no-break (@code{'})
4831 A request line begins with a control character, which is either a single
4832 quote (@samp{'}, the @dfn{no-break control character}) or a period
4833 (@samp{.}, the normal @dfn{control character}). These can be changed;
4834 see @ref{Character Translations}, for details. After this there may be
4835 optional tabs or spaces followed by an identifier which is the name of
4836 the request. This may be followed by any number of space-separated
4837 arguments (@emph{no} tabs here).
4839 @cindex structuring source code of documents or macro packages
4840 @cindex documents, structuring the source code
4841 @cindex macro packages, structuring the source code
4842 Since a control character followed by whitespace only is ignored, it
4843 is common practice to use this feature for structuring the source code
4844 of documents or macro packages.
4858 @cindex blank line macro (@code{blm})
4859 Another possibility is to use the blank line macro request @code{blm}
4860 by assigning an empty macro to it.
4865 .blm do-nothing \" activate blank line macro
4876 .blm \" deactivate blank line macro
4879 @xref{Blank Line Traps}.
4881 @cindex zero width space character (@code{\&})
4882 @cindex character, zero width space (@code{\&})
4883 @cindex space character, zero width (@code{\&})
4884 @cindex @code{\&}, escaping control characters
4885 To begin a line with a control character without it being interpreted,
4886 precede it with @code{\&}. This represents a zero width space, which
4887 means it does not affect the output.
4889 In most cases the period is used as a control character. Several
4890 requests cause a break implicitly; using the single quote control
4891 character prevents this.
4894 * Request Arguments::
4897 @node Request Arguments, , Requests, Requests
4898 @subsubsection Request Arguments
4899 @cindex request arguments
4900 @cindex arguments to requests
4902 Arguments to requests (and macros) are processed much like the shell:
4903 The line is split into arguments according to
4904 spaces.@footnote{Plan@w{ }9's @code{troff} implementation also allows
4905 tabs for argument separation -- @code{gtroff} intentionally doesn't
4906 support this.} An argument which is intended to contain spaces can
4907 either be enclosed in double quotes, or have the spaces @dfn{escaped}
4910 Here are a few examples:
4913 .uh The Mouse Problem
4914 .uh "The Mouse Problem"
4915 .uh The\ Mouse\ Problem
4918 @cindex @code{\~}, difference to @code{\@key{SP}}
4919 @cindex @code{\@key{SP}}, difference to @code{\~}
4921 The first line is the @code{uh} macro being called with 3 arguments,
4922 @samp{The}, @samp{Mouse}, and @samp{Problem}. The latter two have the
4923 same effect of calling the @code{uh} macro with one argument, @samp{The
4924 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
4925 is ``classical'' in the sense that it can be found in most @code{troff}
4926 documents. Nevertheless, it is not optimal in all situations, since
4927 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
4928 can't stretch. @code{gtroff} provides a different command @code{\~} to
4929 insert a stretchable, non-breaking space.}
4931 @cindex @code{"}, in a macro argument
4932 @cindex double quote, in a macro argument
4933 A double quote which isn't preceded by a space doesn't start a macro
4934 argument. If not closing a string, it is printed literally.
4939 .xxx a" "b c" "de"fg"
4943 has the arguments @samp{a"}, @w{@samp{b c}}, @samp{de}, and @samp{fg"}.
4944 Don't rely on this obscure behaviour!
4946 There are two possibilities to get a double quote reliably.
4950 Enclose the whole argument with double quotes and use two consecutive double
4951 quotes to represent a single one. This traditional solution has the
4952 disadvantage that double quotes don't survive argument expansion again if
4953 called in compatibility mode (using the @option{-C} option of @code{groff}):
4957 . tm xx: `\\$1' `\\$2' `\\$3'
4959 . yy "\\$1" "\\$2" "\\$3"
4962 . tm yy: `\\$1' `\\$2' `\\$3'
4964 .xx A "test with ""quotes""" .
4965 @result{} xx: `A' `test with "quotes"' `.'
4966 @result{} yy: `A' `test with ' `quotes""'
4970 If not in compatibility mode, you get the expected result
4973 xx: `A' `test with "quotes"' `.'
4974 yy: `A' `test with "quotes"' `.'
4978 since @code{gtroff} preserves the input level.
4981 Use the double quote glyph @code{\(dq}. This works with and without
4982 compatibility mode enabled since @code{gtroff} doesn't convert @code{\(dq}
4983 back to a double quote input character.
4985 Not that this method won't work with @acronym{UNIX} @code{troff} in general
4986 since the glyph `dq' isn't defined normally.
4989 @cindex @code{ds} request, and double quotes
4990 Double quotes in the @code{ds} request are handled differently.
4991 @xref{Strings}, for more details.
4993 @c ---------------------------------------------------------------------
4995 @node Macros, Escapes, Requests, Embedded Commands
4999 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
5000 which can be invoked by name. They are called in the same manner as
5001 requests -- arguments also may be passed in the same manner.
5003 @xref{Writing Macros}, and @ref{Request Arguments}.
5005 @c ---------------------------------------------------------------------
5007 @node Escapes, , Macros, Embedded Commands
5011 Escapes may occur anywhere in the input to @code{gtroff}. They usually
5012 begin with a backslash and are followed by a single character which
5013 indicates the function to be performed. The escape character can be
5014 changed; see @ref{Character Translations}.
5016 Escape sequences which require an identifier as a parameter accept three
5017 possible syntax forms.
5021 The next single character is the identifier.
5023 @cindex @code{(}, starting a two-character identifier
5025 If this single character is an opening parenthesis, take the following
5026 two characters as the identifier. Note that there is no closing
5027 parenthesis after the identifier.
5029 @cindex @code{[}, starting an identifier
5030 @cindex @code{]}, ending an identifier
5032 If this single character is an opening bracket, take all characters
5033 until a closing bracket as the identifier.
5045 @cindex @code{'}, delimiting arguments
5046 @cindex argument delimiting characters
5047 @cindex characters, argument delimiting
5048 @cindex delimiting characters for arguments
5049 Other escapes may require several arguments and/or some special format.
5050 In such cases the argument is traditionally enclosed in single quotes
5051 (and quotes are always used in this manual for the definitions of escape
5052 sequences). The enclosed text is then processed according to what that
5053 escape expects. Example:
5059 @cindex @code{\o}, possible quote characters
5060 @cindex @code{\b}, possible quote characters
5061 @cindex @code{\X}, possible quote characters
5062 Note that the quote character can be replaced with any other character
5063 which does not occur in the argument (even a newline or a space
5064 character) in the following escapes: @code{\o}, @code{\b}, and
5065 @code{\X}. This makes e.g.
5074 @result{} A caf@'e in Paris
5078 possible, but it is better not to use this feature to avoid confusion.
5080 @cindex @code{\%}, used as delimiter
5081 @cindex @code{\@key{SP}}, used as delimiter
5082 @cindex @code{\|}, used as delimiter
5083 @cindex @code{\^}, used as delimiter
5084 @cindex @code{\@{}, used as delimiter
5085 @cindex @code{\@}}, used as delimiter
5086 @cindex @code{\'}, used as delimiter
5087 @cindex @code{\`}, used as delimiter
5088 @cindex @code{\-}, used as delimiter
5089 @cindex @code{\_}, used as delimiter
5090 @cindex @code{\!}, used as delimiter
5091 @cindex @code{\?}, used as delimiter
5092 @cindex @code{\@@}, used as delimiter
5093 @cindex @code{\)}, used as delimiter
5094 @cindex @code{\/}, used as delimiter
5095 @cindex @code{\,}, used as delimiter
5096 @cindex @code{\&}, used as delimiter
5098 @cindex @code{\:}, used as delimiter
5101 @cindex @code{\@r{<colon>}}, used as delimiter
5103 @cindex @code{\~}, used as delimiter
5104 @cindex @code{\0}, used as delimiter
5105 @cindex @code{\a}, used as delimiter
5106 @cindex @code{\c}, used as delimiter
5107 @cindex @code{\d}, used as delimiter
5108 @cindex @code{\e}, used as delimiter
5109 @cindex @code{\E}, used as delimiter
5110 @cindex @code{\p}, used as delimiter
5111 @cindex @code{\r}, used as delimiter
5112 @cindex @code{\t}, used as delimiter
5113 @cindex @code{\u}, used as delimiter
5114 The following escapes sequences (which are handled similarly to
5115 characters since they don't take a parameter) are also allowed as
5116 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
5117 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
5118 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
5119 @code{\:}, @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d},
5120 @code{\e}, @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.
5121 Again, don't use these if possible.
5123 @cindex @code{\A}, allowed delimiters
5124 @cindex @code{\B}, allowed delimiters
5125 @cindex @code{\Z}, allowed delimiters
5126 @cindex @code{\C}, allowed delimiters
5127 @cindex @code{\w}, allowed delimiters
5128 No newline characters as delimiters are allowed in the following
5129 escapes: @code{\A}, @code{\B}, @code{\Z}, @code{\C}, and @code{\w}.
5131 @cindex @code{\D}, allowed delimiters
5132 @cindex @code{\h}, allowed delimiters
5133 @cindex @code{\H}, allowed delimiters
5134 @cindex @code{\l}, allowed delimiters
5135 @cindex @code{\L}, allowed delimiters
5136 @cindex @code{\N}, allowed delimiters
5137 @cindex @code{\R}, allowed delimiters
5138 @cindex @code{\s}, allowed delimiters
5139 @cindex @code{\S}, allowed delimiters
5140 @cindex @code{\v}, allowed delimiters
5141 @cindex @code{\x}, allowed delimiters
5142 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
5143 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v},
5144 and @code{\x} can't use the following characters as delimiters:
5148 @cindex numbers, and delimiters
5149 @cindex digits, and delimiters
5150 The digits @code{0}-@code{9}.
5153 @cindex operators, as delimiters
5154 @cindex @code{+}, as delimiter
5155 @cindex @code{-}, as delimiter
5156 @cindex @code{/}, as delimiter
5157 @cindex @code{*}, as delimiter
5158 @cindex @code{%}, as delimiter
5159 @cindex @code{<}, as delimiter
5160 @cindex @code{>}, as delimiter
5161 @cindex @code{=}, as delimiter
5162 @cindex @code{&}, as delimiter
5164 @cindex @code{:}, as delimiter
5167 @cindex <colon>, as delimiter
5169 @cindex @code{(}, as delimiter
5170 @cindex @code{)}, as delimiter
5171 @cindex @code{.}, as delimiter
5172 The (single-character) operators @samp{+-/*%<>=&:().}.
5175 @cindex space character
5176 @cindex character, space
5177 @cindex tab character
5178 @cindex character, tab
5179 @cindex newline character
5180 @cindex character, newline
5181 The space, tab, and newline characters.
5184 @cindex @code{\%}, used as delimiter
5186 @cindex @code{\:}, used as delimiter
5189 @cindex @code{\@r{<colon>}}, used as delimiter
5191 @cindex @code{\@{}, used as delimiter
5192 @cindex @code{\@}}, used as delimiter
5193 @cindex @code{\'}, used as delimiter
5194 @cindex @code{\`}, used as delimiter
5195 @cindex @code{\-}, used as delimiter
5196 @cindex @code{\_}, used as delimiter
5197 @cindex @code{\!}, used as delimiter
5198 @cindex @code{\@@}, used as delimiter
5199 @cindex @code{\/}, used as delimiter
5200 @cindex @code{\c}, used as delimiter
5201 @cindex @code{\e}, used as delimiter
5202 @cindex @code{\p}, used as delimiter
5203 All escape sequences except @code{\%}, @code{\:}, @code{\@{}, @code{\@}},
5204 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
5205 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
5208 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5209 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
5210 To have a backslash (actually, the current escape character) appear in the
5211 output several escapes are defined: @code{\\}, @code{\e} or @code{\E}.
5212 These are very similar, and only differ with respect to being used in
5213 macros or diversions. @xref{Character Translations}, for an exact
5214 description of those escapes.
5216 @xref{Implementation Differences}, @ref{Copy-in Mode}, and @ref{Diversions},
5217 @ref{Identifiers}, for more information.
5223 @node Comments, , Escapes, Escapes
5224 @subsubsection Comments
5227 Probably one of the most@footnote{Unfortunately, this is a lie. But
5228 hopefully future @code{gtroff} hackers will believe it @code{:-)}}
5229 common forms of escapes is the comment.
5232 Start a comment. Everything to the end of the input line is ignored.
5234 This may sound simple, but it can be tricky to keep the comments from
5235 interfering with the appearance of the final output.
5237 @cindex @code{ds}, @code{ds1} requests, and comments
5238 @cindex @code{as}, @code{as1} requests, and comments
5239 If the escape is to the right of some text or a request, that portion
5240 of the line is ignored, but the space leading up to it is noticed by
5241 @code{gtroff}. This only affects the @code{.ds} and @code{.as}
5242 request and its variants.
5244 @cindex tabs, before comments
5245 @cindex comments, lining up with tabs
5246 One possibly irritating idiosyncracy is that tabs must not be used to
5247 line up comments. Tabs are not treated as whitespace between the
5248 request and macro arguments.
5250 @cindex undefined request
5251 @cindex request, undefined
5252 A comment on a line by itself is treated as a blank line, because
5253 after eliminating the comment, that is all that remains:
5270 To avoid this, it is common to start the line with @code{.\"} which
5271 causes the line to be treated as an undefined request and thus ignored
5274 @cindex @code{'}, as a comment
5275 Another commenting scheme seen sometimes is three consecutive single
5276 quotes (@code{'''}) at the beginning of a line. This works, but
5277 @code{gtroff} gives a warning about an undefined macro (namely
5278 @code{''}), which is harmless, but irritating.
5282 To avoid all this, @code{gtroff} has a new comment mechanism using the
5283 @code{\#} escape. This escape works the same as @code{\"} except that
5284 the newline is also ignored:
5304 Ignore all input until @code{gtroff} encounters the macro named
5305 @code{.}@var{yy} on a line by itself (or @code{..} if @var{yy} is not
5306 specified). This is useful for commenting out large blocks of text:
5311 This is part of a large block
5312 of text that has been
5313 temporarily(?) commented out.
5315 We can restore it simply by removing
5316 the .ig request and the ".." at the
5319 More text text text...
5326 text text text@dots{} More text text text@dots{}
5330 Note that the commented-out block of text does not
5333 The input is read in copy-mode; auto-incremented registers @emph{are}
5334 affected (@pxref{Auto-increment}).
5338 @c =====================================================================
5340 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, gtroff Reference
5344 Numeric variables in @code{gtroff} are called @dfn{registers}. There
5345 are a number of built-in registers, supplying anything from the date to
5346 details of formatting parameters.
5348 @xref{Identifiers}, for details on register identifiers.
5351 * Setting Registers::
5352 * Interpolating Registers::
5354 * Assigning Formats::
5355 * Built-in Registers::
5358 @c ---------------------------------------------------------------------
5360 @node Setting Registers, Interpolating Registers, Registers, Registers
5361 @subsection Setting Registers
5362 @cindex setting registers (@code{nr}, @code{\R})
5363 @cindex registers, setting (@code{nr}, @code{\R})
5365 Define or set registers using the @code{nr} request or the
5368 @DefreqList {nr, ident value}
5369 @DefescListEnd {\\R, ', ident value, '}
5370 Set number register @var{ident} to @var{value}. If @var{ident}
5371 doesn't exist, @code{gtroff} creates it.
5373 The argument to @code{\R} usually has to be enclosed in quotes.
5374 @xref{Escapes}, for details on parameter delimiting characters.
5376 The @code{\R} escape doesn't produce an input token in @code{gtroff};
5377 with other words, it vanishes completely after @code{gtroff} has
5381 For example, the following two lines are equivalent:
5384 .nr a (((17 + (3 * 4))) % 4)
5385 \R'a (((17 + (3 * 4))) % 4)'
5389 Both @code{nr} and @code{\R} have two additional special forms to
5390 increment or decrement a register.
5392 @DefreqList {nr, ident @t{+}@Var{value}}
5393 @DefreqItem {nr, ident @t{-}@Var{value}}
5394 @DefescItem {\\R, ', ident @t{+}@Var{value}, '}
5395 @DefescListEnd {\\R, ', ident @t{-}@Var{value}, '}
5396 Increment (decrement) register @var{ident} by @var{value}.
5405 @cindex negating register values
5406 To assign the negated value of a register to another register, some care
5407 must be taken to get the desired result:
5421 The surrounding parentheses prevent the interpretation of the minus sign
5422 as a decrementing operator. An alternative is to start the assignment
5438 @cindex removing number register (@code{rr})
5439 @cindex number register, removing (@code{rr})
5440 @cindex register, removing (@code{rr})
5441 Remove number register @var{ident}. If @var{ident} doesn't exist, the
5445 @Defreq {rnn, ident1 ident2}
5446 @cindex renaming number register (@code{rnn})
5447 @cindex number register, renaming (@code{rnn})
5448 @cindex register, renaming (@code{rnn})
5449 Rename number register @var{ident1} to @var{ident2}. If either
5450 @var{ident1} or @var{ident2} doesn't exist, the request is ignored.
5453 @Defreq {aln, ident1 ident2}
5454 @cindex alias, number register, creating (@code{aln})
5455 @cindex creating alias, for number register (@code{aln})
5456 @cindex number register, creating alias (@code{aln})
5457 @cindex register, creating alias (@code{aln})
5458 Create an alias @var{ident1} for a number register @var{ident2}. The
5459 new name and the old name are exactly equivalent. If @var{ident1} is
5460 undefined, a warning of type @samp{reg} is generated, and the request
5461 is ignored. @xref{Debugging}, for information about warnings.
5464 @c ---------------------------------------------------------------------
5466 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
5467 @subsection Interpolating Registers
5468 @cindex interpolating registers (@code{\n})
5469 @cindex registers, interpolating (@code{\n})
5471 Numeric registers can be accessed via the @code{\n} escape.
5473 @DefescList {\\n, , i, }
5474 @DefescItem {\\n, @lparen{}, id, }
5475 @DefescListEnd {\\n, @lbrack{}, ident, @rbrack}
5476 @cindex nested assignments
5477 @cindex assignments, nested
5478 @cindex indirect assignments
5479 @cindex assignments, indirect
5480 Interpolate number register with name @var{ident} (one-character name@w{
5481 }@var{i}, two-character name @var{id}). This means that the value of the
5482 register is expanded in-place while @code{gtroff} is parsing the input line.
5483 Nested assignments (also called indirect assignments) are possible.
5504 @c ---------------------------------------------------------------------
5506 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
5507 @subsection Auto-increment
5508 @cindex auto-increment
5509 @cindex increment, automatic
5511 Number registers can also be auto-incremented and auto-decremented.
5512 The increment or decrement value can be specified with a third
5513 argument to the @code{nr} request or @code{\R} escape.
5515 @Defreq {nr, ident value incr}
5516 @cindex @code{\R}, difference to @code{nr}
5517 Set number register @var{ident} to @var{value}; the increment for
5518 auto-incrementing is set to @var{incr}. Note that the @code{\R}
5519 escape doesn't support this notation.
5522 To activate auto-incrementing, the escape @code{\n} has a special
5525 @DefescList {\\n, +, i, }
5526 @DefescItem {\\n, -, i, }
5527 @DefescItem {\\n, @lparen{}+, id, }
5528 @DefescItem {\\n, @lparen{}-, id, }
5529 @DefescItem {\\n, +@lparen{}, id, }
5530 @DefescItem {\\n, -@lparen{}, id, }
5531 @DefescItem {\\n, @lbrack{}+, ident, @rbrack{}}
5532 @DefescItem {\\n, @lbrack{}-, ident, @rbrack{}}
5533 @DefescItem {\\n, +@lbrack{}, ident, @rbrack{}}
5534 @DefescListEnd {\\n, -@lbrack{}, ident, @rbrack{}}
5535 Before interpolating, increment or decrement @var{ident}
5536 (one-character name@w{ }@var{i}, two-character name @var{id}) by the
5537 auto-increment value as specified with the @code{nr} request (or the
5538 @code{\R} escape). If no auto-increment value has been specified,
5539 these syntax forms are identical to @code{\n}.
5548 \n+a, \n+a, \n+a, \n+a, \n+a
5550 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
5552 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
5560 -5, -10, -15, -20, -25
5564 @cindex increment value without changing the register
5565 @cindex value, incrementing without changing the register
5566 To change the increment value without changing the value of a register
5567 (@var{a} in the example), the following can be used:
5573 @c ---------------------------------------------------------------------
5575 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
5576 @subsection Assigning Formats
5577 @cindex assigning formats (@code{af})
5578 @cindex formats, assigning (@code{af})
5580 When a register is used in the text of an input file (as opposed to
5581 part of an expression), it is textually replaced (or interpolated)
5582 with a representation of that number. This output format can be
5583 changed to a variety of formats (numbers, Roman numerals, etc.). This
5584 is done using the @code{af} request.
5586 @Defreq {af, ident format}
5587 Change the output format of a number register. The first argument
5588 @var{ident} is the name of the number register to be changed, and the
5589 second argument @var{format} is the output format. The following
5590 output formats are available:
5594 Decimal arabic numbers. This is the default format: 0, 1, 2, 3,@w{
5598 Decimal numbers with as many digits as specified. So, @samp{00} would
5599 result in printing numbers as 01, 02, 03,@w{ }@enddots{}
5601 In fact, any digit instead of zero will do; @code{gtroff} only counts
5602 how many digits are specified. As a consequence, @code{af}'s default
5603 format @samp{1} could be specified as @samp{0} also (and exactly this is
5604 returned by the @code{\g} escape, see below).
5607 @cindex Roman numerals
5608 @cindex numerals, Roman
5609 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@enddots{}
5612 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@enddots{}
5615 Upper-case letters: 0, A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@enddots{}
5618 Lower-case letters: 0, a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@enddots{}
5621 Omitting the number register format causes a warning of type
5622 @samp{missing}. @xref{Debugging}, for more details. Specifying a
5623 nonexistent format causes an error.
5625 The following example produces @samp{10, X, j, 010}:
5629 .af a 1 \" the default format
5639 @cindex Roman numerals, maximum and minimum
5640 @cindex maximum values of Roman numerals
5641 @cindex minimum values of Roman numerals
5642 The largest number representable for the @samp{i} and @samp{I} formats
5643 is 39999 (or @minus{}39999); @acronym{UNIX} @code{troff} uses @samp{z}
5644 and @samp{w} to represent 10000 and 5000 in Roman numerals, and so does
5645 @code{gtroff}. Currently, the correct glyphs of Roman numeral five
5646 thousand and Roman numeral ten thousand (Unicode code points
5647 @code{U+2182} and @code{U+2181}, respectively) are not available.
5649 If @var{ident} doesn't exist, it is created.
5651 @cindex read-only register, changing format
5652 @cindex changing format, and read-only registers
5653 Changing the output format of a read-only register causes an error. It
5654 is necessary to first copy the register's value to a writeable register,
5655 then apply the @code{af} request to this other register.
5658 @DefescList {\\g, , i, }
5659 @DefescItem {\\g, @lparen{}, id, }
5660 @DefescListEnd {\\g, @lbrack{}, ident, @rbrack{}}
5661 @cindex format of register (@code{\g})
5662 @cindex register, format (@code{\g})
5663 Return the current format of the specified register @var{ident}
5664 (one-character name@w{ }@var{i}, two-character name @var{id}). For
5665 example, @samp{\ga} after the previous example would produce the
5666 string @samp{000}. If the register hasn't been defined yet, nothing
5670 @c ---------------------------------------------------------------------
5672 @node Built-in Registers, , Assigning Formats, Registers
5673 @subsection Built-in Registers
5674 @cindex built-in registers
5675 @cindex registers, built-in
5677 The following lists some built-in registers which are not described
5678 elsewhere in this manual. Any register which begins with a @samp{.} is
5679 read-only. A complete listing of all built-in registers can be found in
5680 @ref{Register Index}.
5684 @cindex current input file name register (@code{.F})
5685 @cindex input file name, current, register (@code{.F})
5687 This string-valued register returns the current input file name.
5690 @cindex horizontal resolution register (@code{.H})
5691 @cindex resolution, horizontal, register (@code{.H})
5693 Horizontal resolution in basic units.
5696 @cindex vertical resolution register (@code{.V})
5697 @cindex resolution, vertical, register (@code{.V})
5699 Vertical resolution in basic units.
5702 @cindex day of the week register (@code{dw})
5703 @cindex date, day of the week register (@code{dw})
5705 Day of the week (1-7).
5708 @cindex day of the month register (@code{dy})
5709 @cindex date, day of the month register (@code{dy})
5711 Day of the month (1-31).
5714 @cindex month of the year register (@code{mo})
5715 @cindex date, month of the year register (@code{mo})
5717 Current month (1-12).
5720 @cindex date, year register (@code{year}, @code{yr})
5721 @cindex year, current, register (@code{year}, @code{yr})
5727 The current year minus@w{ }1900. Unfortunately, the documentation of
5728 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
5729 incorrectly claimed that @code{yr} contains the last two digits of the
5730 year. That claim has never been true of either traditional @code{troff}
5731 or GNU @code{troff}. Old @code{troff} input that looks like this:
5734 '\" The following line stopped working after 1999
5735 This document was formatted in 19\n(yr.
5739 can be corrected as follows:
5742 This document was formatted in \n[year].
5746 or, to be portable to older @code{troff} versions, as follows:
5750 This document was formatted in \n(y4.
5757 @cindex input line number register (@code{.c}, @code{c.})
5758 @cindex line number, input, register (@code{.c}, @code{c.})
5759 The current @emph{input} line number. Register @samp{.c} is read-only,
5760 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
5761 affecting both @samp{.c} and @samp{c.}.
5765 @cindex output line number register (@code{ln})
5766 @cindex line number, output, register (@code{ln})
5767 The current @emph{output} line number after a call to the @code{nm}
5768 request to activate line numbering.
5770 @xref{Miscellaneous}, for more information about line numbering.
5774 @cindex major version number register (@code{.x})
5775 @cindex version number, major, register (@code{.x})
5776 The major version number. For example, if the version number is@w{
5777 }1.03 then @code{.x} contains@w{ }@samp{1}.
5781 @cindex minor version number register (@code{.y})
5782 @cindex version number, minor, register (@code{.y})
5783 The minor version number. For example, if the version number is@w{
5784 }1.03 then @code{.y} contains@w{ }@samp{03}.
5788 @cindex revision number register (@code{.Y})
5789 The revision number of @code{groff}.
5793 @cindex process ID of @code{gtroff} register (@code{$$})
5794 @cindex @code{gtroff}, process ID register (@code{$$})
5795 The process ID of @code{gtroff}.
5799 @cindex @code{gtroff}, identification register (@code{.g})
5800 @cindex GNU-specific register (@code{.g})
5801 Always@w{ }1. Macros should use this to determine whether they are
5802 running under GNU @code{troff}.
5806 @cindex @acronym{ASCII} approximation output register (@code{.A})
5807 If the command line option @option{-a} is used to produce an
5808 @acronym{ASCII} approximation of the output, this is set to@w{ }1, zero
5809 otherwise. @xref{Groff Options}.
5813 This register is set to@w{ }1 (and to@w{ }0 otherwise) if the current
5814 page is actually being printed, i.e., if the @option{-o} option is being
5815 used to only print selected pages. @xref{Groff Options}, for more
5820 If @code{gtroff} is called with the @option{-T} command line option, the
5821 number register @code{.T} is set to@w{ }1, and zero otherwise.
5822 @xref{Groff Options}.
5825 @cindex output device name string register (@code{.T})
5826 Additionally, @code{gtroff} predefines a single read-write string
5827 register @code{.T} which contains the current output device (for
5828 example, @samp{latin1} or @samp{ps}).
5832 @c =====================================================================
5834 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, gtroff Reference
5835 @section Manipulating Filling and Adjusting
5836 @cindex manipulating filling and adjusting
5837 @cindex filling and adjusting, manipulating
5838 @cindex adjusting and filling, manipulating
5839 @cindex justifying text
5840 @cindex text, justifying
5844 @cindex @code{bp} request, causing implicit linebreak
5845 @cindex @code{ce} request, causing implicit linebreak
5846 @cindex @code{cf} request, causing implicit linebreak
5847 @cindex @code{fi} request, causing implicit linebreak
5848 @cindex @code{fl} request, causing implicit linebreak
5849 @cindex @code{in} request, causing implicit linebreak
5850 @cindex @code{nf} request, causing implicit linebreak
5851 @cindex @code{rj} request, causing implicit linebreak
5852 @cindex @code{sp} request, causing implicit linebreak
5853 @cindex @code{ti} request, causing implicit linebreak
5854 @cindex @code{trf} request, causing implicit linebreak
5855 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
5856 Breaks}. The @code{br} request likewise causes a break. Several
5857 other requests also cause breaks, but implicitly. These are
5858 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
5859 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
5862 Break the current line, i.e., the input collected so far is emitted
5865 If the no-break control character is used, @code{gtroff} suppresses
5876 Initially, @code{gtroff} fills and adjusts text to both margins.
5877 Filling can be disabled via the @code{nf} request and re-enabled with
5878 the @code{fi} request.
5882 @cindex fill mode (@code{fi})
5883 @cindex mode, fill (@code{fi})
5884 Activate fill mode (which is the default). This request implicitly
5885 enables adjusting; it also inserts a break in the text currently being
5886 filled. The read-only number register @code{.u} is set to@w{ }1.
5888 The fill mode status is associated with the current environment
5889 (@pxref{Environments}).
5891 See @ref{Line Control}, for interaction with the @code{\c} escape.
5895 @cindex no-fill mode (@code{nf})
5896 @cindex mode, no-fill (@code{nf})
5897 Activate no-fill mode. Input lines are output as-is, retaining line
5898 breaks and ignoring the current line length. This command implicitly
5899 disables adjusting; it also causes a break. The number register
5900 @code{.u} is set to@w{ }0.
5902 The fill mode status is associated with the current environment
5903 (@pxref{Environments}).
5905 See @ref{Line Control}, for interaction with the @code{\c} escape.
5908 @DefreqList {ad, [@Var{mode}]}
5912 Activation and deactivation of adjusting is done implicitly with
5913 calls to the @code{fi} or @code{nf} requests.
5915 @var{mode} can have one of the following values:
5919 @cindex ragged-right
5920 Adjust text to the left margin. This produces what is traditionally
5921 called ragged-right text.
5925 Adjust text to the right margin, producing ragged-left text.
5928 @cindex centered text
5929 @cindex @code{ce} request, difference to @samp{.ad@w{ }c}
5930 Center filled text. This is different to the @code{ce} request which
5931 only centers text without filling.
5935 Justify to both margins. This is the default used by @code{gtroff}.
5938 With no argument, @code{gtroff} adjusts lines in the same way it did
5939 before adjusting was deactivated (with a call to @code{na}, for
5950 .ad \" back to centering
5954 @cindex adjustment mode register (@code{.j})
5955 The current adjustment mode is available in the read-only number
5956 register @code{.j}; it can be stored and subsequently used to set
5959 The adjustment mode status is associated with the current environment
5960 (@pxref{Environments}).
5964 Disable adjusting. This request won't change the current adjustment
5965 mode: A subsequent call to @code{ad} uses the previous adjustment
5968 The adjustment mode status is associated with the current environment
5969 (@pxref{Environments}).
5973 @DefescListEnd {\\p, , , }
5974 Adjust the current line and cause a break.
5976 In most cases this produces very ugly results since @code{gtroff}
5977 doesn't have a sophisticated paragraph building algorithm (as @TeX{}
5978 have, for example); instead, @code{gtroff} fills and adjusts a paragraph
5982 This is an uninteresting sentence.
5983 This is an uninteresting sentence.\p
5984 This is an uninteresting sentence.
5991 This is an uninteresting sentence. This is an
5992 uninteresting sentence.
5993 This is an uninteresting sentence.
5997 @DefreqList {ss, word_space_size [@Var{sentence_space_size}]}
5999 @DefregListEnd {.sss}
6000 @cindex word space size register (@code{.ss})
6001 @cindex size of word space register (@code{.ss})
6002 @cindex space between words register (@code{.ss})
6003 @cindex sentence space size register (@code{.sss})
6004 @cindex size of sentence space register (@code{.sss})
6005 @cindex space between sentences register (@code{.sss})
6006 Change the minimum size of a space between filled words. It takes its
6007 units as one twelfth of the space width parameter for the current
6008 font. Initially both the @var{word_space_size} and
6009 @var{sentence_space_size} are@w{ }12.
6013 If two arguments are given to the @code{ss} request, the second
6014 argument sets the sentence space size. If the second argument is not
6015 given, sentence space size is set to @var{word_space_size}. The
6016 sentence space size is used in two circumstances: If the end of a
6017 sentence occurs at the end of a line in fill mode, then both an
6018 inter-word space and a sentence space are added; if two spaces follow
6019 the end of a sentence in the middle of a line, then the second space
6020 is a sentence space. If a second argument is never given to the
6021 @code{ss} request, the behaviour of @acronym{UNIX} @code{troff} is the
6022 same as that exhibited by GNU @code{troff}. In GNU @code{troff}, as
6023 in @acronym{UNIX} @code{troff}, a sentence should always be followed
6024 by either a newline or two spaces.
6026 The read-only number registers @code{.ss} and @code{.sss} hold the
6027 values of the parameters set by the first and second arguments of the
6030 The word space and sentence space values are associated with the current
6031 environment (@pxref{Environments}).
6033 Contrary to traditional @acronym{AT&T} @code{troff}, this request is @emph{not}
6034 ignored if a TTY output device is used; the given values are then
6035 rounded down to a multiple of@w{ }12 (@pxref{Implementation Differences}).
6037 The request is ignored if there is no parameter.
6040 @DefreqList {ce, [@Var{nnn}]}
6041 @DefregListEnd {.ce}
6042 @cindex centering lines (@code{ce})
6043 @cindex lines, centering (@code{ce})
6044 Center text. While the @w{@samp{.ad c}} request also centers text,
6045 it fills the text as well. @code{ce} does not fill the
6046 text it affects. This request causes a break. The number of lines
6047 still to be centered is associated with the current environment
6048 (@pxref{Environments}).
6050 The following example demonstrates the differences.
6056 This is a small text fragment which shows the differences
6057 between the `.ce' and the `.ad c' request.
6061 This is a small text fragment which shows the differences
6062 between the `.ce' and the `.ad c' request.
6066 And here the result:
6069 This is a small text fragment which
6070 shows the differences
6071 between the `.ce' and the `.ad c' request.
6073 This is a small text fragment which
6074 shows the differences between the `.ce'
6075 and the `.ad c' request.
6078 With no arguments, @code{ce} centers the next line of text. @var{nnn}
6079 specifies the number of lines to be centered. If the argument is zero
6080 or negative, centering is disabled.
6082 The basic length for centering text is the line length (as set with the
6083 @code{ll} request) minus the indentation (as set with the @code{in}
6084 request). Temporary indentation is ignored.
6086 As can be seen in the previous example, it is a common idiom to turn
6087 on centering for a large number of lines, and to turn off centering
6088 after text to be centered. This is useful for any request which takes
6089 a number of lines as an argument.
6091 The @code{.ce} read-only number register contains the number of lines
6092 remaining to be centered, as set by the @code{ce} request.
6095 @DefreqList {rj, [@Var{nnn}]}
6096 @DefregListEnd {.rj}
6097 @cindex justifying text (@code{rj})
6098 @cindex text, justifying (@code{rj})
6099 @cindex right-justifying (@code{rj})
6100 Justify unfilled text to the right margin. Arguments are identical to
6101 the @code{ce} request. The @code{.rj} read-only number register is
6102 the number of lines to be right-justified as set by the @code{rj}
6103 request. This request causes a break. The number of lines still to be
6104 right-justified is associated with the current environment
6105 (@pxref{Environments}).
6109 @c =====================================================================
6111 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, gtroff Reference
6112 @section Manipulating Hyphenation
6113 @cindex manipulating hyphenation
6114 @cindex hyphenation, manipulating
6116 As discussed in @ref{Hyphenation}, @code{gtroff} hyphenates words.
6117 There are a number of ways to influence hyphenation.
6119 @DefreqList {hy, [@Var{mode}]}
6120 @DefregListEnd {.hy}
6121 Enable hyphenation. The request has an optional numeric argument,
6122 @var{mode}, to restrict hyphenation if necessary:
6126 The default argument if @var{mode} is omitted. Hyphenate without
6127 restrictions. This is also the start-up value of @code{gtroff}.
6130 Do not hyphenate the last word on a page or column.
6133 Do not hyphenate the last two characters of a word.
6136 Do not hyphenate the first two characters of a word.
6139 Values in the previous table are additive. For example, the value@w{
6140 }12 causes @code{gtroff} to neither hyphenate the last two nor the first
6141 two characters of a word.
6143 @cindex hyphenation restrictions register (@code{.hy})
6144 The current hyphenation restrictions can be found in the read-only
6145 number register @samp{.hy}.
6147 The hyphenation mode is associated with the current environment
6148 (@pxref{Environments}).
6152 Disable hyphenation (i.e., set the hyphenation mode to zero). Note
6153 that the hyphenation mode of the last call to @code{hy} is not
6156 The hyphenation mode is associated with the current environment
6157 (@pxref{Environments}).
6160 @DefreqList {hlm, [@Var{nnn}]}
6162 @DefregListEnd {.hlc}
6163 @cindex explicit hyphen (@code{\%})
6164 @cindex hyphen, explicit (@code{\%})
6165 @cindex consecutive hyphenated lines (@code{hlm})
6166 @cindex lines, consecutive hyphenated (@code{hlm})
6167 @cindex hyphenated lines, consecutive (@code{hlm})
6168 Set the maximum number of consecutive hyphenated lines to @var{nnn}.
6169 If this number is negative, there is no maximum. The default value
6170 is@w{ }@minus{}1 if @var{nnn} is omitted. This value is associated
6171 with the current environment (@pxref{Environments}). Only lines
6172 output from a given environment count towards the maximum associated
6173 with that environment. Hyphens resulting from @code{\%} are counted;
6174 explicit hyphens are not.
6176 The current setting of @code{hlm} is available in the @code{.hlm}
6177 read-only number register. Also the number of immediately preceding
6178 consecutive hyphenated lines are available in the read-only number
6179 register @samp{.hlc}.
6182 @Defreq {hw, word1 word2 @dots{}}
6183 Define how @var{word1}, @var{word2}, etc.@: are to be hyphenated. The
6184 words must be given with hyphens at the hyphenation points. For
6192 Besides the space character, any character whose hyphenation code value
6193 is zero can be used to separate the arguments of @code{hw} (see the
6194 documentation for the @code{hcode} request below for more information).
6195 In addition, this request can be used more than once.
6197 Hyphenation exceptions specified with the @code{hw} request are
6198 associated with the current hyphenation language; it causes an error
6199 if there is no current hyphenation language.
6201 This request is ignored if there is no parameter.
6203 In old versions of @code{troff} there was a limited amount of space to
6204 store such information; fortunately, with @code{gtroff}, this is no
6205 longer a restriction.
6208 @DefescList {\\%, , , }
6209 @deffnx Escape @t{\:}
6214 @esindex @r{<colon>}
6216 @cindex hyphenation character (@code{\%})
6217 @cindex character, hyphenation (@code{\%})
6218 @cindex disabling hyphenation (@code{\%})
6219 @cindex hyphenation, disabling (@code{\%})
6220 To tell @code{gtroff} how to hyphenate words on the fly, use the
6221 @code{\%} escape, also known as the @dfn{hyphenation character}.
6222 Preceding a word with this character prevents it from being
6223 hyphenated; putting it inside a word indicates to @code{gtroff} that
6224 the word may be hyphenated at that point. Note that this mechanism
6225 only affects that one occurrence of the word; to change the
6226 hyphenation of a word for the entire document, use the @code{hw}
6229 The @code{\:} escape inserts a zero-width break point
6230 (that is, the word breaks but without adding a hyphen).
6233 ... check the /var/log/\:httpd/\:access_log file ...
6237 @Defreq {hc, [@Var{char}]}
6238 Change the hyphenation character to @var{char}. This character then
6239 works the same as the @code{\%} escape, and thus, no longer appears in
6240 the output. Without an argument, @code{hc} resets the hyphenation
6241 character to be @code{\%} (the default) only.
6243 The hyphenation character is associated with the current environment
6244 (@pxref{Environments}).
6247 @DefreqList {hpf, pattern_file}
6248 @DefreqItem {hpfa, pattern_file}
6249 @DefreqListEnd {hpfcode, a b [c d @dots{}]}
6250 @cindex hyphenation patterns (@code{hpf})
6251 @cindex patterns for hyphenation (@code{hpf})
6252 Read in a file of hyphenation patterns. This file is searched for in
6253 the same way as @file{@var{name}.tmac} (or @file{tmac.@var{name}}) is
6254 searched for if the @option{-m@var{name}} option is specified.
6256 It should have the same format as (simple) @TeX{} patterns files.
6257 More specifically, the following scanning rules are implemented.
6261 A percent sign starts a comment (up to the end of the line)
6262 even if preceded by a backslash.
6265 No support for `digraphs' like @code{\$}.
6268 The only multi-character construction recognized is @code{^^@var{xx}}
6269 (@var{x} is 0-9 or a-f); other use of @code{^} causes an error.
6275 @code{hpf} checks for the expression @code{\patterns@{@dots{}@}}
6276 (possibly with whitespace before and after the braces).
6277 Everything between the braces is taken as hyphenation patterns.
6278 Consequently, @code{@{} and @code{@}} are not allowed in patterns.
6281 Similarly, @code{\hyphenation@{@dots{}@}} gives a list of hyphenation
6285 @code{\endinput} is recognized also.
6288 For backwards compatibility, if @code{\patterns} is missing,
6289 the whole file is treated as a list of hyphenation patterns
6290 (only recognizing the @code{%} character as the start of a comment).
6293 If no @code{hpf} request is specified (either in the document or in a
6294 macro package), @code{gtroff} won't hyphenate at all.
6296 The @code{hpfa} request appends a file of patterns to the current list.
6298 The @code{hpfcode} request defines mapping values for character codes in
6299 hyphenation patterns. @code{hpf} or @code{hpfa} then apply the mapping
6300 (after reading the patterns) before replacing or appending them to
6301 the current list of patterns. Its arguments are pairs of character codes
6302 -- integers from 0 to@w{ }255. The request maps character code@w{ }@var{a}
6303 to code@w{ }@var{b}, code@w{ }@var{c} to code@w{ }@var{d}, and so on. You
6304 can use character codes which would be invalid otherwise.
6309 The set of hyphenation patterns is associated with the current language
6310 set by the @code{hla} request. The @code{hpf} request is usually
6311 invoked by the @file{troffrc} or @file{troffrc-end} file; by default,
6312 @file{troffrc} loads hyphenation patterns for American English (in file
6315 A second call to @code{hpf} (for the same language) will replace the
6316 hyphenation patterns with the new ones.
6318 Invoking @code{hpf} causes an error if there is no current hyphenation
6322 @Defreq {hcode, c1 code1 c2 code2 @dots{}}
6323 @cindex hyphenation code (@code{hcode})
6324 @cindex code, hyphenation (@code{hcode})
6325 Set the hyphenation code of character @var{c1} to @var{code1}, that of
6326 @var{c2} to @var{code2}, etc. A hyphenation code must be a single
6327 input character (not a special character) other than a digit or a
6328 space. Initially each lower-case letter (@samp{a}-@samp{z}) has its
6329 hyphenation code set to itself, and each upper-case letter
6330 (@samp{A}-@samp{Z}) has a hyphenation code which is the lower-case
6333 This request is ignored if it has no parameter.
6336 @DefreqList {hym, [@Var{length}]}
6337 @DefregListEnd {.hym}
6338 @cindex hyphenation margin (@code{hym})
6339 @cindex margin for hyphenation (@code{hym})
6340 @cindex @code{ad} request, and hyphenation margin
6341 Set the (right) hyphenation margin to @var{length}. If the current
6342 adjustment mode is not @samp{b} or @samp{n}, the line is not
6343 hyphenated if it is shorter than @var{length}. Without an argument,
6344 the hyphenation margin is reset to its default value, which is@w{ }0.
6345 The default scaling indicator for this request is @samp{m}. The
6346 hyphenation margin is associated with the current environment
6347 (@pxref{Environments}).
6349 A negative argument resets the hyphenation margin to zero, emitting
6350 a warning of type @samp{range}.
6352 @cindex hyphenation margin register (@code{.hym})
6353 The current hyphenation margin is available in the @code{.hym} read-only
6357 @DefreqList {hys, [@Var{hyphenation_space}]}
6358 @DefregListEnd {.hys}
6359 @cindex hyphenation space (@code{hys})
6360 @cindex @code{ad} request, and hyphenation space
6361 Set the hyphenation space to @var{hyphenation_space}. If the current
6362 adjustment mode is @samp{b} or @samp{n}, don't hyphenate the line
6363 if it can be justified by adding no more than @var{hyphenation_space}
6364 extra space to each word space. Without argument, the hyphenation
6365 space is set to its default value, which is@w{ }0. The default
6366 scaling indicator for this request is @samp{m}. The hyphenation
6367 space is associated with the current environment
6368 (@pxref{Environments}).
6370 A negative argument resets the hyphenation space to zero, emitting a
6371 warning of type @samp{range}.
6373 @cindex hyphenation space register (@code{.hys})
6374 The current hyphenation space is available in the @code{.hys} read-only
6378 @Defreq {shc, [@Var{char}]}
6379 @cindex soft hyphen character, setting (@code{shc})
6380 @cindex character, soft hyphen, setting (@code{shc})
6381 @cindex glyph, soft hyphen (@code{hy})
6382 @cindex soft hyphen glyph (@code{hy})
6383 @cindex @code{char} request, and soft hyphen character
6384 @cindex @code{tr} request, and soft hyphen character
6385 Set the soft hyphen character to @var{char}. If the argument is
6386 omitted, the soft hyphen character is set to the default character
6387 @code{\(hy} (this is the start-up value of @code{gtroff} also). The
6388 soft hyphen character is the character that is inserted when a word is
6389 hyphenated at a line break. If the soft hyphen character does not
6390 exist in the font of the character immediately preceding a potential
6391 break point, then the line is not broken at that point. Neither
6392 definitions (specified with the @code{char} request) nor translations
6393 (specified with the @code{tr} request) are considered when finding the
6394 soft hyphen character.
6397 @DefreqList {hla, language}
6398 @DefregListEnd {.hla}
6399 @cindex @code{hpf} request, and hyphenation language
6400 @cindex @code{hw} request, and hyphenation language
6403 Set the current hyphenation language to the string @var{language}.
6404 Hyphenation exceptions specified with the @code{hw} request and
6405 hyphenation patterns specified with the @code{hpf} and @code{hpfa}
6406 requests are both associated with the current hyphenation language.
6407 The @code{hla} request is usually invoked by the @file{troffrc} or the
6408 @file{troffrc-end} files; @file{troffrc} sets the default language to
6411 @cindex hyphenation language register (@code{.hla})
6412 The current hyphenation language is available as a string in the
6413 read-only number register @samp{.hla}.
6416 .ds curr_language \n[.hla]
6423 @c =====================================================================
6425 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, gtroff Reference
6426 @section Manipulating Spacing
6427 @cindex manipulating spacing
6428 @cindex spacing, manipulating
6430 @Defreq {sp, [@Var{distance}]}
6431 Space downwards @var{distance}. With no argument it advances 1@w{
6432 }line. A negative argument causes @code{gtroff} to move up the page
6433 the specified distance. If the argument is preceded by a @samp{|}
6434 then @code{gtroff} moves that distance from the top of the page. This
6435 request causes a line break. The default scaling indicator is @samp{v}.
6438 @DefreqList {ls, [@Var{nnn}]}
6440 @cindex double spacing (@code{ls})
6441 Output @w{@var{nnn}@minus{}1} blank lines after each line of text.
6442 With no argument, @code{gtroff} uses the previous value before the
6443 last @code{ls} call.
6446 .ls 2 \" This causes double-spaced output
6447 .ls 3 \" This causes triple-spaced output
6448 .ls \" Again double spaced
6451 The line spacing is associated with the current environment
6452 (@pxref{Environments}).
6454 @cindex line spacing register (@code{.L})
6455 The read-only number register @code{.L} contains the current line
6459 @xref{Changing Type Sizes}, for the requests @code{vs} and @code{pvs}
6460 as alternatives to @code{ls}.
6462 @DefescList {\\x, ', spacing, '}
6464 Sometimes, extra vertical spacing is only needed occasionally, e.g.@:
6465 to allow space for a tall construct (like an equation). The @code{\x}
6466 escape does this. The escape is given a numerical argument, usually
6467 enclosed in quotes (like @samp{\x'3p'}); the default scaling indicator
6468 is @samp{v}. If this number is positive extra vertical space is
6469 inserted below the current line. A negative number adds space above.
6470 If this escape is used multiple times on the same line, the maximum of
6473 @xref{Escapes}, for details on parameter delimiting characters.
6475 @cindex extra post-vertical line space register (@code{.a})
6476 The @code{.a} read-only number register contains the most recent
6477 (nonnegative) extra vertical line space.
6479 Using @code{\x} can be necessary in combination with the @code{\b}
6480 escape, as the following example shows.
6483 This is a test with the \[rs]b escape.
6485 This is a test with the \[rs]b escape.
6487 This is a test with \b'xyz'\x'-1m'\x'1m'.
6489 This is a test with the \[rs]b escape.
6491 This is a test with the \[rs]b escape.
6498 This is a test with the \b escape.
6499 This is a test with the \b escape.
6501 This is a test with y.
6503 This is a test with the \b escape.
6504 This is a test with the \b escape.
6510 @DefregListEnd {.ns}
6511 @cindex @code{sp} request, and no-space mode
6512 @cindex no-space mode (@code{ns})
6513 @cindex mode, no-space (@code{ns})
6514 @cindex blank lines, disabling
6515 @cindex lines, blank, disabling
6516 Enable @dfn{no-space mode}. In this mode, spacing (either via
6517 @code{sp} or via blank lines) is disabled. The @code{bp} request to
6518 advance to the next page is also disabled, except if it is accompanied
6519 by a page number (see @ref{Page Control}, for more information). This
6520 mode ends when actual text is output or the @code{rs} request is
6521 encountered which ends no-space mode. The read-only number register
6522 @code{.ns} is set to@w{ }1 as long as no-space mode is active.
6524 This request is useful for macros that conditionally
6525 insert vertical space before the text starts
6526 (for example, a paragraph macro could insert some space
6527 except when it is the first paragraph after a section header).
6531 @c =====================================================================
6533 @node Tabs and Fields, Character Translations, Manipulating Spacing, gtroff Reference
6534 @section Tabs and Fields
6535 @cindex tabs, and fields
6536 @cindex fields, and tabs
6538 @cindex @acronym{EBCDIC} encoding of a tab
6539 A tab character (@acronym{ASCII} char@w{ }9, @acronym{EBCDIC} char@w{
6540 }5) causes a horizontal movement to the next tab stop (much
6541 like it did on a typewriter).
6544 @cindex tab character, non-interpreted (@code{\t})
6545 @cindex character, tab, non-interpreted (@code{\t})
6546 This escape is a non-interpreted tab character. In copy mode
6547 (@pxref{Copy-in Mode}), @code{\t} is the same as a real tab character.
6550 @DefreqList {ta, [@Var{n1} @Var{n2} @dots{} @Var{nn} @t{T} @Var{r1} @Var{r2} @dots{} @Var{rn}]}
6551 @DefregListEnd {.tabs}
6552 Change tab stop positions. This request takes a series of tab
6553 specifiers as arguments (optionally divided into two groups with the
6554 letter @samp{T}) which indicate where each tab stop is to be
6555 (overriding any previous settings).
6557 Tab stops can be specified absolutely, i.e., as the distance from the
6558 left margin. For example, the following sets 6@w{ }tab stops every
6562 .ta 1i 2i 3i 4i 5i 6i
6565 Tab stops can also be specified using a leading @samp{+}
6566 which means that the specified tab stop is set relative to
6567 the previous tab stop. For example, the following is equivalent to the
6571 .ta 1i +1i +1i +1i +1i +1i
6574 @code{gtroff} supports an extended syntax to specify repeat values after
6575 the @samp{T} mark (these values are always taken as relative) -- this is
6576 the usual way to specify tabs set at equal intervals. The following is,
6577 yet again, the same as the previous examples. It does even more since
6578 it defines an infinite number of tab stops separated by one inch.
6584 Now we are ready to interpret the full syntax given at the beginning:
6585 Set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn} and then set
6586 tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn}
6587 and then at @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2},
6588 @dots{}, @var{nn}+@var{rn}+@var{rn}, and so on.
6590 Example: @samp{4c +6c T 3c 5c 2c} is equivalent to @samp{4c 10c 13c 18c
6591 20c 23c 28c 30c @dots{}}.
6593 The material in each tab column (i.e., the column between two tab stops)
6594 may be justified to the right or left or centered in the column. This
6595 is specified by appending @samp{R}, @samp{L}, or @samp{C} to the tab
6596 specifier. The default justification is @samp{L}. Example:
6606 The default unit of the @code{ta} request is @samp{m}.
6609 A tab stop is converted into a non-breakable horizontal movement which
6610 can be neither stretched nor squeezed. For example,
6619 creates a single line which is a bit longer than 10@w{ }inches (a string
6620 is used to show exactly where the tab characters are). Now consider the
6630 @code{gtroff} first converts the tab stops of the line into unbreakable
6631 horizontal movements, then splits the line after the second @samp{b}
6632 (assuming a sufficiently short line length). Usually, this isn't what
6636 Superfluous tabs (i.e., tab characters which do not correspond to a tab
6637 stop) are ignored except the first one which delimits the characters
6638 belonging to the last tab stop for right-justifying or centering.
6639 Consider the following example
6643 .ds ZZ foo\tbar\tfoobar
6644 .ds ZZZ foo\tbar\tfoo\tbar
6655 which produces the following output:
6664 The first line right-justifies the second `foo' relative to the tab
6665 stop. The second line right-justifies `foobar'. The third line finally
6666 right-justifies only `foo' because of the additional tab character which
6667 marks the end of the string belonging to the last defined tab stop.
6670 Tab stops are associated with the current environment
6671 (@pxref{Environments}).
6674 Calling @code{ta} without an argument removes all tab stops.
6677 @cindex tab stops, for TTY output devices
6678 The start-up value of @code{gtroff} is @w{@samp{T 0.5i}} in troff mode
6679 and @w{@samp{T 0.8i}} in nroff mode (the latter is done with an
6680 explicit call to the @code{ta} request in the file @file{tty.tmac}.
6683 @cindex tab settings register (@code{.tabs})
6684 The read-only number register @code{.tabs} contains a string
6685 representation of the current tab settings suitable for use as an
6686 argument to the @code{ta} request.
6689 .ds tab-string \n[.tabs]
6694 @cindex @code{.S} register, Plan@w{ }9 alias for @code{.tabs}
6695 @cindex @code{.tabs} register, Plan@w{ }9 alias (@code{.S})
6696 The @code{troff} version of the Plan@w{ }9 operating system uses
6697 register @code{.S} for the same purpose.
6700 @Defreq {tc, [@Var{fill-char}]}
6701 @cindex tab repetition character (@code{tc})
6702 @cindex character, tab repetition (@code{tc})
6703 Normally @code{gtroff} fills the space to the next tab stop with
6704 whitespace. This can be changed with the @code{tc} request. With no
6705 argument @code{gtroff} reverts to using whitespace, which is the
6706 default. The value of this @dfn{tab repetition} character is
6707 associated with the current environment (@pxref{Environments}).
6710 @DefreqList {linetabs, n}
6711 @DefregListEnd {.linetabs}
6712 @cindex tab, line-tabs mode
6713 @cindex line-tabs mode
6714 @cindex mode, line-tabs
6715 If @var{n} is missing or not zero, enable @dfn{line-tabs} mode,
6716 or disable it otherwise (the default).
6717 In line-tabs mode, @code{gtroff} computes tab distances
6718 relative to the (current) output line instead of the input line.
6720 For example, the following code:
6733 in normal mode, results in the output
6740 in line-tabs mode, the same code outputs
6746 Line-tabs mode is associated with the current environment.
6747 The read-only register @code{.linetabs} is set to@w{ }1 if in line-tabs
6748 mode, and 0 in normal mode.
6756 @c ---------------------------------------------------------------------
6758 @node Leaders, Fields, Tabs and Fields, Tabs and Fields
6762 Sometimes it may may be desirable to use the @code{tc} request to fill a
6763 particular tab stop with a given character (for example dots in a table
6764 of contents), but also normal tab stops on the rest of the line. For
6765 this @code{gtroff} provides an alternate tab mechanism, called
6766 @dfn{leaders} which does just that.
6768 @cindex leader character
6769 A leader character (character code@w{ }1) behaves similarly to a tab
6770 character: It moves to the next tab stop. The only difference is that
6771 for this movement, the fill character defaults to a period character and
6775 @cindex leader character, non-interpreted (@code{\a})
6776 @cindex character, leader, non-interpreted (@code{\a})
6777 This escape is a non-interpreted leader character. In copy mode
6778 (@pxref{Copy-in Mode}), @code{\a} is the same as a real leader
6782 @Defreq {lc, [@Var{fill-char}]}
6783 @cindex leader repetition character (@code{lc})
6784 @cindex character, leader repetition (@code{lc})
6785 Declare the leader character. Without an argument, leaders act the
6786 same as tabs (i.e., using whitespace for filling). @code{gtroff}'s
6787 start-up value is @samp{.}. The value of this @dfn{leader repetition}
6788 character is associated with the current environment
6789 (@pxref{Environments}).
6792 @cindex table of contents
6793 @cindex contents, table of
6794 For a table of contents, to name an example, tab stops may be defined so
6795 that the section number is one tab stop, the title is the second with
6796 the remaining space being filled with a line of dots, and then the page
6797 number slightly separated from the dots.
6800 .ds entry 1.1\tFoo\a\t12
6810 1.1 Foo.......................................... 12
6813 @c ---------------------------------------------------------------------
6815 @node Fields, , Leaders, Tabs and Fields
6819 @cindex field delimiting character (@code{fc})
6820 @cindex delimiting character, for fields (@code{fc})
6821 @cindex character, field delimiting (@code{fc})
6822 @cindex field padding character (@code{fc})
6823 @cindex padding character, for fields (@code{fc})
6824 @cindex character, field padding (@code{fc})
6825 @dfn{Fields} are a more general way of laying out tabular data. A field
6826 is defined as the data between a pair of @dfn{delimiting characters}.
6827 It contains substrings which are separated by @dfn{padding characters}.
6828 The width of a field is the distance on the @emph{input} line from the
6829 position where the field starts to the next tab stop. A padding
6830 character inserts stretchable space similar to @TeX{}'s @code{\hss}
6831 command (thus it can even be negative) to make the sum of all substring
6832 lengths plus the stretchable space equal to the field width. If more
6833 than one padding character is inserted, the available space is evenly
6834 distributed among them.
6836 @Defreq {fc, [@Var{delim-char} [@Var{padding-char}]]}
6837 Define a delimiting and a padding character for fields. If the latter
6838 is missing, the padding character defaults to a space character. If
6839 there is no argument at all, the field mechanism is disabled (which is
6840 the default). Note that contrary to e.g.@: the tab repetition
6841 character, delimiting and padding characters are not associated to the
6842 current environment (@pxref{Environments}).
6855 and here the result:
6864 @c =====================================================================
6866 @node Character Translations, Troff and Nroff Mode, Tabs and Fields, gtroff Reference
6867 @section Character Translations
6868 @cindex character translations
6869 @cindex translations of characters
6871 @cindex control character, changing (@code{cc})
6872 @cindex character, control, changing (@code{cc})
6873 @cindex no-break control character, changing (@code{c2})
6874 @cindex character, no-break control, changing (@code{c2})
6875 @cindex control character, no-break, changing (@code{c2})
6876 The control character (@samp{.}) and the no-break control character
6877 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
6880 @Defreq {cc, [@Var{c}]}
6881 Set the control character to@w{ }@var{c}. With no argument the default
6882 control character @samp{.} is restored. The value of the control
6883 character is associated with the current environment
6884 (@pxref{Environments}).
6887 @Defreq {c2, [@Var{c}]}
6888 Set the no-break control character to@w{ }@var{c}. With no argument the
6889 default control character @samp{'} is restored. The value of the
6890 no-break control character is associated with the current environment
6891 (@pxref{Environments}).
6895 @cindex disabling @code{\} (@code{eo})
6896 @cindex @code{\}, disabling (@code{eo})
6897 Disable the escape mechanism completely. After executing this
6898 request, the backslash character @samp{\} no longer starts an escape
6901 This request can be very helpful in writing macros since it is not
6902 necessary then to double the escape character. Here an example:
6905 .\" This is a simplified version of the
6906 .\" .BR request from the man macro package
6910 . while (\n[.$] >= 2) \@{\
6911 . as result \fB\$1\fR\$2
6914 . if \n[.$] .as result \fB\$1
6922 @Defreq {ec, [@Var{c}]}
6923 @cindex escape character, changing (@code{ec})
6924 @cindex character, escape, changing (@code{ec})
6925 Set the escape character to@w{ }@var{c}. With no argument the default
6926 escape character @samp{\} is restored. It can be also used to
6927 re-enable the escape mechanism after an @code{eo} request.
6929 Note that changing the escape character globally will likely break
6930 macro packages since @code{gtroff} has no mechanism to `intern' macros,
6931 i.e., to convert a macro definition into an internal form which is
6932 independent of its representation (@TeX{} has this mechanism).
6933 If a macro is called, it is executed literally.
6937 @DefreqListEnd {ecr, }
6938 The @code{ecs} request saves the current escape character
6939 in an internal register.
6940 Use this request in combination with the @code{ec} request to
6941 temporarily change the escape character.
6943 The @code{ecr} request restores the escape character
6944 saved with @code{ecs}.
6945 Without a previous call to @code{ecs}, this request
6946 sets the escape character to @code{\}.
6949 @DefescList {\\\\, , , }
6950 @DefescItem {\\e, , , }
6951 @DefescListEnd {\\E, , , }
6952 Print the current escape character (which is the backslash character
6953 @samp{\} by default).
6955 @code{\\} is a `delayed' backslash; more precisely, it is the default
6956 escape character followed by a backslash, which no longer has special
6957 meaning due to the leading escape character. It is @emph{not} an escape
6958 sequence in the usual sense! In any unknown escape sequence
6959 @code{\@var{X}} the escape character is ignored and @var{X} is printed.
6960 But if @var{X} is equal to the current escape character, no warning is
6963 As a consequence, only at top-level or in a diversion a backslash glyph is
6964 printed; in copy-in mode, it expands to a single backslash which then
6965 combines with the following character to an escape sequence.
6967 The @code{\E} escape differs from @code{\e} by printing an escape
6968 character that is not interpreted in copy mode.
6969 Use this to define strings with escapes that work
6970 when used in copy mode (for example, as a macro argument).
6971 The following example defines strings to begin and end
6975 .ds @{ \v'-.3m'\s'\Es[.s]*60/100'
6979 Another example to demonstrate the differences between the various escape
6980 sequences, using a strange escape character, @samp{-}.
6992 The result is surprising for most users, expecting @samp{1} since
6993 @samp{foo} is a valid identifier. What has happened? As mentioned
6994 above, the leading escape character makes the following character
6995 ordinary. Written with the default escape character the sequence
6996 @samp{--} becomes @samp{\-} -- this is the minus sign.
6998 If the escape character followed by itself is a valid escape sequence,
6999 only @code{\E} yields the expected result:
7012 Similar to @code{\\}, the sequence @code{\.} isn't a real escape sequence.
7013 As before, a warning message is suppressed if the escape character is
7014 followed by a dot, and the dot itself is printed.
7031 The first backslash is consumed while the macro is read, and the second
7032 is swallowed while exexuting macro @code{foo}.
7035 A @dfn{translation} is a mapping of an input character to an output
7036 character. The default mappings are given in the font definition files
7037 for the specific output device (@pxref{Font Files}); all mappings (both
7038 with @code{tr} and in the font definition files) occur at output time,
7039 i.e., the input character gets assigned the metric information of the
7040 mapped output character.
7042 @DefreqList {tr, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7043 @DefreqListEnd {trin, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7044 Translate character @var{a} to@w{ }@var{b}, character @var{c} to@w{
7045 }@var{d}, etc. If there is an odd number of arguments, the last one is
7046 translated to the space character.
7048 The @code{trin} request is identical to @code{tr},
7049 but when you unformat a diversion with @code{asciify}
7050 it ignores the translation.
7051 @xref{Diversions}, for details about the @code{asciify} request.
7057 @cindex @code{\(}, and translations
7058 @cindex @code{\[}, and translations
7059 @cindex @code{\'}, and translations
7060 @cindex @code{\`}, and translations
7061 @cindex @code{\-}, and translations
7062 @cindex @code{\_}, and translations
7063 @cindex @code{\C}, and translations
7064 @cindex @code{\N}, and translations
7065 @cindex @code{char} request, and translations
7066 @cindex special characters
7067 @cindex character, special
7068 @cindex numbered character (@code{\N})
7069 @cindex character, numbered (@code{\N})
7070 Special characters (@code{\(@var{xx}}, @code{\[@var{xxx}]},
7071 @code{\C'@var{xxx}'}, @code{\'}, @code{\`}, @code{\-}, @code{\_}),
7072 characters defined with the @code{char} request, and numbered characters
7073 (@code{\N'@var{xxx}'}) can be translated also.
7076 @cindex @code{\e}, and translations
7077 The @code{\e} escape can be translated also.
7080 @cindex @code{\%}, and translations
7081 @cindex @code{\~}, and translations
7082 Characters can be mapped onto the @code{\%} and @code{\~} escapes (but
7083 @code{\%} and @code{\~} can't be mapped onto another character).
7086 @cindex backspace character, and translations
7087 @cindex character, backspace, and translations
7088 @cindex leader character, and translations
7089 @cindex character, leader, and translations
7090 @cindex newline character, and translations
7091 @cindex character, newline, and translations
7092 @cindex tab character, and translations
7093 @cindex character, tab, and translations
7094 @cindex @code{\a}, and translations
7095 @cindex @code{\t}, and translations
7096 The following characters can't be translated: space (with one exception,
7097 see below), backspace, newline, leader (and @code{\a}), tab (and
7101 @cindex @code{shc} request, and translations
7102 Translations are not considered for finding the soft hyphen character
7103 set with the @code{shc} request.
7106 @cindex @code{\&}, and translations
7107 The character pair @samp{@var{c}\&} (this is an arbitrary character@w{
7108 }@var{c} followed by the zero width space character) maps this
7109 character to nothing.
7118 It is even possible to map the space character to nothing:
7127 As shown in the example, the space character can't be the first
7128 character pair as an argument of @code{tr}. Additionally, it is not
7129 possible to map the space character to any other character; requests
7130 like @w{@samp{.tr aa x}} undo @w{@samp{.tr aa \&}} instead.
7132 If justification is active, lines are justified in spite of the
7133 `empty' space character (but there is no minimal distance, i.e.@: the
7134 space character, between words).
7137 After an output character has been constructed (this happens at the
7138 moment immediately before the character is appended to an output
7139 character list, either by direct output, in a macro, diversion, or
7140 string), it is no longer affected by @code{tr}.
7143 Translating undefined characters is possible also; @code{tr} does not
7144 check whether the characters in its argument are defined.
7146 @xref{Gtroff Internals}.
7149 Without an argument, the @code{tr} request is ignored.
7153 @Defreq {trnt, @Var{a}@Var{b}@Var{c}@Var{d}@dots{}}
7154 @cindex @code{\!}, and @code{trnt}
7155 @code{trnt} is the same as the @code{tr} request except that the
7156 translations do not apply to text that is transparently throughput
7157 into a diversion with @code{\!}. @xref{Diversions}, for more
7171 prints @samp{b} to the standard error stream; if @code{trnt} is used
7172 instead of @code{tr} it prints @samp{a}.
7176 @c =====================================================================
7178 @node Troff and Nroff Mode, Line Layout, Character Translations, gtroff Reference
7179 @section Troff and Nroff Mode
7185 Originally, @code{nroff} and @code{troff} were two separate programs,
7186 the former for TTY output, the latter for everything else. With GNU
7187 @code{troff}, both programs are merged into one executable, sending
7188 its output to a device driver (@code{grotty} for TTY devices,
7189 @code{grops} for @sc{PostScript}, etc.) which interprets the
7190 intermediate output of @code{gtroff}. For @acronym{UNIX} @code{troff}
7191 it makes sense to talk about @dfn{Nroff mode} and @dfn{Troff mode}
7192 since the differences are hardcoded. For GNU @code{troff}, this
7193 distinction is not appropriate because @code{gtroff} simply takes the
7194 information given in the font files for a particular device without
7195 handling requests specially if a TTY output device is used.
7197 Usually, a macro package can be used with all output devices.
7198 Nevertheless, it is sometimes necessary to make a distinction between
7199 TTY and non-TTY devices: @code{gtroff} provides two built-in
7200 conditions @samp{n} and @samp{t} for the @code{if}, @code{ie}, and
7201 @code{while} requests to decide whether @code{gtroff} shall behave
7202 like @code{nroff} or like @code{troff}.
7207 Make the @samp{t} built-in condition true (and the @samp{n} built-in
7208 condition false) for @code{if}, @code{ie}, and @code{while}
7209 conditional requests. This is the default if @code{gtroff}
7210 (@emph{not} @code{groff}) is started with the @option{-R} switch to
7211 avoid loading of the start-up files @file{troffrc} and
7212 @file{troffrc-end}. Without @option{-R}, @code{gtroff} stays in troff
7213 mode if the output device is not a TTY (e.g.@: `ps').
7218 Make the @samp{n} built-in condition true (and the @samp{t} built-in
7219 condition false) for @code{if}, @code{ie}, and @code{while}
7220 conditional requests. This is the default if @code{gtroff} uses a TTY
7221 output device; the code for switching to nroff mode is in the file
7222 @file{tty.tmac} which is loaded by the start-up file @code{troffrc}.
7225 @xref{Conditionals and Loops}, for more details on built-in
7229 @c =====================================================================
7231 @node Line Layout, Line Control, Troff and Nroff Mode, gtroff Reference
7232 @section Line Layout
7234 @cindex layout, line
7236 @cindex dimensions, line
7237 @cindex line dimensions
7238 The following drawing shows the dimensions which @code{gtroff} uses for
7239 placing a line of output onto the page. They are labeled with the
7240 request which manipulates each dimension.
7244 |<-----------ll------------>|
7245 +----+----+----------------------+----+
7247 +----+----+----------------------+----+
7249 |<--------paper width---------------->|
7253 These dimensions are:
7257 @cindex left margin (@code{po})
7258 @cindex margin, left (@code{po})
7259 @cindex page offset (@code{po})
7260 @cindex offset, page (@code{po})
7261 @dfn{Page offset} -- this is the leftmost position of text on the final
7262 output, defining the @dfn{left margin}.
7265 @cindex indentation (@code{in})
7266 @cindex line indentation (@code{in})
7267 @dfn{Indentation} -- this is the distance from the left margin where
7271 @cindex line length (@code{ll})
7272 @cindex length of line (@code{ll})
7273 @dfn{Line length} -- this is the distance from the left margin to right
7277 A simple demonstration:
7281 This is text without indentation.
7282 The line length has been set to 3\~inch.
7285 Now the left and right margins are both increased.
7288 Calling .in and .ll without parameters restore
7289 the previous values.
7295 This is text without indenta-
7296 tion. The line length has
7301 Calling .in and .ll without
7302 parameters restore the previ-
7306 @DefreqList {po, [@Var{offset}]}
7307 @DefreqItem {po, @t{+}@Var{offset}}
7308 @DefreqItem {po, @t{-}@Var{offset}}
7311 Set horizontal page offset to @var{offset} (or increment or decrement
7312 the current value by @var{offset}). Note that this request does not
7313 cause a break, so changing the page offset in the middle of text being
7314 filled may not yield the expected result. The initial value is
7315 1@dmn{i}. For TTY output devices, it is set to 0 in the startup file
7316 @file{troffrc}; the default scaling indicator is @samp{m} (and
7317 not @samp{v} as incorrectly documented in the original
7318 @acronym{UNIX} troff manual).
7320 The current page offset can be found in the read-only number register
7323 If @code{po} is called without an argument, the page offset is reset to
7324 the previous value before the last call to @code{po}.
7339 @DefreqList {in, [@Var{indent}]}
7340 @DefreqItem {in, @t{+}@Var{indent}}
7341 @DefreqItem {in, @t{-}@Var{indent}}
7343 Set indentation to @var{indent} (or increment or decrement the
7344 current value by @var{indent}). This request causes a break.
7345 Initially, there is no indentation.
7347 If @code{in} is called without an argument, the indentation is reset to
7348 the previous value before the last call to @code{in}. The default
7349 scaling indicator is @samp{m}.
7351 The indentation is associated with the current environment
7352 (@pxref{Environments}).
7354 If a negative indentation value is specified (which is not allowed),
7355 @code{gtroff} emits a warning of type @samp{range} and sets the
7356 indentation to zero.
7358 The effect of @code{in} is delayed until a partially collected line (if
7359 it exists) is output. A temporary indent value is reset to zero also.
7361 The current indentation (as set by @code{in}) can be found in the
7362 read-only number register @samp{.i}.
7365 @DefreqList {ti, offset}
7366 @DefreqItem {ti, @t{+}@Var{offset}}
7367 @DefreqItem {ti, @t{-}@Var{offset}}
7368 @DefregListEnd {.in}
7369 Temporarily indent the next output line by @var{offset}. If an
7370 increment or decrement value is specified, adjust the temporary
7371 indentation relative to the value set by the @code{in} request.
7373 This request causes a break; its value is associated with the current
7374 environment (@pxref{Environments}). The default scaling indicator
7375 is @samp{m}. A call of @code{ti} without an argument is ignored.
7377 If the total indentation value is negative (which is not allowed),
7378 @code{gtroff} emits a warning of type @samp{range} and sets the
7379 temporary indentation to zero. `Total indentation' is either
7380 @var{offset} if specified as an absolute value, or the temporary plus
7381 normal indentation, if @var{offset} is given as a relative value.
7383 The effect of @code{ti} is delayed until a partially collected line (if
7384 it exists) is output.
7386 The read-only number register @code{.in} is the indentation that applies
7387 to the current output line.
7389 The difference between @code{.i} and @code{.in} is that the latter takes
7390 into account whether a partially collected line still uses the old
7391 indentation value or a temporary indentation value is active.
7394 @DefreqList {ll, [@Var{length}]}
7395 @DefreqItem {ll, @t{+}@Var{length}}
7396 @DefreqItem {ll, @t{-}@Var{length}}
7398 @DefregListEnd {.ll}
7399 Set the line length to @var{length} (or increment or decrement the
7400 current value by @var{length}). Initially, the line length is set to
7401 6.5@dmn{i}. The effect of @code{ll} is delayed until a partially
7402 collected line (if it exists) is output. The default scaling
7403 indicator is @samp{m}.
7405 If @code{ll} is called without an argument, the line length is reset to
7406 the previous value before the last call to @code{ll}. If a negative
7407 line length is specified (which is not allowed), @code{gtroff} emits a
7408 warning of type @samp{range} and sets the line length to zero.
7410 The line length is associated with the current environment
7411 (@pxref{Environments}).
7413 @cindex line length register (@code{.l})
7414 The current line length (as set by @code{ll}) can be found in the
7415 read-only number register @samp{.l}. The read-only number register
7416 @code{.ll} is the line length that applies to the current output line.
7418 Similar to @code{.i} and @code{.in}, the difference between @code{.l}
7419 and @code{.ll} is that the latter takes into account whether a partially
7420 collected line still uses the old line length value.
7424 @c =====================================================================
7426 @node Line Control, Page Layout, Line Layout, gtroff Reference
7427 @section Line Control
7428 @cindex line control
7429 @cindex control, line
7431 It is important to understand how @code{gtroff} handles input and output
7434 Many escapes use positioning relative to the input line. For example,
7438 This is a \h'|1.2i'test.
7453 The main usage of this feature is to define macros which act exactly
7454 at the place where called.
7457 .\" A simple macro to underline a word
7459 . nop \\$1\l'|0\[ul]'
7464 In the above example, @samp{|0} specifies a negative distance from the
7465 current position (at the end of the just emitted argument @code{\$1}) back
7466 to the beginning of the input line. Thus, the @samp{\l} escape draws a
7467 line from right to left.
7469 @cindex input line continuation (@code{\})
7470 @cindex line, input, continuation (@code{\})
7471 @cindex continuation, input line (@code{\})
7472 @cindex output line, continuation (@code{\c})
7473 @cindex line, output, continuation (@code{\c})
7474 @cindex continuation, output line (@code{\c})
7475 @cindex interrupted line
7476 @cindex line, interrupted
7477 @code{gtroff} makes a difference between input and output line
7478 continuation; the latter is also called @dfn{interrupting} a line.
7480 @DefescList {\\@key{RET}, , ,}
7481 @DefescItem {\\c, , ,}
7482 @DefregListEnd{.int}
7483 Continue a line. @code{\@key{RET}} (this is a backslash at the end
7484 of a line immediately followed by a newline) works on the input level,
7485 suppressing the effects of the following newline in the input.
7490 @result{} This is a .test
7493 The @samp{|} operator is also affected.
7495 @cindex @code{\R}, after @code{\c}
7496 @code{\c} works on the output level. Anything after this escape on the
7497 same line is ignored, except @code{\R} which works as usual. Anything
7498 before @code{\c} on the same line will be appended to the current partial
7499 output line. The next non-command line after an interrupted line counts
7500 as a new input line.
7502 The visual results depend on whether no-fill mode is active.
7506 @cindex @code{\c}, and no-fill mode
7507 @cindex no-fill mode, and @code{\c}
7508 @cindex mode, no-fill, and @code{\c}
7509 If no-fill mode is active (using the @code{nf} request), the next input
7510 text line after @code{\c} will be handled as a continuation of the same
7517 @result{} This is a test.
7521 @cindex @code{\c}, and fill mode
7522 @cindex fill mode, and @code{\c}
7523 @cindex mode, fill, and @code{\c}
7524 If fill mode is active (using the @code{fi} request), a word interrupted
7525 with @code{\c} will be continued with the text on the next input text line,
7526 without an intervening space.
7531 @result{} This is a test.
7535 Note that an intervening control line which causes a break is stronger
7536 than @code{\c}, flushing out the current partial line in the usual way.
7538 @cindex interrupted line register (@code{.int})
7539 The @code{.int} register contains a positive value
7540 if the last output line was interrupted with @code{\c}; this is
7541 associated with the current environment (@pxref{Environments}).
7545 @c =====================================================================
7547 @node Page Layout, Page Control, Line Control, gtroff Reference
7548 @section Page Layout
7550 @cindex layout, page
7552 @code{gtroff} provides some very primitive operations for controlling
7555 @DefreqList {pl, [@Var{length}]}
7556 @DefreqItem {pl, @t{+}@Var{length}}
7557 @DefreqItem {pl, @t{-}@Var{length}}
7559 @cindex page length (@code{pl})
7560 @cindex length of page (@code{pl})
7561 Set the @dfn{page length} to @var{length} (or increment or decrement
7562 the current value by @var{length}). This is the length of the
7563 physical output page. The default scaling indicator is @samp{v}.
7565 @cindex page length register (@code{.p})
7566 The current setting can be found in the read-only number register
7571 @cindex bottom margin
7572 @cindex margin, bottom
7573 Note that this only specifies the size of the page, not the top and
7574 bottom margins. Those are not set by @code{gtroff} directly.
7575 @xref{Traps}, for further information on how to do this.
7577 Negative @code{pl} values are possible also, but not very useful: No
7578 trap is sprung, and each line is output on a single page (thus
7579 suppressing all vertical spacing).
7581 If no argument or an invalid argument is given, @code{pl} sets the page
7582 length to 11@dmn{i}.
7588 @code{gtroff} provides several operations which help in setting up top
7589 and bottom titles (or headers and footers).
7591 @Defreq {tl, @t{'}@Var{left}@t{'}@Var{center}@t{'}@Var{right}@t{'}}
7592 @cindex title line (@code{tl})
7593 @cindex three-part title (@code{tl})
7594 @cindex page number character (@code{%})
7595 Print a @dfn{title line}. It consists of three parts: a left
7596 justified portion, a centered portion, and a right justified portion.
7597 The argument separator @samp{'} can be replaced with any character not
7598 occurring in the title line. The @samp{%} character is replaced with
7599 the current page number. This character can be changed with the
7600 @code{pc} request (see below).
7602 Without argument, @code{tl} is ignored.
7608 A title line is not restricted to the top or bottom of a page.
7611 @code{tl} prints the title line immediately, ignoring a partially filled
7612 line (which stays untouched).
7615 It is not an error to omit closing delimiters. For example,
7616 @w{@samp{.tl /foo}} is equivalent to @w{@samp{.tl /foo///}}: It prints a
7617 title line with the left justified word @samp{foo}; the centered and
7618 right justfied parts are empty.
7621 Any modifications to the current environment within @code{tl} (e.g.@:
7622 changing the font or font size) are undone after processing @code{tl}.
7625 @code{tl} accepts the same parameter delimiting characters as the
7626 @code{\A} escape; see @ref{Escapes}.
7630 @DefreqList {lt, [@Var{length}]}
7631 @DefreqItem {lt, @t{+}@Var{length}}
7632 @DefreqItem {lt, @t{-}@Var{length}}
7633 @DefregListEnd {.lt}
7634 @cindex length of title line (@code{lt})
7635 @cindex title line, length (@code{lt})
7636 @cindex title line length register (@code{.lt})
7637 The title line is printed using its own line length, which is
7638 specified (or incremented or decremented) with the @code{lt} request.
7639 Initially, the title line length is set to 6.5@dmn{i}. If a negative
7640 line length is specified (which is not allowed), @code{gtroff} emits a
7641 warning of type @samp{range} and sets the title line length to zero.
7642 The default scaling indicator is @samp{m}. If @code{lt} is called
7643 without an argument, the title length is reset to the previous value
7644 before the last call to @code{lt}.
7646 The current setting of this is available in the @code{.lt} read-only
7647 number register; it is associated with the current environment
7648 (@pxref{Environments}).
7652 @DefreqList {pn, page}
7653 @DefreqItem {pn, @t{+}@Var{page}}
7654 @DefreqItem {pn, @t{-}@Var{page}}
7655 @DefregListEnd {.pn}
7656 @cindex page number (@code{pn})
7657 @cindex number, page (@code{pn})
7658 Change (increase or decrease) the page number of the @emph{next} page.
7659 The only argument is the page number; the request is ignored without a
7662 The read-only number register @code{.pn} contains the number of the next
7663 page: either the value set by a @code{pn} request, or the number of the
7664 current page plus@w{ }1.
7668 @cindex page number register (@code{%})
7669 A read-write register holding the current page number.
7672 @Defreq {pc, [@Var{char}]}
7673 @cindex changing the page number character (@code{pc})
7674 @cindex page number character, changing (@code{pc})
7676 Change the page number character (used by the @code{tl} request) to a
7677 different character. With no argument, this mechanism is disabled.
7678 Note that this doesn't affect the number register@w{ }@code{%}.
7684 @c =====================================================================
7686 @node Page Control, Fonts, Page Layout, gtroff Reference
7687 @section Page Control
7688 @cindex page control
7689 @cindex control, page
7691 @DefreqList {bp, [@Var{page}]}
7692 @DefreqItem {bp, @t{+}@Var{page}}
7693 @DefreqListEnd {bp, @t{-}@Var{page}}
7694 @cindex new page (@code{bp})
7695 @cindex page, new (@code{bp})
7696 Stop processing the current page and move to the next page. This
7697 request causes a break. It can also take an argument to set
7698 (increase, decrease) the page number of the next page. The only
7699 difference between @code{bp} and @code{pn} is that @code{pn} does not
7700 cause a break or actually eject a page.
7703 .de newpage \" define macro
7705 'sp .5i \" vertical space
7706 .tl 'left top'center top'right top' \" title
7707 'sp .3i \" vertical space
7711 @cindex @code{bp} request, and top-level diversion
7712 @cindex top-level diversion, and @code{bp}
7713 @cindex diversion, top-level, and @code{bp}
7714 @code{bp} has no effect if not called within the top-level diversion
7715 (@pxref{Diversions}).
7718 @Defreq {ne, [@Var{space}]}
7719 @cindex orphan lines, preventing with @code{ne}
7720 @cindex conditional page break (@code{ne})
7721 @cindex page break, conditional (@code{ne})
7722 It is often necessary to force a certain amount of space before a new
7723 page occurs. This is most useful to make sure that there is not a
7724 single @dfn{orphan} line left at the bottom of a page. The @code{ne}
7725 request ensures that there is a certain distance, specified by the
7726 first argument, before the next page is triggered (see @ref{Traps},
7727 for further information). The default scaling indicator for @code{ne}
7728 is @samp{v}; the default value of @var{space} is@w{ }1@dmn{v} if no
7731 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
7732 do the following before each paragraph:
7739 @code{ne} will then automatically cause a page break if there is space
7743 @DefreqList {sv, [@Var{space}]}
7744 @DefreqListEnd {os, }
7745 @cindex @code{ne} request, comparison with @code{sv}
7746 @code{sv} is similar to the @code{ne} request; it reserves the
7747 specified amount of vertical space. If the desired amount of space
7748 exists before the next trap (or the bottom page boundary if no trap is
7749 set), the space is output immediately (ignoring a partially filled line
7750 which stays untouched). If there is not enough space, it is stored for
7751 later output via the @code{os} request. The default value is@w{ }1@dmn{v}
7752 if no argument is given; the default scaling indicator is @samp{v}.
7754 @cindex @code{sv} request, and no-space mode
7755 @cindex @code{os} request, and no-space mode
7756 Both @code{sv} and @code{os} ignore no-space mode. While the @code{sv}
7757 request allows negative values for @var{space}, @code{os} will ignore
7762 This register contains the current vertical position. If the vertical
7763 position is zero and the top of page transition hasn't happened yet,
7764 @code{nl} is set to negative value. @code{gtroff} itself does this at
7765 the very beginning of a document before anything has been printed, but
7766 the main usage is to plant a header trap on a page if this page has
7769 Consider the following:
7801 Without resetting @code{nl} to a negative value, the just planted trap
7802 would be active beginning with the @emph{next} page, not the current
7805 @xref{Diversions}, for a comparison with the @code{.h} and @code{.d}
7809 @c =====================================================================
7811 @node Fonts, Sizes, Page Control, gtroff Reference
7815 @code{gtroff} can switch fonts at any point in the text.
7817 The basic set of fonts is @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7818 These are Times Roman, Italic, Bold, and Bold Italic. For non-TTY
7819 devices, there is also at least one symbol font which contains various
7820 special symbols (Greek, mathematics).
7828 * Artificial Fonts::
7829 * Ligatures and Kerning::
7832 @c ---------------------------------------------------------------------
7834 @node Changing Fonts, Font Families, Fonts, Fonts
7835 @subsection Changing Fonts
7838 @DefreqList {ft, [@Var{font}]}
7839 @DefescItem {\\f, , f, }
7840 @DefescItem {\\f, @lparen{}, fn, }
7841 @DefescListEnd {\\f, @lbrack{}, font, @rbrack}
7842 @cindex changing fonts (@code{ft}, @code{\f})
7843 @cindex fonts, changing (@code{ft}, @code{\f})
7844 @cindex @code{sty} request, and changing fonts
7845 @cindex @code{fam} request, and changing fonts
7846 @cindex @code{\F}, and changing fonts
7850 The @code{ft} request and the @code{\f} escape change the current font
7851 to @var{font} (one-character name@w{ }@var{f}, two-character name
7854 If @var{font} is a style name (as set with the @code{sty} request or
7855 with the @code{styles} command in the @file{DESC} file), use it within
7856 the current font family (as set with the @code{fam} request, @code{\F}
7857 escape, or with the @code{family} command in the @file{DESC} file).
7859 @cindex previous font (@code{ft}, @code{\f[]}, @code{\fP})
7860 @cindex font, previous (@code{ft}, @code{\f[]}, @code{\fP})
7861 With no argument or using @samp{P} as an argument, @code{.ft} switches
7862 to the previous font. Use @code{\f[]} to do this with the escape. The
7863 old syntax forms @code{\fP} or @code{\f[P]} are also supported.
7865 Fonts are generally specified as upper-case strings, which are usually
7866 1@w{ }to 4 characters representing an abbreviation or acronym of the
7867 font name. This is no limitation, just a convention.
7869 The example below produces two identical lines.
7878 eggs, bacon, \fBspam\fP and sausage.
7881 Note that @code{\f} doesn't produce an input token in @code{gtroff}.
7882 As a consequence, it can be used in requests like @code{mc} (which
7883 expects a single character as an argument) to change the font on
7890 @xref{Font Positions}, for an alternative syntax.
7893 @Defreq {ftr, f [@Var{g}]}
7894 @cindex @code{ft} request, and font translations
7895 @cindex @code{ul} request, and font translations
7896 @cindex @code{bd} request, and font translations
7897 @cindex @code{\f}, and font translations
7898 @cindex @code{cs} request, and font translations
7899 @cindex @code{tkf} request, and font translations
7900 @cindex @code{special} request, and font translations
7901 @cindex @code{fspecial} request, and font translations
7902 @cindex @code{fp} request, and font translations
7903 @cindex @code{sty} request, and font translations
7904 Translate font@w{ }@var{f} to font@w{ }@var{g}. Whenever a font named@w{
7905 }@var{f} is referred to in a @code{\f} escape sequence, or in the
7906 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf},
7907 @code{special}, @code{fspecial}, @code{fp}, or @code{sty} requests,
7908 font@w{ }@var{g} is used. If @var{g} is missing or equal to@w{ }@var{f}
7909 the translation is undone.
7912 @c ---------------------------------------------------------------------
7914 @node Font Families, Font Positions, Changing Fonts, Fonts
7915 @subsection Font Families
7916 @cindex font families
7917 @cindex families, font
7919 @cindex styles, font
7921 Due to the variety of fonts available, @code{gtroff} has added the
7922 concept of @dfn{font families} and @dfn{font styles}. The fonts are
7923 specified as the concatenation of the font family and style. Specifying
7924 a font without the family part causes @code{gtroff} to use that style of
7927 @cindex PostScript fonts
7928 @cindex fonts, PostScript
7929 Currently, fonts for the devices @option{-Tps}, @option{-Tdvi}, and
7930 @option{-Tlbp} are set up to this mechanism.
7931 By default, @code{gtroff} uses the Times family with the four styles
7932 @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
7934 This way, it is possible to use the basic four fonts and to select a
7935 different font family on the command line (@pxref{Groff Options}).
7937 @DefreqList {fam, [@Var{family}]}
7939 @DefescItem {\\F, , f, }
7940 @DefescItem {\\F, @lparen{}, fm, }
7941 @DefescItem {\\F, @lbrack{}, family, @rbrack}
7942 @DefregListEnd {.fn}
7943 @cindex changing font family (@code{fam}, @code{\F})
7944 @cindex font family, changing (@code{fam}, @code{\F})
7945 Switch font family to @var{family} (one-character name@w{ }@var{f},
7946 two-character name @var{fm}). If no argument is given, switch
7947 back to the previous font family. Use @code{\F[]} to do this with the
7948 escape. Note that @code{\FP} doesn't work; it selects font family
7951 The value at start-up is @samp{T}.
7952 The current font family is available in the read-only number register
7953 @samp{.fam} (this is a string-valued register); it is associated with
7954 the current environment.
7958 .fam H \" helvetica family
7959 spam, \" used font is family H + style R = HR
7960 .ft B \" family H + style B = font HB
7962 .fam T \" times family
7963 spam, \" used font is family T + style B = TB
7964 .ft AR \" font AR (not a style)
7966 .ft R \" family T + style R = font TR
7970 Note that @code{\F} doesn't produce an input token in @code{gtroff}.
7971 As a consequence, it can be used in requests like @code{mc} (which
7972 expects a single character as an argument) to change the font family on
7979 The @samp{.fn} register contains the current @dfn{real font name}
7980 of the current font.
7981 This is a string-valued register.
7982 If the current font is a style, the value of @code{\n[.fn]}
7983 is the proper concatenation of family and style name.
7986 @Defreq {sty, n style}
7987 @cindex changing font style (@code{sty})
7988 @cindex font style, changing (@code{sty})
7989 @cindex @code{cs} request, and font styles
7990 @cindex @code{bd} request, and font styles
7991 @cindex @code{tkf} request, and font styles
7992 @cindex @code{uf} request, and font styles
7993 @cindex @code{fspecial} request, and font styles
7994 Associate @var{style} with font position@w{ }@var{n}. A font position
7995 can be associated either with a font or with a style. The current
7996 font is the index of a font position and so is also either a font or a
7997 style. If it is a style, the font that is actually used is the font
7998 which name is the concatenation of the name of the current
7999 family and the name of the current style. For example, if the current
8000 font is@w{ }1 and font position@w{ }1 is associated with style
8001 @samp{R} and the current font family is @samp{T}, then font
8002 @samp{TR} will be used. If the current font is not a style, then the
8003 current family is ignored. If the requests @code{cs}, @code{bd},
8004 @code{tkf}, @code{uf}, or @code{fspecial} are applied to a style,
8005 they will instead be applied to the member of the current family
8006 corresponding to that style.
8008 @var{n}@w{ }must be a non-negative integer value.
8012 The default family can be set with the @option{-f} option
8013 (@pxref{Groff Options}). The @code{styles} command in the @file{DESC}
8014 file controls which font positions (if any) are initially associated
8015 with styles rather than fonts. For example, the default setting for
8016 @sc{PostScript} fonts
8032 @code{fam} and @code{\F} always check whether the current font position
8033 is valid; this can give surprising results if the current font position is
8034 associated with a style.
8036 In the following example, we want to access the @sc{PostScript} font
8037 @code{FooBar} from the font family @code{Foo}:
8042 @result{} warning: can't find font `FooR'
8046 The default font position at start-up is@w{ }1; for the
8047 @sc{PostScript} device, this is associated with style @samp{R}, so
8048 @code{gtroff} tries to open @code{FooR}.
8050 A solution to this problem is to use a dummy font like the following:
8053 .fp 0 dummy TR \" set up dummy font at position 0
8054 .sty \n[.fp] Bar \" register style `Bar'
8055 .ft 0 \" switch to font at position 0
8056 .fam Foo \" activate family `Foo'
8057 .ft Bar \" switch to font `FooBar'
8060 @xref{Font Positions}.
8063 @c ---------------------------------------------------------------------
8065 @node Font Positions, Using Symbols, Font Families, Fonts
8066 @subsection Font Positions
8067 @cindex font positions
8068 @cindex positions, font
8070 For the sake of old phototypesetters and compatibility with old versions
8071 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
8072 on which various fonts are mounted.
8074 @DefreqList {fp, pos font [@Var{external-name}]}
8076 @DefregListEnd {.fp}
8077 @cindex mounting font (@code{fp})
8078 @cindex font, mounting (@code{fp})
8079 Mount font @var{font} at position @var{pos} (which must be a
8080 non-negative integer). This numeric position can then be referred to
8081 with font changing commands. When @code{gtroff} starts it is using
8082 font position@w{ }1 (which must exist; position@w{ }0 is unused
8083 usually at start-up).
8085 @cindex font position register (@code{.f})
8086 The current font in use, as a font position, is available in the
8087 read-only number register @samp{.f}. This can be useful to remember the
8088 current font for later recall. It is associated with the current
8089 environment (@pxref{Environments}).
8092 .nr save-font \n[.f]
8094 ... text text text ...
8098 @cindex next free font position register (@code{.fp})
8099 The number of the next free font position is available in the read-only
8100 number register @samp{.fp}. This is useful when mounting a new font,
8104 .fp \n[.fp] NEATOFONT
8107 @pindex DESC@r{, and font mounting}
8108 Fonts not listed in the @file{DESC} file are automatically mounted on
8109 the next available font position when they are referenced. If a font
8110 is to be mounted explicitly with the @code{fp} request on an unused
8111 font position, it should be mounted on the first unused font position,
8112 which can be found in the @code{.fp} register. Although @code{gtroff}
8113 does not enforce this strictly, it is not allowed to mount a font at a
8114 position whose number is much greater (approx.@: 1000 positions) than
8115 that of any currently used position.
8117 The @code{fp} request has an optional third argument. This argument
8118 gives the external name of the font, which is used for finding the font
8119 description file. The second argument gives the internal name of the
8120 font which is used to refer to the font in @code{gtroff} after it has
8121 been mounted. If there is no third argument then the internal name is
8122 used as the external name. This feature makes it possible to use
8123 fonts with long names in compatibility mode.
8126 Both the @code{ft} request and the @code{\f} escape have alternative
8127 syntax forms to access font positions.
8129 @DefreqList {ft, nnn}
8130 @DefescItem {\\f, , n, }
8131 @DefescItem {\\f, @lparen{}, nn, }
8132 @DefescListEnd {\\f, @lbrack{}, nnn, @rbrack}
8133 @cindex changing font position (@code{\f})
8134 @cindex font position, changing (@code{\f})
8135 @cindex @code{sty} request, and font positions
8136 @cindex @code{fam} request, and font positions
8137 @cindex @code{\F}, and font positions
8141 Change the current font position to @var{nnn} (one-digit position@w{
8142 }@var{n}, two-digit position @var{nn}), which must be a non-negative
8145 If @var{nnn} is associated with a style (as set with the @code{sty}
8146 request or with the @code{styles} command in the @file{DESC} file), use
8147 it within the current font family (as set with the @code{fam} request,
8148 the @code{\F} escape, or with the @code{family} command in the @file{DESC}
8155 .ft \" switch back to font 1
8159 this is font 1 again
8162 @xref{Changing Fonts}, for the standard syntax form.
8165 @c ---------------------------------------------------------------------
8167 @node Using Symbols, Special Fonts, Font Positions, Fonts
8168 @subsection Using Symbols
8169 @cindex using symbols
8170 @cindex symbols, using
8175 A @dfn{glyph} is a graphical representation of a @dfn{character}.
8176 While a character is an abstract entity containing semantic
8177 information, a glyph is something which can be actually seen on screen
8178 or paper. It is possible that a character has multiple glyph
8179 representation forms (for example, the character `A' can be either
8180 written in a roman or an italic font, yielding two different glyphs);
8181 sometimes more than one character maps to a single glyph (this is a
8182 @dfn{ligature} -- the most common is `fi').
8186 Please note that currently the distinction between glyphs and
8187 characters in this reference is not clearly carried out. This will be
8188 improved eventually in the next revision.
8191 @cindex special fonts
8194 A @dfn{symbol} is simply a named glyph. Within @code{gtroff}, all
8195 glyph names of a particular font are defined in its font file. If the
8196 user requests a glyph not available in this font, @code{gtroff} looks
8197 up an ordered list of @dfn{special fonts}. By default, the
8198 @sc{PostScript} output device supports the two special fonts @samp{SS}
8199 (slanted symbols) and @samp{S} (symbols) (the former is looked up
8200 before the latter). Other output devices use different names for
8201 special fonts. Fonts mounted with the @code{fonts} keyword in the
8202 @file{DESC} file are globally available. To install additional
8203 special fonts locally (i.e.@: for a particular font), use the
8204 @code{fspecial} request.
8206 In summary, @code{gtroff} tries the following to find a given symbol:
8210 If the symbol has been defined with the @code{char} request, use it.
8211 This hides a symbol with the same name in the current font.
8214 Check the current font.
8217 If the symbol has been defined with the @code{fchar} request, use it.
8220 Check all fonts given with the @code{fspecial} request, in the order
8221 of appearance in @code{fspecial} calls.
8224 Check all fonts given with the @code{special} request, in the order
8225 of appearance in @code{special} calls (inclusively the special fonts
8226 defined in the @file{DESC} file, which come first).
8229 As a last resort, consult all fonts loaded up to now (in the order they
8230 have been called the first time) for special fonts and check them.
8233 @xref{Font Files}, and @ref{Special Fonts}, for more details.
8235 @DefescList {\\, @lparen{}, nm, }
8236 @DefescListEnd {\\, @lbrack{}, name, @rbrack}
8237 Insert a symbol @var{name} (two-character name @var{nm}). There is no
8238 special syntax for one-character names -- the natural form
8239 @samp{\@var{n}} would collide with escapes.@footnote{Note that a
8240 one-character symbol is not the same as an input character, i.e., the
8241 character @code{a} is not the same as @code{\[a]}. By default,
8242 @code{groff} defines only a single one-character symbol, @code{\[-]};
8243 it is usually accessed as @code{\-}. On the other hand, @code{gtroff}
8244 has the special feature that @code{\[char@var{XXX}]} is the same as the
8245 input character with character code @var{XXX}. For example,
8246 @code{\[char97]} is identical to the letter @code{a} if @acronym{ASCII}
8247 encoding is active.}
8249 If @var{name} is undefined, a warning of type @samp{char} is generated,
8250 and the escape is ignored. @xref{Debugging}, for information about
8253 @cindex list of available glyphs (@cite{groff_char(7)} man page)
8254 @cindex available glyphs, list (@cite{groff_char(7)} man page)
8255 @cindex glyphs, available, list (@cite{groff_char(7)} man page)
8256 The list of available symbols is device dependent; see the
8257 @cite{groff_char(7)} man page for a complete list for the given output
8258 device. For example, say
8261 man -Tdvi groff_char > groff_char.dvi
8265 for a list using the default DVI fonts (not all versions of the
8266 @code{man} program support the @option{-T} option). If you want to
8267 use an additional macro package to change the used fonts, @code{groff}
8268 must be called directly:
8271 groff -Tdvi -mec -man groff_char.7 > groff_char.dvi
8274 @c XXX list of common symbols
8277 @Defesc {\\C, ', xxx, '}
8278 @cindex named character (@code{\C})
8279 @cindex character, named (@code{\C})
8280 Typeset the character named @var{xxx}. Normally it is more convenient
8281 to use @code{\[@var{xxx}]}, but @code{\C} has the advantage that it is
8282 compatible with newer versions of @code{ditroff} and is available in
8286 @Defesc {\\N, ', n, '}
8287 @cindex numbered character (@code{\N})
8288 @cindex character, numbered (@code{\N})
8289 @cindex @code{char} request, used with @code{\N}
8291 Typeset the character with code@w{ }@var{n} in the current font (this
8292 is @strong{not} the input character code). @var{n}@w{ }can be any
8293 integer. Most devices only have characters with codes between 0
8294 and@w{ }255; the Unicode output device uses codes in the range
8295 0--65535. If the current font does not contain a character with that
8296 code, special fonts are @emph{not} searched. The @code{\N} escape
8297 sequence can be conveniently used in conjunction with the @code{char}
8301 .char \[phone] \f[ZD]\N'37'
8306 @cindex unnamed characters
8307 @cindex characters, unnamed
8308 The code of each character is given in the fourth column in the font
8309 description file after the @code{charset} command. It is possible to
8310 include unnamed characters in the font description file by using a
8311 name of @samp{---}; the @code{\N} escape sequence is the only way to
8315 Some escape sequences directly map onto special glyphs.
8318 This is a backslash followed by the apostrophe character, @acronym{ASCII}
8319 character @code{0x27} (@acronym{EBCDIC} character @code{0x7D}). The same
8320 as @code{\[aa]}, the acute accent.
8324 This is a backslash followed by @acronym{ASCII} character @code{0x60}
8325 (@acronym{EBCDIC} character @code{0x79} usually). The same as
8326 @code{\[ga]}, the grave accent.
8330 This is the same as @code{\[-]}, the minus sign in the current font.
8333 @c XXX should be `glyph', not `character'
8335 @Defreq {cflags, n c1 c2 @dots{}}
8336 @cindex character properties (@code{cflags})
8337 @cindex properties of characters (@code{cflags})
8338 Each character has certain properties associated with it. These
8339 properties can be modified with the @code{cflags} request. The first
8340 argument is the sum of the desired flags and the remaining
8341 arguments are the characters to have those properties. It is possible
8342 to omit the spaces between the characters.
8346 @cindex end-of-sentence characters
8347 @cindex characters, end-of-sentence
8348 the character ends sentences (initially characters @samp{.?!} have this
8352 @cindex hyphenating characters
8353 @cindex characters, hyphenation
8354 lines can be broken before the character (initially no characters have
8358 @cindex @code{hy} glyph, and @code{cflags}
8359 @cindex @code{em} glyph, and @code{cflags}
8360 lines can be broken after the character (initially the characters
8361 @samp{-\(hy\(em} have this property)
8364 @cindex overlapping characters
8365 @cindex characters, overlapping
8366 @cindex @code{ul} glyph, and @code{cflags}
8367 @cindex @code{rn} glyph, and @code{cflags}
8368 @cindex @code{ru} glyph, and @code{cflags}
8369 the character overlaps horizontally (initially the characters
8370 @samp{\(ul\(rn\(ru} have this property)
8373 @cindex @code{br} glyph, and @code{cflags}
8374 the character overlaps vertically (initially character @samp{\(br} has
8378 @cindex transparent characters
8379 @cindex character, transparent
8380 @cindex @code{"}, at end of sentence
8381 @cindex @code{'}, at end of sentence
8382 @cindex @code{)}, at end of sentence
8383 @cindex @code{]}, at end of sentence
8384 @cindex @code{*}, at end of sentence
8385 @cindex @code{dg} glyph, at end of sentence
8386 @cindex @code{rq} glyph, at end of sentence
8387 an end-of-sentence character followed by any number of characters with
8388 this property is treated as the end of a sentence if followed by a
8389 newline or two spaces; in other words the character is
8390 @dfn{transparent} for the purposes of end-of-sentence recognition --
8391 this is the same as having a zero space factor in @TeX{} (initially
8392 characters @samp{"')]*\(dg\(rq} have this property).
8396 @DefreqList {char, c [@Var{string}]}
8397 @DefreqListEnd {fchar, c [@Var{string}]}
8398 @cindex defining character (@code{char})
8399 @cindex character, defining (@code{char})
8400 @cindex creating new characters (@code{char})
8401 @cindex escape character, while defining character
8402 @cindex character, escape, while defining character
8403 @cindex @code{tr} request, and character definitions
8404 @cindex @code{cp} request, and character definitions
8405 @cindex @code{rc} request, and character definitions
8406 @cindex @code{lc} request, and character definitions
8407 @cindex @code{\l}, and character definitions
8408 @cindex @code{\L}, and character definitions
8409 @cindex @code{\&}, and character definitions
8410 @cindex @code{\e}, and character definitions
8411 @cindex @code{hcode} request, and character definitions
8412 Define a new character@w{ }@var{c} to be @var{string} (which can be
8413 empty). Every time character@w{ }@var{c} needs to be printed,
8414 @var{string} is processed in a temporary environment and the result is
8415 wrapped up into a single object. Compatibility mode is turned off and
8416 the escape character is set to @samp{\} while @var{string} is being
8417 processed. Any emboldening, constant spacing or track kerning is
8418 applied to this object rather than to individual characters in
8421 A character defined by this request can be used just
8422 like a normal character provided by the output device. In particular,
8423 other characters can be translated to it with the @code{tr} or
8424 @code{trin} requests; it can be made the leader character by the
8425 @code{lc} request; repeated patterns can be drawn with the character
8426 using the @code{\l} and @code{\L} escape sequences; words containing
8427 the character can be hyphenated correctly if the @code{hcode} request
8428 is used to give the character a hyphenation code.
8430 There is a special anti-recursion
8431 feature: Use of character within the character's definition is handled
8432 like normal characters not defined with @code{char}.
8434 Note that the @code{tr} and @code{trin} requests take precedence if
8435 @code{char} accesses the same character.
8449 The @code{fchar} request defines a fallback character:
8450 @code{gtroff} only checks for characters defined with @code{fchar}
8451 if it cannot find the glyph in the current font.
8452 @code{gtroff} carries out this test before checking special fonts.
8455 @Defreq {rchar, c1 c2 @dots{}}
8456 @cindex removing character definition (@code{rchar})
8457 @cindex character, removing definition (@code{rchar})
8458 Remove the definitions of characters @var{c1}, @var{c2},@w{
8459 }@enddots{} This undoes the effect of a @code{char} or @code{fchar}
8462 It is possible to omit the whitespace between arguments.
8465 @xref{Special Characters}.
8467 @c ---------------------------------------------------------------------
8469 @node Special Fonts, Artificial Fonts, Using Symbols, Fonts
8470 @subsection Special Fonts
8471 @cindex special fonts
8472 @cindex fonts, special
8474 Special fonts are those that @code{gtroff} searches
8475 when it cannot find the requested character in the current font.
8476 The Symbol font is usually a special font.
8478 @code{gtroff} provides the following two requests to add more special
8479 fonts. @xref{Using Symbols}, for a detailed description of the glyph
8480 searching mechanism in @code{gtroff}.
8482 Usually, only non-TTY devices have special fonts.
8484 @DefreqList {special, s1 s2 @dots{}}
8485 @DefreqListEnd {fspecial, f s1 s2 @dots{}}
8488 Use the @code{special} request to define special fonts. They are
8489 appended to the list of global special fonts in the given order.
8490 The first entries in this list are the fonts defined with the
8491 @code{fonts} command in the @file{DESC} file which are marked as
8492 special in the corresponding font description files.
8494 Use the @code{fspecial} request to designate special fonts
8495 only when font@w{ }@var{f} font is active. They are appended to the
8496 list of special fonts for @var{f} in the given order. Initially, this
8500 @c ---------------------------------------------------------------------
8502 @node Artificial Fonts, Ligatures and Kerning, Special Fonts, Fonts
8503 @subsection Artificial Fonts
8504 @cindex artificial fonts
8505 @cindex fonts, artificial
8507 There are a number of requests and escapes for artificially creating
8508 fonts. These are largely vestiges of the days when output devices
8509 did not have a wide variety of fonts, and when @code{nroff} and
8510 @code{troff} were separate programs. Most of them are no longer
8511 necessary in GNU @code{troff}. Nevertheless, they are supported.
8513 @DefescList {\\H, ', height, '}
8514 @DefescItem {\\H, ', @t{+}@Var{height}, '}
8515 @DefescListEnd {\\H, ', @t{-}@Var{height}, '}
8516 @cindex changing the font height (@code{\H})
8517 @cindex font height, changing (@code{\H})
8518 @cindex height, font, changing (@code{\H})
8519 Change (increment, decrement) the height of the current font, but not
8520 the width. If @var{height} is zero, restore the original height.
8521 Default scaling indicator is @samp{z}.
8523 Currently, only the @option{-Tps} device supports this feature.
8525 Note that @code{\H} doesn't produce an input token in @code{gtroff}.
8526 As a consequence, it can be used in requests like @code{mc} (which
8527 expects a single character as an argument) to change the font on
8534 In compatibility mode, @code{gtroff} behaves differently: If an
8535 increment or decrement is used, it is always taken relative to the
8536 current point size and not relative to the previously selected font
8541 \H'+5'test \H'+5'test
8545 prints the word @samp{test} twice with the same font height (five
8546 points larger than the current font size).
8549 @DefescList {\\S, ', slant, '}
8550 @cindex changing the font slant (@code{\S})
8551 @cindex font slant, changing (@code{\S})
8552 @cindex slant, font, changing (@code{\S})
8553 Slant the current font by @var{slant} degrees. Positive values slant
8556 Currently, only the @option{-Tps} device supports this feature.
8558 Note that @code{\S} doesn't produce an input token in @code{gtroff}.
8559 As a consequence, it can be used in requests like @code{mc} (which
8560 expects a single character as an argument) to change the font on
8567 This request is incorrectly documented in the original @acronym{UNIX}
8568 troff manual; the slant is always set to an absolute value.
8571 @Defreq {ul, [@Var{lines}]}
8572 @cindex underlining (@code{ul})
8573 The @code{ul} request normally underlines subsequent lines if a TTY
8574 output device is used. Otherwise, the lines are printed in italics
8575 (only the term `underlined' is used in the following). The single
8576 argument is the number of input lines to be underlined; with no
8577 argument, the next line is underlined. If @var{lines} is zero or
8578 negative, stop the effects of @code{ul} (if it was active). Requests
8579 and empty lines do not count for computing the number of underlined
8580 input lines, even if they produce some output like @code{tl}. Lines
8581 inserted by macros (e.g.@: invoked by a trap) do count.
8583 At the beginning of @code{ul}, the current font is stored and the
8584 underline font is activated. Within the span of a @code{ul} request,
8585 it is possible to change fonts, but after the last line affected by
8586 @code{ul} the saved font is restored.
8588 This number of lines still to be underlined is associated with the
8589 current environment (@pxref{Environments}). The underline font can be
8590 changed with the @code{uf} request.
8592 @c XXX @xref should be changed to grotty
8594 @c @xref{Troff and Nroff Mode}, for a discussion how underlining is
8595 @c implemented in for TTY output devices, and which problems can arise.
8597 The @code{ul} request does not underline spaces.
8600 @Defreq {cu, [@Var{lines}]}
8601 @cindex continuous underlining (@code{cu})
8602 @cindex underlining, continuous (@code{cu})
8603 The @code{cu} request is similar to @code{ul} but underlines spaces as
8604 well (if a TTY output device is used).
8608 @cindex underline font (@code{uf})
8609 @cindex font for underlining (@code{uf})
8610 Set the underline font (globally) used by @code{ul} and @code{cu}. By
8611 default, this is the font at position@w{ }2. @var{font} can be either
8612 a non-negative font position or the name of a font.
8615 @DefreqList {bd, font [@Var{offset}]}
8616 @DefreqItem {bd, font1 font2 [@Var{offset}]}
8618 @cindex imitating bold face (@code{bd})
8619 @cindex bold face, imitating (@code{bd})
8620 Artificially create a bold font by printing each character twice,
8623 Two syntax forms are available.
8627 Imitate a bold font unconditionally. The first argument specifies the
8628 font to embolden, and the second is the number of basic units, minus
8629 one, by which the two characters is offset. If the second argument is
8630 missing, emboldening is turned off.
8632 @var{font} can be either a non-negative font position or the name of a
8635 @var{offset} is available in the @code{.b} read-only register if a
8636 special font is active; in the @code{bd} request, its default unit is
8639 @cindex @code{fspecial} request, and imitating bold
8641 @cindex embolding of special fonts
8642 @cindex special fonts, emboldening
8644 Imitate a bold form conditionally. Embolden @var{font1} by
8645 @var{offset} only if font @var{font2} is the current font. This
8646 command can be issued repeatedly to set up different emboldening
8647 values for different current fonts. If the second argument is
8648 missing, emboldening is turned off for this particular current font.
8650 This affects special fonts only (either set up with the @code{special}
8651 command in font files or with the @code{fspecial} request).
8655 @Defreq {cs, font [@Var{width} [@Var{em-size}]]}
8656 @cindex constant character space mode (@code{cs})
8657 @cindex mode for constant character space (@code{cs})
8658 @cindex character, constant space
8659 @cindex @code{ps} request, and constant character space mode
8660 Switch to and from constant character space mode. If activated, the
8661 width of every character is @math{@var{width}/36} ems. The em size is
8662 given absolutely by @var{em-size}; if this argument is missing, the em
8663 value is taken from the current font size (as set with the @code{ps}
8664 request) when the font is effectively in use. Without second and
8665 third argument, constant character space mode is deactivated.
8667 Default scaling indicator for @var{em-size} is @samp{z}; @var{width} is
8671 @c ---------------------------------------------------------------------
8673 @node Ligatures and Kerning, , Artificial Fonts, Fonts
8674 @subsection Ligatures and Kerning
8675 @cindex ligatures and kerning
8676 @cindex kerning and ligatures
8678 Ligatures are groups of characters that are run together. For
8679 example, the letters `f' and `i' can form a ligature `fi' as in the
8680 word `file'. This produces a cleaner look (albeit subtle) to the
8681 printed output. Usually, ligatures are not available in fonts for TTY
8684 Most @sc{PostScript} fonts support the fi and fl ligatures. The C/A/T
8685 typesetter that was the target of @acronym{AT&T} @code{troff} also
8686 supported `ff', `ffi', and `ffl' ligatures. Advanced typesetters or
8687 `expert' fonts may include ligatures for `ft' and `ct', although GNU
8688 @code{troff} does not support these (yet).
8690 @DefreqList {lg, [@Var{flag}]}
8691 @DefregListEnd {.lg}
8692 @cindex activating ligatures (@code{lg})
8693 @cindex ligatures, activating (@code{lg})
8694 @cindex ligatures enabled register (@code{.lg})
8695 Switch the ligature mechanism on or off; if the parameter is non-zero
8696 or missing, ligatures are enabled, otherwise disabled. Default is on.
8697 The current ligature mode can be found in the read-only number register
8698 @code{.lg} (set to 1 or@w{ }2 if ligatures are enabled, 0@w{ }otherwise).
8700 Setting the ligature mode to@w{ }2 enables the two-character ligatures
8701 (fi, fl, and ff) and disables the three-character ligatures (ffi and
8705 @dfn{Pairwise kerning} is another subtle typesetting mechanism that
8706 modifies the distance between a character pair to improve readability.
8707 In most cases (but not always) the distance is decreased.
8709 For example, compare the combination of the letters `V' and `A'. With
8710 kerning, `VA' is printed. Without kerning it appears as `V@w{}A'.
8712 Typewriter-like fonts and fonts for terminals where all characters
8713 have the same width don't use kerning.
8715 @DefreqList {kern, [@Var{flag}]}
8716 @DefregListEnd {.kern}
8717 @cindex activating kerning (@code{kern})
8718 @cindex kerning, activating (@code{kern})
8719 @cindex kerning enabled register (@code{.kern})
8720 Switch kerning on or off. If the parameter is non-zero or missing,
8721 enable pairwise kerning, otherwise disable it. The read-only number
8722 register @code{.kern} is set to@w{ }1 if pairwise kerning is enabled,
8725 @cindex zero width space character (@code{\&})
8726 @cindex character, zero width space (@code{\&})
8727 @cindex space character, zero width (@code{\&})
8728 If the font description file contains pairwise kerning information,
8729 characters from that font are kerned. Kerning between two characters
8730 can be inhibited by placing @code{\&} between them: @samp{V\&A}.
8732 @xref{Font File Format}.
8735 @cindex track kerning
8736 @cindex kerning, track
8737 @dfn{Track kerning} expands or reduces the space between characters.
8738 This can be handy, for example, if you need to squeeze a long word
8739 onto a single line or spread some text to fill a narrow column. It
8740 must be used with great care since it is usually considered bad
8741 typography if the reader notices the effect.
8743 @Defreq {tkf, f s1 n1 s2 n2}
8744 @cindex activating track kerning (@code{tkf})
8745 @cindex track kerning, activating (@code{tkf})
8746 Enable track kerning for font@w{ }@var{f}. If the current font is@w{
8747 }@var{f} the width of every character is increased by an amount
8748 between @var{n1} and @var{n2} (@var{n1}, @var{n2} can be negative); if
8749 the current point size is less than or equal to @var{s1} the width is
8750 increased by @var{n1}; if it is greater than or equal to @var{s2} the
8751 width is increased by @var{n2}; if the point size is greater than or
8752 equal to @var{s1} and less than or equal to @var{s2} the increase in
8753 width is a linear function of the point size.
8755 The default scaling indicator is @samp{z} for @var{s1} and @var{s2},
8756 @samp{p} for @var{n1} and @var{n2}.
8758 Note that the track kerning amount is added even to the rightmost character
8759 in a line; for large values it is thus recommended to increase the line
8760 length by the same amount to compensate it.
8763 Sometimes, when typesetting letters of different fonts, more or less
8764 space at such boundaries are needed. There are two escapes to help
8768 @cindex italic correction (@code{\/})
8769 @cindex correction, italic (@code{\/})
8770 @cindex correction between italic and roman character (@code{\/}, @code{\,})
8771 @cindex roman character, correction after italic character (@code{\/})
8772 @cindex italic character, correction before roman character (@code{\/})
8773 Increase the width of the preceding character so that the spacing
8774 between that character and the following character is correct if the
8775 following character is a roman character. For example, if an
8776 italic@w{ }@code{f} is immediately followed by a roman right
8777 parenthesis, then in many fonts the top right portion of the@w{ }@code{f}
8778 overlaps the top left of the right parenthesis. Use this escape
8779 sequence whenever an italic character is immediately followed by a
8780 roman character without any intervening space. This small amount of
8781 space is also called @dfn{italic correction}.
8787 @result{} {@it f}@r{)}
8789 @result{} @i{f}@r{)}
8795 @Defesc {\\\,, , , }
8796 @cindex left italic correction (@code{\,})
8797 @cindex correction, left italic (@code{\,})
8798 @cindex roman character, correction before italic character (@code{\,})
8799 @cindex italic character, correction after roman character (@code{\,})
8800 Modify the spacing of the following character so that the spacing
8801 between that character and the preceding character is correct if the
8802 preceding character is a roman character. Use this escape sequence
8803 whenever a roman character is immediately followed by an italic
8804 character without any intervening space. In analogy to above, this
8805 space could be called @dfn{left italic correction}, but this term
8812 @result{} @r{q}@i{f}
8814 @result{} @r{q}@math{@ptexcomma}@i{f}
8821 Insert a zero-width character, which is invisible. Its intended use
8822 is to stop interaction of a character with its surrounding.
8826 It prevents the insertion of extra space after an end-of-sentence
8832 @result{} Test. Test.
8835 @result{} Test. Test.
8839 It prevents interpretation of a control character at the beginning of
8844 @result{} warning: `Test' not defined
8850 It prevents kerning between two characters.
8858 @result{} @r{V@w{}A}
8864 It is needed to map an arbitrary character to nothing in the @code{tr}
8865 request (@pxref{Character Translations}).
8870 This escape is similar to @code{\&} except that it behaves like a
8871 character declared with the @code{cflags} request to be transparent
8872 for the purposes of an end-of-sentence character.
8874 Its main usage is in macro definitions to protect against arguments
8875 starting with a control character.
8887 @result{}This is a test.' This is a test.
8891 @result{}This is a test.' This is a test.
8896 @c =====================================================================
8898 @node Sizes, Strings, Fonts, gtroff Reference
8904 @cindex size of type
8905 @cindex vertical spacing
8906 @cindex spacing, vertical
8907 @code{gtroff} uses two dimensions with each line of text, type size
8908 and vertical spacing. The @dfn{type size} is approximately the height
8909 of the tallest character.@footnote{This is usually the parenthesis.
8910 Note that in most cases the real dimensions of the glyphs in a font
8911 are @emph{not} related to its type size! For example, the standard
8912 @sc{PostScript} font families `Times Roman', `Helvetica', and
8913 `Courier' can't be used together at 10@dmn{pt}; to get acceptable
8914 output, the size of `Helvetica' has to be reduced by one point, and
8915 the size of `Courier' must be increased by one point.} @dfn{Vertical
8916 spacing} is the amount of space @code{gtroff} allows for a line of
8917 text; normally, this is about 20%@w{ }larger than the current type
8918 size. Ratios smaller than this can result in hard-to-read text;
8919 larger than this, it spreads the text out more vertically (useful for
8920 term papers). By default, @code{gtroff} uses 10@w{ }point type on
8921 12@w{ }point spacing.
8924 The difference between type size and vertical spacing is known, by
8925 typesetters, as @dfn{leading} (this is pronounced `ledding').
8928 * Changing Type Sizes::
8929 * Fractional Type Sizes::
8932 @c ---------------------------------------------------------------------
8934 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
8935 @subsection Changing Type Sizes
8937 @DefreqList {ps, [@Var{size}]}
8938 @DefreqItem {ps, @t{+}@Var{size}}
8939 @DefreqItem {ps, @t{-}@Var{size}}
8940 @DefescItem {\\s, , size, }
8942 @cindex changing type sizes (@code{ps}, @code{\s})
8943 @cindex type sizes, changing (@code{ps}, @code{\s})
8944 @cindex point sizes, changing (@code{ps}, @code{\s})
8945 Use the @code{ps} request or the @code{\s} escape to change (increase,
8946 decrease) the type size (in points). Specify @var{size} as either an
8947 absolute point size, or as a relative change from the current size.
8948 The size@w{ }0, or no argument, goes back to the previous size.
8950 Default scaling indicator of @code{size} is @samp{z}. If @code{size}
8951 is zero or negative, it is set to 1@dmn{u}.
8953 @cindex type size registers (@code{.s}, @code{.ps})
8954 @cindex point size registers (@code{.s}, @code{.ps})
8955 The read-only number register @code{.s} returns the point size in
8956 points as a decimal fraction. This is a string. To get the point
8957 size in scaled points, use the @code{.ps} register instead.
8959 @code{.s} is associated with the current environment
8960 (@pxref{Environments}).
8967 wink, wink, \s+2nudge, nudge,\s+8 say no more!
8971 The @code{\s} escape may be called in a variety of ways. Much like
8972 other escapes there must be a way to determine where the argument ends
8973 and the text begins. Any of the following forms are valid:
8977 Set the point size to @var{n}@w{ }points. @var{n}@w{ }must be either
8978 0 or in the range 4 to@w{ }39.
8982 Increase or decrease the point size by @var{n}@w{ }points. @var{n}@w{
8983 }must be exactly one digit.
8986 Set the point size to @var{nn}@w{ }points. @var{nn} must be exactly
8993 Increase or decrease the point size by @var{nn}@w{ }points. @var{nn}
8994 must be exactly two digits.
8997 Note that @code{\s} doesn't produce an input token in @code{gtroff}.
8998 As a consequence, it can be used in requests like @code{mc} (which
8999 expects a single character as an argument) to change the font on
9006 @xref{Fractional Type Sizes}, for yet another syntactical form of
9007 using the @code{\s} escape.
9010 @Defreq {sizes, s1 s2 @dots{} sn [0]}
9011 Some devices may only have certain permissible sizes, in which case
9012 @code{gtroff} rounds to the nearest permissible size.
9013 The @file{DESC} file specifies which sizes are permissible for the device.
9015 Use the @code{sizes} request to change the permissible sizes
9016 for the current output device.
9017 Arguments are in scaled points;
9018 the @code{sizescale} line in the
9019 @file{DESC} file for the output device
9020 provides the scaling factor.
9021 For example, if the scaling factor is 1000,
9022 then the value 12000 is 12@w{ }points.
9024 Each argument can be a single point size (such as 12000),
9025 or a range of sizes (such as 4000-72000).
9026 You can optionally end the list with a zero.
9029 @DefreqList {vs, [@Var{space}]}
9030 @DefreqItem {vs, @t{+}@Var{space}}
9031 @DefreqItem {vs, @t{-}@Var{space}}
9033 @cindex changing vertical line spacing (@code{vs})
9034 @cindex vertical line spacing, changing (@code{vs})
9035 @cindex vertical line spacing register (@code{.v})
9036 Change (increase, decrease) the vertical spacing by @var{space}. The
9037 default scaling indicator is @samp{p}.
9039 If @code{vs} is called without an argument, the vertical spacing is
9040 reset to the previous value before the last call to @code{vs}.
9042 @cindex @code{.V} register, and @code{vs}
9043 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9044 zero or negative; the vertical spacing is then set to the vertical
9045 resolution (as given in the @code{.V} register).
9047 The read-only number register @code{.v} contains the current vertical
9048 spacing; it is associated with the current environment
9049 (@pxref{Environments}).
9052 @cindex vertical line spacing, effective value
9053 The effective vertical line spacing consists of four components.
9057 The vertical line spacing as set with the @code{vs} request.
9059 @cindex post-vertical line spacing
9060 @cindex line spacing, post-vertical (@code{pvs})
9062 The @dfn{post-vertical line spacing} as set with the @code{pvs} request.
9063 This is vertical space which will be added after a line has been
9066 @cindex extra pre-vertical line space (@code{\x})
9067 @cindex line space, extra pre-vertical (@code{\x})
9069 The @dfn{extra pre-vertical line space} as set with the @code{\x} request,
9070 using a negative value. This is vertical space which will be added once
9071 before the current line has been output.
9073 @cindex extra post-vertical line space (@code{\x})
9074 @cindex line space, extra post-vertical (@code{\x})
9076 The @dfn{extra post-vertical line space} as set with the @code{\x} request,
9077 using a positive value. This is vertical space which will be added once
9078 after the current line has been output.
9081 @cindex double spacing (@code{vs}, @code{pvs})
9082 It is usually better to use @code{vs} or @code{pvs} instead of @code{ls}
9083 to produce double-spaced documents: @code{vs} and @code{pvs} have a finer
9084 granularity for the inserted vertical space compared to @code{ls};
9085 furthermore, certain preprocessors assume single spacing.
9087 @xref{Manipulating Spacing}, for more details on the @code{\x} escape
9088 and the @code{ls} request.
9090 @DefreqList {pvs, [@Var{space}]}
9091 @DefreqItem {pvs, @t{+}@Var{space}}
9092 @DefreqItem {pvs, @t{-}@Var{space}}
9093 @DefregListEnd {.pvs}
9094 @cindex @code{ls} request, alternative to (@code{pvs})
9095 @cindex post-vertical line spacing, changing (@code{pvs})
9096 @cindex post-vertical line spacing register (@code{.pvs})
9097 Change (increase, decrease) the post-vertical spacing by
9098 @var{space}. The default scaling indicator is @samp{p}.
9100 If @code{pvs} is called without an argument, the post-vertical spacing is
9101 reset to the previous value before the last call to @code{pvs}.
9103 @code{gtroff} creates a warning of type @samp{range} if @var{space} is
9104 zero or negative; the vertical spacing is then set to zero.
9106 The read-only number register @code{.pvs} contains the current
9107 post-vertical spacing; it is associated with the current environment
9108 (@pxref{Environments}).
9112 @c ---------------------------------------------------------------------
9114 @node Fractional Type Sizes, , Changing Type Sizes, Sizes
9115 @subsection Fractional Type Sizes
9116 @cindex fractional type sizes
9117 @cindex fractional point sizes
9118 @cindex type sizes, fractional
9119 @cindex point sizes, fractional
9120 @cindex sizes, fractional
9122 @cindex @code{s} unit
9123 @cindex unit, @code{s}
9124 @cindex @code{z} unit
9125 @cindex unit, @code{z}
9126 @cindex @code{ps} request, with fractional type sizes
9127 @cindex @code{cs} request, with fractional type sizes
9128 @cindex @code{tkf} request, with fractional type sizes
9129 @cindex @code{\H}, with fractional type sizes
9130 @cindex @code{\s}, with fractional type sizes
9131 A @dfn{scaled point} is equal to @math{1/@var{sizescale}} points,
9132 where @var{sizescale} is specified in the @file{DESC} file (1@w{ }by
9133 default). There is a new scale indicator @samp{z} which has the
9134 effect of multiplying by @var{sizescale}. Requests and escape
9135 sequences in @code{gtroff} interpret arguments that represent a point
9136 size as being in units of scaled points, but they evaluate each such
9137 argument using a default scale indicator of @samp{z}. Arguments
9138 treated in this way are the argument to the @code{ps} request, the
9139 third argument to the @code{cs} request, the second and fourth
9140 arguments to the @code{tkf} request, the argument to the @code{\H}
9141 escape sequence, and those variants of the @code{\s} escape sequence
9142 that take a numeric expression as their argument (see below).
9144 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
9145 is equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
9146 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to
9147 10250@w{ }scaled points, which is equal to 10.25@w{ }points.
9149 @code{gtroff} disallows the use of the @samp{z} scale indicator in
9150 instances where it would make no sense, such as a numeric
9151 expression whose default scale indicator was neither @samp{u} nor
9152 @samp{z}. Similarly it would make
9153 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
9154 numeric expression whose default scale indicator was @samp{z}, and so
9155 @code{gtroff} disallows this as well.
9157 There is also new scale indicator @samp{s} which multiplies by the
9158 number of units in a scaled point. So, for example, @samp{\n[.ps]s} is
9159 equal to @samp{1m}. Be sure not to confuse the @samp{s} and @samp{z}
9163 A read-only number register returning the point size in scaled points.
9165 @code{.ps} is associated with the current environment
9166 (@pxref{Environments}).
9170 @DefregListEnd {.sr}
9171 @cindex last-requested point size registers (@code{.psr}, @code{.sr})
9172 @cindex point size registers, last-requested (@code{.psr}, @code{.sr})
9173 @cindex @code{.ps} register, in comparison with @code{.psr}
9174 @cindex @code{.s} register, in comparison with @code{.sr}
9175 The last-requested point size in scaled points is contained in the
9176 @code{.psr} read-only number register. The last requested point size
9177 in points as a decimal fraction can be found in @code{.sr}. This is a
9178 string-valued read-only number register.
9180 Note that the requested point sizes are device-independent, whereas
9181 the values returned by the @code{.ps} and @code{.s} registers are not.
9182 For example, if a point size of 11@dmn{pt} is requested, and a
9183 @code{sizes} request (or a @code{sizescale} line in a @file{DESC} file)
9184 specifies 10.95@dmn{pt} instead, this value is actually used.
9186 Both registers are associated with the current environment
9187 (@pxref{Environments}).
9190 The @code{\s} escape has the following syntax for working with
9191 fractional type sizes:
9196 Set the point size to @var{n}@w{ }scaled points; @var{n}@w{ }is a numeric
9197 expression with a default scale indicator of @samp{z}.
9207 Increase or or decrease the point size by @var{n}@w{ }scaled points;
9208 @var{n}@w{ }is a numeric expression with a default scale indicator of
9215 @c =====================================================================
9217 @node Strings, Conditionals and Loops, Sizes, gtroff Reference
9221 @code{gtroff} has string variables, which are entirely for user
9222 convenience (i.e.@: there are no built-in strings exept @code{.T}, but
9223 even this is a read-write string variable).
9225 @DefreqList {ds, name [@Var{string}]}
9226 @DefreqItem {ds1, name [@Var{string}]}
9227 @DefescItem {\\*, , n, }
9228 @DefescItem {\\*, @lparen{}, nm, }
9229 @DefescListEnd {\\*, @lbrack{}, name, @rbrack{}}
9230 @cindex string interpolation (@code{\*})
9231 @cindex string expansion (@code{\*})
9232 @cindex interpolation of strings (@code{\*})
9233 @cindex expansion of strings (@code{\*})
9234 Define and access a string variable @var{name} (one-character name@w{
9235 }@var{n}, two-character name @var{nm}). If @var{name} already exists,
9236 @code{ds} overwrites the previous definition.
9241 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
9243 The \*(UX Operating System
9246 The @code{\*} escape @dfn{interpolates} (expands in-place) a
9247 previously-defined string variable. To be more precise, the stored
9248 string is pushed onto the input stack which is then parsed by
9249 @code{gtroff}. Similar to number registers, it is possible to nest
9250 strings, i.e. string variables can be called within string variables.
9252 If the string named by the @code{\*} escape does not exist, it is
9253 defined as empty, and a warning of type @samp{mac} is emitted (see
9254 @ref{Debugging}, for more details).
9256 @cindex comments, with @code{ds}
9257 @cindex @code{ds} request, and comments
9258 @strong{Caution:} Unlike other requests, the second argument to the
9259 @code{ds} request takes up the entire line including trailing spaces.
9260 This means that comments on a line with such a request can introduce
9261 unwanted space into a string.
9264 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
9268 Instead the comment should be put on another line or have the comment
9269 escape adjacent with the end of the string.
9272 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\" UNIX trademark
9275 @cindex trailing quotes
9276 @cindex quotes, trailing
9277 @cindex leading spaces with @code{ds}
9278 @cindex spaces with @code{ds}
9279 @cindex @code{ds} request, and leading spaces
9280 To produce leading space the string can be started with a double
9281 quote. No trailing quote is needed; in fact, any trailing quote is
9282 included in your string.
9285 .ds sign " Yours in a white wine sauce,
9288 @cindex multi-line strings
9289 @cindex strings, multi-line
9290 @cindex newline character, in strings, escaping
9291 @cindex escaping newline characters, in strings
9292 Strings are not limited to a single line of text. A string can span
9293 several lines by escaping the newlines with a backslash. The
9294 resulting string is stored @emph{without} the newlines.
9297 .ds foo lots and lots \
9298 of text are on these \
9302 It is not possible to have real newlines in a string. To put a single
9303 double quote character into a string, use two consecutive double quote
9306 The @code{ds1} request turns off compatibility mode
9307 while interpreting a string. To be more precise, a @dfn{compatibility
9308 save} input token is inserted at the beginning of the string, and a
9309 @dfn{compatibility restore} input token at the end.
9313 .ds aa The value of xxx is \\n[xxx].
9314 .ds1 bb The value of xxx ix \\n[xxx].
9319 @result{} warning: number register `[' not defined
9320 @result{} The value of xxx is 0xxx].
9322 @result{} The value of xxx ix 12345.
9325 @cindex name space, common, of macros, diversions, and strings
9326 @cindex common name space of macros, diversions, and strings
9327 @cindex macros, shared name space with strings and diversions
9328 @cindex strings, shared name space with macros and diversions
9329 @cindex diversions, shared name space with macros and strings
9330 Strings, macros, and diversions (and boxes) share the same name space.
9331 Internally, even the same mechanism is used to store them. This has
9332 some interesting consequences. For example, it is possible to call a
9333 macro with string syntax and vice versa.
9340 @result{} This is a funny test.
9342 .ds yyy a funny test
9345 @result{} This is a funny test.
9348 Diversions and boxes can be also called with string syntax. It is not
9349 possible to pass arguments to a macro if called with @code{\*}.
9351 Another consequence is that you can copy one-line diversions or boxes
9359 .ds yyy This is \*[xxx]\c
9361 @result{} @r{This is a }@i{test}.
9365 As the previous example shows, it is possible to store formatted
9366 output in strings. The @code{\c} escape prevents the insertion of an
9367 additional blank line in the output.
9369 Copying diversions longer than a single output line produces
9379 .ds yyy This is \*[xxx]\c
9381 @result{} test This is a funny.
9384 Usually, it is not predictable whether a diversion contains one or
9385 more output lines, so this mechanism should be avoided. With
9386 @acronym{UNIX} @code{troff}, this was the only solution to strip off a
9387 final newline from a diversion. Another disadvantage is that the
9388 spaces in the copied string are already formatted, making them
9389 unstretchable. This can cause ugly results.
9391 @cindex stripping final newline in diversions
9392 @cindex diversion, stripping final newline
9393 @cindex final newline, stripping in diversions
9394 @cindex newline, final, stripping in diversions
9395 @cindex horizontal space, unformatting
9396 @cindex space, horizontal, unformatting
9397 @cindex unformatting horizontal space
9398 A clean solution to this problem is available in GNU @code{troff},
9399 using the requests @code{chop} to remove the final newline of a
9400 diversion, and @code{unformat} to make the horizontal spaces
9413 @result{} This is a funny test.
9416 @xref{Gtroff Internals}, for more information.
9419 @DefreqList {as, name [@Var{string}]}
9420 @DefreqListEnd {as1, name [@Var{string}]}
9421 @cindex appending to a string (@code{as})
9422 @cindex string, appending (@code{as})
9423 The @code{as} request is similar to @code{ds} but appends @var{string}
9424 to the string stored as @var{name} instead of redefining it. If
9425 @var{name} doesn't exist yet, it is created.
9428 .as sign " with shallots, onions and garlic,
9431 The @code{as1} request is similar to @code{as}, but compatibility mode
9432 is switched off while the appended string is interpreted. To be more
9433 precise, a @dfn{compatibility save} input token is inserted at the
9434 beginning of the appended string, and a @dfn{compatibility restore}
9435 input token at the end.
9438 Rudimentary string manipulation routines are given with the next two
9441 @Defreq {substring, str n1 [@Var{n2}]}
9442 @cindex substring (@code{substring})
9443 Replace the string in register@w{ }@var{str} with the substring
9444 defined by the indices @var{n1} and@w{ }@var{n2}. The first character
9445 in the string has index one. If @var{n2} is omitted, it is taken to
9446 be equal to the string's length. If the index value @var{n1} or
9447 @var{n2} is negative or zero, it is counted from the end of the
9448 string, going backwards: The last character has index@w{ }0, the
9449 character before the last character has index@w{ }@minus{}1, etc.
9459 @Defreq {length, reg str}
9460 @cindex length of a string (@code{length})
9461 @cindex string, length of (@code{length})
9462 Compute the number of characters of @var{str} and return it in the
9463 number register @var{reg}. If @var{reg} doesn't exist, it is created.
9464 @code{str} is read in copy mode.
9467 .ds xxx abcd\h'3i'efgh
9475 @cindex renaming request (@code{rn})
9476 @cindex request, renaming (@code{rn})
9477 @cindex renaming macro (@code{rn})
9478 @cindex macro, renaming (@code{rn})
9479 @cindex renaming string (@code{rn})
9480 @cindex string, renaming (@code{rn})
9481 @cindex renaming diversion (@code{rn})
9482 @cindex diversion, renaming (@code{rn})
9483 Rename the request, macro, diversion, or string @var{xx} to @var{yy}.
9487 @cindex removing request (@code{rm})
9488 @cindex request, removing (@code{rm})
9489 @cindex removing macro (@code{rm})
9490 @cindex macro, removing (@code{rm})
9491 @cindex removing string (@code{rm})
9492 @cindex string, removing (@code{rm})
9493 @cindex removing diversion (@code{rm})
9494 @cindex diversion, removing (@code{rm})
9495 Remove the request, macro, diversion, or string @var{xx}. @code{gtroff}
9496 treats subsequent invocations as if the object had never been defined.
9499 @Defreq {als, new old}
9500 @cindex alias, string, creating (@code{als})
9501 @cindex alias, macro, creating (@code{als})
9502 @cindex alias, diversion, creating (@code{als})
9503 @cindex creating alias, for string (@code{als})
9504 @cindex creating alias, for macro (@code{als})
9505 @cindex creating alias, for diversion (@code{als})
9506 @cindex string, creating alias (@code{als})
9507 @cindex macro, creating alias (@code{als})
9508 @cindex diversion, creating alias (@code{als})
9509 Create an alias named @var{new} for the request, string, macro, or
9510 diversion object named @var{old}. The new name and the old name are
9511 exactly equivalent (it is similar to a hard rather than a soft
9512 link). If @var{old} is undefined, @code{gtroff} generates a warning of
9513 type @samp{mac} and ignores the request.
9517 Remove (chop) the last character from the macro, string, or diversion
9518 named @var{xx}. This is useful for removing the newline from the end
9519 of diversions that are to be interpolated as strings. This command
9520 can be used repeatedly; see @ref{Gtroff Internals}, for details on
9521 nodes inserted additionally by @code{gtroff}.
9524 @xref{Identifiers}, and @ref{Comments}.
9527 @c =====================================================================
9529 @node Conditionals and Loops, Writing Macros, Strings, gtroff Reference
9530 @section Conditionals and Loops
9531 @cindex conditionals and loops
9532 @cindex loops and conditionals
9535 * Operators in Conditionals::
9540 @c ---------------------------------------------------------------------
9542 @node Operators in Conditionals, if-else, Conditionals and Loops, Conditionals and Loops
9543 @subsection Operators in Conditionals
9545 @cindex @code{if} request, operators to use with
9546 @cindex @code{while} request, operators to use with
9547 In @code{if} and @code{while} requests, there are several more
9548 operators available:
9553 True if the current page is even or odd numbered (respectively).
9556 True if the document is being processed in nroff mode (i.e., the
9557 @code{.nroff} command has been issued).
9560 True if the document is being processed in troff mode (i.e., the
9561 @code{.troff} command has been issued).
9564 Always false. This condition is for compatibility with other
9565 @code{troff} versions only.
9567 @item '@var{xxx}'@var{yyy}'
9568 True if the string @var{xxx} is equal to the string @var{yyy}. Other
9569 characters can be used in place of the single quotes; the same set of
9570 delimiters as for the @code{\D} escape is used (@pxref{Escapes}).
9571 @code{gtroff} formats the strings before being compared:
9582 The resulting motions, character sizes, and fonts have to
9583 match,@footnote{The created output nodes must be identical.
9584 @xref{Gtroff Internals}.} and not the individual motion, size, and
9585 font requests. In the previous example, @samp{|} and @samp{\fR|\fP}
9586 both result in a roman @samp{|} character with the same point size and
9587 at the same location on the page, so the strings are equal. If
9588 @samp{.ft@w{ }I} had been added before the @samp{.ie}, the result
9589 would be ``false'' because (the first) @samp{|} produces an italic
9590 @samp{|} rather than a roman one.
9593 True if there is a number register named @var{xxx}.
9596 True if there is a string, macro, diversion, or request named @var{xxx}.
9599 True if there is a color named @var{xxx}.
9602 True if there is a character @var{ch} available; @var{ch} is either an
9603 @acronym{ASCII} character or a special character (@code{\(@var{ch}} or
9604 @code{\[@var{ch}]}); the condition is also true if @var{ch} has been
9605 defined by the @code{char} request.
9608 Note that these operators can't be combined with other operators like
9609 @samp{:} or @samp{&}; only a leading @samp{!} (without whitespace
9610 between the exclamation mark and the operator) can be used to negate
9622 A whitespace after @samp{!} always evaluates to zero (this bizarre
9623 behaviour is due to compatibility with @acronym{UNIX} @code{troff}).
9631 @result{} r xxx true
9634 It is possible to omit the whitespace before the argument to the
9635 @samp{r}, @samp{d}, and @samp{c} operators.
9639 @c ---------------------------------------------------------------------
9641 @node if-else, while, Operators in Conditionals, Conditionals and Loops
9645 @code{gtroff} has if-then-else constructs like other languages, although
9646 the formatting can be painful.
9648 @Defreq {if, expr anything}
9649 Evaluate the expression @var{expr}, and executes @var{anything} (the
9650 remainder of the line) if @var{expr} evaluates to non-zero (true).
9651 @var{anything} is interpreted as though it was on a line by itself
9652 (except that leading spaces are swallowed). @xref{Expressions}, for
9658 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true
9663 @Defreq{nop, anything}
9664 Executes @var{anything}.
9665 This is similar to @code{.if@w{ }1}.
9668 @DefreqList {ie, expr anything}
9669 @DefreqListEnd {el, anything}
9670 Use the @code{ie} and @code{el} requests to write an if-then-else.
9671 The first request is the `if' part and the latter is the `else' part.
9674 .ie n .ls 2 \" double spacing in nroff
9675 .el .ls 1 \" single spacing in troff
9679 @c there is a bug in makeinfo <= 4.1a: you can't have `@{' as an argument
9682 @c and in 4.2 you still can't use @{ in macros.
9684 @c @DefescList {\@{, , , }
9685 @c @DefescListEnd {\@}, , , }
9686 @deffn Escape @t{\@{}
9687 @deffnx Escape @t{\@}}
9690 @cindex begin of conditional block (@code{\@{})
9691 @cindex end of conditional block (@code{\@}})
9692 @cindex conditional block, begin (@code{\@{})
9693 @cindex conditional block, end (@code{\@}})
9694 @cindex block, conditional, begin (@code{\@{})
9695 @cindex block, condititional, end (@code{\@}})
9696 In many cases, an if (or if-else) construct needs to execute more than
9697 one request. This can be done using the @code{\@{} and @code{\@}}
9698 escapes. The following example shows the possible ways to use these
9699 escapes (note the position of the opening and closing braces).
9716 @c ---------------------------------------------------------------------
9718 @node while, , if-else, Conditionals and Loops
9722 @code{gtroff} provides a looping construct using the @code{while}
9723 request, which is used much like the @code{if} (and related) requests.
9725 @Defreq {while, expr anything}
9726 Evaluate the expression @var{expr}, and repeatedly execute
9727 @var{anything} (the remainder of the line) until @var{expr} evaluates
9732 .while (\na < 9) \@{\
9736 @result{} 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
9741 @cindex @code{de} request, and @code{while}
9744 The body of a @code{while} request is treated like the body of a
9745 @code{de} request: @code{gtroff} temporarily stores it in a macro
9746 which is deleted after the loop has been exited. It can considerably
9747 slow down a macro if the body of the @code{while} request (within the
9748 macro) is large. Each time the macro is executed, the @code{while}
9749 body is parsed and stored again as a temporary macro.
9754 . while (\\n[num] > 0) \@{\
9755 . \" many lines of code
9761 @cindex recursive macros
9762 @cindex macros, recursive
9764 The traditional and ofter better solution (@acronym{UNIX} @code{troff}
9765 doesn't have the @code{while} request) is to use a recursive macro
9766 instead which is parsed only once during its definition.
9770 . if (\\n[num] > 0) \@{\
9771 . \" many lines of code
9784 Note that the number of available recursion levels is set to@w{ }1000
9785 (this is a compile-time constant value of @code{gtroff}).
9788 The closing brace of a @code{while} body must end a line.
9793 . while (\n[a] < 10) \@{\
9796 @result{} unbalanced \@{ \@}
9802 @cindex @code{while} request, confusing with @code{br}
9803 @cindex @code{break} request, in a @code{while} loop
9804 @cindex @code{continue} request, in a @code{while} loop
9805 Break out of a @code{while} loop. Be sure not to confuse this with
9806 the @code{br} request (causing a line break).
9809 @Defreq {continue, }
9810 Finish the current iteration of a @code{while} loop, immediately
9811 restarting the next iteration.
9817 @c =====================================================================
9819 @node Writing Macros, Page Motions, Conditionals and Loops, gtroff Reference
9820 @section Writing Macros
9821 @cindex writing macros
9822 @cindex macros, writing
9824 A @dfn{macro} is a collection of text and embedded commands which can
9825 be invoked multiple times. Use macros to define common operations.
9827 @DefreqList {de, name [@Var{end}]}
9828 @DefreqItem {de1, name [@Var{end}]}
9829 @DefreqListEnd {dei, name [@Var{end}]}
9830 Define a new macro named @var{name}. @code{gtroff} copies subsequent
9831 lines (starting with the next one) into an internal buffer until it
9832 encounters the line @samp{..} (two dots). The optional second
9833 argument to @code{de} changes this to a macro to @samp{.@var{end}}.
9835 There can be whitespace after the first dot in the line containing the
9836 ending token (either @samp{.} or macro @samp{@var{end}}).
9838 Here a small example macro called @samp{P} which causes a break and
9839 inserts some vertical space. It could be used to separate paragraphs.
9848 The following example defines a macro within another. Remember that
9849 expansion must be protected twice; once for reading the macro and
9853 \# a dummy macro to avoid a warning
9859 . nop \f[B]Hallo \\\\$1!\f[]
9865 @result{} @b{Hallo Joe!}
9869 Since @code{\f} has no expansion, it isn't necessary to protect its
9870 backslash. Had we defined another macro within @code{bar} which takes
9871 a parameter, eight backslashes would be necessary before @samp{$1}.
9873 The @code{de1} request turns off compatibility mode
9874 while executing the macro. On entry, the current compatibility mode
9875 is saved and restored at exit.
9881 The value of xxx is \\n[xxx].
9884 The value of xxx ix \\n[xxx].
9890 @result{} warning: number register
\e' not defined
9891 @result{} The value of xxx is 0xxx].
9893 @result{} The value of xxx ix 12345.
9896 The @code{dei} request defines a macro indirectly.
9897 That is, it expands strings whose names
9898 are @var{name} or @var{end} before performing the append.
9916 Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
9918 Note that macro identifiers are shared with identifiers for strings and
9922 @DefreqList {am, xx}
9923 @DefreqItem {am1, xx}
9924 @DefreqListEnd {ami, xx yy}
9925 @cindex appending to a macro (@code{am})
9926 @cindex macro, appending (@code{am})
9927 Works similarly to @code{de} except it appends onto the macro named
9928 @var{xx}. So, to make the previously defined @samp{P} macro actually
9929 do indented instead of block paragraphs, add the necessary code to the
9930 existing macro like this:
9938 The @code{am1} request turns off compatibility mode
9939 while executing the appended macro piece. To be more precise, a
9940 @dfn{compatibility save} input token is inserted at the beginning of
9941 the appended code, and a @dfn{compatibility restore} input token at
9944 The @code{ami} request appends indirectly,
9945 meaning that @code{gtroff} expands strings whose names
9946 are @var{xx} or @var{yy} before performing the append.
9949 Using @file{trace.tmac}, you can trace calls to @code{am} and @code{am1}.
9952 @xref{Strings}, for the @code{als} request to rename a macro.
9954 The @code{de}, @code{am}, @code{di}, @code{da}, @code{ds}, and
9955 @code{as} requests (together with its variants) only create a new object
9956 if the name of the macro, diversion or string diversion is currently
9957 undefined or if it is defined to be a request; normally they modify the
9958 value of an existing object.
9961 Exit a macro, immediately returning to the caller.
9969 @c ---------------------------------------------------------------------
9971 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
9972 @subsection Copy-in Mode
9973 @cindex copy-in mode
9974 @cindex mode, copy-in
9976 @cindex @code{\n}, when reading text for a macro
9977 @cindex @code{\$}, when reading text for a macro
9978 @cindex @code{\*}, when reading text for a macro
9979 @cindex @code{\\}, when reading text for a macro
9980 @cindex \@key{RET}, when reading text for a macro
9981 When @code{gtroff} reads in the text for a macro or diversion, it copies
9982 the text (including request lines, but excluding escapes) into an
9983 internal buffer. Escapes are converted into an internal form,
9984 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
9985 @code{\@key{RET}} which are evaluated and inserted into the text where
9986 the escape was located. This is known as @dfn{copy-in} mode or
9989 What this means is that you can specify when these escapes are to be
9990 evaluated (either at copy-in time or at the time of use) by insulating
9991 the escapes with an extra backslash. Compare this to the @code{\def}
9992 and @code{\edef} commands in @TeX{}.
9994 The following example prints the numbers 20 and@w{ }10:
10006 @c ---------------------------------------------------------------------
10008 @node Parameters, , Copy-in Mode, Writing Macros
10009 @subsection Parameters
10012 The arguments to a macro can be examined using a variety of escapes.
10015 @cindex number of arguments register (@code{.$})
10016 The number of arguments in a macro. This is a read-only number register.
10019 Any individual argument can be retrieved with one of the following
10022 @DefescList {\\$, , n, }
10023 @DefescItem {\\$, @lparen{}, nn, }
10024 @DefescListEnd {\\$, @lbrack{}, nnn, @rbrack{}}
10025 @cindex copy-in mode, and macro arguments
10026 @cindex macro, arguments (@code{\$})
10027 @cindex arguments, macro (@code{\$})
10028 Retrieve the @var{n}@dmn{th}, @var{nn}@dmn{th} or @var{nnn}@dmn{th}
10029 argument. As usual, the first form only accepts a single number
10030 (larger than zero), the second a two-digit number (larger or equal
10031 to@w{ }10), and the third any positive integer value (larger
10032 than zero). Macros can have an unlimited number of arguments. Note
10033 that due to copy-in mode, use two backslashes on these in actual use to
10034 prevent interpolation until the macro is actually invoked.
10037 @Defreq {shift, [@Var{n}]}
10038 Shift the arguments 1@w{ }position, or as
10039 many positions as specified by its argument. After executing this
10040 request, argument@w{ }@var{i} becomes argument @math{@var{i}-@var{n}};
10041 arguments 1 to@w{ }@var{n} are no longer available. Shifting by
10042 negative amounts is currently undefined.
10045 @DefescList {\\$*, , , }
10046 @DefescListEnd {\\$@@, , , }
10047 In some cases it is convenient to use all of the arguments at once (for
10048 example, to pass the arguments along to another macro). The @code{\$*}
10049 escape concatenates all the arguments separated by spaces. A
10050 similar escape is @code{\$@@}, which concatenates all the
10051 arguments with each surrounded by double quotes, and separated by
10052 spaces. If not in compatibility mode, the input level of double quotes
10053 is preserved (see @ref{Request Arguments}).
10056 @Defesc {\\$0, , , }
10057 @cindex macro name register (@code{\$0})
10058 @cindex @code{als} request, and @code{\$0}
10059 The name used to invoke the current macro.
10060 The @code{als} request can make a macro have more than one name.
10065 . if \\n[error] \@{\
10066 . tm \\$0: Houston, we have a problem.
10071 .als foo generic-macro
10072 .als bar generic-macro
10076 @xref{Request Arguments}.
10079 @c =====================================================================
10081 @node Page Motions, Drawing Requests, Writing Macros, gtroff Reference
10082 @section Page Motions
10083 @cindex page motions
10084 @cindex motions, page
10086 @xref{Manipulating Spacing}, for a discussion of the main request for
10087 vertical motion, @code{sp}.
10089 @DefreqList {mk, [@Var{reg}]}
10090 @DefreqListEnd {rt, [@Var{dist}]}
10091 @cindex marking vertical page location (@code{mk})
10092 @cindex page location, vertical, marking (@code{mk})
10093 @cindex location, vertical, page, marking (@code{mk})
10094 @cindex vertical page location, marking (@code{mk})
10095 @cindex returning to marked vertical page location (@code{rt})
10096 @cindex page location, vertical, returning to marked (@code{rt})
10097 @cindex location, vertical, page, returning to marked (@code{rt})
10098 @cindex vertical page location, returning to marked (@code{rt})
10099 The request @code{mk} can be used to mark a location on a page, for
10100 movement to later. This request takes a register name as an argument
10101 in which to store the current page location. With no argument it
10102 stores the location in an internal register. The results of this can
10103 be used later by the @code{rt} or the @code{sp} request (or the
10106 The @code{rt} request returns @emph{upwards} to the location marked
10107 with the last @code{mk} request. If used with an argument, return to
10108 a position which distance from the top of the page is @var{dist} (no
10109 previous call to @code{mk} is necessary in this case). Default scaling
10110 indicator is @samp{v}.
10112 Here a primitive solution for a two-column macro.
10115 .nr column-length 1.5i
10117 .nr bottom-margin 1m
10124 . ll \\n[column-length]u
10125 . wh -\\n[bottom-margin]u 2c-trap
10132 . ie \\n[right-side] \@{\. nr right-side 0
10133 . po -(\\n[column-length]u + \\n[column-gap]u)
10135 . wh -\\n[bottom-margin]u
10138 . \" switch to right side
10140 . po +(\\n[column-length]u + \\n[column-gap]u)
10149 This is a small test which shows how the
10150 rt request works in combination with mk.
10153 Starting here, text is typeset in two columns.
10154 Note that this implementation isn't robust
10155 and thus not suited for a real two-column
10162 This is a small test which shows how the
10163 rt request works in combination with mk.
10165 Starting here, isn't robust
10166 text is typeset and thus not
10167 in two columns. suited for a
10168 Note that this real two-column
10169 implementation macro.
10173 The following escapes give fine control of movements about the page.
10175 @Defesc {\\v, ', e, '}
10176 @cindex vertical motion (@code{\v})
10177 @cindex motion, vertical (@code{\v})
10178 Move vertically, usually from the current location on the page (if no
10179 absolute position operator @samp{|} is used). The
10180 argument@w{ }@var{e} specifies the distance to move; positive is
10181 downwards and negative upwards. The default scaling indicator for this
10182 escape is @samp{v}. Beware, however, that @code{gtroff} continues text
10183 processing at the point where the motion ends, so you should always
10184 balance motions to avoid interference with text processing.
10186 @code{\v} doesn't trigger a trap. This can be quite useful; for example,
10187 consider a page bottom trap macro which prints a marker in the margin to
10188 indicate continuation of a footnote or something similar.
10191 There are some special-case escapes for vertical motion.
10193 @Defesc {\\r, , , }
10194 Move upwards@w{ }1@dmn{v}.
10197 @Defesc {\\u, , , }
10198 Move upwards@w{ }.5@dmn{v}.
10201 @Defesc {\\d, , , }
10202 Move down@w{ }.5@dmn{v}.
10205 @Defesc {\\h, ', e, '}
10206 @cindex inserting horizontal space (@code{\h})
10207 @cindex horizontal space (@code{\h})
10208 @cindex space, horizontal (@code{\h})
10209 @cindex horizontal motion (@code{\h})
10210 @cindex motion, horizontal (@code{\h})
10211 Move horizontally, usually from the current location (if no absolute
10212 position operator @samp{|} is used). The expression@w{ }@var{e}
10213 indicates how far to move: positive is rightwards and negative
10214 leftwards. The default scaling indicator for this escape is @samp{m}.
10217 There are a number of special-case escapes for horizontal motion.
10219 @Defesc {\\@key{SP}, , , }
10220 @cindex space, unbreakable
10221 @cindex unbreakable space
10222 An unbreakable and unpaddable (i.e.@: not expanded during filling)
10223 space. (Note: This is a backslash followed by a space.)
10226 @Defesc {\\~, , , }
10227 An unbreakable space that stretches like a normal inter-word space
10228 when a line is adjusted.
10231 @Defesc {\\|, , , }
10232 A 1/6@dmn{th} em space. Ignored for TTY output devices (rounded to
10236 @Defesc {\\^, , , }
10237 A 1/12@dmn{th} em space. Ignored for TTY output devices (rounded to
10241 @Defesc {\\0, , , }
10242 @cindex space, width of a digit (@code{\0})
10243 @cindex digit width space (@code{\0})
10244 A space the size of a digit.
10247 The following string sets the @TeX{} logo:
10250 .ds TeX T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
10253 @DefescList {\\w, ', text, '}
10260 @DefregListEnd {skw}
10261 @cindex width escape (@code{\w})
10262 Return the width of the specified @var{text} in basic units.
10263 This allows horizontal movement based on the width of some
10264 arbitrary text (e.g.@: given as an argument to a macro).
10267 The length of the string `abc' is \w'abc'u.
10268 @result{} The length of the string `abc' is 72u.
10271 Font changes may occur in @var{text} which don't affect current
10274 After use, @code{\w} sets several registers:
10279 The highest and lowest point of the baseline, respectively, in @var{text}.
10283 Like the @code{st} and @code{sb} registers, but takes account of the
10284 heights and depths of characters. With other words, this gives the
10285 highest and lowest point of @var{text}.
10288 Defines the kinds of characters occurring in @var{text}:
10292 only short characters, no descenders or tall characters.
10295 at least one descender.
10298 at least one tall character.
10301 at least one each of a descender and a tall character.
10305 The amount of horizontal space (possibly negative) that should be added
10306 to the last character before a subscript.
10309 How far to right of the center of the last character in the @code{\w}
10310 argument, the center of an accent from a roman font should be placed
10311 over that character.
10315 @DefescList {\\k, , p, }
10316 @DefescItem {\\k, @lparen{}, ps, }
10317 @DefescListEnd {\\k, @lbrack{}, position, @rbrack}
10318 @cindex saving horizontal input line position (@code{\k})
10319 @cindex horizontal input line position, saving (@code{\k})
10320 @cindex input line position, horizontal, saving (@code{\k})
10321 @cindex position, horizontal input line, saving (@code{\k})
10322 @cindex line, input, horizontal position, saving (@code{\k})
10323 Store the current horizontal position in the @emph{input} line in
10324 number register with name @var{position} (one-character name@w{ }@var{p},
10325 two-character name @var{ps}). Use this, for example, to return to the
10326 beginning of a string for highlighting or other decoration.
10330 @cindex horizontal input line position register (@code{hp})
10331 @cindex input line, horizontal position, register (@code{hp})
10332 @cindex position, horizontal, in input line, register (@code{hp})
10333 @cindex line, input, horizontal position, register (@code{hp})
10334 The current horizontal position at the input line.
10338 @cindex horizontal output line position register (@code{.k})
10339 @cindex output line, horizontal position, register (@code{.k})
10340 @cindex position, horizontal, in output line, register (@code{.k})
10341 @cindex line, output, horizontal position, register (@code{.k})
10342 A read-only number register containing the current horizontal output
10346 @Defesc {\\o, ', @Var{a}@Var{b}@Var{c}, '}
10347 @cindex overstriking characters (@code{\o})
10348 @cindex characters, overstriking (@code{\o})
10349 Overstrike characters @var{a}, @var{b}, @var{c}, @dots{}; the characters
10350 are centered, and the resulting spacing is the largest width of the
10351 affected characters.
10354 @Defesc {\\z, , c, , }
10355 @cindex zero-width printing (@code{\z}, @code{\Z})
10356 @cindex printing, zero-width (@code{\z}, @code{\Z})
10357 Print character @var{c} with zero width, i.e., without spacing. Use
10358 this to overstrike characters left-aligned.
10361 @Defesc {\\Z, ', anything, '}
10362 @cindex zero-width printing (@code{\z}, @code{\Z})
10363 @cindex printing, zero-width (@code{\z}, @code{\Z})
10364 Print @var{anything}, then restore the horizontal and vertical position.
10365 The argument may not contain tabs or leaders.
10367 The following is an example of a strike-through macro:
10372 \Z@@\v'-.25m'\l'\\n[ww]u'@@\\$1
10377 an actual emergency!
10382 @c =====================================================================
10384 @node Drawing Requests, Traps, Page Motions, gtroff Reference
10385 @section Drawing Requests
10386 @cindex drawing requests
10387 @cindex requests for drawing
10389 @code{gtroff} provides a number of ways to draw lines and other figures
10390 on the page. Used in combination with the page motion commands (see
10391 @ref{Page Motions}, for more info), a wide variety of figures can be
10392 drawn. However, for complex drawings these operations can be quite
10393 cumbersome, and it may be wise to use graphic preprocessors like
10394 @code{gpic} or @code{ggrn}. @xref{gpic}, and @ref{ggrn}, for more
10397 All drawing is done via escapes.
10399 @DefescList {\\l, ', @Var{l}, '}
10400 @DefescListEnd {\\l, ', @Var{l}@Var{c}, '}
10401 @cindex drawing horizontal lines (@code{\l})
10402 @cindex horizontal line, drawing (@code{\l})
10403 @cindex line, horizontal, drawing (@code{\l})
10404 Draw a line horizontally. @var{l} is the length of the line to be
10405 drawn. If it is positive, start the line at the current location and
10406 draw to the right; its end point is the new current location. Negative
10407 values are handled differently: The line starts at the current location
10408 and draws to the left, but the current location doesn't move.
10410 @var{l} can also be specified absolutely (i.e.@: with a leading
10411 @samp{|}) which draws back to the beginning of the input line.
10412 Default scaling indicator is @samp{m}.
10414 @cindex underscore character (@code{\[ru]})
10415 @cindex character, underscore (@code{\[ru]})
10416 @cindex line drawing character
10417 @cindex character, for line drawing
10418 The optional second parameter@w{ }@var{c} is a character to draw the line
10419 with. If this second argument is not specified, @code{gtroff} uses
10420 the underscore character, @code{\[ru]}.
10422 @cindex zero width space character (@code{\&})
10423 @cindex character, zero width space (@code{\&})
10424 @cindex space character, zero width (@code{\&})
10425 To separate the two arguments (to prevent @code{gtroff} from
10426 interpreting a drawing character as a scaling indicator) use @code{\&}.
10428 Here a small useful example:
10432 \[br]\\$*\[br]\l'|0\[rn]'\l'|0\[ul]'
10437 Note that this works by outputting a box rule (a vertical line), then
10438 the text given as an argument and then another box rule. Finally, the
10439 line drawing escapes both draw from the current location to the
10440 beginning of the @emph{input} line -- this works because the line
10441 length is negative, not moving the current point.
10444 @DefescList {\\L, ', @Var{l}, '}
10445 @DefescListEnd {\\L, ', @Var{l}@Var{c}, '}
10446 @cindex drawing vertical lines (@code{\L})
10447 @cindex vertical line drawing (@code{\L})
10448 @cindex line, vertical, drawing (@code{\L})
10449 @cindex line drawing character
10450 @cindex character for line drawing
10451 @cindex box rule character (@code{\[br]})
10452 @cindex character, box rule (@code{\[br]})
10453 Draw vertical lines. Its parameters are
10454 similar to the @code{\l} escape, except that the default scaling
10455 indicator is @samp{v}. The movement is downwards for positive values,
10456 and upwards for negative values. The default character is the box rule
10457 character, @code{\[br]}. As with the vertical motion escapes, text
10458 processing blindly continues where the line ends.
10461 This is a \L'3v'test.
10465 Here the result, produced with @code{grotty}.
10475 @Defesc {\\D, ', command arg @dots{}, '}
10476 The @code{\D} escape provides a variety of drawing functions.
10477 Note that on character devices, only vertical and horizontal lines are
10478 supported within @code{grotty}; other devices may only support a subset
10479 of the available drawing functions.
10481 The default scaling indicator for all subcommands of @code{\D} is
10482 @samp{m} for horizontal distances and @samp{v} for vertical ones.
10483 Exceptions are @w{@code{\D'f @dots{}'}} and @w{@code{\D't @dots{}'}}
10484 which use @code{u} as the default.
10487 @item \D'l @var{dx} @var{dy}'
10488 @cindex line, drawing (@w{@code{\D'l @dots{}'}})
10489 @cindex drawing a line (@w{@code{\D'l @dots{}'}})
10490 Draw a line from the current location to the relative point specified by
10491 (@var{dx},@var{dy}).
10493 The following example is a macro for creating a box around a text string;
10494 for simplicity, the box margin is taken as a fixed value, 0.2@dmn{m}.
10500 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10501 \D'l 0 -(\\n[rst]u - \\n[rsb]u + .4m)'\
10502 \D'l (\\n[@@wd]u + .4m) 0'\
10503 \D'l 0 (\\n[rst]u - \\n[rsb]u + .4m)'\
10504 \D'l -(\\n[@@wd]u + .4m) 0'\
10505 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10512 First, the width of the string is stored in register @code{@@wd}. Then,
10513 four lines are drawn to form a box, properly offset by the box margin.
10514 The registers @code{rst} and @code{rsb} are set by the @code{\w} escape,
10515 containing the largest height and depth of the whole string.
10517 @item \D'c @var{d}'
10518 @cindex circle, drawing (@w{@code{\D'c @dots{}'}})
10519 @cindex drawing a circle (@w{@code{\D'c @dots{}'}})
10520 Draw a circle with a diameter of@w{ }@var{d} with the leftmost point at the
10523 @item \D'C @var{d}'
10524 @cindex circle, solid, drawing (@w{@code{\D'C @dots{}'}})
10525 @cindex drawing a solid circle (@w{@code{\D'C @dots{}'}})
10526 @cindex solid circle, drawing (@w{@code{\D'C @dots{}'}})
10527 Draw a solid circle with the same parameters as an outlined circle. No
10530 @item \D'e @var{x} @var{y}'
10531 @cindex drawing an ellipse (@w{@code{\D'e @dots{}'}})
10532 @cindex ellipse, drawing (@w{@code{\D'e @dots{}'}})
10533 Draw an ellipse with a horizontal diameter of @var{x} and a vertical
10534 diameter of @var{y} with the leftmost point at the current position.
10536 @item \D'E @var{x} @var{y}'
10537 @cindex ellipse, solid, drawing (@w{@code{\D'E @dots{}'}})
10538 @cindex drawing a solid ellipse (@w{@code{\D'E @dots{}'}})
10539 @cindex solid ellipse, drawing (@w{@code{\D'E @dots{}'}})
10540 Draw a solid ellipse with the same parameters as an outlined ellipse.
10541 No outline is drawn.
10543 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
10544 @cindex arc, drawing (@w{@code{\D'a @dots{}'}})
10545 @cindex drawing an arc (@w{@code{\D'a @dots{}'}})
10546 Draw an arc clockwise from the current location through the two
10547 specified relative locations (@var{dx1},@var{dy1}) and
10548 (@var{dx2},@var{dy2}). The coordinates of the first point are relative
10549 to the current position, and the coordinates of the second point are
10550 relative to the first point.
10552 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10553 @cindex drawing a spline (@w{@code{\D'~ @dots{}'}})
10554 @cindex spline, drawing (@w{@code{\D'~ @dots{}'}})
10555 Draw a spline from the current location to the relative point
10556 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}), and so on.
10558 @item \D'f @var{n}'
10559 @cindex gray shading (@w{@code{\D'f @dots{}'}})
10560 @cindex shading filled objects (@w{@code{\D'f @dots{}'}})
10561 Set the shade of gray to be used for filling solid objects to@w{
10562 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
10563 corresponds solid white and 1000 to solid black, and values in between
10564 correspond to intermediate shades of gray. This applies only to solid
10565 circles, solid ellipses, and solid polygons. By default, a level of
10568 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10569 @cindex drawing a polygon (@w{@code{\D'p @dots{}'}})
10570 @cindex polygon, drawing (@w{@code{\D'p @dots{}'}})
10571 Draw a polygon from the current location to the relative position
10572 (@var{dx1},@var{dy1}) and then to (@var{dx2},@var{dy2}) and so on.
10573 When the specified data points are exhausted, a line is drawn back
10574 to the starting point.
10576 @item \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{}'
10577 @cindex polygon, solid, drawing (@w{@code{\D'P @dots{}'}})
10578 @cindex drawing a solid polygon (@w{@code{\D'P @dots{}'}})
10579 @cindex solid polygon, drawing (@w{@code{\D'P @dots{}'}})
10580 Draw a solid polygon with the same parameters as an outlined polygon.
10581 No outline is drawn.
10583 Here a better variant of the box macro to fill the box with some color.
10584 Note that the box must be drawn before the text since colors in
10585 @code{gtroff} are not transparent; the filled polygon would hide the
10592 \h'-.2m'\v'(.2m - \\n[rsb]u)'\
10594 \D'P 0 -(\\n[rst]u - \\n[rsb]u + .4m) \
10595 (\\n[@@wd]u + .4m) 0 \
10596 0 (\\n[rst]u - \\n[rsb]u + .4m) \
10597 -(\\n[@@wd]u + .4m) 0'\
10598 \h'.2m'\v'-(.2m - \\n[rsb]u)'\
10605 @item \D't @var{n}'
10606 @cindex line thickness (@w{@code{\D't @dots{}'}})
10607 @cindex thickness of lines (@w{@code{\D't @dots{}'}})
10608 Set the current line thickness to @var{n}@w{ }machine units. A value of
10609 zero selects the smallest available line thickness. A negative value
10610 makes the line thickness proportional to the current point size (this is
10611 the default behaviour of @code{ditroff}).
10615 @xref{Drawing Functions}.
10617 @Defesc {\\b, ', string, '}
10618 @cindex pile, character (@code{\b})
10619 @cindex character pile (@code{\b})
10620 @cindex stacking characters (@code{\b})
10621 @dfn{Pile} a sequence of characters vertically, and center it vertically
10622 on the current line. Use it to build large brackets and braces.
10624 Here an example how to create a large opening brace:
10627 \b'\[lt]\[bv]\[lk]\[bv]\[lb]'
10630 @cindex @code{\b}, limitations
10631 @cindex limitations of @code{\b} escape
10632 The first character is on the top, the last character in the argument is
10633 at the bottom. Note that @code{gtroff} separates the characters
10634 vertically by 1@dmn{m}, and the whole object is centered 0.5@dmn{m}
10635 above the current baseline; the largest character width is used as the
10636 width for the whole object. This rather unflexible positioning
10637 algorithm doesn't work with @option{-Tdvi} since the bracket pieces vary
10638 in height for this device. Instead, use the @code{eqn} preprocessor.
10640 @xref{Manipulating Spacing}, how to adjust the vertical spacing with
10641 the @code{\x} escape.
10645 @c =====================================================================
10647 @node Traps, Diversions, Drawing Requests, gtroff Reference
10651 @dfn{Traps} are locations, which, when reached, call a specified
10652 macro. These traps can occur at a given location on the page, at a
10653 given location in the current diversion, at a blank line,
10654 after a certain number of input lines, or at the end of input.
10656 @cindex planting a trap
10657 @cindex trap, planting
10658 Setting a trap is also called @dfn{planting}.
10659 @cindex trap, springing
10660 @cindex springing a trap
10661 It is also said that a trap is @dfn{sprung} if the associated macro
10665 * Page Location Traps::
10666 * Diversion Traps::
10667 * Input Line Traps::
10668 * Blank Line Traps::
10669 * End-of-input Traps::
10672 @c ---------------------------------------------------------------------
10674 @node Page Location Traps, Diversion Traps, Traps, Traps
10675 @subsection Page Location Traps
10676 @cindex page location traps
10677 @cindex traps, page location
10679 @dfn{Page location traps} perform an action when @code{gtroff}
10680 reaches or passes a certain vertical location on the page. Page
10681 location traps have a variety of purposes, including:
10685 setting headers and footers
10688 setting body text in multiple columns
10694 @DefreqList {vpt, flag}
10695 @DefregListEnd {.vpt}
10696 @cindex enabling vertical position traps (@code{vpt})
10697 @cindex vertical position traps, enabling (@code{vpt})
10698 @cindex vertical position trap enable register (@code{.vpt})
10699 Enable vertical position traps if @var{flag} is non-zero, or disables
10700 them otherwise. Vertical position traps are traps set by the @code{wh}
10701 or @code{dt} requests. Traps set by the @code{it} request are not
10702 vertical position traps. The parameter that controls whether vertical
10703 position traps are enabled is global. Initially vertical position traps
10704 are enabled. The current setting of this is available in the
10705 @code{.vpt} read-only number register.
10708 @Defreq {wh, dist [@Var{macro}]}
10709 Set a page location trap. Positive values for @var{dist} set
10710 the trap relative to the top of the page; negative values set
10711 the trap relative to the bottom of the page. Default scaling
10712 indicator is @samp{v}.
10714 @var{macro} is the name of the macro to execute when the
10715 trap is sprung. If @var{macro} is missing, remove the first trap
10716 (if any) at @var{dist}.
10718 @cindex page headers
10719 @cindex page footers
10722 The following is a simple example of how many macro packages
10723 set headers and footers.
10726 .de hd \" Page header
10732 .de fo \" Page footer
10738 .wh 0 hd \" trap at top of the page
10739 .wh -1i fo \" trap one inch from bottom
10742 A trap at or below the bottom of the page is ignored; it can be made
10743 active by either moving it up or increasing the page length so that the
10744 trap is on the page.
10746 It is possible to have more than one trap at the same location; to do so,
10747 the traps must be defined at different locations, then moved together with
10748 the @code{ch} request; otherwise the second trap would replace the first
10749 one. Earlier defined traps hide later defined traps if moved to the same
10750 position (the many empty lines caused by the @code{bp} request are omitted):
10783 @cindex distance to next trap register (@code{.t})
10784 @cindex trap, distance, register (@code{.t})
10785 A read-only number register holding the distance to the next trap.
10787 If there are no traps between the current position and the bottom of the
10788 page, it contains the distance to the page bottom. In a diversion, the
10789 distance to the page bottom is infinite (the returned value is the biggest
10790 integer which can be represented in @code{groff}) if there are no diversion
10794 @Defreq {ch, macro dist}
10795 @cindex changing trap location (@code{ch})
10796 @cindex trap, changing location (@code{ch})
10797 Change the location of a trap.
10798 The first argument is the name of the macro to be invoked at
10799 the trap, and the second argument is the new location for the trap
10800 (note that the parameters are specified the opposite of the @code{wh}
10801 request). This is useful for building up footnotes in a diversion to
10802 allow more space at the bottom of the page for them.
10804 Default scaling indicator for @var{dist} is @samp{v}. If @var{dist}
10805 is missing, the trap is removed.
10811 ... (simplified) footnote example ...
10817 The read-only number register @code{.ne} contains the amount of space
10818 that was needed in the last @code{ne} request that caused a trap to be
10819 sprung. Useful in conjunction with the @code{.trunc} register.
10820 @xref{Page Control}, for more information.
10824 @cindex @code{ne} request, and the @code{.trunc} register
10825 @cindex truncated vertical space register (@code{.trunc})
10826 A read-only register containing the amount of vertical space truncated
10827 by the most recently sprung vertical position trap, or, if the trap was
10828 sprung by an @code{ne} request, minus the amount of vertical motion
10829 produced by the @code{ne} request. In other words, at the point a trap
10830 is sprung, it represents the difference of what the vertical position
10831 would have been but for the trap, and what the vertical position
10835 @c ---------------------------------------------------------------------
10837 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
10838 @subsection Diversion Traps
10839 @cindex diversion traps
10840 @cindex traps, diversion
10842 @Defreq {dt, dist macro}
10843 @cindex @code{.t} register, and diversions
10844 @cindex setting diversion trap (@code{dt})
10845 @cindex diversion trap, setting (@code{dt})
10846 @cindex trap, diversion, setting (@code{dt})
10847 Set a trap @emph{within} a diversion.
10848 @var{dist} is the location of the trap
10849 (identical to the @code{.wh} request; default scaling indicator is
10850 @samp{v}) and @var{macro} is the name of the macro to be invoked. The
10851 number register @code{.t} still works within diversions.
10852 @xref{Diversions}, for more information.
10855 @c ---------------------------------------------------------------------
10857 @node Input Line Traps, Blank Line Traps, Diversion Traps, Traps
10858 @subsection Input Line Traps
10859 @cindex input line traps
10860 @cindex traps, input line
10862 @DefreqList {it, n macro}
10863 @DefreqItem {itc, n macro}
10864 @cindex setting input line trap (@code{it})
10865 @cindex input line trap, setting (@code{it})
10866 @cindex trap, input line, setting (@code{it})
10867 Set an input line trap.
10868 @var{n}@w{ }is the number of lines of input which may be read before
10869 springing the trap, @var{macro} is the macro to be invoked.
10870 Request lines are not counted as input lines.
10872 For example, one possible use is to have a macro which prints the
10873 next @var{n}@w{ }lines in a bold font.
10886 @cindex input line traps and interrupted lines (@code{itc})
10887 @cindex interrupted lines and input line traps (@code{itc})
10888 @cindex traps, input line, and interrupted lines (@code{itc})
10889 @cindex lines, interrupted, and input line traps (@code{itc})
10890 The @code{itc} request is identical,
10891 except that a line interrupted with @code{\c}
10892 counts as one input line.
10894 Both requests are associated with the current environment
10895 (@pxref{Environments}); switching to another environment disables the
10896 current input trap, and going back reactivates it, restoring the number
10897 of already processed lines.
10900 @c ---------------------------------------------------------------------
10902 @node Blank Line Traps, End-of-input Traps, Input Line Traps, Traps
10903 @subsection Blank Line Traps
10904 @cindex blank line traps
10905 @cindex traps, blank line
10907 @Defreq {blm, macro}
10908 @cindex blank line macro (@code{blm})
10909 Set a blank line trap.
10910 @code{gtroff} executes @var{macro} when it encounters a blank line in
10914 @c ---------------------------------------------------------------------
10916 @node End-of-input Traps, , Blank Line Traps, Traps
10917 @subsection End-of-input Traps
10918 @cindex end-of-input traps
10919 @cindex traps, end-of-input
10921 @Defreq {em, macro}
10922 @cindex setting end-of-input trap (@code{em})
10923 @cindex end-of-input trap, setting (@code{em})
10924 @cindex trap, end-of-input, setting (@code{em})
10925 @cindex end-of-input macro (@code{em})
10926 @cindex macro, end-of-input (@code{em})
10927 Set a trap at the end of input. @var{macro} is executed after the
10928 last line of the input file has been processed.
10930 For example, if the document had to have a section at the bottom of the
10931 last page for someone to approve it, the @code{em} request could be
10937 . sp |(\\n[.t] - 6v)
10951 @c =====================================================================
10953 @node Diversions, Environments, Traps, gtroff Reference
10954 @section Diversions
10957 In @code{gtroff} it is possible to @dfn{divert} text into a named
10958 storage area. Due to the similarity to defining macros it is sometimes
10959 said to be stored in a macro. This is used for saving text for output
10960 at a later time, which is useful for keeping blocks of text on the same
10961 page, footnotes, tables of contents, and indices.
10963 @cindex top-level diversion
10964 @cindex diversion, top-level
10965 For orthogonality it is said that @code{gtroff} is in the @dfn{top-level
10966 diversion} if no diversion is active (i.e., the data is diverted to the
10969 @DefreqList {di, macro}
10970 @DefreqListEnd {da, macro}
10971 @cindex beginning diversion (@code{di})
10972 @cindex diversion, beginning (@code{di})
10973 @cindex ending diversion (@code{di})
10974 @cindex diversion, ending (@code{di})
10975 @cindex appending to a diversion (@code{da})
10976 @cindex diversion, appending (@code{da})
10977 Begin a diversion. Like the @code{de}
10978 request, it takes an argument of a macro name to divert subsequent text
10979 into. The @code{da} macro appends to an existing diversion.
10981 @code{di} or @code{da} without an argument ends the diversion.
10984 @DefreqList {box, macro}
10985 @DefreqListEnd {boxa, macro}
10986 Begin (or appends to) a diversion like the
10987 @code{di} and @code{da} requests.
10988 The difference is that @code{box} and @code{boxa}
10989 do not include a partially-filled line in the diversion.
11001 @result{} Before the box. After the box.
11003 @result{} In the box.
11010 Before the diversion.
11015 After the diversion.
11017 @result{} After the diversion.
11019 @result{} Before the diversion. In the diversion.
11022 @code{box} or @code{boxa} without an argument ends the diversion.
11026 @DefregListEnd {.d}
11027 @cindex @code{nl} register, and @code{.d}
11028 @cindex nested diversions
11029 @cindex diversion, nested
11030 @cindex diversion name register (@code{.z})
11031 @cindex vertical position in diversion register (@code{.d})
11032 @cindex position, vertical, in diversion, register (@code{.d})
11033 @cindex diversion, vertical position in, register (@code{.d})
11034 Diversions may be nested. The read-only number register @code{.z}
11035 contains the name of the current diversion (this is a string-valued
11036 register). The read-only number register @code{.d} contains the current
11037 vertical place in the diversion. If not in a diversion it is the same
11038 as the register @code{nl}.
11042 @cindex high-water mark register (@code{.h})
11043 @cindex mark, high-water, register (@code{.h})
11044 @cindex position of lowest text line (@code{.h})
11045 @cindex text line, position of lowest (@code{.h})
11046 The @dfn{high-water mark} on the current page. It corresponds to the
11047 text baseline of the lowest line on the page. This is a read-only
11051 .tm .h==\n[.h], nl==\n[nl]
11052 @result{} .h==0, nl==-1
11056 .tm .h==\n[.h], nl==\n[nl]
11057 @result{} .h==40, nl==120
11060 @cindex @code{.h} register, difference to @code{nl}
11061 @cindex @code{nl} register, difference to @code{.h}
11063 As can be seen in the previous example, empty lines are not considered
11064 in the return value of the @code{.h} register.
11068 @DefregListEnd {dl}
11069 After completing a diversion, the read-write number registers @code{dn}
11070 and @code{dl} contain the vertical and horizontal size of the diversion.
11074 .\" Center text both horizontally & vertically
11076 .\" Enclose macro definitions in .eo and .ec
11077 .\" to avoid the doubling of the backslash
11079 .\" macro .(c starts centering mode
11090 .\" macro .)c terminates centering mode
11095 . nr @@s (((\n[.t]u - \n[dn]u) / 2u) - 1v)
11107 .\" End of macro definitions, restore escape mechanism
11113 @DefescList {\\!, , , }
11114 @DefescListEnd {\\?, , @Var{anything}, \\?}
11115 @cindex transparent output (@code{\!}, @code{\?})
11116 @cindex output, transparent (@code{\!}, @code{\?})
11117 Prevent requests, macros, and escapes from being
11118 interpreted when read into a diversion. This takes the given text
11119 and @dfn{transparently} embeds it into the diversion. This is useful for
11120 macros which shouldn't be invoked until the diverted text is actually
11123 The @code{\!} escape transparently embeds text up to
11124 and including the end of the line.
11125 The @code{\?} escape transparently embeds text until the next
11126 occurrence of the @code{\?} escape. For example:
11133 @var{anything} may not contain newlines; use @code{\!} to embed
11134 newlines in a diversion. The escape sequence @code{\?} is also
11135 recognized in copy mode and turned into a single internal code; it is
11136 this code that terminates @var{anything}. Thus the following example
11143 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
11157 Both escapes read the data in copy mode.
11160 @Defreq {asciify, div}
11161 @cindex unformatting diversions (@code{asciify})
11162 @cindex diversion, unformatting (@code{asciify})
11163 @cindex @code{trin} request, and @code{asciify}
11164 @dfn{Unformat} the diversion specified by @var{div}
11165 in such a way that @acronym{ASCII} characters, characters translated with
11166 the @code{trin} request, space characters, and some escape sequences that
11167 were formatted and diverted are treated like ordinary input
11168 characters when the diversion is reread. It can be also used for gross
11169 hacks; for example, the following sets register@w{ }@code{n} to@w{ }1.
11182 @xref{Copy-in Mode}.
11185 @Defreq {unformat, div}
11186 Like @code{asciify}, unformat the specified diversion.
11187 However, @code{unformat} only unformats spaces and tabs
11189 Unformatted tabs are treated as input tokens,
11190 and spaces are stretchable again.
11192 The vertical size of lines is not preserved; glyph information (font,
11193 font size, space width, etc.)@: is retained.
11197 @c =====================================================================
11199 @node Environments, Suppressing output, Diversions, gtroff Reference
11200 @section Environments
11201 @cindex environments
11203 It happens frequently that some text should be printed in a certain
11204 format regardless of what may be in effect at the time, for example, in
11205 a trap invoked macro to print headers and footers. To solve this
11206 @code{gtroff} processes text in @dfn{environments}. An
11207 environment contains most of the parameters that control text
11208 processing. It is possible to switch amongst these environments; by
11209 default @code{gtroff} processes text in environment@w{ }0. The
11210 following is the information kept in an environment.
11214 font parameters (size, family, style, character height and slant, space
11215 and sentence space size)
11218 page parameters (line length, title length, vertical spacing,
11219 line spacing, indentation, line numbering, centering, right-justifying,
11220 underlining, hyphenation data)
11223 fill and adjust mode
11226 tab stops, tab and leader characters, escape character,
11227 no-break and hyphen indicators, margin character data
11230 partially collected lines
11236 drawing and fill colours
11239 These environments may be given arbitrary names (see @ref{Identifiers},
11240 for more info). Old versions of @code{troff} only had environments
11241 named @samp{0}, @samp{1}, and @samp{2}.
11243 @DefreqList {ev, [@Var{env}]}
11244 @DefregListEnd {.ev}
11245 @cindex switching environments (@code{ev})
11246 @cindex environment, switching (@code{ev})
11247 @cindex environment number/name register (@code{.ev})
11248 Switch to another environment. The argument @var{env} is the name of
11249 the environment to switch to. With no argument, @code{gtroff} switches
11250 back to the previous environment. There is no limit on the number of
11251 named environments; they are created the first time that they are
11252 referenced. The @code{.ev} read-only register contains the name or
11253 number of the current environment. This is a string-valued register.
11255 Note that a call to @code{ev} (with argument) pushes the previously
11256 active environment onto a stack. If, say, environments @samp{foo},
11257 @samp{bar}, and @samp{zap} are called (in that order), the first
11258 @code{ev} request without parameter switches back to environment
11259 @samp{bar} (which is popped off the stack), and a second call
11260 switches back to environment @samp{foo}.
11262 Here is an example:
11275 \(dg Note the large, friendly letters.
11281 @cindex copying environment (@code{evc})
11282 @cindex environment, copying (@code{evc})
11283 Copy the environment @var{env} into the current environment.
11285 The following environment data is not copied:
11289 Partially filled lines.
11292 The status whether the previous line was interrupted.
11295 The number of lines still to center, or to right-justify, or to underline
11296 (with or without underlined spaces); they are set to zero.
11299 The status whether a temporary indent is active.
11302 Input traps and its associated data.
11305 Line numbering mode is disabled; it can be reactivated with
11309 The number of consecutive hyphenated lines (set to zero).
11315 @DefregListEnd {.csk}
11316 @cindex environment, last character
11317 The @code{\n[.cht]} register contains the
11318 maximum extent (above the baseline)
11319 of the last character added to the current environment.
11321 The @code{\n[.cdp]} register contains the
11322 maximum extent (below the baseline)
11323 of the last character added to the current environment.
11325 The @code{\n[.csk]} register contains the
11326 @dfn{skew} (how far to the right of the character's center
11327 that @code{gtroff} shold place an accent)
11328 of the last character added to the current environment.
11332 @c =====================================================================
11334 @node Suppressing output, Colors, Environments, gtroff Reference
11335 @section Suppressing output
11337 @Defesc {\\O, , num, }
11338 @cindex suppressing output (@code{\O})
11339 @cindex output, suppressing (@code{\O})
11340 Disable or enable output depending on the value of @var{num}:
11344 Disable any ditroff glyphs from being emitted to the device driver,
11345 provided that the escape occurs at the outer level (see @code{\O3} and
11349 Enable output of glyphs, provided that the escape occurs at the outer
11357 @code{\O0} and @code{\O1} also reset the four registers @samp{opminx},
11358 @samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
11359 @xref{Register Index}. These four registers mark the top left and
11360 bottom right hand corners of a box which encompasses all written glyphs.
11364 Provided that the escape occurs at the outer level, enable output of
11365 glyphs and also write out to @code{stderr} the page number and four
11366 registers encompassing the glyphs previously written since the last call
11370 Begin a nesting level. This is really an internal mechanism for
11371 @code{grohtml} while producing images. They are generated by running
11372 the troff source through troff to the PostScript device and GhostScript
11373 to produce images in PNG format. The @code{\O3} escape will start a new
11374 page if the device is not html (to reduce the possibility of images
11375 crossing a page boundary).
11378 End a nesting level.
11380 @item \O[5Pfilename]
11381 This escape is @code{grohtml} specific. Provided that this escape
11382 occurs at the outer nesting level write the @code{filename} to
11383 @code{stderr}. The position of the image, @var{P}, must be specified
11384 and must be one of @code{l}, @code{r}, @code{c}, or@w{ }@code{i} (left,
11385 right, centered, inline). @var{filename} will be associated with the
11386 production of the next inline image.
11391 @c =====================================================================
11393 @node Colors, I/O, Suppressing output, gtroff Reference
11397 @Defreq {defcolor, ident scheme color_components}
11398 Define color with name @var{ident}. @var{scheme} can be one of the
11399 following values: @code{rgb} (three components), @code{cym} (three
11400 components), @code{cmyk} (four components), and @code{gray} or
11401 @code{grey} (one component).
11403 @cindex default color
11404 @cindex color, default
11405 Color components can be given either as a hexadecimal string or as
11406 positive decimal integers in the range 0--65535. A hexadecimal string
11407 contains all color components concatenated. It must start with either
11408 @code{#} or @code{##}; the former specifies hex values in the range
11409 0--255 (which are internally multiplied by@w{ }257), the latter in the
11410 range 0--65535. Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
11411 (magenta). The default color name @c{default} can't be redefined; its
11412 value is device-specific (usually black). It is possible that the
11413 default color for @code{\m} and @code{\M} is not identical.
11415 @cindex @code{f} unit, and colors
11416 @cindex unit, @code{f}, and colors
11417 A new scaling indicator@w{ }@code{f} has been introduced which multiplies
11418 its value by 65536; this makes it convenient to specify color components
11419 as fractions in the range 0 to@w{ }1 (1f equals 65536u). Example:
11422 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
11425 Note that @code{f} is the default scaling indicator for the
11426 @code{defcolor} request, thus the above statement is equivalent to
11429 .defcolor darkgreen rgb 0.1 0.5 0.2
11433 @DefescList {\\m, , c, }
11434 @DefescItem {\\m, @lparen{}, co, }
11435 @DefescListEnd {\\m, @lbrack{}, color, @rbrack}
11436 Set drawing color. The following example shows how to turn the next four
11440 \m[red]these are in red\m[] and these words are in black.
11443 The escape @code{\m[]} returns to the previous color.
11445 The drawing color is associated with the current environment
11446 (@pxref{Environments}).
11449 @DefescList {\\M, , c, }
11450 @DefescItem {\\M, @lparen{}, co, }
11451 @DefescListEnd {\\M, @lbrack{}, color, @rbrack}
11452 Set background color for filled objects drawn with the
11453 @code{\D'@dots{}'} commands.
11455 A red ellipse can be created with the following code:
11458 \M[red]\h'0.5i'\D'E 2i 1i'\M[]
11461 The escape @code{\M[]} returns to the previous fill color.
11463 The fill color is associated with the current environment
11464 (@pxref{Environments}).
11468 @c =====================================================================
11470 @node I/O, Postprocessor Access, Colors, gtroff Reference
11473 @cindex input and output requests
11474 @cindex requests for input and output
11475 @cindex output and input requests
11477 @code{gtroff} has several requests for including files:
11480 @cindex including a file (@code{so})
11481 @cindex file, inclusion (@code{so})
11482 Read in the specified @var{file} and
11483 includes it in place of the @code{so} request. This is quite useful for
11484 large documents, e.g.@: keeping each chapter in a separate file.
11485 @xref{gsoelim}, for more information.
11488 @Defreq {pso, command}
11489 Read the standard output from the specified @var{command}
11490 and includes it in place of the @code{pso} request.
11492 This request causes an error if used in safer mode (which is the default).
11493 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11497 @Defreq {mso, file}
11498 Identical to the @code{so} request except that @code{gtroff}
11499 searches for the specified
11500 @var{file} in the same directories as macro files for the
11501 the @option{-m} command line option. If the file name to be included
11502 has the form @file{@var{name}.tmac} and it isn't found, @code{mso} tries
11503 to include @file{tmac.@var{name}} and vice versa.
11506 @DefreqList {trf, file}
11507 @DefreqListEnd {cf, file}
11508 @cindex transparent output (@code{cf}, @code{trf})
11509 @cindex output, transparent (@code{cf}, @code{trf})
11510 Transparently output the contents of @var{file}. Each line is output
11511 as if it were preceded by @code{\!}; however, the lines are not subject
11512 to copy mode interpretation. If the file does not end with a newline,
11513 then a newline is added (@code{trf} only). For example, to define a
11514 macro@w{ }@code{x} containing the contents of file@w{ }@file{f}, use
11522 Both @code{trf} and @code{cf}, when used in a diversion,
11523 embeds an object in the diversion which, when reread, causes the
11524 contents of @var{file} to be transparently copied through to the
11525 output. In @acronym{UNIX} @code{troff}, the contents of @var{file}
11526 is immediately copied through to the output regardless of whether there
11527 is a current diversion; this behaviour is so anomalous that it must be
11530 @cindex @code{trf} request, and invalid characters
11531 @cindex characters, invalid for @code{trf} request
11532 @cindex invalid characters for @code{trf} request
11533 While @code{cf} copies the contents of @var{file} completely unprocessed,
11534 @code{trf} disallows characters such as NUL that are not valid
11535 @code{gtroff} input characters (@pxref{Identifiers}).
11537 Both requests cause a line break.
11540 @Defreq {nx, [@Var{file}]}
11541 @cindex processing next file (@code{nx})
11542 @cindex file, processing next (@code{nx})
11543 @cindex next file, processing (@code{nx})
11544 Force @code{gtroff} to continue processing of
11545 the file specified as an argument. If no argument is given, immediately
11546 jump to the end of file.
11549 @Defreq {rd, [@Var{prompt} [@Var{arg1} @Var{arg2} @dots{}]]}
11550 @cindex reading from standard input (@code{rd})
11551 @cindex standard input, reading from (@code{rd})
11552 @cindex input, standard, reading from (@code{rd})
11553 Read from standard input, and include what is read as though it
11554 were part of the input file. Text is read until a blank line
11557 If standard input is a TTY input device (keyboard), write @var{prompt}
11558 to standard error, followed by a colon (or send BEL for a beep if no
11559 argument is given).
11561 Arguments after @var{prompt} are available for the input. For example,
11568 with the input @w{@samp{This is \$2.}} prints
11575 @cindex form letters
11576 @cindex letters, form
11577 Using the @code{nx} and @code{rd} requests,
11578 it is easy to set up form letters. The form
11579 letter template is constructed like this, putting the following lines
11580 into a file called @file{repeat.let}:
11596 @cindex @code{ex} request, used with @code{nx} and @code{rd}
11598 When this is run, a file containing the following lines should be
11599 redirected in. Note that requests included in this file are executed
11600 as though they were part of the form letter. The last block of input
11601 is the @code{ex} request which tells groff to stop processing. If
11602 this was not there, groff would not know when to stop.
11606 708 NW 19th Av., #202
11613 San Diego, CA 92103
11621 Pipe the output of @code{gtroff} to the shell command(s)
11622 specified by @var{pipe}. This request must occur before
11623 @code{gtroff} has a chance to print anything.
11625 @code{pi} causes an error if used in safer mode (which is the default).
11626 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11629 Multiple calls to @code{pi} are allowed, acting as a chain. For example,
11637 is the same as @w{@samp{.pi foo | bar}}.
11639 @cindex @code{groff}, and @code{pi} request
11640 @cindex @code{pi} request, and @code{groff}
11641 Note that the intermediate output format of @code{gtroff} is piped to
11642 the specified commands. Consequently, calling @code{groff} without the
11643 @option{-Z} option normally causes a fatal error.
11646 @DefreqList {sy, cmds}
11647 @DefregListEnd {systat}
11648 Execute the shell command(s) specified by @var{cmds}. The output is not
11649 saved anyplace, so it is up to the user to do so.
11651 This request causes an error if used in safer mode (which is the default).
11652 Use @code{groff}'s or @code{troff}'s @option{-U} option to activate unsafe
11655 For example, the following example introduces the current time
11658 @cindex time, current
11659 @cindex current time
11662 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
11663 (localtime(time))[2,1,0]' > /tmp/x\n[$$]
11665 .sy rm /tmp/x\n[$$]
11670 Note that this works by having the @code{perl} script (run by @code{sy})
11671 print out the @code{nr} requests which set the number registers
11672 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in with
11673 the @code{so} request.
11675 @cindex @code{system()} return value register (@code{systat})
11676 The @code{systat} read-write number register contains the return value
11677 of the @code{system()} function executed by the last @code{sy} request.
11680 @DefreqList {open, stream file}
11681 @DefreqListEnd {opena, stream file}
11682 @cindex opening file (@code{open})
11683 @cindex file, opening (@code{open})
11684 @cindex appending to a file (@code{opena})
11685 @cindex file, appending to (@code{opena})
11686 Open the specified @var{file} for writing and
11687 associates the specified @var{stream} with it.
11689 The @code{opena} request is like @code{open}, but if the file exists,
11690 append to it instead of truncating it.
11692 Both @code{open} and @code{opena} cause an error if used in safer mode
11693 (which is the default). Use @code{groff}'s or @code{troff}'s @option{-U}
11694 option to activate unsafe mode.
11697 @DefreqList {write, stream data}
11698 @DefreqListEnd {writec, stream data}
11699 @cindex copy-in mode, and @code{write} requests
11700 @cindex mode, copy-in, and @code{write} requests
11701 @cindex writing to file (@code{write})
11702 @cindex file, writing to (@code{write})
11703 Write to the file associated with the specified @var{stream}.
11704 The stream must previously have
11705 been the subject of an open request. The remainder of the line is
11706 interpreted as the @code{ds} request reads its second argument: A
11707 leading @samp{"} is stripped, and it is read in copy-in mode.
11709 The @code{writec} request is like @code{write}, but only
11710 @code{write} appends a newline to the data.
11713 @Defreq {writem, stream xx}
11714 @cindex @code{asciify} request, and @code{writem}
11715 Write the contents of the macro or string @var{xx}
11716 to the file associated with the specified @var{stream}.
11718 @var{xx} is read in copy mode, i.e., already formatted elements are
11719 ignored. Consequently, diversions must be unformatted with the
11720 @code{asciify} request before calling @code{writem}. Usually, this
11721 means a loss of information.
11724 @Defreq {close, stream}
11725 @cindex closing file (@code{close})
11726 @cindex file, closing (@code{close})
11727 Close the specified @var{stream};
11728 the stream is no longer an acceptable argument to the
11729 @code{write} request.
11731 Here a simple macro to write an index entry.
11737 . write idx \\n[%] \\$*
11746 @DefescList {\\V, , e, }
11747 @DefescItem {\\V, @lparen{}, ev, }
11748 @DefescListEnd {\\V, @lbrack{}, env, @rbrack}
11749 Interpolate the contents of the specified environment variable
11750 @var{env} (one-character name@w{ }@var{e}, two-character name @var{ev})
11751 as returned by the function @code{getenv}. @code{\V} is interpreted
11756 @c =====================================================================
11758 @node Postprocessor Access, Miscellaneous, I/O, gtroff Reference
11759 @section Postprocessor Access
11760 @cindex postprocessor access
11761 @cindex access of postprocessor
11763 There are two escapes which give information directly to the
11764 postprocessor. This is particularly useful for embedding
11765 @sc{PostScript} into the final document.
11767 @Defesc {\\X, ', xxx, '}
11768 Embeds its argument into the @code{gtroff}
11769 output preceded with @w{@samp{x X}}.
11771 @cindex @code{\&}, in @code{\X}
11772 @cindex @code{\)}, in @code{\X}
11773 @cindex @code{\%}, in @code{\X}
11775 @cindex @code{\:}, in @code{\X}
11778 @cindex @code{\@r{<colon>}}, in @code{\X}
11780 The escapes @code{\&}, @code{\)}, @code{\%}, and @code{\:} are ignored
11781 within @code{\X}; all other escapes (except @code{\\} which produces a
11782 backslash) cause an error.
11784 @kindex use_charnames_in_special
11785 @pindex DESC@r{, and @code{use_charnames_in_special}}
11786 @cindex @code{\X}, and special characters
11787 If the @samp{use_charnames_in_special} keyword is set in the @file{DESC}
11788 file, special characters no longer cause an error; the name @var{xx} is
11789 represented as @samp{\(@var{xx})} in the @w{@samp{x X}} output command.
11790 Additionally, the backslash is represented as @code{\\}.
11792 This mechanism is currently used by @code{grohtml} only.
11795 @DefescList {\\Y, , n, }
11796 @DefescItem {\\Y, @lparen{}, nm, }
11797 @DefescListEnd {\\Y, @lbrack{}, name, @rbrack}
11798 This is approximately equivalent to @samp{\X'\*[@var{name}]'}
11799 (one-character name@w{ }@var{n}, two-character name @var{nm}).
11800 However, the contents of the string or macro @var{name} are not
11801 interpreted; also it is permitted for @var{name} to have been defined
11802 as a macro and thus contain newlines (it is not permitted for the
11803 argument to @code{\X} to contain newlines). The inclusion of
11804 newlines requires an extension to the @acronym{UNIX} @code{troff}
11805 output format, and confuses drivers that do not know about this
11806 extension (@pxref{Line Continuation}).
11809 @xref{Output Devices}.
11812 @c =====================================================================
11814 @node Miscellaneous, Gtroff Internals, Postprocessor Access, gtroff Reference
11815 @section Miscellaneous
11817 This section documents parts of @code{gtroff} which cannot (yet) be
11818 categorized elsewhere in this manual.
11820 @Defreq {nm, [@Var{start} [@Var{inc} [@Var{space} [@Var{indent}]]]]}
11821 @cindex printing line numbers (@code{nm})
11822 @cindex line numbers, printing (@code{nm})
11823 @cindex numbers, line, printing (@code{nm})
11824 Print line numbers.
11825 @var{start} is the line number of the @emph{next}
11826 output line. @var{inc} indicates which line numbers are printed.
11827 For example, the value@w{ }5 means to emit only line numbers which
11828 are multiples of@w{ }5; this defaults to@w{ }1. @var{space} is the
11829 space to be left between the number and the text; this defaults to
11830 one digit space. The fourth argument is the indentation of the line
11831 numbers, defaulting to zero. Both @var{space} and @var{indent} are
11832 given as multiples of digit spaces; they can be negative also.
11833 Without any arguments, line numbers are turned off.
11835 @code{gtroff} reserves three digit spaces for the line number (which is
11836 printed right-justified) plus the amount given by @var{indent}; the
11837 output lines are concatenated to the line numbers, separated by
11838 @var{space}, and @emph{without} reducing the line length. Depending
11839 on the value of the horizontal page offset (as set with the
11840 @code{po} request), line numbers which are longer than the reserved
11841 space stick out to the left, or the whole line is moved to the right.
11843 Parameters corresponding to missing arguments are not changed; any
11844 non-digit argument (to be more precise, any argument starting with a
11845 character valid as a delimiter for identifiers) is also treated as
11848 If line numbering has been disabled with a call to @code{nm} without
11849 an argument, it can be reactivated with @samp{.nm +0}, using the
11850 previously active line numbering parameters.
11852 The parameters of @code{nm} are associated with the current environment
11853 (@pxref{Environments}). The current output line number is available
11854 in the number register @code{ln}.
11859 This test shows how line numbering works with groff.
11861 This test shows how line numbering works with groff.
11865 This test shows how line numbering works with groff.
11867 This test shows how line numbering works with groff.
11871 And here the result:
11874 This test shows how
11875 line numbering works
11876 999 with groff. This
11877 1000 test shows how line
11878 1001 numbering works with
11880 This test shows how
11883 This test shows how
11884 1005 line numbering
11889 @Defreq {nn, [@Var{skip}]}
11890 Temporarily turn off line numbering. The argument is the number
11891 of lines not to be numbered; this defaults to@w{ }1.
11894 @Defreq {mc, char [@Var{dist}]}
11895 @cindex margin character (@code{mc})
11896 @cindex character, for margins (@code{mc})
11897 Print margin character to the right of the text.
11898 The first argument is the character to be
11899 printed. The second argument is the distance away from the right
11900 margin. If missing, the previously set value is used; default is
11901 10@dmn{pt}). For text lines that are too long (that is, longer than
11902 the text length plus @var{dist}), the margin character is directly
11903 appended to the lines.
11905 With no arguments the margin character is turned off.
11906 If this occurs before a break, no margin character is printed.
11908 @cindex @code{tl} request, and @code{mc}
11909 For empty lines and lines produced by the @code{tl} request no margin
11910 character is emitted.
11912 The margin character is associated with the current environment
11913 (@pxref{Environments}).
11917 This is quite useful for indicating text that has changed, and, in fact,
11918 there are programs available for doing this (they are called
11919 @code{nrchbar} and @code{changebar} and can be found in any
11920 @samp{comp.sources.unix} archive.
11926 ... margin char example ...
11931 @DefreqList {psbb, filename}
11935 @DefregListEnd {ury}
11936 @cindex PostScript, bounding box
11937 @cindex bounding box
11938 Retrieve the bounding box of the PostScript image
11939 found in @var{filename}.
11940 The file must conform to
11941 Adobe's @dfn{Document Structuring Conventions} (DSC);
11942 the command searches for a @code{%%BoundingBox} comment
11943 and extracts the bounding box values into the number registers
11944 @code{llx}, @code{lly}, @code{urx}, and @code{ury}.
11945 If an error occurs (for example, @code{psbb} cannot find
11946 the @code{%%BoundingBox} comment),
11947 it sets the four number registers to zero.
11951 @c =====================================================================
11953 @node Gtroff Internals, Debugging, Miscellaneous, gtroff Reference
11954 @section @code{gtroff} Internals
11956 @cindex input token
11957 @cindex token, input
11958 @cindex output node
11959 @cindex node, output
11960 @code{gtroff} processes input in three steps. One or more input
11961 characters are converted to an @dfn{input token}.@footnote{Except the
11962 escapes @code{\f}, @code{\F}, @code{\H}, @code{\R}, @code{\s}, and
11963 @code{\S} which are processed immediately if not in copy-in mode.}
11964 Then, one or more input tokens are converted to an @dfn{output node}.
11965 Finally, output nodes are converted to the intermediate output language
11966 understood by all output devices.
11968 Actually, before step one happens, @code{gtroff} converts certain
11969 escape sequences into reserved input characters (not accessible by
11970 the user); such reserved characters are used for other internal
11971 processing also -- this is the very reason why not all characters
11972 are valid input. @xref{Identifiers}, for more on this topic.
11974 For example, the input string @samp{fi\[:u]} is converted into a
11975 character token @samp{f}, a character token @samp{i}, and a special
11976 token @samp{:u} (representing u@w{ }umlaut). Later on, the character
11977 tokens @samp{f} and @samp{i} are merged to a single output node
11978 representing the ligature glyph @samp{fi} (provided the current font
11979 has a glyph for this ligature); the same happens with @samp{:u}. All
11980 output glyph nodes are `processed' which means that they are invariably
11981 associated with a given font, font size, advance width, etc. During
11982 the formatting process, @code{gtroff} itself adds various nodes to
11983 control the data flow.
11985 Macros, diversions, and strings collect elements in two chained lists:
11986 a list of input tokens which have been passed unprocessed, and a list
11987 of output nodes. Consider the following the diversion.
11999 It contains these elements.
12001 @multitable {@i{vertical size node}} {token list} {element number}
12002 @item node list @tab token list @tab element number
12004 @item @i{line start node} @tab --- @tab 1
12005 @item @i{glyph node @code{a}} @tab --- @tab 2
12006 @item @i{word space node} @tab --- @tab 3
12007 @item --- @tab @code{b} @tab 4
12008 @item --- @tab @code{\n} @tab 5
12009 @item @i{glyph node @code{c}} @tab --- @tab 6
12010 @item @i{vertical size node} @tab --- @tab 7
12011 @item @i{vertical size node} @tab --- @tab 8
12012 @item --- @tab @code{\n} @tab 9
12015 @cindex @code{\v}, internal representation
12017 Elements 1, 7, and@w{ }8 are inserted by @code{gtroff}; the latter two
12018 (which are always present) specify the vertical extent of the last
12019 line, possibly modified by @code{\x}. The @code{br} request finishes
12020 the current partial line, inserting a newline input token which is
12021 subsequently converted to a space when the diversion is reread. Note
12022 that the word space node has a fixed width which isn't stretchable
12023 anymore. To convert horizontal space nodes back to input tokens, use
12024 the @code{unformat} request.
12026 Macros only contain elements in the token list (and the node list is
12027 empty); diversions and strings can contain elements in both lists.
12029 Some requests like @code{tr} or @code{cflags} work on glyph
12030 identifiers only; this means that the associated glyph can be changed
12031 without destroying this association. This can be very helpful for
12032 substituting glyphs. In the following example, we assume that
12033 glyph @samp{foo} isn't available by default, so we provide a
12034 substitution using the @code{fchar} request and map it to input
12035 character @samp{x}.
12043 Now let us assume that we install an additional special font
12044 @samp{bar} which has glyph @samp{foo}.
12052 Since glyphs defined with @code{fchar} are searched before glyphs
12053 in special fonts, we must call @code{rchar} to remove the definition
12054 of the fallback glyph. Anyway, the translation is still active;
12055 @samp{x} now maps to the real glyph @samp{foo}.
12058 @c =====================================================================
12060 @node Debugging, Implementation Differences, Gtroff Internals, gtroff Reference
12064 @code{gtroff} is not easy to debug, but there are some useful features
12065 and strategies for debugging.
12067 @Defreq {lf, line filename}
12069 @cindex multi-file documents
12070 @cindex documents, multi-file
12071 @cindex setting input line number (@code{lf})
12072 @cindex input line number, setting (@code{lf})
12073 @cindex number, input line, setting (@code{lf})
12074 Change the line number and the file name @code{gtroff} shall use for
12075 error and warning messages. @var{line} is the input line number of the
12078 Without argument, the request is ignored.
12080 This is a debugging aid for documents which are split into many files,
12081 then put together with @code{soelim} and other preprocessors. Usually,
12082 it isn't invoked manually.
12085 @DefreqList {tm, string}
12086 @DefreqItem {tm1, string}
12087 @DefreqListEnd {tmc, string}
12088 @cindex printing to stderr (@code{tm}, @code{tm1}, @code{tmc})
12089 @cindex stderr, printing to (@code{tm}, @code{tm1}, @code{tmc})
12090 Send @var{string} to the standard error output;
12091 this is very useful for printing debugging messages among other things.
12093 @var{string} is read in copy mode.
12095 The @code{tm} request ignores leading spaces of @var{string}; @code{tm1}
12096 handles its argument similar to the @code{ds} request: a leading double
12097 quote in @var{string} is stripped to allow initial blanks.
12099 The @code{tmc} request is similar to @code{tm1} but does
12100 not append a newline (as is done in @code{tm} and @code{tm1}).
12103 @Defreq {ab, [@Var{string}]}
12104 @cindex aborting (@code{ab})
12105 Similar to the @code{tm} request, except that
12106 it causes @code{gtroff} to stop processing. With no argument it
12107 prints @samp{User Abort.} to standard error.
12111 @cindex @code{ex} request, use in debugging
12112 @cindex exiting (@code{ex})
12113 The @code{ex} request also causes @code{gtroff} to stop processing;
12114 see also @ref{I/O}.
12117 When doing something involved it is useful to leave the debugging
12118 statements in the code and have them turned on by a command line flag.
12121 .if \n(DB .tm debugging output
12125 To activate these statements say
12131 If it is known in advance that there will be many errors and no useful
12132 output, @code{gtroff} can be forced to suppress formatted output with
12133 the @option{-z} flag.
12136 @cindex dumping symbol table (@code{pm})
12137 @cindex symbol table, dumping (@code{pm})
12138 Print the entire symbol table on @code{stderr}. Names of all defined
12139 macros, strings, and diversions are print together with their size in
12140 bytes. Since @code{gtroff} sometimes adds nodes by itself, the
12141 returned size can be larger than expected.
12143 This request differs from @acronym{UNIX} @code{troff}: @code{gtroff}
12144 reports the sizes of diversions, ignores an additional argument to
12145 print only the total of the sizes, and the size isn't returned in
12146 blocks of 128 characters.
12150 @cindex dumping number registers (@code{pnr})
12151 @cindex number registers, dumping (@code{pnr})
12152 Print the names and contents of all
12153 currently defined number registers on @code{stderr}.
12157 @cindex dumping traps (@code{ptr})
12158 @cindex traps, dumping (@code{ptr})
12159 Print the names and positions of all traps
12160 (not including input line traps and diversion traps) on @code{stderr}.
12161 Empty slots in the page trap list are printed as well, because they can
12162 affect the priority of subsequently planted traps.
12166 @cindex flush output (@code{fl})
12167 @cindex output, flush (@code{fl})
12168 @cindex interactive use of @code{gtroff}
12169 @cindex @code{gtroff}, interactive use
12170 Instruct @code{gtroff} to flush its output immediately. The intent
12171 is for interactive use, but this behaviour is currently not
12172 implemented in @code{gtroff}. Contrary to @acronym{UNIX} @code{troff},
12173 TTY output is sent to a device driver also (@code{grotty}), making it
12174 non-trivial to communicate interactively.
12176 This request causes a line break.
12179 @Defreq {backtrace, }
12180 @cindex backtrace of input stack (@code{backtrace})
12181 @cindex input stack, backtrace (@code{backtrace})
12182 Print a backtrace of the input stack to the standard error stream.
12184 Consider the following in file @file{test}:
12198 On execution, @code{gtroff} prints the following:
12201 test:2: backtrace: macro `xxx'
12202 test:5: backtrace: macro `yyy'
12203 test:8: backtrace: file `test'
12206 The option @option{-b} of @code{gtroff} internally calls a variant of
12207 this request on each error and warning.
12211 @cindex input stack, setting limit
12212 Use the @code{slimit} number register
12213 to set the maximum number of objects on the input stack.
12214 If @code{slimit} is less than or equal to@w{ }0,
12215 there is no limit set.
12216 With no limit, a buggy recursive macro can exhaust virtual memory.
12220 @code{gtroff} has command line options for printing out more warnings
12221 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
12222 or an error occurs. The most verbose level of warnings is @option{-ww}.
12224 @DefreqList {warn, [@Var{flags}]}
12225 @DefregListEnd {.warn}
12226 @cindex level of warnings (@code{warn})
12227 @cindex warnings, level (@code{warn})
12228 Control the level of warnings checked for. The @var{flags} are the sum
12229 of the numbers associated with each warning that is to be enabled; all
12230 other warnings are disabled. The number associated with each warning is
12231 listed below. For example, @w{@code{.warn 0}} disables all warnings,
12232 and @w{@code{.warn 1}} disables all warnings except that about missing
12233 characters. If no argument is given, all warnings are enabled.
12235 The read-only number register @code{.warn} contains the current warning
12243 @c ---------------------------------------------------------------------
12245 @node Warnings, , Debugging, Debugging
12246 @subsection Warnings
12249 The warnings that can be given to @code{gtroff} are divided into the
12250 following categories. The name associated with each warning is used by
12251 the @option{-w} and @option{-W} options; the number is used by the
12252 @code{warn} request and by the @code{.warn} register.
12257 Non-existent characters. This is enabled by default.
12261 Invalid numeric expressions. This is enabled by default.
12262 @xref{Expressions}.
12268 In fill mode, lines which could not be broken so that their length was
12269 less than the line length. This is enabled by default.
12273 Missing or mismatched closing delimiters.
12277 @cindex @code{ie} request, and warnings
12278 @cindex @code{el} request, and warnings
12279 Use of the @code{el} request with no matching @code{ie} request.
12284 Meaningless scaling indicators.
12288 Out of range arguments.
12292 Dubious syntax in numeric expressions.
12296 @cindex @code{di} request, and warnings
12297 @cindex @code{da} request, and warnings
12298 Use of @code{di} or @code{da} without an argument when there is no
12303 @cindex @code{de}, @code{de1}, @code{dei} requests, and warnings
12304 @cindex @code{am}, @code{am1}, @code{ami} requests, and warnings
12305 @cindex @code{ds}, @code{ds1} requests, and warnings
12306 @cindex @code{as}, @code{as1} requests, and warnings
12307 @cindex @code{di} request, and warnings
12308 @cindex @code{da} request, and warnings
12309 @cindex @code{box}, @code{boxa} requests, and warnings
12310 @cindex @code{\*}, and warnings
12311 Use of undefined strings, macros and diversions. When an undefined
12312 string, macro, or diversion is used, that string is automatically
12313 defined as empty. So, in most cases, at most one warning is given
12318 @cindex @code{nr} request, and warnings
12319 @cindex @code{\R}, and warnings
12320 @cindex @code{\n}, and warnings
12321 Use of undefined number registers. When an undefined number register is
12322 used, that register is automatically defined to have a value of@w{ }0.
12323 So, in most cases, at most one warning is given for use of a particular
12328 @cindex @code{\t}, and warnings
12329 Use of a tab character where a number was expected.
12333 @cindex @code{\@}}, and warnings
12334 Use of @code{\@}} where a number was expected.
12338 Requests that are missing non-optional arguments.
12342 Invalid input characters.
12346 Unrecognized escape sequences. When an unrecognized escape sequence
12347 @code{\@var{X}} is encountered, the escape character is ignored, and
12348 @var{X} is printed.
12352 @cindex compatibility mode
12353 Missing space between a request or macro and its argument. This warning
12354 is given when an undefined name longer than two characters is
12355 encountered, and the first two characters of the name make a defined
12356 name. The request or macro is not invoked. When this warning is
12357 given, no macro is automatically defined. This is enabled by default.
12358 This warning never occurs in compatibility mode.
12362 Non-existent fonts. This is enabled by default.
12366 Invalid escapes in text ignored with the @code{ig} request. These are
12367 conditions that are errors when they do not occur in ignored text.
12371 Color related warnings.
12374 All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
12375 intended that this covers all warnings that are useful with traditional
12383 @c =====================================================================
12385 @node Implementation Differences, , Debugging, gtroff Reference
12386 @section Implementation Differences
12387 @cindex implementation differences
12388 @cindex differences in implementation
12389 @cindex incompatibilities with @acronym{AT&T} @code{troff}
12390 @cindex compatibility mode
12391 @cindex mode, compatibility
12393 GNU @code{troff} has a number of features which cause incompatibilities
12394 with documents written with old versions of @code{troff}.
12397 @cindex names, long
12398 Long names cause some incompatibilities. @acronym{UNIX} @code{troff}
12405 @cindex @code{\*}, incompatibilities with @acronym{AT&T} @code{troff}
12406 @cindex @code{\n}, incompatibilities with @acronym{AT&T} @code{troff}
12408 as defining a string @samp{ab} with contents @samp{cd}. Normally, GNU
12409 @code{troff} interprets this as a call of a macro named
12410 @code{dsabcd}. Also @acronym{UNIX} @code{troff} interprets
12411 @code{\*[} or @code{\n[} as references to a string or number register
12412 called @samp{[}. In GNU @code{troff}, however, this is normally
12413 interpreted as the start of a long name. In compatibility mode GNU
12414 @code{troff} interprets long names in the traditional way
12415 (which means that they are not recognized as names).
12417 @DefreqList {cp, [@Var{n}]}
12418 @DefreqItem {do, cmd}
12419 @DefregListEnd {.C}
12420 If @var{n} is missing or non-zero, turn on compatibility mode;
12421 otherwise, turn it off.
12424 register @code{.C} is@w{ }1 if compatibility mode is on, 0@w{
12427 Compatibility mode can be turned on with the
12428 @option{-C} command line option.
12430 The @code{do} request turns off compatibility mode
12431 while executing its arguments as a @code{gtroff} command.
12438 executes the @code{fam} request when compatibility mode
12441 @code{gtroff} restores the previous compatibility setting
12442 before interpreting any files sourced by the @var{cmd}.
12445 @cindex input level in delimited arguments
12446 @cindex delimited arguments, incompatibilities with @acronym{AT&T} @code{troff}
12447 Two other features are controlled by @option{-C}. If not in
12448 compatibility mode, GNU @code{troff} preserves the input level in
12449 delimited arguments:
12457 In compatibility mode, the string @samp{72def'} is returned; without
12458 @option{-C} the resulting string is @samp{168} (assuming a TTY output
12461 @cindex @code{\f}, incompatibilities with @acronym{AT&T} @code{troff}
12462 @cindex @code{\H}, incompatibilities with @acronym{AT&T} @code{troff}
12463 @cindex @code{\R}, incompatibilities with @acronym{AT&T} @code{troff}
12464 @cindex @code{\s}, incompatibilities with @acronym{AT&T} @code{troff}
12465 @cindex @code{\S}, incompatibilities with @acronym{AT&T} @code{troff}
12466 Finally, the escapes @code{\f}, @code{\H}, @code{\R}, @code{\s}, and
12467 @code{\S} are transparent for recognizing the beginning of a line only
12468 in compatibility mode (this is a rather obscure feature). For example,
12478 prints @samp{Hallo!} in bold face if in compatibility mode, and
12479 @samp{.xx} in bold face otherwise.
12481 @cindex @code{\A}, incompatibilities with @acronym{AT&T} @code{troff}
12482 @cindex @code{\|}, incompatibilities with @acronym{AT&T} @code{troff}
12483 @cindex @code{\^}, incompatibilities with @acronym{AT&T} @code{troff}
12484 @cindex @code{\&}, incompatibilities with @acronym{AT&T} @code{troff}
12485 @cindex @code{\@{}, incompatibilities with @acronym{AT&T} @code{troff}
12486 @cindex @code{\@}}, incompatibilities with @acronym{AT&T} @code{troff}
12487 @cindex @code{\@key{SP}}, incompatibilities with @acronym{AT&T} @code{troff}
12488 @cindex @code{\'}, incompatibilities with @acronym{AT&T} @code{troff}
12489 @cindex @code{\`}, incompatibilities with @acronym{AT&T} @code{troff}
12490 @cindex @code{\-}, incompatibilities with @acronym{AT&T} @code{troff}
12491 @cindex @code{\_}, incompatibilities with @acronym{AT&T} @code{troff}
12492 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12493 @cindex @code{\%}, incompatibilities with @acronym{AT&T} @code{troff}
12494 @cindex @code{\c}, incompatibilities with @acronym{AT&T} @code{troff}
12495 GNU @code{troff} does not allow the use of the escape sequences
12496 @code{\|}, @code{\^}, @code{\&}, @code{\@{}, @code{\@}},
12497 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
12498 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
12499 registers, fonts or environments; @acronym{UNIX} @code{troff} does. The
12500 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
12501 avoiding use of these escape sequences in names.
12503 @cindex fractional point sizes
12504 @cindex fractional type sizes
12505 @cindex point sizes, fractional
12506 @cindex type sizes, fractional
12507 @cindex sizes, fractional
12508 @cindex @code{ps} request, incompatibilities with @acronym{AT&T} @code{troff}
12509 Fractional point sizes cause one noteworthy incompatibility. In
12510 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
12511 indicators and thus
12518 sets the point size to 10@w{ }points, whereas in GNU @code{troff} it
12519 sets the point size to 10@w{ }scaled points. @xref{Fractional Type
12520 Sizes}, for more information.
12522 @cindex @code{bd} request, incompatibilities with @acronym{AT&T} @code{troff}
12523 @cindex @code{cs} request, incompatibilities with @acronym{AT&T} @code{troff}
12524 @cindex @code{tr} request, incompatibilities with @acronym{AT&T} @code{troff}
12525 @cindex @code{fp} request, incompatibilities with @acronym{AT&T} @code{troff}
12526 @cindex input and output characters, compatibility with @acronym{AT&T} @code{troff}
12527 @cindex output characters, compatibility with @acronym{AT&T} @code{troff}
12528 @cindex characters, input and output, compatibility with @acronym{AT&T} @code{troff}
12529 In GNU @code{troff} there is a fundamental difference between
12530 unformatted, input characters, and formatted, output characters.
12531 Everything that affects how an output character is output is stored
12532 with the character; once an output character has been constructed it is
12533 unaffected by any subsequent requests that are executed, including
12534 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
12535 Normally output characters are constructed from input characters at the
12536 moment immediately before the character is added to the current output
12537 line. Macros, diversions and strings are all, in fact, the same type of
12538 object; they contain lists of input characters and output characters in
12539 any combination. An output character does not behave like an input
12540 character for the purposes of macro processing; it does not inherit any
12541 of the special properties that the input character from which it was
12542 constructed might have had. For example,
12552 @cindex printing backslash (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12553 @cindex backslash, printing (@code{\\}, @code{\e}, @code{\E}, @code{\[rs]})
12554 @cindex @code{\e}, incompatibilities with @acronym{AT&T} @code{troff}
12555 @cindex @code{\!}, incompatibilities with @acronym{AT&T} @code{troff}
12556 @cindex @code{\?}, incompatibilities with @acronym{AT&T} @code{troff}
12557 @cindex transparent output, incompatibilities with @acronym{AT&T} @code{troff}
12558 @cindex output, transparent, incompatibilities with @acronym{AT&T} @code{troff}
12560 prints @samp{\\} in GNU @code{troff}; each pair of input backslashes
12561 is turned into one output backslash and the resulting output backslashes
12562 are not interpreted as escape characters when they are reread.
12563 @acronym{UNIX} @code{troff} would interpret them as escape characters
12564 when they were reread and would end up printing one @samp{\}. The
12565 correct way to obtain a printable backslash is to use the @code{\e}
12566 escape sequence: This always prints a single instance of the current
12567 escape character, regardless of whether or not it is used in a
12568 diversion; it also works in both GNU @code{troff} and @acronym{UNIX}
12569 @code{troff}.@footnote{To be completely independent of the current
12570 escape character, use @code{\(rs} which represents a reverse solidus
12571 (backslash) glyph.} To store, for some reason, an escape sequence in a
12572 diversion that will be interpreted when the diversion is reread, either
12573 use the traditional @code{\!} transparent output facility, or, if this
12574 is unsuitable, the new @code{\?} escape sequence.
12576 @xref{Diversions}, for more information.
12580 @c =====================================================================
12581 @c =====================================================================
12583 @node Preprocessors, Output Devices, gtroff Reference, Top
12584 @chapter Preprocessors
12585 @cindex preprocessors
12587 This chapter describes all preprocessors that come with @code{groff} or
12588 which are freely available.
12601 @c =====================================================================
12603 @node geqn, gtbl, Preprocessors, Preprocessors
12604 @section @code{geqn}
12605 @cindex @code{eqn}, the program
12606 @cindex @code{geqn}, the program
12614 @c ---------------------------------------------------------------------
12616 @node Invoking geqn, , geqn, geqn
12617 @subsection Invoking @code{geqn}
12618 @cindex invoking @code{geqn}
12619 @cindex @code{geqn}, invoking
12624 @c =====================================================================
12626 @node gtbl, gpic, geqn, Preprocessors
12627 @section @code{gtbl}
12628 @cindex @code{tbl}, the program
12629 @cindex @code{gtbl}, the program
12637 @c ---------------------------------------------------------------------
12639 @node Invoking gtbl, , gtbl, gtbl
12640 @subsection Invoking @code{gtbl}
12641 @cindex invoking @code{gtbl}
12642 @cindex @code{gtbl}, invoking
12647 @c =====================================================================
12649 @node gpic, ggrn, gtbl, Preprocessors
12650 @section @code{gpic}
12651 @cindex @code{pic}, the program
12652 @cindex @code{gpic}, the program
12660 @c ---------------------------------------------------------------------
12662 @node Invoking gpic, , gpic, gpic
12663 @subsection Invoking @code{gpic}
12664 @cindex invoking @code{gpic}
12665 @cindex @code{gpic}, invoking
12670 @c =====================================================================
12672 @node ggrn, grap, gpic, Preprocessors
12673 @section @code{ggrn}
12674 @cindex @code{grn}, the program
12675 @cindex @code{ggrn}, the program
12683 @c ---------------------------------------------------------------------
12685 @node Invoking ggrn, , ggrn, ggrn
12686 @subsection Invoking @code{ggrn}
12687 @cindex invoking @code{ggrn}
12688 @cindex @code{ggrn}, invoking
12693 @c =====================================================================
12695 @node grap, grefer, ggrn, Preprocessors
12696 @section @code{grap}
12697 @cindex @code{grap}, the program
12699 A free implementation of @code{grap}, written by Ted Faber,
12700 is available as an extra package from the following address:
12703 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
12707 @c =====================================================================
12709 @node grefer, gsoelim, grap, Preprocessors
12710 @section @code{grefer}
12711 @cindex @code{refer}, the program
12712 @cindex @code{grefer}, the program
12717 * Invoking grefer::
12720 @c ---------------------------------------------------------------------
12722 @node Invoking grefer, , grefer, grefer
12723 @subsection Invoking @code{grefer}
12724 @cindex invoking @code{grefer}
12725 @cindex @code{grefer}, invoking
12730 @c =====================================================================
12732 @node gsoelim, , grefer, Preprocessors
12733 @section @code{gsoelim}
12734 @cindex @code{soelim}, the program
12735 @cindex @code{gsoelim}, the program
12740 * Invoking gsoelim::
12743 @c ---------------------------------------------------------------------
12745 @node Invoking gsoelim, , gsoelim, gsoelim
12746 @subsection Invoking @code{gsoelim}
12747 @cindex invoking @code{gsoelim}
12748 @cindex @code{gsoelim}, invoking
12754 @c =====================================================================
12755 @c =====================================================================
12757 @node Output Devices, File formats, Preprocessors, Top
12758 @chapter Output Devices
12759 @cindex output devices
12760 @cindex devices for output
12765 * Special Characters::
12776 @c =====================================================================
12778 @node Special Characters, grotty, Output Devices, Output Devices
12779 @section Special Characters
12780 @cindex special characters
12781 @cindex characters, special
12788 @c =====================================================================
12790 @node grotty, grops, Special Characters, Output Devices
12791 @section @code{grotty}
12792 @cindex @code{grotty}, the program
12797 * Invoking grotty::
12800 @c ---------------------------------------------------------------------
12802 @node Invoking grotty, , grotty, grotty
12803 @subsection Invoking @code{grotty}
12804 @cindex invoking @code{grotty}
12805 @cindex @code{grotty}, invoking
12809 @c The following is no longer true; fix and extend it.
12812 @c @cindex Teletype
12813 @c @cindex ISO 6249 SGR
12814 @c @cindex terminal control sequences
12815 @c @cindex control sequences, for terminals
12816 @c For TTY output devices, underlining is done by emitting sequences of
12817 @c @samp{_} and @samp{\b} (the backspace character) before the actual
12818 @c character. Literally, this is printing an underline character, then
12819 @c moving back one character position, and printing the actual character
12820 @c at the same position as the underline character (similar to a
12821 @c typewriter). Usually, a modern terminal can't interpret this (and the
12822 @c original Teletype machines for which this sequence was appropriate are
12823 @c no longer in use). You need a pager program like @code{less} which
12824 @c translates this into ISO 6429 SGR sequences to control terminals.
12827 @c =====================================================================
12829 @node grops, grodvi, grotty, Output Devices
12830 @section @code{grops}
12831 @cindex @code{grops}, the program
12837 * Embedding PostScript::
12840 @c ---------------------------------------------------------------------
12842 @node Invoking grops, Embedding PostScript, grops, grops
12843 @subsection Invoking @code{grops}
12844 @cindex invoking @code{grops}
12845 @cindex @code{grops}, invoking
12849 @c ---------------------------------------------------------------------
12851 @node Embedding PostScript, , Invoking grops, grops
12852 @subsection Embedding @sc{PostScript}
12853 @cindex embedding PostScript
12854 @cindex PostScript, embedding
12859 @c =====================================================================
12861 @node grodvi, grolj4, grops, Output Devices
12862 @section @code{grodvi}
12863 @cindex @code{grodvi}, the program
12868 * Invoking grodvi::
12871 @c ---------------------------------------------------------------------
12873 @node Invoking grodvi, , grodvi, grodvi
12874 @subsection Invoking @code{grodvi}
12875 @cindex invoking @code{grodvi}
12876 @cindex @code{grodvi}, invoking
12881 @c =====================================================================
12883 @node grolj4, grolbp, grodvi, Output Devices
12884 @section @code{grolj4}
12885 @cindex @code{grolj4}, the program
12890 * Invoking grolj4::
12893 @c ---------------------------------------------------------------------
12895 @node Invoking grolj4, , grolj4, grolj4
12896 @subsection Invoking @code{grolj4}
12897 @cindex invoking @code{grolj4}
12898 @cindex @code{grolj4}, invoking
12903 @c =====================================================================
12905 @node grolbp, grohtml, grolj4, Output Devices
12906 @section @code{grolbp}
12907 @cindex @code{grolbp}, the program
12912 * Invoking grolbp::
12915 @c ---------------------------------------------------------------------
12917 @node Invoking grolbp, , grolbp, grolbp
12918 @subsection Invoking @code{grolbp}
12919 @cindex invoking @code{grolbp}
12920 @cindex @code{grolbp}, invoking
12925 @c =====================================================================
12927 @node grohtml, gxditview, grolbp, Output Devices
12928 @section @code{grohtml}
12929 @cindex @code{grohtml}, the program
12934 * Invoking grohtml::
12935 * grohtml specific registers and strings::
12938 @c ---------------------------------------------------------------------
12940 @node Invoking grohtml, grohtml specific registers and strings, grohtml, grohtml
12941 @subsection Invoking @code{grohtml}
12942 @cindex invoking @code{grohtml}
12943 @cindex @code{grohtml}, invoking
12947 @c ---------------------------------------------------------------------
12949 @node grohtml specific registers and strings, , Invoking grohtml, grohtml
12950 @subsection @code{grohtml} specific registers and strings
12951 @cindex registers specific to @code{grohtml}
12952 @cindex strings specific to @code{grohtml}
12953 @cindex @code{grohtml}, registers and strings
12955 @DefmpregList {ps4html, grohtml}
12956 @DefstrListEnd {www-image-template, grohtml}
12957 The registers @code{ps4html} and @code{www-image-template} are defined
12958 by the @code{pre-grohtml} preprocessor. @code{pre-grohtml} reads in
12959 the @code{troff} input, marks up the inline equations and passes the
12963 troff -Tps -rps4html=1 -dwww-image-template=@var{template}
12973 The PostScript device is used to create all the image files, and the
12974 register @code{ps4html} enables the macro sets to ignore floating
12975 keeps, footers, and headings.
12977 The register @code{www-image-template} is set to the user specified
12978 template name or the default name.
12982 @c =====================================================================
12984 @node gxditview, , grohtml, Output Devices
12985 @section @code{gxditview}
12986 @cindex @code{gxditview}, the program
12991 * Invoking gxditview::
12994 @c ---------------------------------------------------------------------
12996 @node Invoking gxditview, , gxditview, gxditview
12997 @subsection Invoking @code{gxditview}
12998 @cindex invoking @code{gxditview}
12999 @cindex @code{gxditview}, invoking
13006 @c =====================================================================
13007 @c =====================================================================
13009 @node File formats, Installation, Output Devices, Top
13010 @chapter File formats
13011 @cindex file formats
13012 @cindex formats, file
13022 @c =====================================================================
13024 @node gtroff Output, Font Files, File formats, File formats
13025 @section @code{gtroff} Output
13026 @cindex @code{gtroff}, output
13027 @cindex output, @code{gtroff}
13029 This section describes the format output of GNU @code{troff}. The
13030 output format used by GNU @code{troff} is very similar -- but
13031 not identical -- to that used by
13032 @acronym{UNIX} device-independent @code{troff} (@code{ditroff}).
13037 * Drawing Functions::
13038 * Line Continuation::
13041 @c ---------------------------------------------------------------------
13043 @node Output Format, Device Control, gtroff Output, gtroff Output
13044 @subsection Output Format
13045 @cindex output format
13046 @cindex format of output
13048 @cindex 8-bit input
13049 @cindex input, 8-bit
13050 The output format is text based, as opposed to a binary format (like
13051 @TeX{} DVI). The output format is @w{8-bit} clean, thus single
13052 characters can have the eighth bit set, as can the names of fonts and
13053 special characters.
13055 The output format consists of single command characters with attached
13056 parameters which are separated from subsequent text by whitespace or a
13059 The names of characters and fonts can be of arbitrary length; drivers
13060 should not assume that they are only two characters long (as
13061 @code{ditroff} does).
13063 When a character is to be printed, that character is always in the
13064 current font. Unlike @code{ditroff}, it is not necessary for drivers to
13065 search special fonts to find a character.
13086 @item @var{nn}@var{c}
13090 @var{xxx} is any sequence of characters terminated by a space or a
13091 newline; the first character should be printed at the current position,
13092 the the current horizontal position should be increased by the width of
13093 the first character, and so on for each character. The width of the
13094 character is that given in the font file, appropriately scaled for the
13095 current point size, and rounded so that it is a multiple of the
13096 horizontal resolution. Special characters cannot be printed using this
13100 @pindex DESC@r{, and @code{tcommand}}
13101 This command is only allowed if the @samp{tcommand} line is present in
13102 the @file{DESC} file.
13104 @item u@var{n} @var{xxx}
13105 This is same as the @samp{t} command except that after printing each
13106 character, the current horizontal position is increased by the sum of
13107 the width of that character and@w{ }@var{n}.
13109 This command is only allowed if the @samp{tcommand} line is present in
13110 the @file{DESC} file.
13112 @item n@var{a}@var{b}
13120 @pindex DESC@r{, and @code{sizescale}}
13121 The argument to the @samp{s} command is in scaled points (units of
13122 points/@var{n}, where @var{n} is the argument to the @samp{sizescale}
13123 command in the @file{DESC} file).
13130 @item D@var{c} @var{x}@dots{}\n
13134 @c ---------------------------------------------------------------------
13136 @node Device Control, Drawing Functions, Output Format, gtroff Output
13137 @subsection Device Control
13138 @cindex device control
13139 @cindex control of devices
13141 The @samp{x} command is normally followed by a letter or word indicating
13142 the function to perform, followed by whitespace separated arguments.
13144 The first argument can be abbreviated to the first letter.
13153 @item x res @var{n} @var{h} @var{v}
13158 The argument to the @w{@samp{x Height}} command is also in scaled
13162 The first three output commands are guaranteed to be:
13171 For example, the input
13174 crunchy \fH\s+2frog\s0\fP!?
13184 ... sample output here ...
13188 @c ---------------------------------------------------------------------
13190 @node Drawing Functions, Line Continuation, Device Control, gtroff Output
13191 @subsection Drawing Functions
13192 @cindex drawing functions
13193 @cindex functions for drawing
13196 The @samp{D} drawing command has been extended. These extensions are
13197 used by GNU @code{pic} only if the @option{-x} option is given.
13199 @xref{Drawing Requests}.
13204 Set the shade of gray to be used for filling solid objects to@w{
13205 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
13206 corresponds solid white and 1000 to solid black, and values in between
13207 correspond to intermediate shades of gray. This applies only to solid
13208 circles, solid ellipses and solid polygons. By default, a level of@w{
13209 }1000 is used. Whatever color a solid object has, it should
13210 completely obscure everything beneath it. A value greater than@w{ }1000
13211 or less than@w{ }0 can also be used: this means fill with the shade of
13212 gray that is currently being used for lines and text. Normally this
13213 is black, but some drivers may provide a way of changing this.
13216 Draw a solid circle with a diameter of@w{ }@var{d} with the leftmost
13217 point at the current position.
13219 @item DE @var{dx} @var{dy}
13220 Draw a solid ellipse with a horizontal diameter of@w{ }@var{dx} and a
13221 vertical diameter of@w{ }@var{dy} with the leftmost point at the current
13224 @item Dp @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
13225 Draw a polygon with automatic closure. The first vertex is at the
13226 current position, the second vertex at an offset (@var{dx1},@var{dy1})
13227 from the current position, the second vertex at an offset
13228 (@var{dx2},@var{dy2}) from the first vertex, and so on up to the
13229 @var{n}@dmn{th} vertex. At the moment, GNU @code{pic} only uses this
13230 command to generate triangles and rectangles.
13232 @item DP @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
13233 Like @code{Dp} but draw a solid rather than outlined polygon.
13236 @cindex line thickness
13237 @cindex thickness of lines
13238 Set the current line thickness to @var{n}@w{ }machine units.
13239 Traditionally, @acronym{UNIX} @code{troff} drivers use a line thickness
13240 proportional to the current point size; drivers should continue to do
13241 this if no @code{Dt} command has been given, or if a @code{Dt} command
13242 has been given with a negative value of@w{ }@var{n}. A zero value of@w{
13243 }@var{n} selects the smallest available line thickness.
13246 A difficulty arises in how the current position should be changed after
13247 the execution of these commands. This is not of great importance since
13248 the code generated by GNU @code{pic} does not depend on this. Given a
13249 drawing command of the form
13252 \D'@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}'
13255 @cindex @code{\w}, and drawing commands
13256 @cindex @code{st} register, and drawing commands
13257 @cindex @code{sb} register, and drawing commands
13259 where @var{c} is not one of @samp{c}, @samp{e}, @samp{l}, @samp{a} or
13260 @samp{~}, @acronym{UNIX} @code{troff} treats each x@w{ }value
13261 as a horizontal quantity, and each y@w{ }value as a vertical
13262 quantity; it assumes that the width of the drawn object is the sum of
13263 all x@w{ }values, and that the height is the sum of all y@w{ }values.
13264 (The assumption about the height can be seen by examining the @code{st}
13265 and @code{sb} registers after using such a @code{D}@w{ }command in a
13266 @code{\w} escape sequence.) This rule also holds for all the original
13267 drawing commands with the exception of @code{De}. For the sake of
13268 compatibility GNU @code{troff} also follows this rule, even though it
13269 produces an ugly result in the case of the @code{Df}, @code{Dt}, and, to
13270 a lesser extent, @code{DE}@w{ }commands. Thus after executing a
13271 @code{D}@w{ }command of the form
13274 D@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}
13278 the current position should be increased horizontally by the sum of all
13279 x@w{ }values and vertically by the sum of all y@w{ }values.
13281 @c ---------------------------------------------------------------------
13283 @node Line Continuation, , Drawing Functions, gtroff Output
13284 @subsection Line Continuation
13285 @cindex line continuation in output commands
13286 @cindex output commands, line continuation
13288 There is a continuation convention which permits the argument to the
13289 @w{@samp{x X}} command to contain newlines: When outputting the argument
13290 to the @w{@samp{x X}} command, GNU @code{troff} follows each newline
13291 in the argument with a @samp{+} character (as usual, it terminates
13292 the entire argument with a newline); thus if the line after the line
13293 containing the @w{@samp{x X}} command starts with @samp{+}, then the
13294 newline ending the line containing the @w{@samp{x X}} command should be
13295 treated as part of the argument to the @w{@samp{x X}} command, the
13296 @samp{+} should be ignored, and the part of the line following the
13297 @samp{+} should be treated like the part of the line following the
13298 @w{@samp{x X}} command.
13301 @c =====================================================================
13303 @node Font Files, , gtroff Output, File formats
13304 @section Font Files
13306 @cindex files, font
13308 The @code{gtroff} font format is roughly a superset of the
13309 @code{ditroff} font format. Unlike the @code{ditroff} font format,
13310 there is no associated binary format; all files are text files. The
13311 font files for device @var{name} are stored in a directory
13312 @file{dev@var{name}}. There are two types of file: a device description
13313 file called @file{DESC} and for each font@w{ }@var{f} a font file
13314 called@w{ }@file{@var{f}}.
13317 * DESC File Format::
13318 * Font File Format::
13321 @c ---------------------------------------------------------------------
13323 @node DESC File Format, Font File Format, Font Files, Font Files
13324 @subsection @file{DESC} File Format
13325 @cindex @file{DESC} file, format
13326 @cindex font description file, format
13327 @cindex format of font description file
13328 @pindex DESC@r{ file format}
13330 The @file{DESC} file can contain the following types of line:
13335 There are @var{n}@w{ }machine units per inch.
13339 The horizontal resolution is @var{n}@w{ }machine units.
13343 The vertical resolution is @var{n}@w{ }machine units.
13345 @item sizescale @var{n}
13347 The scale factor for point sizes. By default this has a value of@w{ }1.
13348 One scaled point is equal to one point/@var{n}. The arguments to the
13349 @code{unitwidth} and @code{sizes} commands are given in scaled points.
13350 @xref{Fractional Type Sizes}, for more information.
13352 @item unitwidth @var{n}
13354 Quantities in the font files are given in machine units for fonts whose
13355 point size is @var{n}@w{ }scaled points.
13359 This means that the postprocessor can handle the @samp{t} and @samp{u}
13362 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
13364 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
13365 @var{sn} scaled points. The list of sizes must be terminated by a@w{
13366 }0. Each @var{si} can also be a range of sizes @var{m}-@var{n}. The
13367 list can extend over more than one line.
13369 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
13371 The first @var{m}@w{ }font positions are associated with styles
13372 @var{S1} @dots{} @var{Sm}.
13374 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
13376 Fonts @var{F1} @dots{} @var{Fn} are mounted in the font positions
13377 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
13378 styles. This command may extend over more than one line. A font name
13379 of@var{ }0 means no font is mounted on the corresponding font position.
13381 @item family @var{fam}
13383 The default font family is @var{fam}.
13387 This line and everything following in the file are ignored. It is
13388 allowed for the sake of backwards compatibility.
13391 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
13392 are mandatory. Other commands are ignored by @code{gtroff} but may be
13393 used by postprocessors to store arbitrary information about the device
13394 in the @file{DESC} file.
13396 @c XXX add other commands resp. xrefs to output devices
13397 @c XXX add obsolete commands
13399 @c ---------------------------------------------------------------------
13401 @node Font File Format, , DESC File Format, Font Files
13402 @subsection Font File Format
13403 @cindex font file, format
13404 @cindex format of font files
13406 A font file has two sections. The first section is a sequence of lines
13407 each containing a sequence of blank delimited words; the first word in
13408 the line is a key, and subsequent words give a value for that key.
13413 The name of the font is@w{ }@var{f}.
13415 @item spacewidth @var{n}
13417 The normal width of a space is@w{ }@var{n}.
13419 @item slant @var{n}
13421 The characters of the font have a slant of @var{n}@w{ }degrees.
13422 (Positive means forward.)
13424 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
13426 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
13427 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
13428 @samp{ffl}. For backwards compatibility, the list of ligatures may be
13429 terminated with a@w{ }0. The list of ligatures may not extend over more
13434 The font is special; this means that when a character is requested that
13435 is not present in the current font, it is searched for in any
13436 special fonts that are mounted.
13439 Other commands are ignored by @code{gtroff} but may be used by
13440 postprocessors to store arbitrary information about the font in the font
13443 @cindex comments in font files
13444 @cindex font files, comments
13446 The first section can contain comments which start with the @samp{#}
13447 character and extend to the end of a line.
13449 The second section contains one or two subsections. It must contain a
13450 @code{charset} subsection and it may also contain a @code{kernpairs}
13451 subsection. These subsections can appear in any order. Each
13452 subsection starts with a word on a line by itself.
13455 The word @code{charset} starts the character set subsection. The
13456 @code{charset} line is followed by a sequence of lines. Each line gives
13457 information for one character. A line comprises a number of fields
13458 separated by blanks or tabs. The format is
13460 @c XXX fix it for new HTML additions
13463 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
13466 @cindex 8-bit input
13467 @cindex input, 8-bit
13468 @cindex accessing unnamed characters with @code{\N}
13469 @cindex unnamed characters, accessing with @code{\N}
13470 @cindex characters, unnamed, accessing with @code{\N}
13473 @var{name} identifies the character: If @var{name} is a single
13474 character@w{ }@var{c} then it corresponds to the @code{gtroff} input
13475 character@w{ }@var{c}; if it is of the form @samp{\@var{c}} where @var{c}
13476 is a single character, then it corresponds to the @code{gtroff} input
13477 character@w{ }\@var{c}; otherwise it corresponds to the groff input
13478 character @samp{\[@var{name}]}. (If it is exactly two characters
13479 @var{xx} it can be entered as @samp{\(@var{xx}}.) @code{gtroff}
13480 supports 8-bit characters; however some utilities have difficulties with
13481 eight-bit characters. For this reason, there is a convention that the
13482 name @samp{char@var{n}} is equivalent to the single character whose code
13483 is@w{ }@var{n}. For example, @samp{char163} would be equivalent to the
13484 character with code@w{ }163 which is the pounds sterling sign in @w{ISO
13485 Latin-1} character set. The name @samp{---} is special and indicates
13486 that the character is unnamed; such characters can only be used by means
13487 of the @code{\N} escape sequence in @code{gtroff}.
13489 @c XXX input encodings vs. output encodings
13491 The @var{type} field gives the character type:
13495 the character has an descender, for example, `p';
13498 the character has an ascender, for example, `b';
13501 the character has both an ascender and a descender, for example, `('.
13504 The @var{code} field gives the code which the postprocessor uses to
13505 print the character. The character can also be input to @code{gtroff}
13506 using this code by means of the @code{\N} escape sequence. The code can
13507 be any integer. If it starts with @samp{0} it is interpreted as
13508 octal; if it starts with @samp{0x} or @samp{0X} it is interpreted as
13511 Anything on the line after the @var{code} field is ignored.
13513 The @var{metrics} field has the form:
13516 @var{width}[,@var{height}[,@var{depth}[,@var{italic_correction}
13517 [,@var{left_italic_correction}[,@var{subscript_correction}]]]]]
13521 There must not be any spaces between these subfields (it has been split
13522 here into two lines for better legibility only). Missing subfields are
13523 assumed to be@w{ }0. The subfields are all decimal integers. Since
13524 there is no associated binary format, these values are not required to
13525 fit into a variable of type @samp{char} as they are in @code{ditroff}.
13526 The @var{width} subfield gives the width of the character. The
13527 @var{height} subfield gives the height of the character (upwards is
13528 positive); if a character does not extend above the baseline, it should
13529 be given a zero height, rather than a negative height. The @var{depth}
13530 subfield gives the depth of the character, that is, the distance below
13531 the lowest point below the baseline to which the character extends
13532 (downwards is positive); if a character does not extend below above the
13533 baseline, it should be given a zero depth, rather than a negative depth.
13534 The @var{italic_correction} subfield gives the amount of space that
13535 should be added after the character when it is immediately to be
13536 followed by a character from a roman font. The
13537 @var{left_italic_correction} subfield gives the amount of space that
13538 should be added before the character when it is immediately to be
13539 preceded by a character from a roman font. The
13540 @var{subscript_correction} gives the amount of space that should be
13541 added after a character before adding a subscript. This should be less
13542 than the italic correction.
13544 A line in the @code{charset} section can also have the format
13551 This indicates that @var{name} is just another name for the character
13552 mentioned in the preceding line.
13555 The word @code{kernpairs} starts the kernpairs section. This contains a
13556 sequence of lines of the form:
13559 @var{c1} @var{c2} @var{n}
13563 This means that when character @var{c1} appears next to character
13564 @var{c2} the space between them should be increased by@w{ }@var{n}.
13565 Most entries in the kernpairs section have a negative value for@w{
13570 @c =====================================================================
13571 @c =====================================================================
13573 @node Installation, Request Index, File formats, Top
13574 @chapter Installation
13575 @cindex installation
13581 @c =====================================================================
13582 @c =====================================================================
13584 @node Request Index, Escape Index, Installation, Top
13585 @chapter Request Index
13587 Requests appear without the leading control character (normally either
13588 @samp{.} or @samp{'}).
13594 @c =====================================================================
13595 @c =====================================================================
13597 @node Escape Index, Operator Index, Request Index, Top
13598 @chapter Escape Index
13600 Any escape sequence @code{\@var{X}} with @var{X} not in the list below
13601 emits a warning, printing character @var{X}.
13607 @c =====================================================================
13608 @c =====================================================================
13610 @node Operator Index, Register Index, Escape Index, Top
13611 @chapter Operator Index
13617 @c =====================================================================
13618 @c =====================================================================
13620 @node Register Index, Macro Index, Operator Index, Top
13621 @chapter Register Index
13623 The macro package or program a specific register belongs to is appended in
13626 A register name@w{ }@code{x} consisting of exactly one character can be
13627 accessed as @samp{\nx}. A register name @code{xx} consisting of exactly
13628 two characters can be accessed as @samp{\n(xx}. Register names @code{xxx}
13629 of any length can be accessed as @samp{\n[xxx]}.
13635 @c =====================================================================
13636 @c =====================================================================
13638 @node Macro Index, String Index, Register Index, Top
13639 @chapter Macro Index
13641 The macro package a specific macro belongs to is appended in brackets.
13642 They appear without the leading control character (normally @samp{.}).
13648 @c =====================================================================
13649 @c =====================================================================
13651 @node String Index, Glyph Name Index, Macro Index, Top
13652 @chapter String Index
13654 The macro package or program a specific string belongs to is appended in
13657 A string name@w{ }@code{x} consisting of exactly one character can be
13658 accessed as @samp{\*x}. A string name @code{xx} consisting of exactly
13659 two characters can be accessed as @samp{\*(xx}. String names @code{xxx}
13660 of any length can be accessed as @samp{\*[xxx]}.
13667 @c =====================================================================
13668 @c =====================================================================
13670 @node Glyph Name Index, Font File Keyword Index, String Index, Top
13671 @chapter Glyph Name Index
13673 A glyph name @code{xx} consisting of exactly two characters can be
13674 accessed as @samp{\(xx}. Glyph names @code{xxx} of any length can be
13675 accessed as @samp{\[xxx]}.
13681 @c =====================================================================
13682 @c =====================================================================
13684 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
13685 @chapter Font File Keyword Index
13691 @c =====================================================================
13692 @c =====================================================================
13694 @node Program and File Index, Concept Index, Font File Keyword Index, Top
13695 @chapter Program and File Index
13701 @c =====================================================================
13702 @c =====================================================================
13704 @node Concept Index, , Program and File Index, Top
13705 @chapter Concept Index