* doc/groff.texinfo: Introducing macros `Deffn' and `Defmac' to
[s-roff.git] / doc / groff.texinfo
blob8e5c73d76659df7f71191907a899c23e3889416a
1 \input texinfo   @c -*-texinfo-*-
3 @c
4 @c If you use texinfo.tex 1999-09-25.10 or earlier please convert this
5 @c manual with `texi2dvi -e groff.texinfo' due to a bug in expanding
6 @c user-defined macros.
7 @c
9 @c %**start of header (This is for running Texinfo on a region.)
10 @setfilename  groff
11 @settitle The GNU Troff Manual
12 @setchapternewpage odd
13 @footnotestyle separate
14 @c %**end of header (This is for running Texinfo on a region.)
17 @c We use the following indices:
19 @c   cindex: concepts
20 @c   findex: requests, escapes, and functions
21 @c   vindex: registers
22 @c   kindex: commands in font files
23 @c   pindex: programs and files
24 @c   tindex: environment variables
25 @c   maindex: macros and strings
26 @c   glindex: glyph names
28 @c tindex and cindex are merged.
30 @defcodeindex ma
31 @defcodeindex gl
32 @syncodeindex tp cp
35 @macro Deffn{category, name, arg}
36 @deffn \category\ @t{\name\} \arg\
37 @end macro
39 @macro Deffnx{category, name, arg}
40 @deffnx \category\ @t{\name\} \arg\
41 @end macro
43 @macro Defmac{name, arg}
44 @defmac @t{\name\} \arg\
45 @end macro
47 @macro Defmacx{name, arg}
48 @defmacx @t{\name\} \arg\
49 @end macro
52 @c XXX comment all examples
55 @dircategory Miscellaneous
56 @direntry
57 * Groff: (groff).  The GNU troff document formatting system.
58 @end direntry
61 @smallbook
64 @iftex
65 @finalout
66 @end iftex
69 @ifinfo
70 This Info file documents GNU troff version 1.16.
72 Published by the Free Software Foundation
73 59 Temple Place, Suite 330
74 Boston, MA  02111-1307  USA
76 Copyright (C) 1994-2000 Free Software Foundation, Inc.
78 Permission is granted to make and distribute verbatim copies of this
79 manual provided the copyright notice and this permission notice are
80 preserved on all copies.
82 @ignore
83 Permission is granted to process this file through TeX and print the
84 results, provided the printed document carries copying permission notice
85 identical to this one except for the removal of this paragraph (this
86 paragraph not being relevant to the printed manual).
88 @end ignore
89 Permission is granted to copy and distribute modified versions of this
90 manual under the conditions for verbatim copying, provided that the
91 entire resulting derived work is distributed under the terms of a
92 permission notice identical to this one.
94 Permission is granted to copy and distribute translations of this manual
95 into another language, under the above conditions for modified versions,
96 except that this permission notice may be stated in a translation
97 approved by the Foundation.
99 Permission is granted to copy and distribute modified versions of this
100 manual under the conditions for verbatim copying, provided also that the
101 section entitled ``GNU General Public License'' is included exactly as
102 in the original, and provided that the entire resulting derived work is
103 distributed under the terms of a permission notice identical to this
104 one.
106 Permission is granted to copy and distribute translations of this manual
107 into another language, under the above conditions for modified versions,
108 except that the section entitled ``GNU General Public License'' may be
109 included in a translation approved by the Free Software Foundation
110 instead of in the original English.
111 @end ifinfo
114 @titlepage
115 @title groff
116 @subtitle The GNU implementation of @code{troff}
117 @subtitle Edition 1.16
118 @subtitle Spring 2000
119 @author by Trent A.@w{ }Fisher
120 @author and Werner Lemberg
122 @c Include the Distribution inside the titlepage environment so
123 @c that headings are turned off.  Headings on and off do not work.
125 @page
126 @vskip 0pt plus 1filll
127 Copyright @copyright@w{ }1994-2000 Free Software Foundation,@w{ }Inc.
128 @sp 2
129 Version 1.16 of @code{groff}, @*
130 Spring 2000
131 @sp 2
132 Published by the Free Software Foundation @*
133 59 Temple Place, Suite 330 @*
134 Boston, MA  02111-1307  USA
137 Permission is granted to make and distribute verbatim copies of this
138 manual provided the copyright notice and this permission notice are
139 preserved on all copies.
141 Permission is granted to copy and distribute modified versions of this
142 manual under the conditions for verbatim copying, provided also that the
143 section entitled ``GNU General Public License'' is included exactly as
144 in the original, and provided that the entire resulting derived work is
145 distributed under the terms of a permission notice identical to this
146 one.
148 Permission is granted to copy and distribute translations of this manual
149 into another language, under the above conditions for modified versions,
150 except that the section entitled ``GNU General Public License'' may be
151 included in a translation approved by the Free Software Foundation
152 instead of in the original English.
154 Cover art by Etienne Suvasa.
155 @end titlepage
156 @page
160 @node Top, Copying, (dir), (dir)
162 @ifinfo
163 This Info file documents groff version 1.16, the GNU implementation of
164 the troff typesetting system.
166 This is an in-progress document; contributions, comments, or
167 contributions are welcome.  Send them to bug-groff@@gnu.org.
168 @end ifinfo
170 @menu
171 * Copying::                     
172 * Introduction::                
173 * Invoking groff::              
174 * Tutorial for Macro Users::    
175 * Macro Packages::              
176 * Programming Tutorial::        
177 * Preprocessors::               
178 * Output Devices::              
179 * File formats::                
180 * Installation::                
181 * Request and Operator Index::  
182 * Register Index::              
183 * Macro and String Index::      
184 * Glyph Name Index::            
185 * Font File Keyword Index::     
186 * Program and File Index::      
187 * Concept Index::               
188 @end menu
192 @node Copying, Introduction, Top, Top
193 @cindex copying
194 @unnumbered GNU GENERAL PUBLIC LICENSE
195 @center Version 2, June 1991
197 @display
198 Copyright @copyright{}@w{ }1989, 1991 Free Software Foundation, Inc.
199 59@w{ }Temple Place, Suite@w{ }330, Boston, MA@w{ }02111, USA
201 Everyone is permitted to copy and distribute verbatim copies of this
202 license document, but changing it is not allowed.
203 @end display
205 @unnumberedsec Preamble
207 The licenses for most software are designed to take away your freedom to
208 share and change it.  By contrast, the GNU General Public License is
209 intended to guarantee your freedom to share and change free software --
210 to make sure the software is free for all its users.  This General
211 Public License applies to most of the Free Software Foundation's
212 software and to any other program whose authors commit to using it.
213 (Some other Free Software Foundation software is covered by the GNU
214 Library General Public License instead.)  You can apply it to your
215 programs, too.
217 When we speak of free software, we are referring to freedom, not price.
218 Our General Public Licenses are designed to make sure that you have the
219 freedom to distribute copies of free software (and charge for this
220 service if you wish), that you receive source code or can get it if you
221 want it, that you can change the software or use pieces of it in new
222 free programs; and that you know you can do these things.
224 To protect your rights, we need to make restrictions that forbid anyone
225 to deny you these rights or to ask you to surrender the rights.  These
226 restrictions translate to certain responsibilities for you if you
227 distribute copies of the software, or if you modify it.
229 For example, if you distribute copies of such a program, whether gratis
230 or for a fee, you must give the recipients all the rights that you have.
231 You must make sure that they, too, receive or can get the source code.
232 And you must show them these terms so they know their rights.
234 We protect your rights with two steps: (1)@w{ }copyright the software,
235 and (2)@w{ }offer you this license which gives you legal permission to
236 copy, distribute and/or modify the software.
238 Also, for each author's protection and ours, we want to make certain
239 that everyone understands that there is no warranty for this free
240 software.  If the software is modified by someone else and passed on, we
241 want its recipients to know that what they have is not the original, so
242 that any problems introduced by others will not reflect on the original
243 authors' reputations.
245 Finally, any free program is threatened constantly by software patents.
246 We wish to avoid the danger that redistributors of a free program will
247 individually obtain patent licenses, in effect making the program
248 proprietary.  To prevent this, we have made it clear that any patent
249 must be licensed for everyone's free use or not licensed at all.
251 The precise terms and conditions for copying, distribution and
252 modification follow.
254 @iftex
255 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
256 @end iftex
257 @ifinfo
258 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
259 @end ifinfo
261 @enumerate 0
262 @item
263 This License applies to any program or other work which contains a
264 notice placed by the copyright holder saying it may be distributed under
265 the terms of this General Public License.  The ``Program'', below,
266 refers to any such program or work, and a ``work based on the Program''
267 means either the Program or any derivative work under copyright law:
268 that is to say, a work containing the Program or a portion of it, either
269 verbatim or with modifications and/or translated into another language.
270 (Hereinafter, translation is included without limitation in the term
271 ``modification''.)  Each licensee is addressed as ``you''.
273 Activities other than copying, distribution and modification are not
274 covered by this License; they are outside its scope.  The act of running
275 the Program is not restricted, and the output from the Program is
276 covered only if its contents constitute a work based on the Program
277 (independent of having been made by running the Program).  Whether that
278 is true depends on what the Program does.
280 @item
281 You may copy and distribute verbatim copies of the Program's source code
282 as you receive it, in any medium, provided that you conspicuously and
283 appropriately publish on each copy an appropriate copyright notice and
284 disclaimer of warranty; keep intact all the notices that refer to this
285 License and to the absence of any warranty; and give any other
286 recipients of the Program a copy of this License along with the Program.
288 You may charge a fee for the physical act of transferring a copy, and
289 you may at your option offer warranty protection in exchange for a fee.
291 @item
292 You may modify your copy or copies of the Program or any portion of it,
293 thus forming a work based on the Program, and copy and distribute such
294 modifications or work under the terms of Section@w{ }1 above, provided
295 that you also meet all of these conditions:
297 @enumerate a
298 @item
299 You must cause the modified files to carry prominent notices stating
300 that you changed the files and the date of any change.
302 @item
303 You must cause any work that you distribute or publish, that in whole or
304 in part contains or is derived from the Program or any part thereof, to
305 be licensed as a whole at no charge to all third parties under the terms
306 of this License.
308 @item
309 If the modified program normally reads commands interactively when run,
310 you must cause it, when started running for such interactive use in the
311 most ordinary way, to print or display an announcement including an
312 appropriate copyright notice and a notice that there is no warranty (or
313 else, saying that you provide a warranty) and that users may
314 redistribute the program under these conditions, and telling the user
315 how to view a copy of this License.  (Exception: if the Program itself
316 is interactive but does not normally print such an announcement, your
317 work based on the Program is not required to print an announcement.)
318 @end enumerate
320 These requirements apply to the modified work as a whole.  If
321 identifiable sections of that work are not derived from the Program, and
322 can be reasonably considered independent and separate works in
323 themselves, then this License, and its terms, do not apply to those
324 sections when you distribute them as separate works.  But when you
325 distribute the same sections as part of a whole which is a work based on
326 the Program, the distribution of the whole must be on the terms of this
327 License, whose permissions for other licensees extend to the entire
328 whole, and thus to each and every part regardless of who wrote it.
330 Thus, it is not the intent of this section to claim rights or contest
331 your rights to work written entirely by you; rather, the intent is to
332 exercise the right to control the distribution of derivative or
333 collective works based on the Program.
335 In addition, mere aggregation of another work not based on the Program
336 with the Program (or with a work based on the Program) on a volume of a
337 storage or distribution medium does not bring the other work under the
338 scope of this License.
340 @item
341 You may copy and distribute the Program (or a work based on it, under
342 Section@w{ }2) in object code or executable form under the terms of
343 Sections@w{ }1 and@w{ }2 above provided that you also do one of the
344 following:
346 @enumerate a
347 @item
348 Accompany it with the complete corresponding machine-readable source
349 code, which must be distributed under the terms of Sections@w{ }1 and@w{
350 }2 above on a medium customarily used for software interchange; or,
352 @item
353 Accompany it with a written offer, valid for at least three years, to
354 give any third party, for a charge no more than your cost of physically
355 performing source distribution, a complete machine-readable copy of the
356 corresponding source code, to be distributed under the terms of
357 Sections@w{ }1 and@w{ }2 above on a medium customarily used for software
358 interchange; or,
360 @item
361 Accompany it with the information you received as to the offer to
362 distribute corresponding source code.  (This alternative is allowed only
363 for noncommercial distribution and only if you received the program in
364 object code or executable form with such an offer, in accord with
365 Subsection@w{ }b above.)
366 @end enumerate
368 The source code for a work means the preferred form of the work for
369 making modifications to it.  For an executable work, complete source
370 code means all the source code for all modules it contains, plus any
371 associated interface definition files, plus the scripts used to control
372 compilation and installation of the executable.  However, as a special
373 exception, the source code distributed need not include anything that is
374 normally distributed (in either source or binary form) with the major
375 components (compiler, kernel, and so on) of the operating system on
376 which the executable runs, unless that component itself accompanies the
377 executable.
379 If distribution of executable or object code is made by offering access
380 to copy from a designated place, then offering equivalent access to copy
381 the source code from the same place counts as distribution of the source
382 code, even though third parties are not compelled to copy the source
383 along with the object code.
385 @item
386 You may not copy, modify, sublicense, or distribute the Program except
387 as expressly provided under this License.  Any attempt otherwise to
388 copy, modify, sublicense or distribute the Program is void, and will
389 automatically terminate your rights under this License.  However,
390 parties who have received copies, or rights, from you under this License
391 will not have their licenses terminated so long as such parties remain
392 in full compliance.
394 @item
395 You are not required to accept this License, since you have not signed
396 it.  However, nothing else grants you permission to modify or distribute
397 the Program or its derivative works.  These actions are prohibited by
398 law if you do not accept this License.  Therefore, by modifying or
399 distributing the Program (or any work based on the Program), you
400 indicate your acceptance of this License to do so, and all its terms and
401 conditions for copying, distributing or modifying the Program or works
402 based on it.
404 @item
405 Each time you redistribute the Program (or any work based on the
406 Program), the recipient automatically receives a license from the
407 original licensor to copy, distribute or modify the Program subject to
408 these terms and conditions.  You may not impose any further restrictions
409 on the recipients' exercise of the rights granted herein.  You are not
410 responsible for enforcing compliance by third parties to this License.
412 @item
413 If, as a consequence of a court judgment or allegation of patent
414 infringement or for any other reason (not limited to patent issues),
415 conditions are imposed on you (whether by court order, agreement or
416 otherwise) that contradict the conditions of this License, they do not
417 excuse you from the conditions of this License.  If you cannot
418 distribute so as to satisfy simultaneously your obligations under this
419 License and any other pertinent obligations, then as a consequence you
420 may not distribute the Program at all.  For example, if a patent license
421 would not permit royalty-free redistribution of the Program by all those
422 who receive copies directly or indirectly through you, then the only way
423 you could satisfy both it and this License would be to refrain entirely
424 from distribution of the Program.
426 If any portion of this section is held invalid or unenforceable under
427 any particular circumstance, the balance of the section is intended to
428 apply and the section as a whole is intended to apply in other
429 circumstances.
431 It is not the purpose of this section to induce you to infringe any
432 patents or other property right claims or to contest validity of any
433 such claims; this section has the sole purpose of protecting the
434 integrity of the free software distribution system, which is implemented
435 by public license practices.  Many people have made generous
436 contributions to the wide range of software distributed through that
437 system in reliance on consistent application of that system; it is up to
438 the author/donor to decide if he or she is willing to distribute
439 software through any other system and a licensee cannot impose that
440 choice.
442 This section is intended to make thoroughly clear what is believed to be
443 a consequence of the rest of this License.
445 @item
446 If the distribution and/or use of the Program is restricted in certain
447 countries either by patents or by copyrighted interfaces, the original
448 copyright holder who places the Program under this License may add an
449 explicit geographical distribution limitation excluding those countries,
450 so that distribution is permitted only in or among countries not thus
451 excluded.  In such case, this License incorporates the limitation as if
452 written in the body of this License.
454 @item
455 The Free Software Foundation may publish revised and/or new versions of
456 the General Public License from time to time.  Such new versions will be
457 similar in spirit to the present version, but may differ in detail to
458 address new problems or concerns.
460 Each version is given a distinguishing version number.  If the Program
461 specifies a version number of this License which applies to it and ``any
462 later version'', you have the option of following the terms and
463 conditions either of that version or of any later version published by
464 the Free Software Foundation.  If the Program does not specify a version
465 number of this License, you may choose any version ever published by the
466 Free Software Foundation.
468 @item
469 If you wish to incorporate parts of the Program into other free programs
470 whose distribution conditions are different, write to the author to ask
471 for permission.  For software which is copyrighted by the Free Software
472 Foundation, write to the Free Software Foundation; we sometimes make
473 exceptions for this.  Our decision will be guided by the two goals of
474 preserving the free status of all derivatives of our free software and
475 of promoting the sharing and reuse of software generally.
477 @iftex
478 @heading NO WARRANTY
479 @end iftex
480 @ifinfo
481 @center NO WARRANTY
482 @end ifinfo
484 @item
485 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
486 THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW@.  EXCEPT WHEN
487 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
488 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER
489 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
490 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE@.
491 THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
492 YOU@.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
493 NECESSARY SERVICING, REPAIR OR CORRECTION.
495 @item
496 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
497 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
498 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
499 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
500 DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
501 (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
502 INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
503 THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
504 OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
505 @end enumerate
507 @iftex
508 @heading END OF TERMS AND CONDITIONS
509 @end iftex
510 @ifinfo
511 @center END OF TERMS AND CONDITIONS
512 @end ifinfo
515 @page
516 @unnumberedsec How to Apply These Terms to Your New Programs
518 If you develop a new program, and you want it to be of the greatest
519 possible use to the public, the best way to achieve this is to make it
520 free software which everyone can redistribute and change under these
521 terms.
523 To do so, attach the following notices to the program.  It is safest to
524 attach them to the start of each source file to most effectively convey
525 the exclusion of warranty; and each file should have at least the
526 ``copyright'' line and a pointer to where the full notice is found.
528 @smallexample
529 @var{one line to give the program's name and an idea of what it does.}
530 Copyright (C) 19@var{yy} @var{name of author}
532 This program is free software; you can redistribute it and/or modify
533 it under the terms of the GNU General Public License as published by
534 the Free Software Foundation; either version 2 of the License, or (at
535 your option) any later version.
537 This program is distributed in the hope that it will be useful, but
538 WITHOUT ANY WARRANTY; without even the implied warranty of
539 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@.  See the GNU
540 General Public License for more details.
542 You should have received a copy of the GNU General Public License
543 along with this program; if not, write to the Free Software
544 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
545 @end smallexample
547 Also add information on how to contact you by electronic and paper mail.
549 If the program is interactive, make it output a short notice like this
550 when it starts in an interactive mode:
552 @smallexample
553 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
554 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type
555 `show w'.  This is free software, and you are welcome to redistribute
556 it under certain conditions; type `show c' for details.
557 @end smallexample
559 The hypothetical commands @samp{show@w{ }w} and @samp{show@w{ }c} should
560 show the appropriate parts of the General Public License.  Of course,
561 the commands you use may be called something other than @samp{show@w{
562 }w} and @samp{show@w{ }c}; they could even be mouse-clicks or menu
563 items---whatever suits your program.
565 You should also get your employer (if you work as a programmer) or your
566 school, if any, to sign a ``copyright disclaimer'' for the program, if
567 necessary.  Here is a sample; alter the names:
569 @smallexample
570 @group
571 Yoyodyne, Inc., hereby disclaims all copyright interest
572 in the program `Gnomovision' (which makes passes at compilers)
573 written by James Hacker.
575 @var{signature of Ty Coon}, 1 April 1989
576 Ty Coon, President of Vice
577 @end group
578 @end smallexample
580 This General Public License does not permit incorporating your program
581 into proprietary programs.  If your program is a subroutine library, you
582 may consider it more useful to permit linking proprietary applications
583 with the library.  If this is what you want to do, use the GNU Library
584 General Public License instead of this License.
588 @node Introduction, Invoking groff, Copying, Top
589 @chapter Introduction
590 @cindex introduction
592 GNU @code{troff} (or @code{groff}) is a system for typesetting
593 documents.  @code{troff} is very flexible and has been in existence (and
594 use) for about 3@w{ }decades.  It is quite widespread and firmly
595 entrenched in the @acronym{UNIX} community.
597 @menu
598 * What Is groff?::              
599 * History::                     
600 * groff Capabilities::          
601 * Macro Package Intro::         
602 * Preprocessor Intro::          
603 * Output device intro::         
604 * Credits::                     
605 @end menu
608 @node What Is groff?, History, Introduction, Introduction
609 @section What Is @code{groff}?
610 @cindex what is @code{groff}?
611 @cindex @code{groff} -- what is it?
613 @code{groff} is of an older generation of document preparation systems,
614 which operate more like compilers than the more recent interactive
615 @acronym{WYSIWYG}@footnote{What You See Is What You Get} systems.
616 @code{groff} and its contemporary counterpart, @TeX{}, both work using a
617 @dfn{batch} paradigm: The input (or @dfn{source}) files are normal text
618 files with embedded formatting commands.  These files can then be
619 processed by @code{groff} to produce a typeset document on a variety of
620 devices.
622 Likewise, @code{groff} should not be confused with a @dfn{word
623 processor}, since that term connotes an integrated system which includes
624 an editor and a text formatter.  Also, many word processors follow the
625 @acronym{WYSIWYG} paradigm which was discussed earlier.
627 Although @acronym{WYSIWYG} systems may be easier to use, they have a
628 number of disadvantages compared to @code{troff}:
630 @itemize @bullet{}
631 @item
632 They must be used on a graphics display to do any operations on a
633 document.
634 @item
635 Most of the @acronym{WYSIWYG} systems are either non-free or are not
636 very portable.
637 @item
638 @code{troff} is firmly entrenched in all @acronym{UNIX} systems.
639 @item
640 It is difficult to have a wide range of capabilities available within
641 the confines of a GUI/window system.
642 @item
643 It is more difficult to make global changes to a document.
644 @end itemize
646 @quotation
647 ``GUIs normally make it simple to accomplish simple actions and
648 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
649 @code{comp.unix.wizards})
650 @end quotation
653 @node History, groff Capabilities, What Is groff?, Introduction
654 @section History
655 @cindex history
657 @cindex @code{runoff}
658 @code{troff} can trace its origins back to a formatting program called
659 @code{runoff} which ran on MIT's CTSS system.  This name came from the
660 common phrase of the time ``I'll run off a document.''
662 @cindex @code{roff}
663 The first version of @acronym{UNIX} was developed on a PDP-7 which was
664 sitting around Bell Labs.  In 1971 the developers wanted to get a PDP-11
665 for further work on the operating system.  In order to justify the cost
666 for this system, they proposed that they would implement a document
667 formatting system for the AT&T patents division.  This first formatting
668 program was a reimplementation of @code{runoff}.  In accordance with
669 @acronym{UNIX}'s penchant for abbreviations, it was named @code{roff}
670 (an abbreviation of @code{runoff}).
672 @cindex @code{nroff}
673 When they needed a more flexible language, a new version of @code{roff}
674 called @code{nroff} (Newer @code{roff}) was written.  It had a much more
675 complicated syntax, but provided the basis for all future versions.
676 When they got a Graphic Systems CAT Phototypesetter, J.@w{ }F.@w{
677 }Ossanna wrote a version of @code{nroff} which would drive it.  It was
678 dubbed @code{troff} for typesetter @code{roff}, although many people
679 have speculated that it actually means Times @code{roff} because of the
680 use of the Times font family in @code{troff} by default.  As such, the
681 name @code{troff} is pronounced `@w{t-roff}' rather than `trough'.
683 With @code{troff} came @code{nroff} (they were actually the same program
684 except for some @samp{#ifdefs}), which was for producing output for line
685 printers and character terminals.  It understood everything @code{troff}
686 did, and ignored the commands which were not applicable (e.g.@: font
687 changes).
689 Since there are several things which cannot be done easily in
690 @code{troff}, work on several preprocessors began.  These programs would
691 transform certain parts of a document into @code{troff}, which made a
692 very natural use of pipes in @acronym{UNIX}.
694 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
695 specified in a much simpler and more intuitive manner.  @code{tbl} is a
696 preprocessor for formatting tables.  The @code{refer} preprocessor (and
697 the similar program, @code{bib}) processes citations in a document
698 according to a bibliographic database.
700 Unfortunately, Ossanna's @code{troff} was written in PDP-11 assembly
701 language and produced output specifically for the CAT phototypesetter.
702 He rewrote it in C, although it was now 7000@w{ }lines of uncommented
703 code and still dependent on the CAT.  As the CAT became less common, and
704 was no longer supported by the manufacturer, the need to make it support
705 other devices became a priority.  However, before this could be done, he
706 was killed in an auto accident.
708 @pindex ditroff
709 @cindex @code{ditroff}
710 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
711 newly rewritten version produced a device independent code which was
712 very easy for postprocessors to read and translate to the appropriate
713 printer codes.  Also, this new version of @code{troff} (called
714 @code{ditroff} for `device independent @code{troff}') had several
715 extensions, which included drawing functions.
717 Due to the additional abilities of the new version of @code{troff},
718 several new preprocessors appeared.  The @code{pic} preprocessor
719 provides a wide range of drawing functions.  Likewise the @code{ideal}
720 preprocessor did the same, although via a much different paradigm.  The
721 @code{grap} preprocessor took specifications for graphs, but, unlike
722 other preprocessors, produced @code{pic} code.
724 James Clark began work on a GNU implementation of @code{ditroff} in
725 early@w{ }1989.  The first version, @code{groff}@w{ }0.3.1, was released
726 June@w{ }1990.  @code{groff} included
728 @itemize @bullet{}
729 @item
730 A replacement for @code{ditroff} with many extensions.
731 @item
732 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
733 @item
734 Postprocessors for character devices, @sc{PostScript}, @TeX{} DVI, and
735 X@w{ }windows.  GNU @code{troff} also eliminated the need for a separate
736 @code{nroff} program with a postprocessor which would produce
737 @acronym{ASCII} output.
738 @item
739 A version of the @option{-me} macros and an implementation of the
740 @option{-man} macros.
741 @end itemize
743 Also, a front-end was included which could construct the, sometimes
744 painfully long, pipelines required for all the post- and preprocessors.
746 Development of GNU @code{troff} progressed rapidly, and saw the
747 additions of a replacement for @code{refer}, an implementation of the
748 @option{-ms} and @option{-mm} macros, and a program to deduce how to
749 format a document (@code{grog}).
751 It was declared a stable (i.e.@: non-beta) package with the release of
752 version@w{ }1.04 around November@w{ }1991.
754 Beginning in@w{ }1999, @code{groff} has new maintainers (the package was
755 an orphan for a few years).  As a result, new features and programs like
756 @code{grn}, a preprocessor for gremlin images, and @code{grohtml}, an
757 output device to produce @acronym{HTML} output, have been added.
760 @node groff Capabilities, Macro Package Intro, History, Introduction
761 @section @code{groff} Capabilities
762 @cindex @code{groff} capabilities
763 @cindex capabilities of @code{groff}
765 So what exactly is @code{groff} capable of doing?  @code{groff} provides
766 a wide range of low-level text formatting operations.  Using these, it
767 is possible to perform a wide range of formatting tasks, such as
768 footnotes, table of contents, multiple columns, etc.
770 @itemize @bullet{}
771 @item
772 Text filling, adjusting, and centering
773 @item
774 Hyphenation
775 @item
776 Page control
777 @item
778 Font and character size control
779 @item
780 Vertical spacing (i.e.@: double spacing)
781 @item
782 Line length and indenting
783 @item
784 Macros, strings, diversions, and traps
785 @item
786 Number registers
787 @item
788 Tabs, leaders, and fields
789 @item
790 Input and output conventions and character translation
791 @item
792 Overstrike, bracket, line drawing, and zero-width functions
793 @item
794 Local horizontal and vertical motions and the width function
795 @item
796 Three-part titles
797 @item
798 Output line numbering
799 @item
800 Conditional acceptance of input
801 @item
802 Environment switching
803 @item
804 Insertions from the standard input
805 @item
806 Input/output file switching
807 @item
808 Output and error messages
809 @end itemize
812 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
813 @section Macro Packages
814 @cindex macro packages
816 Since @code{groff} provides such low level facilities, it can be quite
817 difficult to use by itself.  However, @code{groff} provides a
818 @dfn{macro} facility to specify how certain routine operations (e.g.@w{
819 }starting paragraphs, printing headers and footers, etc.)@: should be
820 done.  These macros can be collected together into a @dfn{macro
821 package}.  There are a number of macro packages available; the most
822 common (and the ones described in this manual) are @option{-man},
823 @option{-mdoc}, @option{-me}, @option{-ms}, and @option{-mm}.
826 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
827 @section Preprocessors
828 @cindex preprocessors
830 Although @code{groff} provides most functions needed to format a
831 document, some operations would be unwieldy (e.g.@: to draw pictures).
832 Therefore, programs called preprocessors were written which understand
833 their own language and produce the necessary @code{groff} operations.
834 These preprocessors are able to differentiate their own input from the
835 rest of the document via markers.
837 To use a preprocessor, @acronym{UNIX} pipes are used to feed the output
838 from the preprocessor into @code{groff}.  Any number of preprocessors
839 may be used on a given document; in this case, the preprocessors are
840 linked together into one pipeline.  However, in @code{groff}, the user
841 does not need to construct the pipe, but only tell @code{groff} what
842 preprocessors to use.
844 @code{groff} currently has preprocessors for producing tables
845 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
846 (@code{pic} and @code{grn}), and for processing bibliographies
847 (@code{refer}).  An associated program which is useful when dealing with
848 preprocessors is @code{soelim}.
850 A free implementation of @code{grap}, a preprocessor for drawing graphs,
851 can be obtained as an extra package.
853 There are other preprocessors in existence, but, unfortunately, no free
854 implementations are available.  Among them are preprocessors for drawing
855 mathematical pictures (@code{ideal}) and chemical structures
856 (@code{chem}).
859 @node Output device intro, Credits, Preprocessor Intro, Introduction
860 @section Output Devices
861 @cindex postprocessors
862 @cindex output devices
863 @cindex devices for output
865 @code{groff} actually produces device independent code which may be fed
866 into a postprocessor which will produce output for a particular device.
867 Currently, @code{groff} has postprocessors for @sc{PostScript},
868 character terminals, X@w{ }Windows (for previewing), @TeX{} DVI format,
869 HP LaserJet@w{ }4 and Canon LBP printers, and @acronym{HTML}.
872 @node Credits,  , Output device intro, Introduction
873 @section Credits
874 @cindex credits
876 Large portions of this manual were taken from existing documents, most
877 notably, the manual pages for the @code{groff} package by James Clark,
878 and Eric Allman's papers on the @option{-me} macro package.
880 The section on the @option{-man} macro package is partly based on
881 Susan@w{ }G.@: Kleinmann's @file{groff_man} manual page written for the
882 Debian GNU/Linux system.
886 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
887 @chapter Invoking @code{groff}
888 @cindex invoking @code{groff}
889 @cindex @code{groff} invocation
891 @pindex groff
892 @pindex gtroff
893 This section focuses on how to invoke the @code{groff} front end.  This
894 front end takes care of the details of constructing the pipeline among
895 the preprocessors, @code{gtroff} and the postprocessor.
897 It has become a tradition that GNU programs get the prefix @samp{g} to
898 distinguish it from its original counterparts provided by the host
899 (@pxref{Environment}, for more details).  Thus, for example, @code{geqn}
900 is GNU @code{eqn}.  On operating systems like Linux or the Hurd, which
901 don't contain proprietary software, this prefix is omitted since GNU
902 @code{troff} is the only used incarnation of @code{troff}.  Exception:
903 @code{groff} is never replaced by @code{roff}.
905 @menu
906 * Groff Options::               
907 * Environment::                 
908 * Invocation Examples::         
909 @end menu
912 @node Groff Options, Environment, Invoking groff, Invoking groff
913 @section Options
914 @cindex options
916 @pindex groff
917 @pindex gtroff
918 @pindex gpic
919 @pindex geqn
920 @pindex ggrn
921 @pindex gtbl
922 @pindex grefer
923 @pindex gsoelim
924 @code{groff} normally runs the @code{gtroff} program and a postprocessor
925 appropriate for the selected device.  The default device is @samp{ps}.
926 It can optionally preprocess with any of @code{gpic}, @code{geqn},
927 @code{gtbl}, @code{ggrn}, @code{grefer}, or @code{gsoelim}.
929 This section only documents options to the @code{groff} front end.  Many
930 of the arguments to @code{groff} are passed on to @code{gtroff},
931 therefore those are also included.  Arguments to pre- or postprocessors
932 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
933 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
934 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
935 grohtml}, @ref{Invoking grodvi}, @ref{Invoking grolj4}, @ref{Invoking
936 grolbp}, and @ref{Invoking gxditview}.
938 The command line format for @code{groff} is:
940 @example
941 groff [ -abeghilpstvzCENRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
942       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
943       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
944       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
945       [ @var{files}@dots{} ]
946 @end example
948 The command line format for @code{gtroff} is as follows.  As can be
949 seen, many of the options to @code{groff} are actually passed on to
950 @code{gtroff}.
952 @example
953 gtroff [ -abivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
954        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
955        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
956        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
957 @end example
959 Options without an argument can be grouped behind a single @option{-}.
960 A filename of @samp{-} denotes the standard input.
962 @pindex grog
963 The @code{grog} command can be used to guess the correct @code{groff}
964 command to format a file.
966 @table @samp
967 @item -h
968 Print a help message.
969 @item -e
970 Preprocess with @code{geqn}.
971 @item -t
972 Preprocess with @code{gtbl}.
973 @item -g
974 Preprocess with @code{ggrn}.
975 @item -p
976 Preprocess with @code{gpic}.
977 @item -s
978 Preprocess with @code{gsoelim}.
979 @item -R
980 Preprocess with @code{grefer}.  No mechanism is provided for passing
981 arguments to @code{grefer} because most @code{grefer} options have
982 equivalent commands which can be included in the file.  @xref{grefer},
983 for more details.
985 @pindex troffrc
986 @pindex troffrc-end
987 Note that @code{gtroff} also accepts a @option{-R} option, which is not
988 accessible via @code{groff}.  This option prevents the loading of the
989 @file{troffrc} and @file{troffrc-end} files.
990 @item -v
991 Make programs run by @code{groff} print out their version number.
992 @item -V
993 Print the pipeline on stdout instead of executing it.
994 @item -z
995 Suppress output from @code{gtroff}.  Only error messages will be
996 printed.
997 @item -Z
998 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
999 will automatically run the appropriate postprocessor.
1000 @item -P@var{arg}
1001 Pass @var{arg} to the postprocessor.  Each argument should be passed
1002 with a separate @option{-P} option.  Note that @code{groff} does not
1003 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
1004 @item -l
1005 Send the output to a printer.  The command used for this is specified by
1006 the print command in the device description file.
1007 @item -L@var{arg}
1008 Pass @var{arg} to the spooler.  Each argument should be passed with a
1009 separate @option{-L} option.  Note that @code{groff} does not prepend a
1010 @samp{-} to @var{arg} before passing it to the postprocessor.
1011 @item -T@var{dev}
1012 Prepare output for device @var{dev}.  The default device is @samp{ps}.
1013 The following are the output devices currently available:
1014 @table @code
1015 @item ps
1016 For @sc{PostScript} printers and previewers.
1017 @item dvi
1018 For @TeX{} DVI format.
1019 @item X75
1020 For a 75@dmn{dpi} X11 previewer.
1021 @item X100
1022 For a 100@dmn{dpi} X11 previewer.
1023 @item ascii
1024 For typewriter-like devices.
1025 @item latin1
1026 For typewriter-like devices using the @w{ISO Latin-1} (@w{ISO 8859-1})
1027 character set.
1028 @item utf8
1029 For typewriter-like devices which use the Unicode (@w{ISO 10646})
1030 character set with @w{UTF-8} encoding.
1031 @item lj4
1032 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
1033 @item lbp
1034 For Canon @acronym{CAPSL} printers (@w{LBP-4} and @w{LBP-8} series laser
1035 printers).
1036 @item html
1037 To produce @acronym{HTML} output.
1038 @end table
1040 The postprocessor to be used for a device is specified by the
1041 @code{postpro} command in the device description file.  (@xref{Font
1042 Files}, for more info.)  This can be overridden with the @option{-X}
1043 option.
1044 @item -X
1045 Preview with @code{gxditview} instead of using the usual postprocessor.
1046 This is unlikely to produce good results except with @option{-Tps}.
1048 Note that this is not the same as using @option{-TX75} or
1049 @option{-TX100} to view a document with @code{gxditview}: The former
1050 will us the metrics of the specified device, whereas the latter will use
1051 X-specific fonts and metrics.
1052 @item -N
1053 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1054 the @option{-N} option in @code{geqn}.
1055 @item -S
1056 Safer mode.  Pass the @option{-S} option to @code{gpic} and use the
1057 @option{-msafer} macros with @code{gtroff} (enabled by default).
1058 @item -U
1059 Unsafe mode.  Reverts to the old unsafe behaviour.
1060 @item -a
1061 Generate an @acronym{ASCII} approximation of the typeset output.
1062 @item -b
1063 Print a backtrace with each warning or error message.  This backtrace
1064 should help track down the cause of the error.  The line numbers given
1065 in the backtrace may not always be correct: @code{gtroff} can get
1066 confused by @code{as} or @code{am} requests while counting line numbers.
1067 @item -i
1068 Read the standard input after all the named input files have been
1069 processed.
1070 @item -w@var{name}
1071 Enable warning @var{name}.  Available warnings are described in
1072 @ref{Debugging}.  Multiple @option{-w} options are allowed.
1073 @item -W@var{name}
1074 Inhibit warning @var{name}.  Multiple @option{-W} options are allowed.
1075 @item -E
1076 Inhibit all error messages.
1077 @item -C
1078 Enable compatibility mode.
1079 @item -d@var{cs}
1080 @itemx -d@var{name}=s
1081 Define @var{c} or @var{name} to be a string @var{s}; @var{c} must be a
1082 one-letter @var{name}.
1083 @item -f@var{fam}
1084 Use @var{fam} as the default font family.
1085 @item -m@var{name}
1086 Read in the file @file{tmac.@var{name}}.  Normally this will be searched
1087 for in the library directory of @code{groff}.
1088 @item -n@var{num}
1089 Number the first page @var{num}.
1090 @item -o@var{list}
1091 @vindex .P
1092 Output only pages in @var{list}, which is a comma-separated list of page
1093 ranges; @var{n} means print page @var{n}, @samp{@var{m}-@var{n}} means
1094 print every page between @var{m} and @var{n}, @samp{-@var{n}} means
1095 print every page up to @var{n}, @samp{@var{n}-} means print every page
1096 from @var{n}.  @code{gtroff} will exit after printing the last page in
1097 the list.
1099 Within @code{gtroff}, this information can be extracted with the
1100 @samp{.P} register.  @xref{Built-in Registers}.
1101 @item -r@var{cn}
1102 @itemx -r@var{name}=@var{n}
1103 Set number register @var{c} or @var{name} to @var{n}; @var{c} must be a
1104 one-letter @var{name}; @var{n} can be any @code{gtroff} numeric
1105 expression.
1106 @item -F@var{dir}
1107 Search @var{dir} for subdirectories dev@var{name} (@var{name} is the
1108 name of the device) for the @file{DESC} file and font files before the
1109 normal directory.
1110 @item -M@var{dir}
1111 Search directory @var{dir} for macro files before the normal directory.
1112 @item -I@var{dir}
1113 This option is as described in @ref{gsoelim}.  It implies the
1114 @option{-s} option.
1115 @end table
1118 @node Environment, Invocation Examples, Groff Options, Invoking groff
1119 @section Environment
1120 @cindex environment variables
1121 @cindex variables in environment
1123 There are also several environment variables (of the operating system,
1124 not within @code{gtroff}) which can modify the behavior of @code{groff}.
1126 @table @code
1127 @item GROFF_COMMAND_PREFIX
1128 @tindex GROFF_COMMAND_PREFIX
1129 If this is set to @var{X}, then @code{groff} will run
1130 @var{X}@code{troff} instead of @code{gtroff}.  This also applies to
1131 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{refer}, and
1132 @code{soelim}.  It does not apply to @code{grops}, @code{grodvi},
1133 @code{grotty}, @code{grohtml}, @code{grolj4}, and @code{gxditview}.
1134 @item GROFF_TMAC_PATH
1135 @tindex GROFF_TMAC_PATH
1136 A colon separated list of directories in which to search for macro
1137 files.
1138 @item GROFF_TYPESETTER
1139 @tindex GROFF_TYPESETTER
1140 The default output device.
1141 @item GROFF_FONT_PATH
1142 @tindex GROFF_FONT_PATH
1143 A colon separated list of directories in which to search for the
1144 @code{dev}@var{name} directory.
1145 @item PATH
1146 @tindex PATH
1147 The search path for commands executed by @code{groff}.
1148 @item GROFF_TMPDIR
1149 @tindex GROFF_TMPDIR
1150 @tindex TMPDIR
1151 The directory in which temporary files will be created.  If this is not
1152 set and @env{TMPDIR} is set, temporary files will be created in that
1153 directory.  Otherwise temporary files will be created in @code{/tmp}.
1154 The @code{grops} and @code{grefer} commands can create temporary files.
1155 @end table
1158 @node Invocation Examples,  , Environment, Invoking groff
1159 @section Invocation Examples
1160 @cindex invocation examples
1161 @cindex examples of invocation
1163 This section will list several common uses of @code{groff} and the
1164 command line which will accomplish it.
1166 @example
1167 groff file
1168 @end example
1170 @noindent
1171 This command processes @var{file} without a macro package or a
1172 preprocessor.  The output device is the default, @var{ps}, and the
1173 output is sent to stdout.
1175 @example
1176 groff -t -mandoc -Tascii file | less
1177 @end example
1179 @noindent
1180 This is basically what a call to the @code{man} program does.  The
1181 manual page @var{file} is processed with the @option{-mandoc} macros
1182 (which in turn either calls the @option{-man} or the @option{-mdoc}
1183 macro package), using the @code{tbl} preprocessor and the
1184 @acronym{ASCII} output device.  Finally, the result is displayed with
1185 the @code{less} pager.
1187 @example
1188 groff -X -me file
1189 @end example
1191 @noindent
1192 Preview @var{file} with @code{gxditview}, using the @option{-me} macro
1193 package.  Since no @option{-T} option is specified, use the default
1194 device (@samp{ps}).
1196 @example
1197 groff -man -rD1 -z file
1198 @end example
1200 @noindent
1201 Check @var{file} with the @option{-man} macro package, forcing
1202 double-sided printing---don't produce any output.
1204 @subsection @code{grog}
1206 @code{grog} reads files and guesses which of the @code{groff}
1207 preprocessors and/or macro packages are are required for formatting
1208 them, and prints the @code{groff} command including those options on the
1209 standard output.  The options generated are one of @option{-e},
1210 @option{-man}, @option{-me}, @option{-mm}, @option{-ms}, @option{-p},
1211 @option{-R}, @option{-g}, @option{-s}, and @option{-t}.
1213 A filename of @samp{-} is taken to refer to the standard input.  If no
1214 files are specified the standard input will be read.  Any specified
1215 options will be included in the printed command.  No space is allowed
1216 between options and their arguments.  For example,
1218 @example
1219 grog -Tdvi paper.ms
1220 @end example
1222 @noindent
1223 will guess the appropriate command to print @file{paper.ms} and then
1224 print it to the command line after adding the @option{-Tdvi} option.
1225 For direct execution, enclose the call to @code{grog} in backquotes on
1226 the @acronym{UNIX} shell prompt:
1228 @example
1229 `grog -Tdvi paper.ms` > paper.dvi
1230 @end example
1232 @noindent
1233 As seen in the example, it is still necessary to redirect the output to
1234 something meaningful (i.e.@: either a file or a pager program like
1235 @code{less}).
1239 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1240 @chapter Tutorial for Macro Users
1241 @cindex tutorial for macro users
1242 @cindex macro tutorial for users
1243 @cindex user's tutorial for macros
1244 @cindex user's macro tutorial
1246 Most users tend to use a macro package to format their papers.  This
1247 means that the whole breadth of @code{groff} is not necessary for most
1248 people.  This chapter covers the material needed to efficiently use a
1249 macro package.
1251 @menu
1252 * Basics::                      
1253 * Common Features::             
1254 @end menu
1257 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1258 @section Basics
1259 @cindex basics
1261 This section covers some of the basic concepts necessary to understand
1262 how to use a macro package.@footnote{This section is derived from
1263 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1264 References are made throughout to more detailed information, if desired.
1266 @code{gtroff} reads an input file prepared by the user and outputs a
1267 formatted document suitable for publication or framing.  The input
1268 consists of text, or words to be printed, and embedded commands
1269 (@dfn{requests} and @dfn{escapes}), which tell @code{gtroff} how to
1270 format the output.  For more detail on this @pxref{Embedded Commands}.
1272 The word @dfn{argument} is used in this manual to mean a word or number
1273 which appears on the same line as a request which modifies the meaning
1274 of that request.  For example, the request
1276 @example
1278 @end example
1280 @noindent
1281 spaces one line, but
1283 @example
1284 .sp 4
1285 @end example
1287 @noindent
1288 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1289 request which says to space four lines instead of one.  Arguments are
1290 separated from the request and from each other by spaces.  More details
1291 on this can be found in @ref{Request Arguments}.
1293 The primary function of @code{gtroff} is to collect words from input
1294 lines, fill output lines with those words, justify the right hand margin
1295 by inserting extra spaces in the line, and output the result.  For
1296 example, the input:
1298 @example
1299 Now is the time
1300 for all good men
1301 to come to the aid
1302 of their party.
1303 Four score and seven
1304 years ago,...
1305 @end example
1307 @noindent
1308 will be read, packed onto output lines, and justified to produce:
1310 @quotation
1311 Now is the time for all good men to come to the aid of their party.
1312 Four score and seven years ago,...
1313 @end quotation
1315 @cindex break
1316 @cindex line break
1317 Sometimes a new output line should be started even though the current
1318 line is not yet full; for example, at the end of a paragraph.  To do
1319 this it is possible to cause a @dfn{break}, which starts a new output
1320 line.  Some requests cause a break automatically, as do blank input
1321 lines and input lines beginning with a space.
1323 Not all input lines are text to be formatted.  Some of the input lines
1324 are requests which describe how to format the text.  Requests always
1325 have a period (@samp{.}) or an apostrophe (@samp{'}) as the first
1326 character of the input line.
1328 The text formatter also does more complex things, such as automatically
1329 numbering pages, skipping over page boundaries, putting footnotes in the
1330 correct place, and so forth.
1332 Here a few hints for preparing text for input to @code{gtroff}.  First,
1333 keep the input lines short.  Short input lines are easier to edit, and
1334 @code{gtroff} will pack words onto longer lines anyhow.  In keeping with
1335 this, it is helpful to begin a new line after every period, comma, or
1336 phrase, since common corrections are to add or delete sentences or
1337 phrases.  Secondly, do not hyphenate words at the end of
1338 lines---@code{gtroff} is smart enough to hyphenate words for the user as
1339 needed, but is not smart enough to take hyphens out and join a word back
1340 together.  Also, words such as ``mother-in-law'' should not be broken
1341 over a line, since then a space can occur where not wanted, such as
1342 ``@w{mother- in}-law''.
1344 @findex ls
1345 @cindex double spacing
1346 @cindex spacing
1347 @code{gtroff} will double space output text automatically if using the
1348 request @w{@samp{.ls 2}}.  Single spaced mode can be reactivated by
1349 typing @w{@samp{.ls 1}}.
1351 A number of requests allow to change the way the output looks, sometimes
1352 called the @dfn{layout} of the output page.  Most of these requests
1353 adjust the placing of @dfn{white space} (blank lines or spaces).
1355 @findex bp
1356 @cindex new page
1357 The @samp{.bp} request starts a new page, causing a line break.
1359 @findex sp
1360 @cindex blank lines
1361 @cindex empty lines
1362 @cindex lines, empty
1363 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1364 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1365 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1366 @var{N}@w{ }centimeters).  For example, the input:
1368 @example
1369 .sp 1.5i
1370 My thoughts on the subject
1372 @end example
1374 @noindent
1375 leaves one and a half inches of space, followed by the line ``My
1376 thoughts on the subject'', followed by a single blank line.
1378 @findex ce
1379 @cindex centering lines
1380 @cindex lines, centering
1381 Text lines can be centered by using the @code{ce} request.  The line
1382 after @code{ce} is centered (horizontally) on the page.  To center more
1383 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1384 of lines to center), followed by the @var{N}@w{ }lines.  To center many
1385 lines without counting them, type:
1387 @example
1388 .ce 1000
1389 lines to center
1390 .ce 0
1391 @end example
1393 @noindent
1394 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1395 lines, in other words, stop centering.
1397 @findex br
1398 @cindex line break
1399 @cindex break
1400 All of these requests cause a break; that is, they always start a new
1401 line.  To start a new line without performing any other action, use
1402 @code{br}.
1405 @node Common Features,  , Basics, Tutorial for Macro Users
1406 @section Common Features
1407 @cindex common features
1408 @cindex features, common
1410 @code{gtroff} provides very low level operations for formatting a
1411 document.  There are many common routine operations which are done in
1412 all documents.  These common operations are written into @dfn{macros}
1413 and collected into a @dfn{macro package}.
1415 All macro packages provide certain common capabilities which fall into
1416 the following categories.
1418 @subsection Paragraphs
1419 @cindex paragraphs
1421 One of the most common and most used capability is starting a paragraph.
1422 There are a number of different types of paragraphs, any of which can be
1423 initiated with macros supplied by the macro package.  Normally,
1424 paragraphs start with a blank line and the first line indented, like the
1425 text in this manual.  There are also block style paragraphs, which omit
1426 the indentation:
1428 @example
1429 Some   men  look   at  constitutions   with  sanctimonious
1430 reverence, and deem them like the ark of the covenant, too
1431 sacred to be touched.
1432 @end example
1434 @noindent
1435 And there are also indented paragraphs which begin with a tag or label
1436 at the margin and the remaining text indented.
1438 @example
1439 one   This is  the first paragraph.  Notice  how the first
1440       line of  the resulting  paragraph lines up  with the
1441       other lines in the paragraph.
1442 longlabel
1443       This  paragraph   had  a  long   label.   The  first
1444       character of text on the first line will not line up
1445       with  the  text  on  second  and  subsequent  lines,
1446       although they will line up with each other.
1447 @end example
1449 A variation of this is a bulleted list.
1450 @c XXX description
1452 @subsection Sections and Chapters
1454 Most macro packages supply some form of section headers.  The simplest
1455 kind is simply the heading on a line by itself in bold type.  Others
1456 supply automatically numbered section heading or different heading
1457 styles at different levels.  Some, more sophisticated, macro packages
1458 supply macros for starting chapters and appendices.
1460 @subsection Headers and Footers
1462 Every macro package gives some way to manipulate the headers and
1463 footers (or @dfn{titles}) on each page.  Some packages will allow for
1464 different ones on the even and odd pages (for material printed in a book
1465 form).
1467 The titles are called three-part titles, that is, there is a
1468 left-justified part, a centered part, and a right-justified part.  An
1469 automatically generated page number may be put in any of these fields
1470 with the @samp{%} character (@pxref{Page Layout} for more details).
1472 @subsection Page Layout
1474 Most macro packages let thte user specify top and bottom margins and
1475 other details about the appearance of the printed pages.
1477 @subsection Displays
1478 @cindex displays
1480 Displays are sections of text to be set off from the body of the paper.
1481 Major quotes, tables, and figures are types of displays, as are all the
1482 examples used in this document.
1484 @cindex quotes, major
1485 @cindex major quotes
1486 @dfn{Major quotes} are quotes which are several lines long, and hence
1487 are set in from the rest of the text without quote marks around them.
1489 @cindex list
1490 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
1491 should be used when the material to be printed should not be filled and
1492 justified like normal text, such as columns of figures or the examples
1493 used in this paper.
1495 @cindex keep
1496 A @dfn{keep} is a display of lines which are kept on a single page if
1497 possible.  An example for a keep might be a diagram.  Keeps differ from
1498 lists in that lists may be broken over a page boundary whereas keeps
1499 will not.
1501 @cindex keep, floating
1502 @cindex floating keep
1503 Floating keeps move relative to the text.  Hence, they are good for
1504 things which will be referred to by name, such as ``See figure@w{ }3''.
1505 A floating keep will appear at the bottom of the current page if it will
1506 fit; otherwise, it will appear at the top of the next page.  Meanwhile,
1507 the surrounding text will `flow' around the keep, thus leaving now blank
1508 areas.
1510 @subsection Footnotes and annotations
1511 @cindex footnotes
1512 @cindex annotations
1514 There are a number of requests to save text for later printing.
1516 @dfn{Footnotes} are printed at the bottom of the current page.
1518 @cindex delayed text
1519 @dfn{Delayed text} is very similar to a footnote except that it is
1520 printed when called for explicitly.  This allows a list of references to
1521 appear (for example) at the end of each chapter, as is the convention in
1522 some disciplines.
1524 Most macro packages which supply this functionality also supply a means
1525 of automatically numbering either type of annotation.
1527 @subsection Table of Contents
1528 @cindex table of contents
1529 @cindex contents, table of
1531 @dfn{Tables of contents} are a type of delayed text having a tag
1532 (usually the page number) attached to each entry after a row of dots.
1533 The table accumulates throughout the paper until printed, usually after
1534 the paper has ended.  Many macro packages will provide the ability to
1535 have several tables of contents (i.e.@: one standard one, one for
1536 tables, etc).
1538 @subsection Indices
1539 @cindex index
1541 While some macro packages will use the term @dfn{index}, none actually
1542 provide that functionality.  The facilities they call indices are
1543 actually more appropriate for tables of contents.
1545 @subsection Paper formats
1546 @cindex paper formats
1548 Some macro packages provide stock formats for various kinds of
1549 documents.  Many of them provide a common format for the title and
1550 opening pages of a technical paper.  The @option{-mm} macros in
1551 particular provide formats for letters and memoranda.
1553 @subsection Multiple Columns
1555 Some macro packages (except @option{-man}) provide the ability to have
1556 two or more columns on a page.
1558 @subsection Font and Size changes
1560 The built-in font and size functions are not always intuitive, so all
1561 macro packages provide macros to make these operations simpler.
1563 @subsection Predefined Strings
1565 Most macro packages provide various predefined strings for a variety of
1566 uses; examples are sub- and superscripts, printable dates, quotes and
1567 various special characters.
1569 @subsection Preprocessor Support
1571 All macro packages provide support for the various preprocessors.
1573 @subsection Configuration and Customization
1575 Some macro packages provide means of customizing many of details of how
1576 the package behaves.  This ranges from setting the default type size to
1577 changing the appearance of section headers.
1581 @node Macro Packages, Programming Tutorial, Tutorial for Macro Users, Top
1582 @chapter Macro Packages
1583 @cindex macro packages
1584 @cindex packages, macros
1586 This chapter documents the main macro packages that come with
1587 @code{groff}.
1589 @menu
1590 * -man::                        
1591 * -mdoc::                       
1592 * -ms::                         
1593 * -me::                         
1594 * -mm::                         
1595 @end menu
1598 @node -man, -mdoc, Macro Packages, Macro Packages
1599 @section -man
1600 @cindex @option{-man}
1601 @pindex tmac.an
1603 This is the most popular and probably the most important macro package
1604 of @code{groff}.  It is easy to use, and a vast majority of manual pages
1605 are based on it.
1607 @menu
1608 * Man options::                 
1609 * Man usage::                   
1610 * Man font macros::             
1611 * Miscellaneous man stuff::     
1612 @end menu
1614 @node Man options, Man usage, -man, -man
1615 @subsection Options
1617 The command line format for using the @option{-man} macros with
1618 @code{groff} is:
1620 @c XXX document @TMAC_AN_PREFIX@
1622 @example
1623 groff -man [ -rC1 ] [ -rD1 ] [ -rP @var{nnn} ] [ -rX @var{nnn} ]
1624       [ @var{files}@dots{} ] 
1625 @end example
1627 @table @code
1628 @item -rC1
1629 If more than one manual page is given on the command line, number the
1630 pages continuously, rather than starting each at@w{ }1.
1631 @item -rD1
1632 Double-sided printing.  Footers for even and odd pages are formatted
1633 differently.
1634 @item -rP @var{nnn}
1635 Enumeration of pages will start with @var{nnn} rather than with@w{ }1.
1636 @item -rX @var{nnn}
1637 After page @var{nnn}, number pages as @var{nnn}a, @var{nnn}b,
1638 @var{nnn}c, etc.  For example, the option @option{-rX2} will produce the
1639 following page numbers: 1, 2, 2a, 2b, 2c, etc.
1640 @end table
1642 @node Man usage, Man font macros, Man options, -man
1643 @subsection Usage
1645 @pindex man.local
1646 This section describes the available macros for manual pages.  For
1647 further customization, put additional macros and requests into the file
1648 @file{man.local} which will be loaded immediately after @file{tmac.an}.
1650 @maindex TH
1651 @Defmac{TH, title section [@var{extra1}] [@var{extra2}] [@var{extra3}]}
1652 Sets the title of the man page to @var{title} and the section to
1653 @var{section}, which must take on a value between 1 and@w{ }8.  The
1654 value @var{section} may also have a string appended, e.g.@: @samp{.pm},
1655 to indicate a specific subsection of the man pages.
1657 Both @var{title} and @var{section} are positioned at the left and right
1658 in the header line (with @var{section} in parentheses immediately
1659 appended to @var{title}.  @var{extra1} will be positioned in the middle
1660 of the footer line.  @var{extra2} will be positioned at the left in the
1661 footer line (resp.@: at the left on even pages and at the right on odd
1662 pages if double-sided printing is active).  @var{extra3} is centered in
1663 the header line.
1665 For @acronym{HTML} output, headers and footers are completely supressed.
1667 Additionally, this macro starts a new page; the new line number is@w{ }1
1668 again (except if the @option{-rC1} option is given on the command
1669 line)---this feature is intended only for formatting multiple man pages;
1670 a single man page should contain exactly one @code{TH} macro at the
1671 beginning of the file.
1672 @end defmac
1674 @maindex SH
1675 @Defmac{SH, [@var{heading}]}
1676 Sets up an unnumbered section heading sticking out to the left.  Prints
1677 out all the text following @code{SH} up to the end of the line (resp.@:
1678 the text in the next line if there is no argument to @code{SH}) in bold
1679 face, at a default size of 9@w{ }point.  Additionally, the left margin
1680 for the following text is reset to its default value.
1681 @end defmac
1683 @maindex SS
1684 @Defmac{SS, [@var{heading}]}
1685 Sets up an unnumbered section heading.  Prints out all the text
1686 following @code{SS} up to the end of the line (resp.@: the text in the
1687 next line if there is no argument to @code{SS}) in bold face, at a
1688 default size of 10@w{ }point.  Additionally, the left margin for the
1689 following text is reset to its default value.
1690 @end defmac
1692 @maindex TP
1693 @Defmac{TP, [@var{nnn}]}
1694 Sets up an indented paragraph with label.  The indentation is set to
1695 @var{nnn} if that argument is supplied (the default unit is @samp{n} if
1696 omitted), otherwise it is set to the default indentation value.
1698 The first line of text following this macro is interpreted as a string
1699 to be printed flush-left, as it is appropriate for a label.  It is not
1700 interpreted as part of a paragraph, so there is no attempt to fill the
1701 first line with text from the following input lines.  Nevertheless, if
1702 the label is not as wide as the indentation, then the paragraph starts
1703 at the same line (but indented), continuing on the following lines.  If
1704 the label is wider than the indentation, then the descriptive part of
1705 the paragraph begins on the line following the label, entirely indented.
1706 Note that neither font shape nor font size of the label is set to a
1707 default value; on the other hand, the rest of the text will have default
1708 font settings.
1709 @end defmac
1711 @maindex LP
1712 @maindex PP
1713 @maindex P
1714 @Defmac{LP}
1715 @Defmacx{PP}
1716 @Defmacx{P}
1717 These macros are mutual aliases.  Any of them causes a line break at the
1718 current position, followed by a vertical space downwards by the amount
1719 specified by the @code{PD} macro.  The font size and shape are reset to
1720 the default value (10@dmn{pt} resp.@: Roman).  Finally, the current left
1721 margin is restored.
1722 @end defmac
1724 @maindex IP
1725 @Defmac{IP, [@var{designator}] [@var{nnn}]}
1726 Sets up an indented paragraph, using @var{designator} as a tag to mark
1727 its beginning.  The indentation is set to @var{nnn} if that argument is
1728 supplied (default unit is @samp{n}), otherwise the default indentation
1729 value is used.  Font size and face of the paragraph (but not the
1730 designator) are reset to its default values.  To start an indented
1731 paragraph with a particular indentation but without a designator, use
1732 @samp{""} (two doublequotes) as the first argument of @code{IP}.
1734 For example, to start a paragraph with bullets as the designator and
1735 4@dmn{en} indentation, write
1737 @example
1738 .IP \(bu 4
1739 @end example
1740 @end defmac
1742 @maindex HP
1743 @Defmac{HP, [@var{nnn}]}
1744 Sets up a paragraph with hanging left indentation.  The indentation is
1745 set to @var{nnn} if that argument is supplied (default unit is
1746 @samp{n}), otherwise the default indentation value is used.  Font size
1747 and face are reset to its default values.
1748 @end defmac
1750 @maindex RS
1751 @Defmac{RS, [@var{nnn}]}
1752 This macro moves the left margin to the right by the value @var{nnn} if
1753 specified (default unit is @samp{n}); otherwise the default indentation
1754 value is used.  Calls to the @code{RS} macro can be nested.
1755 @end defmac
1757 @maindex RE
1758 @Defmac{RE, [@var{nnn}]}
1759 This macro moves the left margin back to level @var{nnn}; if no argument
1760 is given, it moves one level back.  The first level (i.e., no call to
1761 @code{RS} yet) has number@w{ }1, and each call to @code{RS} increases
1762 the level by@w{ }1.
1763 @end defmac
1765 @maindex SH
1766 @maindex SS
1767 @maindex TP
1768 @maindex LP
1769 @maindex PP
1770 @maindex P
1771 @maindex IP
1772 @maindex HP
1773 To summarize, the following macros cause a line break with the insertion
1774 of vertical space (which amount can be changed with the @code{PD}
1775 macro): @code{SH}, @code{SS}, @code{TP}, @code{LP} (@code{PP},
1776 @code{P}), @code{IP}, and @code{HP}.
1778 @maindex RS
1779 @maindex RE
1780 The macros @code{RS} and @code{RE} also cause a break but no insertion
1781 of vertical space.
1783 @node Man font macros, Miscellaneous man stuff, Man usage, -man
1784 @subsection Macros to set fonts
1786 The standard font is Roman; the default text size is 10@w{ }point.
1788 @maindex SM
1789 @Defmac{SM, [@var{text}]}
1790 Causes the text on the same line or the text on the next line to appear
1791 in a font that is one point size smaller than the default font.
1792 @end defmac
1794 @maindex SB
1795 @Defmac{SB, [@var{text}]}
1796 Causes the text on the same line or the text on the next line to appear
1797 in boldface font, one point size smaller than the default font.
1798 @end defmac
1800 @maindex BI
1801 @Defmac{BI, text}
1802 Causes text on the same line to appear alternately in bold face and
1803 italic.  The text must be on the same line as the macro call.  Thus
1805 @example
1806 .BI this "word and" that
1807 @end example
1809 @noindent
1810 would cause `this' and `that' to appear in bold face, while `word and'
1811 appears in italics.
1812 @end defmac
1814 @maindex IB
1815 @Defmac{IB, text}
1816 Causes text to appear alternately in italic and bold face.  The text
1817 must be on the same line as the macro call.
1818 @end defmac
1820 @maindex RI
1821 @Defmac{RI, text}
1822 Causes text on the same line to appear alternately in roman and italic.
1823 The text must be on the same line as the macro call.
1824 @end defmac
1826 @maindex IR
1827 @Defmac{IR, text}
1828 Causes text on the same line to appear alternately in italic and roman.
1829 The text must be on the same line as the macro call.
1830 @end defmac
1832 @maindex BR
1833 @Defmac{BR, text}
1834 Causes text on the same line to appear alternately in bold face and
1835 roman.  The text must be on the same line as the macro call.
1836 @end defmac
1838 @maindex RB
1839 @Defmac{RB, text}
1840 Causes text on the same line to appear alternately in roman and bold
1841 face.  The text must be on the same line as the macro call.
1842 @end defmac
1844 @maindex R
1845 @Defmac{R, [@var{text}]}
1846 Causes @var{text} to appear in roman font.  If no text is present on the
1847 line where the macro is called, then the text of the next line appears
1848 in roman.  This is the default font to which text is returned at the end
1849 of processing of the other macros.
1850 @end defmac
1852 @maindex B
1853 @Defmac{B, [@var{text}]}
1854 Causes @var{text} to appear in bold face.  If no text is present on the
1855 line where the macro is called, then the text of the next line appears
1856 in bold face.
1857 @end defmac
1859 @maindex I
1860 @Defmac{I, [@var{text}]}
1861 Causes @var{text} to appear in italic.  If no text is present on the
1862 line where the macro is called, then the text of the next line appears
1863 in italic.
1864 @end defmac
1866 @node Miscellaneous man stuff,  , Man font macros, -man
1867 @subsection Miscellaneous
1869 @pindex grohtml
1870 @cindex @option{-man}, default indentation
1871 @cindex default indentation, @option{-man}
1872 The default indentation is 7.2@dmn{n} for all output devices except for
1873 @code{grohtml} which uses 1.2@dmn{i} instead.
1875 @maindex DT
1876 @maindex TH
1877 @Defmac{DT}
1878 Sets tabs every 0.5@w{ }inches.  Since this macro is always called
1879 during a @code{TH} request, it makes sense to call it only if the tab
1880 positions have been changed.
1881 @end defmac
1883 @maindex PD
1884 @Defmac{PD, [@var{nnn}]}
1885 Adjusts the empty space before a new paragraph (resp.@: section).  The
1886 optional argument gives the amount of space (default units are
1887 @samp{v}); without parameter, the value is reset to its default value
1888 (1@w{ }line for tty devices, 0.4@dmn{v}@w{ }otherwise).
1889 @end defmac
1891 @maindex SH
1892 @maindex SS
1893 @maindex TP
1894 @maindex LP
1895 @maindex PP
1896 @maindex P
1897 @maindex IP
1898 @maindex HP
1899 This affects the macros @code{SH}, @code{SS}, @code{TP}, @code{LP}
1900 (resp.@: @code{PP} and @code{P}), @code{IP}, and @code{HP}.
1902 The following strings are defined:
1904 @maindex \*S
1905 @Defmac{\\*S}
1906 Switch back to the default font size.
1907 @end defmac
1909 @maindex \*R
1910 @Defmac{\\*R}
1911 The `registered' sign.
1912 @end defmac
1914 @maindex \*(Tm
1915 @Defmac{\\*(Tm}
1916 The `trademark' sign.
1917 @end defmac
1919 @maindex \*(lq
1920 @maindex \*(rq
1921 @glindex lq
1922 @glindex rq
1923 @Defmac{\\*(lq}
1924 @Defmacx{\\*(rq}
1925 Left and right quote.
1926 This is equal to @code{\(lq} and @code{\(rq}, respectively.
1927 @end defmac
1929 @cindex preprocessor, calling convention
1930 @cindex calling convention of preprocessors
1931 If a preprocessor like @code{gtbl} or @code{geqn} is needed, it has
1932 become usage to make the first line of the man page look like this:
1934 @example
1935 .\" @var{word}
1936 @end example
1938 @pindex geqn
1939 @pindex grefer
1940 @pindex gtbl
1941 @pindex man
1942 Note the single space character after the double quote.  @var{word}
1943 consists of letters for the needed preprocessors: @samp{e} for
1944 @code{geqn}, @samp{r} for @code{grefer}, @samp{t} for @code{gtbl}.
1945 Modern implementations of the @code{man} program read this first line
1946 and automatically call the right preprocessor(s).
1949 @node -mdoc, -ms, -man, Macro Packages
1950 @section -mdoc
1951 @cindex @option{-mdoc}
1953 @c XXX documentation
1956 @node -ms, -me, -mdoc, Macro Packages
1957 @section -ms
1958 @cindex @option{-ms}
1960 @c XXX documentation
1963 @node -me, -mm, -ms, Macro Packages
1964 @section -me
1965 @cindex @option{-me}
1967 @c XXX documentation
1970 @node -mm,  , -me, Macro Packages
1971 @section -mm
1972 @cindex @option{-mm}
1974 @c XXX documentation
1978 @node Programming Tutorial, Preprocessors, Macro Packages, Top
1979 @chapter Programming Tutorial
1980 @cindex programming tutorial
1981 @cindex tutorial for programming
1983 This chapter covers @strong{all} of the facilities of @code{gtroff}.
1984 Users of macro packages may skip it if not interested in details.
1987 @menu
1988 * Text::                        
1989 * Input Conventions::           
1990 * Measurements::                
1991 * Expressions::                 
1992 * Identifiers::                 
1993 * Embedded Commands::           
1994 * Registers::                   
1995 * Manipulating Filling and Adjusting::  
1996 * Manipulating Hyphenation::    
1997 * Manipulating Spacing::        
1998 * Tabs and Fields::             
1999 * Character Translations::      
2000 * Line Layout::                 
2001 * Page Layout::                 
2002 * Page Control::                
2003 * Fonts::                       
2004 * Sizes::                       
2005 * Strings::                     
2006 * Conditionals and Loops::      
2007 * Writing Macros::              
2008 * Page Motions::                
2009 * Drawing Requests::            
2010 * Traps::                       
2011 * Diversions::                  
2012 * Environments::                
2013 * I/O::                         
2014 * Postprocessor Access::        
2015 * Miscellaneous::               
2016 * Debugging::                   
2017 * Implementation Differences::  
2018 * Summary::                     
2019 @end menu
2022 @node Text, Input Conventions, Programming Tutorial, Programming Tutorial
2023 @section Text
2024 @cindex text
2026 @code{gtroff} input files contain text with control commands
2027 interspersed throughout.  But, even without control codes, @code{gtroff}
2028 will still do several things with the input text: filling and adjusting,
2029 adding additional space after sentences, hyphenating and inserting
2030 implicit line breaks.
2032 @menu
2033 * Filling and Adjusting::       
2034 * Hyphenation::                 
2035 * Sentences::                   
2036 * Tab Stops::                   
2037 * Implicit Line Breaks::        
2038 @end menu
2040 @node Filling and Adjusting, Hyphenation, Text, Text
2041 @subsection Filling and Adjusting
2042 @cindex filling and adjusting
2043 @cindex adjusting and filling
2045 When @code{gtroff} reads in text it collects words from input and fits
2046 as many of them together on one output line as it can.  This is known as
2047 @dfn{filling}.
2049 @cindex leading spaces
2050 @cindex spaces, leading
2051 @cindex extra spaces
2052 @cindex spaces, extra
2053 @cindex trailing spaces
2054 @cindex spaces, trailing
2055 Once @code{gtroff} has a @dfn{filled} line it will try to @dfn{adjust}
2056 it.  Which means it will widen the spacing between words until the text
2057 reaches the right margin (in the default adjustment mode).  Extra spaces
2058 between words are preserved, but spaces at the end of lines are ignored.
2059 Spaces at the front of a line will cause a @dfn{break} (breaks will be
2060 explained in @ref{Implicit Line Breaks})
2062 @xref{Manipulating Filling and Adjusting}.
2064 @node Hyphenation, Sentences, Filling and Adjusting, Text
2065 @subsection Hyphenation
2066 @cindex hyphenation
2068 Since the odds of finding a set of words, for every output line, which
2069 will fit nicely on a line without inserting excessive amounts of space
2070 between words is not great, @code{gtroff} will hyphenate words so that
2071 lines can be justified without there being too much space between words.
2072 It uses an internal hyphenation algorithm (a simplified version of the
2073 algorithm used within @TeX{}), to indicate which words can be hyphenated
2074 and how to do so.  When a word is hyphenated the first part of the word
2075 will be added to the current filled line being output (with an attached
2076 hyphen), and the other portion will be added to the next line to be
2077 filled.
2079 @xref{Manipulating Hyphenation}.
2081 @node Sentences, Tab Stops, Hyphenation, Text
2082 @subsection Sentences
2083 @cindex sentences
2085 Although it is often debated, some typesetting rules say there should be
2086 different amounts of space after various punctuation marks.  For
2087 example, the @emph{Chicago typsetting manual} says that a period at the
2088 end of a sentence should have twice as much space following it as would
2089 a comma or a period as part of an abbreviation.
2091 @c XXX exact citation of Chigago manual
2093 @cindex sentence space
2094 @cindex space between sentences
2095 @cindex french-spacing
2096 @code{gtroff} does this by flagging certain characters (normally
2097 @samp{!}, @samp{?} and @samp{.}) as @dfn{end of sentence} characters.
2098 When @code{gtroff} encounters one of these characters at the end of a
2099 line it will append two @dfn{sentence spaces} in the formatted output.
2100 (Thus, one of the conventions mentioned in @ref{Input Conventions}).
2102 @c XXX also describe how characters like ) are treated here -jjc
2103 @c gotta do some research on this -trent
2105 @node Tab Stops, Implicit Line Breaks, Sentences, Text
2106 @subsection Tab Stops
2107 @cindex tab stops
2108 @cindex stops, tabulator
2109 @cindex tab character
2110 @cindex character, tabulator
2112 @code{gtroff} translates @dfn{tabulator characters}, also called
2113 @dfn{tabs} (normally code point @code{0x09}), in the input into
2114 movements to the next tabulator stop.  These tab stops are initially
2115 located every half inch across the page.  Using this simple tables can
2116 easily be made.  However, it can often be deceptive as the appearance
2117 (and width) of the text on a terminal and the results from @code{gtroff}
2118 can vary greatly.
2120 Also, a possible sticking point is that lines beginning with tab
2121 characters will still be filled, again producing unexpected results.
2122 For example, the following input
2124 @multitable {12345678} {12345678} {12345678} {12345678}
2125 @item
2126 @tab 1 @tab 2 @tab 3
2127 @item
2128 @tab   @tab 4 @tab 5
2129 @end multitable
2131 @noindent
2132 will produce
2134 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
2135 @item
2136 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
2137 @end multitable
2139 @xref{Tabs and Fields}.
2141 @node Implicit Line Breaks,  , Tab Stops, Text
2142 @subsection Implicit Line Breaks
2143 @cindex implicit line breaks
2144 @cindex line, implicit breaks
2145 @cindex break
2146 @cindex break, implicit
2147 @cindex line break
2149 An important concept in @code{gtroff} is the @dfn{break}.  When a break
2150 occurs, @code{gtroff} will output the partially filled line
2151 (unjustified), and resume collecting and filling text on the next output
2152 line.
2154 @cindex blank line
2155 @cindex empty line
2156 @cindex line, blank
2157 There are several ways to cause a break in @code{gtroff}.  A blank line
2158 will not only cause a break, but it will also cause a one line vertical
2159 space (effectively a blank line) to be output.
2161 A line which begins with a space will cause a break and the space will
2162 be output at the beginning of the next line.  Note that this space isn't
2163 adjusted, even in fill mode.
2165 The end of file will also cause a break---otherwise the last line of the
2166 document may vanish!
2168 Certain requests also cause breaks, implicitly or explicitly.  This will
2169 be discussed later.
2171 @xref{Manipulating Filling and Adjusting}.
2172 @c XXX list all requests which cause a break
2175 @node Input Conventions, Measurements, Text, Programming Tutorial
2176 @section Input Conventions
2177 @cindex input conventions
2178 @cindex conventions for input
2180 Since @code{gtroff} does filling automatically, it is traditional in
2181 @code{groff} not to try and type things in as nicely formatted
2182 paragraphs.  These are some conventions commonly used when typing
2183 @code{gtroff} text:
2185 @itemize @bullet{}
2186 @item
2187 Break lines after punctuation, particularly at the end of sentences,
2188 and in other logical places.  Keep separate phrases on lines by
2189 themselves, as entire phrases are often added or deleted when editing.
2190 @item
2191 Try to keep lines less than 40-60@w{ }characters, to allow space for
2192 inserting more text.
2193 @item
2194 Do not try to do any formatting in a @acronym{WYSIWYG} manner (i.e.@:
2195 don't try and use spaces to get proper indentation).
2196 @end itemize
2199 @node Measurements, Expressions, Input Conventions, Programming Tutorial
2200 @section Measurements
2201 @cindex measurements
2203 @cindex units of measurement
2204 @cindex basic units
2205 @cindex machine units
2206 @cindex measurement units
2207 @cindex @code{u} unit
2208 @cindex unit, @code{u}
2209 @code{gtroff} (like any other programs) requires numeric parameters to
2210 specify various measurements.  Most numeric parameters@footnote{those
2211 that specify vertical or horizontal motion or a type size} may have a
2212 @dfn{measurement unit} attached.  These units are specified as a single
2213 character which immediately follows the number or expression.  Each of
2214 these units are understood, by @code{gtroff}, to be a multiple of its
2215 @dfn{basic unit}.  So, whenever a different measurement unit is
2216 specified @code{gtroff} converts this into its @dfn{basic units}.  This
2217 basic unit, represented by a @samp{u}, is a device dependent measurement
2218 which is quite small, ranging from 1/75th to 1/72000th of an inch.  The
2219 values may be given as fractional numbers---nevertheless, fractional
2220 basic units are always rounded to integers.
2222 Some of the measurement units are completely independent of any of the
2223 current settings (e.g.@: type size) of @code{gtroff}.
2225 @table @code
2226 @item i
2227 @cindex inch
2228 @cindex @code{i} unit
2229 @cindex unit, @code{i}
2230 Inches.  An antiquated measurement unit still in use in certain
2231 backwards countries.  One inch is equal to@w{ }2.54@dmn{cm}.
2232 @item c
2233 @cindex centimeter
2234 @cindex @code{c} unit
2235 @cindex unit, @code{c}
2236 Centimeters.  One centimeter is equal to@w{ }0.3937@dmn{in}.
2237 @item p
2238 @cindex points
2239 @cindex @code{p} unit
2240 @cindex unit, @code{p}
2241 Points.  This is a typesetter's measurement used for measure type size.
2242 It is 72@w{ }points to an inch.
2243 @item P
2244 @cindex pica
2245 @cindex @code{P} unit
2246 @cindex unit, @code{P}
2247 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
2248 12@w{ }points to a pica).
2249 @item s
2250 @itemx z
2251 @cindex @code{s} unit
2252 @cindex unit, @code{s}
2253 @cindex @code{z} unit
2254 @cindex unit, @code{z}
2255 @xref{Fractional Type Sizes}, for a discussion of these units.
2256 @end table
2258 The other measurements understood by @code{gtroff} are dependent on
2259 settings currently in effect in @code{gtroff}.  These are very useful
2260 for specifying measurements which should look proper with any size of
2261 text.
2263 @table @code
2264 @item m
2265 @cindex em unit
2266 @cindex @code{m} unit
2267 @cindex unit, @code{m}
2268 Ems.  This unit is equal to the current font size in points.  So called
2269 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
2270 in the current font.
2271 @item n
2272 @cindex en unit
2273 @cindex @code{n} unit
2274 @cindex unit, @code{n}
2275 Ens.  This is half of an em.
2276 @item v
2277 @cindex vertical space
2278 @cindex space, vertical
2279 @cindex @code{v} unit
2280 @cindex unit, @code{v}
2281 Vertical space.  This is equivalent to the current line spacing.
2282 @xref{Sizes}, for more information about this.
2283 @item M
2284 @cindex @code{M} unit
2285 @cindex unit, @code{M}
2286 100ths of an em.
2287 @end table
2289 @xref{Fractional Type Sizes}.
2291 @menu
2292 * Default Units::               
2293 @end menu
2295 @node Default Units,  , Measurements, Measurements
2296 @subsection Default Units
2297 @cindex default units
2298 @cindex units, default
2300 Many requests take a default unit.  While this can be helpful at times,
2301 it can cause strange errors in some expressions.  For example, the line
2302 length request expects em units.  Here are several attempts to get a
2303 line length of 3.5@w{ }inches and the results:
2305 @example
2306 3.5i      @result{}   3.5i
2307 7/2       @result{}   0i
2308 7/2i      @result{}   0i
2309 7i/2      @result{}   0.1i
2310 7i/2u     @result{}   3.5i
2311 @end example
2313 @noindent
2314 Everything will be converted to basic units first.  In the above example
2315 it is assumed that 1@dmn{i} equals@w{ }240@dmn{u}, and 1@dmn{m}
2316 equals@w{ }10@dmn{p} (thus 1@dmn{m} equals@w{ }33@dmn{u}).  The value
2317 7i/2 will be first handled as 7i/2m, then converted to 1680u/66u which
2318 is 25@dmn{u}, and this is approximately 0.1@dmn{i}.
2320 As a conclusion, the safest way to specify measurements is to always
2321 attach a scaling indicator.  If you want to multiply or divide by a
2322 certain scalar value, use @samp{u} as the unit for that value.
2325 @node Expressions, Identifiers, Measurements, Programming Tutorial
2326 @section Expressions
2327 @cindex expressions
2329 @code{gtroff} has most of operators common to other languages:
2331 @c XXX more details; examples
2333 @itemize @bullet
2334 @item
2335 @cindex arithmetic operators
2336 @cindex operators, arithmetic
2337 @findex +
2338 @findex -
2339 @findex /
2340 @findex *
2341 @findex %
2342 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
2343 (division), @samp{*} (multiplication), @samp{%} (modulo).
2345 @code{gtroff} only provides integer arithmetic.  The internal type used
2346 for computing results is @samp{int}, which is usually a 32@dmn{bit}
2347 signed integer.
2348 @item
2349 @cindex comparison operators
2350 @cindex operators, comparison
2351 @findex <
2352 @findex >
2353 @findex >=
2354 @findex <=
2355 @findex =
2356 @findex ==
2357 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
2358 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
2359 (equal), @samp{==} (the same as @samp{=}).
2360 @item
2361 @cindex logical operators
2362 @cindex operators, logical
2363 @findex &
2364 @findex :
2365 Logical: @samp{&} (logical and), @samp{:} (logical or).
2366 @item
2367 @cindex unary operators
2368 @cindex operators, unary
2369 @findex -
2370 @findex +
2371 @findex !
2372 @findex if
2373 @findex while
2374 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
2375 (just for completeness; does nothing in expressions), @samp{!} (logical
2376 not; this works only within @code{if} and @code{while} requests).  See
2377 below for the use of unary operators in motion requests.
2378 @item
2379 @cindex extremum operators
2380 @cindex operators, extremum
2381 @findex >?
2382 @findex <?
2383 Extrema: @samp{>?} (maximum), @samp{<?} (minimum).  For example,
2384 @samp{5>?3} yields@w{ }@samp{5}.
2385 @c XXX add examples
2386 @item
2387 @cindex scaling operator
2388 @cindex operator, scaling
2389 Scaling: @code{(@var{c};@var{e})}.  Evaluate @var{e} using @var{c} as
2390 the default scaling indicator.  If @var{c} is missing, ignore scaling
2391 indicators in the evaluation of @var{e}.
2392 @end itemize
2394 @cindex parentheses
2395 @cindex order of evaluation in expressions
2396 @cindex expression, order of evaluation
2397 @findex (
2398 @findex )
2399 Parentheses may be used as in any other language.  However, in
2400 @code{gtroff} they are necessary to ensure order of evaluation.
2401 @code{gtroff} has no operator precedence; expressions are evaluated left
2402 to right.  This means that @samp{3+5*4} is evaluated as if it were
2403 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, as expected.
2405 @findex +
2406 @findex -
2407 @findex |
2408 @cindex motion operators
2409 @cindex operators, motion
2410 For many requests which cause a motion on the page, the unary operators
2411 work differently.  The @samp{+} and @samp{-} operators then indicate a
2412 motion relative to the current position (down or up, respectively), and
2413 the @samp{|} operator indicates an absolute position on the page or
2414 input line.
2415 @c XXX (????)
2416 @samp{+} and @samp{-} are also treated differently by the following
2417 requests and escapes: @code{bp}, @code{in}, @code{ll}, @code{lt},
2418 @code{nm}, @code{nr}, @code{pl}, @code{pn}, @code{po}, @code{ps},
2419 @code{rt}, @code{ti}, @code{\R}, and @code{\s}.  Here the plus and minus
2420 signs indicate increments resp.@: decrements.
2422 @c XXX add more xref
2423 @xref{Setting Registers}.
2425 @cindex space characters in expressions
2426 @cindex expressions and space characters
2427 Due to the way arguments are parsed, spaces are not allowed in
2428 expressions, unless the entire expression is surrounded by parentheses.
2430 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
2433 @node Identifiers, Embedded Commands, Expressions, Programming Tutorial
2434 @section Identifiers
2435 @cindex identifiers
2437 Like any other language, @code{gtroff} has rules for properly formed
2438 @dfn{identifiers}.  In @code{gtroff}, an identifier can be made up of
2439 almost any printable character.  The exception are the following
2440 characters:
2442 @itemize @bullet
2443 @cindex whitespace characters
2444 @cindex newline character
2445 @cindex character, whitespace
2446 @item
2447 Whitespace characters (space, tabs, and newlines).
2448 @cindex character, backspace
2449 @cindex backspace character
2450 @item
2451 Backspace (@code{0x08}) and character code @code{0x01}.
2452 @cindex illegal input characters
2453 @cindex input characters, illegal
2454 @cindex characters, illegal input
2455 @cindex unicode
2456 @item
2457 The following input characters are illegal and will be ignored, causing
2458 a warning message: @code{0x00}, @code{0x0B}, @code{0x0D}-@code{0x1F},
2459 @code{0x80}-@code{0x9F}.  Currently, some of these reserved codepoints
2460 are used internally, thus making it non-trivial to extend @code{gtroff}
2461 to cover Unicode or other character sets resp.@: encodings which use
2462 characters of these ranges.
2464 Note that illegal characters will be removed before parsing; an
2465 identifier `foo', followed by an illegal character, followed by `bar'
2466 will be treated as `foobar'.
2467 @end itemize
2469 For example, any of the following is valid.
2471 @example
2475 end-list
2477 @end example
2479 @findex ]
2480 Note that identifiers longer than two characters with a closing bracket
2481 (@samp{]}) in its name can't be accessed with escape sequences which
2482 expect an identifier as a parameter.
2484 @c XXX xref
2486 @Deffn{Escape, \\A, ident}
2487 Whether an identifier @var{ident} is valid in @code{gtroff} can be
2488 tested with the @code{\A} escape.  It expands to the character@w{ }1
2489 or@w{ }0 according to whether its argument (delimited by quotes usually)
2490 is or is not acceptable as the name of a string, macro, diversion,
2491 number register, environment, or font.  It will return@w{ }0 if no
2492 argument is given.  This is useful for looking up user input in some
2493 sort of associative table.
2495 @example
2496 \A'end-list'
2497     @result{} 1
2498 @end example
2499 @end deffn
2501 @xref{Escapes}, for details on parameter delimiting characters.
2503 @c XXX add xrefs above
2505 Identifiers in @code{gtroff} can be any length, but, in some contexts,
2506 @code{gtroff} needs to be told where identifiers end and text begins
2507 (and in different ways depending on their length).
2509 @findex (
2510 @findex [
2511 @findex ]
2512 @itemize @bullet{}
2513 @item
2514 Single character.
2515 @item
2516 Two characters.  Must be prefixed with @samp{(} in some situations.
2517 @item
2518 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
2519 and@w{ }@samp{]} in some situations.  Any length identifier can be put
2520 in brackets.
2521 @end itemize
2523 @cindex undefined identifiers
2524 @cindex indentifiers, undefined
2525 Unlike many other programming languages, undefined identifiers are
2526 silently ignored or expanded to nothing.
2528 @c XXX add info about -ww command line option.
2530 @xref{Interpolating Registers}, and @ref{Strings}.
2533 @node Embedded Commands, Registers, Identifiers, Programming Tutorial
2534 @section Embedded Commands
2535 @cindex embedded commands
2536 @cindex commands, embedded
2538 Most documents need more functionality beyond filling, adjusting and
2539 implicit line breaking.  In order to gain further functionality,
2540 @code{gtroff} allows commands to be embedded into the text, in two ways.
2542 The first is a @dfn{request} which takes up an entire line, and does
2543 some large scale operation (e.g.@: break lines, start new pages).
2545 The other is an @dfn{escape} which can be embedded anywhere in the text,
2546 or even as an argument to a request.
2547 @c XXX (Not always?)
2548 Escapes generally do more minor operations like sub- and superscripts,
2549 print a symbol, etc.
2551 @menu
2552 * Requests::                    
2553 * Macros::                      
2554 * Escapes::                     
2555 @end menu
2557 @node Requests, Macros, Embedded Commands, Embedded Commands
2558 @subsection Requests
2559 @cindex requests
2561 @cindex control character
2562 @cindex character, control
2563 @findex '
2564 @findex .
2565 A request line begins with a control character, which is either a single
2566 quote (@samp{'}) or a period (@samp{.}).  These can be changed; see
2567 @ref{Character Translations}, for details.  After this there may be
2568 optional tabs or spaces followed by an identifier which is the name of
2569 the request.  This may be followed by any number of space-separated
2570 arguments.
2572 @cindex zero width space character
2573 @cindex character, zero width space
2574 @cindex space character, zero width
2575 @findex \&
2576 To begin a line with a control character without it being interpreted,
2577 precede it with @code{\&}.  This represents a zero width space, which
2578 means it will not affect the output.
2580 In most cases the period is used as a control character.  Several
2581 requests will cause a break; using the single quote control character
2582 will prevent this.
2584 @menu
2585 * Request Arguments::           
2586 @end menu
2588 @node Request Arguments,  , Requests, Requests
2589 @subsubsection Request Arguments
2590 @cindex request arguments
2591 @cindex arguments to requests
2593 Arguments to requests (and macros) are processed much like the shell:
2594 The line is split into arguments according to spaces.  An argument which
2595 is intended to contain spaces can either be enclosed in quotes (single
2596 or double), or have the spaces @dfn{escaped} with backslashes.
2598 @example
2599 .uh The Mouse Problem
2600 .uh "The Mouse Problem"
2601 .uh The\ Mouse\ Problem
2602 @end example
2604 @findex \~
2605 @findex \@key{SP}
2606 @noindent
2607 The first line is the @code{uh} macro being called with 3 arguments,
2608 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
2609 same effect or calling the @code{uh} macro with one argument @samp{The
2610 Mouse Problem}.@footnote{The last solution, i.e., using escaped spaces,
2611 is `classical' in the sense that it can be found in most @code{troff}
2612 documents.  Nevertheless, it is not optimal in all situations since
2613 @w{@samp{\ }} inserts a fixed-width, non-breaking space character which
2614 can't stretch.  @code{gtroff} provides a different command @code{\~} to
2615 insert a stretchable, non-breaking space.}
2617 @findex ds
2618 Note, however, that the @code{ds} request works differently.
2619 @xref{Strings}, for more details.
2621 @node Macros, Escapes, Requests, Embedded Commands
2622 @subsection Macros
2623 @cindex macros
2625 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
2626 which can be invoked by name.  They are called in the same manner as
2627 requests---arguments also may be passed in the same manner.
2629 @xref{Writing Macros}, and @ref{Request Arguments}.
2631 @node Escapes,  , Macros, Embedded Commands
2632 @subsection Escapes
2633 @cindex escapes
2635 Escapes may occur anywhere in the input to @code{gtroff}.  They begin
2636 with a backslash usually and are followed by a single character which
2637 indicates the function to be performed.  The escape character can be
2638 changed; see @ref{Character Translations}.
2640 @findex (
2641 @findex [
2642 @findex ]
2643 Escape sequences which require an identifier as a parameter accept three
2644 possible syntax forms.
2646 @itemize @bullet
2647 @item
2648 The next single character is the identifier.
2649 @item
2650 If this single character is an opening parenthesis, take the following
2651 two characters as the identifier.  Note that there is no closing
2652 parenthesis after the identifier.
2653 @item
2654 If this single character is an opening bracket, take all characters
2655 until a closing bracket as the identifier.
2656 @end itemize
2658 @noindent
2659 Examples:
2661 @example
2663 \n(XX
2664 \*[TeX]
2665 @end example
2667 @findex '
2668 @cindex argument delimiting characters
2669 @cindex characters, argument delimiting
2670 @cindex delimiting characters for arguments
2671 Other escapes may require several arguments and/or some special format.
2672 In such cases the argument is traditionally enclosed in single quotes
2673 (and quotes are always used in this manual for the definitions of escape
2674 sequences).  The enclosed text is then processed according to what that
2675 escape expects.  Example:
2677 @example
2678 \l'1.5i\(bu'
2679 @end example
2681 @findex \o
2682 @findex \b
2683 @findex \X
2684 Note that the quote character can be replaced with any other character
2685 which does not occur in the argument (even a newline or a space
2686 character) in the following escapes: @code{\o}, @code{\b}, and
2687 @code{\X}.  This makes e.g.
2689 @example
2690 A caf
2695 in Paris
2696   @result{} A caf@'e in Paris
2697 @end example
2699 @noindent
2700 possible, but it is better not to use this feature to avoid confusion.
2702 @findex \%
2703 @findex \@key{SP}
2704 @findex \|
2705 @findex \^
2706 @findex \@{
2707 @findex \@}
2708 @findex \'
2709 @findex \`
2710 @findex \-
2711 @findex \_
2712 @findex \!
2713 @findex \?
2714 @findex \@@
2715 @findex \)
2716 @findex \/
2717 @findex \,
2718 @findex \&
2719 @findex \~
2720 @findex \0
2721 @findex \a
2722 @findex \c
2723 @findex \d
2724 @findex \e
2725 @findex \E
2726 @findex \p
2727 @findex \r
2728 @findex \t
2729 @findex \u
2730 The following escapes sequences (which are handled similarly to
2731 characters since they don't take a parameter) are also allowed as
2732 delimiters: @code{\%}, @w{@samp{\ }}, @code{\|}, @code{\^}, @code{\@{},
2733 @code{\@}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
2734 @code{\?}, @code{\@@}, @code{\)}, @code{\/}, @code{\,}, @code{\&},
2735 @code{\~}, @code{\0}, @code{\a}, @code{\c}, @code{\d}, @code{\e},
2736 @code{\E}, @code{\p}, @code{\r}, @code{\t}, and @code{\u}.  Again, don't
2737 use these if possible.
2739 @findex \A
2740 @findex \Z
2741 @findex \C
2742 @findex \w
2743 No newline characters as delimiters are allowed in the following
2744 escapes: @code{\A}, @code{\Z}, @code{\C}, and @code{\w}.
2746 @findex \D
2747 @findex \h
2748 @findex \H
2749 @findex \l
2750 @findex \L
2751 @findex \N
2752 @findex \R
2753 @findex \s
2754 @findex \S
2755 @findex \v
2756 @findex \x
2757 Finally, the escapes @code{\D}, @code{\h}, @code{\H}, @code{\l},
2758 @code{\L}, @code{\N}, @code{\R}, @code{\s}, @code{\S}, @code{\v}, and
2759 @code{\x} can't use the following characters as delimiters:
2761 @itemize @bullet
2762 @cindex numbers
2763 @cindex digits
2764 @item
2765 The digits @code{0}-@code{9}.
2766 @cindex operators
2767 @findex +
2768 @findex -
2769 @findex /
2770 @findex *
2771 @findex %
2772 @findex <
2773 @findex >
2774 @findex =
2775 @findex &
2776 @findex :
2777 @findex (
2778 @findex )
2779 @findex .
2780 @item
2781 The (single character) operators @samp{+-/*%<>=&:().}.
2782 @item
2783 @cindex space character
2784 @cindex character, space
2785 @cindex tab character
2786 @cindex character, tab
2787 @cindex newline character
2788 @cindex character, newline
2789 The space, tab, and newline characters.
2790 @findex \%
2791 @findex \@{
2792 @findex \@}
2793 @findex \'
2794 @findex \`
2795 @findex \-
2796 @findex \_
2797 @findex \!
2798 @findex \@@
2799 @findex \/
2800 @findex \c
2801 @findex \e
2802 @findex \p
2803 @item
2804 All escape sequences except @code{\%}, @code{\@{}, @code{\@}},
2805 @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!}, @code{\@@},
2806 @code{\/}, @code{\c}, @code{\e}, and @code{\p}.
2807 @end itemize
2809 @findex \\
2810 @findex \e
2811 @findex \E
2812 To have a backslash appear in the output several escapes are defined:
2813 @code{\\}, @code{\e} or @code{\E}.  These are very similar, and only
2814 differ with respect to being used in macros or diversions.
2815 @xref{Copy-in Mode}, and @ref{Diversions}, for more information.
2817 @xref{Identifiers}.
2819 @menu
2820 * Comments::                    
2821 @end menu
2823 @node Comments,  , Escapes, Escapes
2824 @subsubsection Comments
2825 @cindex comments
2827 Probably one of the most@footnote{Unfortunately, this is a lie.  But
2828 hopefully future @code{gtroff} hackers will believe it :-)} common forms
2829 of escapes is the comment.
2831 @Deffn{Escape, \\"}
2832 Start a comment.  Everything to the end of the input line is ignored.
2834 This may sound simple, but it can be tricky to keep the comments from
2835 interfering with the appearance of the final output.
2837 @findex ds
2838 If the escape is to the right of some text or a request, that portion of
2839 the line will be ignored, but the space leading up to it will be noticed
2840 by @code{gtroff}.  This only affects the @code{.ds} request.
2841 @c XXX (any others?)
2843 One possibly irritating idiosyncracy is that tabs must not be used to
2844 line up comments.  Tabs are not treated as white space between the
2845 request and macro arguments.
2847 @cindex undefined request
2848 @cindex request, undefined
2849 A comment on a line by itself will be treated as a blank line, because
2850 after eliminating the comment, that is all that remains:
2852 @example
2853 Test
2854 \" comment
2855 Test
2856 @end example
2858 @noindent
2859 will produce
2861 @example
2862 Test
2864 Test
2865 @end example
2867 As a consequence, it is common to start the line with @code{.\"} which
2868 will cause the line to be treated as an undefined request and thus
2869 ignored completely.
2871 @findex '
2872 Another commenting scheme seen sometimes is three consecutive single
2873 quotes (@code{'''}) at the beginning of a line.  This works, but
2874 @code{gtroff} will give a warning about an undefined macro (namely
2875 @code{''}, which is harmless, but irritating.
2876 @end deffn
2878 @Deffn{Escape, \\#}
2879 Now to avoid all this @code{gtroff} has a new comment mechanism using
2880 the @code{\#} escape.  This escape works the same as @code{\"} except
2881 that the newline is also ignored:
2883 @example
2884 Test
2885 \# comment
2886 Test
2887 @end example
2889 @noindent
2890 will produce
2892 @example
2893 Test Test
2894 @end example
2896 @noindent
2897 as expected.
2898 @end deffn
2900 @findex ig
2901 For large blocks of text, the @code{ig} request may be useful.
2903 @c XXX definition of .ig
2905 @xref{Strings}.
2907 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, Programming Tutorial
2908 @section Registers
2909 @cindex registers
2911 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
2912 are a number of built-in registers, supplying anything from the date to
2913 details of formatting parameters.
2915 @xref{Identifiers}, for details on register identifiers.
2917 @menu
2918 * Setting Registers::           
2919 * Interpolating Registers::     
2920 * Auto-increment::              
2921 * Assigning Formats::           
2922 * Built-in Registers::          
2923 @end menu
2925 @node Setting Registers, Interpolating Registers, Registers, Registers
2926 @subsection Setting Registers
2927 @cindex setting registers
2928 @cindex registers, setting
2930 Registers are defined resp.@: set via the @code{nr} request or the
2931 @code{\R} escape.
2933 @Deffn{Request, nr, ident value}
2934 @Deffnx{Escape, \\R, ident value}
2935 Set number register @var{ident} to @var{value}.  If @var{ident} doesn't
2936 exist, it will be created.
2937 @end deffn
2939 For example, the following two lines are equivalent:
2941 @example
2942 .nr a 1
2943 \R'a 1'
2944 @end example
2946 Both @code{nr} and @code{\N} have two additional special forms to
2947 increment resp.@: decrement a register.
2949 @Deffn{Request, nr, ident +value}
2950 @Deffnx{Request, nr, ident -value}
2951 @Deffnx{Escape, \\N, ident +value}
2952 @Deffnx{Escape, \\N, ident -value}
2953 Increment (decrement) register @var{ident} by @var{value}.
2955 @example
2956 .nr a 1
2957 .nr a +1
2959     @result{} 2
2960 @end example
2962 To assign the negated value of a register to another register, some care
2963 must be taken to get the desired result:
2965 @example
2966 .nr a 7
2967 .nr b 3
2968 .nr a -\nb
2970     @result{} 4
2971 .nr a (-\nb)
2973     @result{} -3
2974 @end example
2976 @noindent
2977 The surrounding parentheses prevent the interpretation of the minus sign
2978 as a decrementing operator.
2979 @end deffn
2981 @Deffn{Request, rr, ident}
2982 Remove number register @var{ident}.
2983 @end deffn
2985 @Deffn{Request, rnn, ident1 ident2}
2986 Rename number register @var{ident1} to @var{ident2}.
2987 @end deffn
2989 @Deffn{Request, aln, ident1 ident2}
2990 This request creates an alias @var{ident1} for a number register
2991 @var{ident2}.  The new name and the old name will be exactly equivalent.
2992 If @var{ident1} is undefined, a warning of type @samp{reg} will be
2993 generated, and the request will be ignored.  @xref{Debugging}, for
2994 information about warnings.
2995 @end deffn
2997 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
2998 @subsection Interpolating Registers
2999 @cindex interpolating registers
3000 @cindex registers, interpolating
3002 Numeric registers can be accessed via the @code{\n} escape.
3004 @Deffn{Escape, \\n, ident}
3005 @c XXX is the following correct?
3006 Interpolate number register @var{ident}.  This means that the value of
3007 the register is expanded in-place while @code{gtroff} is parsing the
3008 input line.
3010 @example
3011 .nr a 5
3012 .nr as \na+\na
3013 \n(as
3014     @result{} 10
3015 @end example
3016 @end deffn
3018 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
3019 @subsection Auto-increment
3020 @cindex auto-increment
3021 @cindex increment, automatic
3023 Number registers can also be auto-incremented and auto-decremented.  The
3024 increment resp.@: decrement factor can be specified with a third
3025 argument to the @code{nr} request or @code{\N} escape.
3027 @Deffn{Request, nr, ident value incr}
3028 @Deffnx{Escape, \\N, ident value incr}
3029 Set number register @var{ident} to @var{value}; the increment for
3030 auto-incrementing is set to @var{incr}.
3031 @end deffn
3033 To activate auto-incrementing, the escape @code{\n} has a special syntax
3034 form.
3036 @Deffn{Escape, \\n, +ident}
3037 @Deffnx{Escape, \\n, -ident}
3038 Before interpolating, increment resp.@: decrement @var{ident} by the
3039 auto-increment value as specified with the @code{nr} request (or the
3040 @code{\N} escape).  If no auto-increment value has been specified, both
3041 syntax forms are identical to @code{\n}.
3042 @end deffn
3044 For example,
3046 @example
3047 .nr a 0 1
3048 .nr xx 0 5
3049 .nr foo 0 -2
3050 \n+a, \n+a, \n+a, \n+a, \n+a
3052 \n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
3054 \n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
3055 @end example
3057 @noindent
3058 produces
3060 @example
3061 1, 2, 3, 4, 5
3062 -5, -10, -15, -20, -25
3063 -2, -4, -6, -8, -10
3064 @end example
3066 To change the increment value without changing the value of a register,
3067 the following can be used.
3069 @example
3070 .nr a \na 10
3071 @end example
3073 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
3074 @subsection Assigning Formats
3075 @cindex assigning formats
3076 @cindex formats, assigning
3078 When a register is used in the text of an input file (as opposed to part
3079 of an expression) it is textually replaced (or interpolated) with a
3080 representation of that number.  This output format can be changed to a
3081 variety of formats (numbers, Roman numerals, etc).  This is done using
3082 the @code{af} request.
3084 @Deffn{Request, af, ident format}
3086 Change the output format of a number register.  The first argument
3087 @var{ident} is the name of the number register to be changed, and the
3088 second argument @var{format} is the output format.  The following output
3089 formats are available:
3091 @table @code
3092 @item 1
3093 This is the default format, decimal numbers: 1, 2, 3,@w{ }@dots{}
3094 @item 0@dots{}01
3095 Decimal numbers with as many leading zeros as specified.  So, @samp{01}
3096 would result in 01, 02, 03,@w{ }@dots{}
3097 @item I
3098 @cindex roman numerals
3099 @cindex numerals, Roman
3100 Upper-case Roman numerals: 0, I, II, III, IV,@w{ }@dots{}
3101 @item i
3102 Lower-case Roman numerals: 0, i, ii, iii, iv,@w{ }@dots{}
3103 @item A
3104 Upper-case letters: A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@dots{}
3105 @item a
3106 Lower-case letters: a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@dots{}
3107 @end table
3109 The following example will produce @samp{10, X, j, 010}:
3111 @example
3112 .nr a 10
3113 .af a 1           \" the default format
3114 \na,
3115 .af a I
3116 \na,
3117 .af a a
3118 \na,
3119 .af a 001
3121 @end example
3122 @end deffn
3124 @Deffn{Escape, \\g, ident}
3125 Return the current format of the specified register @var{ident}.  For
3126 example, @samp{\ga} after the previous example would produce the string
3127 @samp{001}.  If the register hasn't been defined yet, nothing is
3128 returned.
3129 @end deffn
3131 @node Built-in Registers,  , Assigning Formats, Registers
3132 @subsection Built-in Registers
3133 @cindex built-in registers
3134 @cindex registers, built-in
3136 The following lists some built-in registers which are not described
3137 elsewhere in this manual.  Any register which begin with a @samp{.} is
3138 read-only.  A complete listing of all built-in registers can be found in
3139 @ref{Register Index}.
3141 @table @code
3142 @item .H
3143 @cindex horizontal resolution
3144 @cindex resolution, horizontal
3145 @vindex .H
3146 Horizontal resolution in basic units.
3147 @item .V
3148 @cindex vertical resolution
3149 @cindex resolution, vertical
3150 @vindex .V
3151 Vertical resolution in basic units.
3152 @item dw
3153 @cindex day of the week
3154 @cindex date, day of the week
3155 @vindex dw
3156 Day of the week (1-7).
3157 @item dy
3158 @cindex day of the month
3159 @cindex date, day of the month
3160 @vindex dy
3161 Day of the month (1-31).
3162 @item mo
3163 @cindex month of the year
3164 @cindex date, month of the year
3165 @vindex mo
3166 Current month (1-12).
3167 @item year
3168 @cindex date, year
3169 @cindex year, current
3170 @vindex year
3171 The current year.
3172 @item yr
3173 @vindex yr
3174 The current year minus@w{ }1900.  Unfortunately, the documentation of
3175 @acronym{UNIX} Version@w{ }7's @code{troff} had a year@w{ }2000 bug: It
3176 incorrectly claimed that @code{yr} contains the last two digits of the
3177 year.  That claim has never been true of either traditional @code{troff}
3178 or GNU @code{troff}.  Old @code{troff} input that looks like this:
3180 @example
3181 '\" The following line stopped working after 1999
3182 This document was formatted in 19\n(yr.
3183 @end example
3185 @noindent
3186 can be corrected as follows:
3188 @example
3189 This document was formatted in \n[year].
3190 @end example
3192 @noindent
3193 or, to be portable to older @code{troff} versions, as follows:
3195 @example
3196 .nr y4 1900+\n(yr
3197 This document was formatted in \n(y4.
3198 @end example
3200 @item .c
3201 @vindex .c
3202 @itemx c.
3203 @vindex c.
3204 @cindex input line number
3205 @cindex line number, input
3206 The current @emph{input} line number.  Register @samp{.c} is read-only,
3207 whereas @samp{c.} (a @code{gtroff} extension) is writable also,
3208 affecting both @samp{.c} and @samp{c.}.
3209 @item ln
3210 @vindex ln
3211 @findex nm
3212 @cindex output line number
3213 @cindex line number, output
3214 The current @emph{output} line number after a call to the @code{nm}
3215 request to activate line numbering.
3216 @c XXX xref nm request
3217 @item .x
3218 @vindex .x
3219 @cindex major version number
3220 @cindex version number, major
3221 The major version number.  For example, if the version number is@w{
3222 }1.03 then @code{.x} will contain@w{ }@samp{1}.
3223 @item .y
3224 @vindex .y
3225 @cindex minor version number
3226 @cindex version number, minor
3227 The minor version number.  For example, if the version number is@w{
3228 }1.03 then @code{.y} will contain@w{ }@samp{03}.
3229 @item .Y
3230 @vindex .Y
3231 @cindex revision number
3232 The revision number of @code{groff}.
3233 @item .g
3234 @vindex .g
3235 Always@w{ }1.  Macros should use this to determine whether they are
3236 running under GNU @code{troff}.
3237 @item .A
3238 @vindex .A
3239 If the current output device is @acronym{ASCII}, this is set to@w{ }1,
3240 zero otherwise.
3241 @item .P
3242 @vindex .P
3243 This register indicates whether the current page is actually being
3244 printed, i.e., whether the @option{-o} option is being used to only
3245 print selected pages.  @xref{Groff Options}, for more information.
3246 @end table
3249 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, Programming Tutorial
3250 @section Manipulating Filling and Adjusting
3251 @cindex manipulating filling and adjusting
3252 @cindex filling and adjusting, manipulating
3253 @cindex adjusting and filling, manipulating
3254 @cindex justifying text
3255 @cindex text, justifying
3257 @cindex break
3258 @cindex line break
3259 @findex bp
3260 @findex ce
3261 @findex cf
3262 @findex fi
3263 @findex fl
3264 @findex in
3265 @findex nf
3266 @findex rj
3267 @findex sp
3268 @findex ti
3269 @findex trf
3270 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
3271 Breaks}.  The @code{br} request will likewise cause a break.  Several
3272 other requests will also cause breaks, but implicitly.  These are
3273 @code{bp}, @code{ce}, @code{cf}, @code{fi}, @code{fl}, @code{in},
3274 @code{nf}, @code{rj}, @code{sp}, @code{ti}, and @code{trf}.
3276 @Deffn{Request, br, }
3277 Break the current line, i.e., the input collected so far will be emitted
3278 without adjustment.
3279 @end deffn
3281 @findex nf
3282 @findex fi
3283 @vindex .u
3284 Initially, @code{gtroff} will fill and adjust text to both margins.
3285 Filling can be disabled via the @code{nf} request and re-enabled with
3286 the @code{fi} request.  These implicitly disable and re-enable
3287 adjusting.  Both of these will cause a break in the text currently being
3288 filled.  The number register @code{.u} is equal to@w{ }1 in fill mode
3289 and@w{ }0 in no-fill mode.
3291 @findex ad
3292 @findex na
3293 Adjusting can be disabled with the @code{ad} request and re-enabled with
3294 the @code{na} request.  The @code{ad} request takes a single argument to
3295 indicate how to adjust text.
3297 @table @samp
3298 @item l
3299 @cindex ragged-right
3300 Adjust text to the left margin.  This produces what is traditionally
3301 called ragged-right text.
3302 @item r
3303 @cindex ragged-left
3304 Adjust text to the right margin, producing ragged-left text.
3305 @item c
3306 @cindex centered text
3307 Center filled text.
3308 @c XXX difference to .ce?
3309 @item b
3310 @itemx n
3311 Justify to both margins.  This is default of @code{gtroff}.
3312 @end table
3314 With no argument to @code{ad}, @code{gtroff} will adjust lines the same
3315 way it was the last time it was filling.  For example:
3317 @example
3318 text
3319 .ad r
3320 text
3321 .ad c
3322 text
3324 text
3325 .ad  \" back to centering
3326 text
3327 @end example
3329 @vindex .j
3330 The current adjustment mode is available in the number register
3331 @code{.j}.
3333 @findex \p
3334 The escape @code{\p} will cause a break and the remaining text to be
3335 adjusted.
3337 @cindex word space size
3338 @cindex size of word space
3339 @cindex space between words
3340 @cindex sentence space size
3341 @cindex size of sentence space
3342 @cindex space between sentences
3343 @findex ss
3344 The @code{ss} request changes the minimum size of a space between filled
3345 words.  It takes its units as one twelfth of the space width parameter
3346 for the current font.  Initially both the word space size and the
3347 sentence space size are@w{ }12.
3349 If two arguments are given to the @code{ss} request, the second argument
3350 gives the sentence space size.  If the second argument is not given, the
3351 sentence space size will be the same as the word space size.  The
3352 sentence space size is used in two circumstances: If the end of a
3353 sentence occurs at the end of a line in fill mode, then both an
3354 inter-word space and a sentence space will be added; if two spaces
3355 follow the end of a sentence in the middle of a line, then the second
3356 space will be a sentence space.  Note that the behaviour of
3357 @acronym{UNIX} @code{troff} will be exactly that exhibited by GNU
3358 @code{troff} if a second argument is never given to the @code{ss}
3359 request.  In GNU @code{troff}, as in @acronym{UNIX} @code{troff}, a
3360 sentence should always be followed with either a newline or two spaces.
3362 @vindex .ss
3363 @vindex .sss
3364 The number registers @code{.ss} and @code{.sss} are the values of the
3365 parameters set by the first and second arguments of the @code{ss}
3366 request.
3368 @findex ce
3369 @cindex centering lines
3370 @cindex lines, centering
3371 The @code{ce} request will center text.  While the @w{@samp{ad c}}
3372 request will also center text, it has the side effect of filling the
3373 text.  The @code{.ce} request will not fill the text it affects.  This
3374 request causes a break.
3376 With no arguments, @code{ce} will fill the next line of text.  The
3377 single argument @code{ce} takes is a number indicating the number of
3378 lines to be centered.  If the argument is zero, centering is disabled.
3380 A common idiom is to turn on centering for a large number of lines, and
3381 to turn off centering after text to be centered.  This is useful for any
3382 request which takes a number of lines as an argument.
3384 @example
3385 .ce 1000
3386 replace this
3387 with
3388 something
3389 more interesting
3390 @dots{}
3391 .ce 0
3392 @end example
3394 @vindex .ce
3395 The @code{.ce} number register contains the number of lines remaining to
3396 be centered, as set by the @code{ce} request.
3398 @cindex justifying text
3399 @cindex text, justifying
3400 @cindex right-justifying
3401 @findex rj
3402 @vindex .rj
3403 A similar request is @code{rj} request which will justify unfilled text
3404 to the right margin.  Its arguments are identical to the @code{ce}
3405 request.  The @code{.rj} number register is the number of lines to be
3406 right-justified as set by the @code{rj} request.  This request causes a
3407 line break.
3410 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, Programming Tutorial
3411 @section Manipulating Hyphenation
3412 @cindex manipulating hyphenation
3413 @cindex hyphenation, manipulating
3415 As discussed in @ref{Hyphenation}, @code{gtroff} will hyphenate words.
3416 There are a number of ways to influence how hyphenation is done.
3418 @findex nh
3419 @findex hy
3420 @vindex .hy
3421 Hyphenation can be turned off with the @code{nh} request, and turned
3422 back on with the @code{hy} request.  However, the hyphenation facilities
3423 of @code{gtroff} are far more flexible than this.  The @code{hy} request
3424 can be used to tell @code{gtroff} to restrict hyphenation to certain
3425 cases.  The request takes a single numeric argument.  The current
3426 hyphenation restrictions can be found in the number register @code{.hy}.
3428 @table @samp
3429 @item 1
3430 The default argument, which indicates to hyphenate without restrictions.
3431 @item 2
3432 Do not hyphenate the last word on a page or column.
3433 @item 4
3434 Do not hyphenate the last two characters of a word.
3435 @item 8
3436 Do not hyphenate the first two characters of a word.
3437 @end table
3439 The values in the previous table are additive.  For example, the
3440 value@w{ }12 causes @code{gtroff} to neither hyphenate the last two nor
3441 the first two characters of a word.
3443 @findex hlm
3444 @vindex .hlc
3445 @vindex .hlm
3446 @findex \%
3447 @cindex explicit hyphens
3448 @cindex hyphen, explicit
3449 The @code{hlm} request will set the maximum number of consecutive
3450 hyphenated lines to the value given as the first argument.  If this
3451 number is negative, there is no maximum.  The default value is@w{ }-1.
3452 This value is associated with the current environment.  Only lines
3453 output from an environment count towards the maximum associated with
3454 that environment.  Hyphens resulting from @code{\%} are counted;
3455 explicit hyphens are not.  The current setting of this is available in
3456 the @code{.hlm} register.  Also the number of immediately preceding
3457 consecutive hyphenated lines are available in the number register
3458 @code{.hlc}.
3460 @findex hw
3461 The @code{hw} request specifies how a specific word is to be hyphenated.
3462 It takes only one argument which is the word with hyphens at the
3463 hyphenation points.  For example:
3465 @example
3466 .hw in-sa-lub-rious
3467 @end example
3469 @noindent
3470 This request can be used more than once.
3472 @c XXX
3473 @c In old versions of troff there was a
3474 @c limited amount of space to store such information, fortunately,
3475 @c with groff, this is no longer a restriction.
3477 @findex \%
3478 @cindex hyphenation character
3479 @cindex character, hyphenation
3480 @cindex disabling hyphenation
3481 @cindex hyphenation, disabling
3482 To tell @code{gtroff} how to hyphenate words on the fly, the @code{\%}
3483 escape, also known as the @dfn{hyphenation character}, can be used.
3484 Preceding a word with this character will prevent it from being
3485 hyphenated, putting it in a word will indicate to @code{gtroff} that the
3486 word may be hyphenated at that point.  Note that this mechanism will
3487 only affect one word; to change the hyphenation of a word for the entire
3488 document, use the @code{hw} request.
3490 @findex hc
3491 The @code{hc} request changes the hyphenation character.  The character
3492 specified as an argument will then work the same as the @code{\%}
3493 escape, and, thus, no longer appear in the output.  Without an argument
3494 it will return the hyphenation character to @code{\%}.
3496 @cindex hyphenation patterns
3497 @cindex pattern for hyphenation
3498 @findex hpf
3499 To further customize hyphenation the @code{hpf} request will read in a
3500 file of hyphenation patterns.  This file will be searched for in the
3501 same way that @file{tmac.@var{name}} is searched for when the
3502 @option{-m@var{name}} option is specified.
3504 It should have the same format as the argument to the @code{\patterns}
3505 primitive in @TeX{}; the letters appearing in this file are interpreted
3506 as hyphenation codes.  A @samp{%} character in the patterns file
3507 introduces a comment that continues to the end of the line.
3509 @findex hla
3510 @findex hpf
3511 @pindex troffrc
3512 @pindex troffrc-end
3513 The set of hyphenation patterns is associated with the current language
3514 set by the @code{hla} request.  The @code{hpf} request is usually
3515 invoked by the @file{troffrc} or @file{troffrc-end} file.
3517 @findex hcode
3518 The @code{hcode} request has the following syntax:
3520 @example
3521 .hcode @var{c1 code1 c2 code2...}
3522 @end example
3524 It sets the hyphenation code of character @var{c1} to @var{code1} and
3525 that of @var{c2} to @var{code2}.  A hyphenation code must be a single
3526 input character (not a special character) other than a digit or a space.
3527 Initially each lower-case letter has a hyphenation code, which is
3528 itself, and each upper-case letter has a hyphenation code which is the
3529 lower-case version of itself.
3531 @cindex hyphenation margin
3532 @cindex margin for hyphenation
3533 @findex hym
3534 @vindex .hym
3535 The @code{hym} request will set the hyphenation margin to the value
3536 given as its argument: when the current adjustment mode is not@w{
3537 }@samp{b}, the line will not be hyphenated if the line is no more than
3538 that amount short.  The default hyphenation margin is@w{ }0.  The
3539 default scaling indicator for this request is@w{ }m.  The hyphenation
3540 margin is associated with the current environment.  The current
3541 hyphenation margin is available in the @code{.hym} register.
3543 @cindex hyphenation space
3544 @findex hys
3545 @vindex .hys
3546 The @code{hys} request sets the hyphenation space to the value given as
3547 the first argument: when the current adjustment mode is@w{ }@samp{b},
3548 don't hyphenate the line if the line can be justified by adding no more
3549 than that amount of extra space to each word space.  The default
3550 hyphenation space is@w{ }0.  The default scaling indicator for this
3551 request is@w{ }m.  The hyphenation space is associated with the current
3552 environment.  The current hyphenation space is available in the
3553 @code{.hys} register.
3555 @cindex soft hyphen character
3556 @cindex character, soft hyphen
3557 @findex shc
3558 @glindex hy
3559 The @code{shc} request will set the soft hyphen character to the
3560 character given as an argument.  If the argument is omitted, the soft
3561 hyphen character will be set to the default character @code{\(hy}.  The
3562 soft hyphen character is the character which will be inserted when a
3563 word is hyphenated at a line break.  If the soft hyphen character does
3564 not exist in the font of the character immediately preceding a potential
3565 break point, then the line will not be broken at that point.  Neither
3566 definitions (specified with the @code{char} request) nor translations
3567 (specified with the @code{tr} request) are considered when finding the
3568 soft hyphen character.
3570 @findex hla
3571 @findex hpf
3572 @findex hw
3573 @vindex .hla
3574 @pindex troffrc
3575 @pindex troffrc-end
3576 The @code{hla} request will set the current hyphenation language to that
3577 given by the first argument.  Hyphenation exceptions specified with the
3578 @code{hw} request and hyphenation patterns specified with the @code{hpf}
3579 request are both associated with the current hyphenation language.  The
3580 @code{hla} request is usually invoked by the @file{troffrc} or the
3581 @file{troffrc-end} files.  The current hyphenation language is available
3582 in the number register @code{.hla}.
3585 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, Programming Tutorial
3586 @section Manipulating Spacing
3587 @cindex manipulating spacing
3588 @cindex spacing, manipulating
3590 @findex sp
3591 The @code{sp} request will cause @code{gtroff} to space downwards the
3592 distance specified as the first argument.  With no argument it will
3593 advance 1@w{ }line.  A negative argument will cause @code{gtroff} to
3594 move up the page the specified distance.  If the argument is preceded by
3595 a @samp{|} @code{gtroff} will move that distance from the top of the
3596 page.  This request causes a line break.
3598 @cindex double-spacing
3599 @findex ls
3600 @vindex .L
3601 For double or triple spaced output use @code{ls}.  This request causes
3602 @code{troff} to output @var{n}-1 blank lines after each line of text,
3603 where @var{n} is the argument given to the @code{ls} request.  With no
3604 argument @code{gtroff} will go back to single spacing.  The number
3605 register @code{.L} contains the current line spacing setting.
3607 @findex \x
3608 @vindex .a
3609 Sometimes, extra vertical spacing is only needed occasionally, i.e.@: to
3610 allow space for a tall construct (like an equation).  The @code{\x}
3611 escape will do this.  The escape is given a numerical argument (like
3612 @samp{\x'3p'}).  If this number is positive extra vertical space will be
3613 inserted below the current line.  A negative number will add space
3614 above.  If this escape is used multiple times on the same line, the
3615 maximum of the values is used.  The @code{.a} number register contains
3616 the most recent (nonnegative) extra vertical line space.
3618 @c XXX
3619 @example
3620 ... example of inline equation ...
3621 @end example
3623 @findex ns
3624 @findex rs
3625 @cindex no-space mode
3626 @cindex mode, no-space
3627 Spacing (either via @code{sp} or via blank lines) can be disabled with
3628 the @code{ns} request.  This will enable @dfn{no-space mode}.  This mode
3629 will end when actual text is output or the @code{rs} request is
3630 encountered.  No-space mode will also prevent requests to advance to the
3631 next page unless they are accompanied by a page number (@pxref{Page
3632 Control}, for more information).
3635 @node Tabs and Fields, Character Translations, Manipulating Spacing, Programming Tutorial
3636 @section Tabs and Fields
3637 @cindex tabs and fields
3638 @cindex fields and tabs
3640 @findex \t
3641 Tab stops are much like those on a typewriter: a tab character (or the
3642 @code{\t} escape) on input will cause horizontal motion to the next tab
3643 stop.
3645 @findex ta
3646 Tab stops can be changed with the @code{ta} request.  This request takes
3647 a series of numbers as arguments which indicate where each tab stop is
3648 to be (overriding any previous settings).  These can be specified
3649 absolutely, i.e.@: as the distance from the left margin.  For example,
3650 the following will set tab stops every one inch.
3652 @example
3653 .ta 1i 2i 3i 4i 5i 6i
3654 @end example
3656 Tab stops can also be specified relatively (using a leading @samp{+})
3657 which means that the specified tab stop will be set that distance from
3658 the previous tab stop.  For example, the following is equivalent to the
3659 previous example.
3661 @example
3662 .ta 1i +1i +1i +1i +1i +1i
3663 @end example
3665 After the specified tab stops repeat values may be set for tabs beyond
3666 the last one specified.  This is most commonly used to specify tabs set
3667 at equal intervals.  The complete syntax for setting tabs is
3669 @example
3670 ta @var{n1} @var{n2} @dots{} @var{nn} T @var{r1} @var{r2} @dots{} @var{rn}
3671 @end example
3673 @noindent
3674 This will set tabs at positions @var{n1}, @var{n2}, @dots{}, @var{nn}
3675 and then set tabs at @var{nn}+@var{r1}, @var{nn}+@var{r2}, @dots{},
3676 @var{nn}+@var{rn} and then at @var{nn}+@var{rn}+@var{r1},
3677 @var{nn}+@var{rn}+@var{r2}, @dots{}, @var{nn}+@var{rn}+@var{rn}, and so
3678 on.  For example the following is, yet again, the same as the previous
3679 examples.
3681 @example
3682 .ta T 1i
3683 @end example
3685 The material in each tab column may be justified to the right or left
3686 or centered in the column.  This is specified by appending an
3687 @samp{R}, @samp{L} or @samp{C} to the number specifying that tab stop.
3688 The default justification is @samp{L}.  Example:
3690 @example
3691 .ta 1i 2iC 2iR
3692 @end example
3694 @vindex .tabs
3695 The number register @code{.tabs} contains a string representation of the
3696 current tab settings suitable for use as an argument to the @code{ta}
3697 request.
3699 @findex tc
3700 Normally @code{gtroff} will fill the space to the next tab stop with
3701 spaces.  This can be change with the @code{tc} request.  With no
3702 argument @code{gtroff} will revert to using spaces.
3704 @subsection Leaders
3705 @cindex leaders
3707 @findex lc
3708 Sometimes it may may be desirable to use the @code{tc} request to fill a
3709 particular tab stop with a given character, but also normal tab stops on
3710 the rest of the line.  For this @code{gtroff} provides an alternate tab
3711 mechanism, called @dfn{leaders} which will do just that.  They are used
3712 exclusively to produce a repeated run of characters to the next tab
3713 stop.
3715 The character that will be repeated can be declared with the @code{lc}
3716 request.  Without an argument, the leaders will act the same as tabs.
3718 @findex \a
3719 Leader are invoked by using the @code{\a} escape while specifying the
3720 @code{ta} request.
3722 @cindex table of contents
3723 @cindex contents, table of
3724 For a table of contents, to name an example, tab stops may be defined so
3725 that the section number is one tab stop, the title is the second with
3726 the remaining space being filled with a line of dots, and then the page
3727 number slightly separated from the dots.
3729 @example
3730 .lc .
3731 .ta .5iR 5i +.25i
3732 1.1\tFoo\a\t12
3733 @end example
3735 @subsection Fields
3736 @cindex fields
3738 @findex fc
3739 Fields are a more general way of laying out tabular data.
3741 @code{fc}
3743 @c XXX add explanation
3745 @node Character Translations, Line Layout, Tabs and Fields, Programming Tutorial
3746 @section Character Translations
3747 @cindex character translations
3748 @cindex translations of characters
3750 @findex cc
3751 @findex c2
3752 @findex .
3753 @findex '
3754 The control character (@samp{.}) and the no-break control character
3755 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
3756 respectively.  The single argument is the new character to be used.
3757 With no argument the normal control character is restored.
3759 @findex ec
3760 @findex eo
3761 The @code{eo} request will completely disable the escape mechanism.  The
3762 @code{ec} request can be used to change the escape character from the
3763 default @samp{\} to what is specified as an argument.  It can be also
3764 used to re-enable the escape mechanism after an @code{eo} request.
3766 @findex tr
3767 The @code{tr} request will translate characters.
3769 @c XXX more info
3771 @findex trnt
3772 @findex \!
3773 @code{trnt} is the same as the @code{tr} request except that the
3774 translations do not apply to text that is transparently throughput into
3775 a diversion with @code{\!}.  @xref{Diversions}, for more information.
3776 For example,
3778 @example
3779 .tr ab
3780 .di x
3781 \!.tm a
3784 @end example
3786 @noindent
3787 will print @samp{b}; if @code{trnt} is used instead of @code{tr} it will
3788 print @samp{a}.
3791 @node Line Layout, Page Layout, Character Translations, Programming Tutorial
3792 @section Line Layout
3793 @cindex line layout
3794 @cindex layout, line
3796 @cindex dimensions, line
3797 @cindex line dimensions
3798 The following drawing shows the dimensions which @code{gtroff} uses for
3799 placing a line of output onto the page.  They are labeled with the
3800 request which manipulates that dimension.
3802 @example
3803 @group
3804               | -->| in |<--                   |
3805            -->| po |<-----------ll------------>|
3806               +----+----+----------------------+----+
3807               |    :    :                      :    |
3808               +----+----+----------------------+----+
3809 @end group
3810 @end example
3812 @noindent
3813 These dimensions are:
3815 @ftable @code
3816 @item po
3817 @cindex left margin
3818 @cindex margin, left
3819 @cindex page offset
3820 @cindex offset, page
3821 @vindex .o
3822 @dfn{Page offset}--This is the leftmost position of text on the final
3823 output, defining the @dfn{left margin}.  It can be adjusted with the
3824 @code{po} request, and the current setting can be found in the built-in
3825 number register @code{.o}.  Note that this request does not cause a
3826 break, so changing the page offset in the middle of text being filled
3827 may not yield the expected result.
3828 @item in
3829 @cindex indentation
3830 @cindex line indentation
3831 @findex in
3832 @vindex .i
3833 @dfn{Indentation}--This is the distance from the left margin where text
3834 will be printed.  This can be adjusted with the @code{in} request, and
3835 the current setting can be found in the built-in number register.
3836 @code{.i}.  This request causes a break.
3838 @findex ti
3839 @vindex .in
3840 There is also the request @code{ti} which will cause one output line to
3841 be indented, after which the indentation returns to@w{ }0.  This request
3842 causes a break.  The number register @code{.in} is the indent that
3843 applies to the current output line.
3844 @item ll
3845 @cindex line length
3846 @cindex length of line
3847 @vindex .l
3848 @vindex .ll
3849 @dfn{Line length}--This is the distance from the left margin to right
3850 margin.  This can be adjusted with the @code{ll} request, and the
3851 current setting can be found in the built-in number register @code{.l}
3852 Note, as the figure implies, line length is not affected by the current
3853 indentation.  The number register @code{.ll} is the line length that
3854 applies to the current output line.
3855 @end ftable
3857 @example
3858 .in +.5i
3859 .ll -.5i
3860 A bunch of really boring text which should
3861 be indented from both margins.
3862 Replace me with a better (and more) example!
3863 .in -.5i
3864 .ll +.5i
3865 @end example
3868 @node Page Layout, Page Control, Line Layout, Programming Tutorial
3869 @section Page Layout
3870 @cindex page layout
3871 @cindex layout, page
3873 @code{gtroff} provides some very primitive operations for controlling
3874 page layout.
3876 @cindex page length
3877 @cindex length of page
3878 @findex pl
3879 @vindex .p
3880 The @dfn{page length} can be specified via the @code{pl} request.  This
3881 is the length of the physical output page.  The current setting can be
3882 found in the built-in number register @code{.p}.  Note that this only
3883 specifies the size of the page, not the top and bottom margins.  Those
3884 are not done by groff directly.  @xref{Traps}, for further information
3885 on how to do this.
3887 @cindex headers
3888 @cindex footers
3889 @cindex titles
3890 @code{gtroff} provides several operations which help in setting up top
3891 and bottom titles (or headers and footers)
3893 @cindex title line
3894 @cindex three-part title
3895 @findex tl
3896 @findex %
3897 The @code{tl} request will print a @dfn{title line}, which consists of
3898 three parts: a left justified portion, a centered portion and a right
3899 justified portion.  The argument to @code{tl} is specified as
3900 @code{'@var{left}'@var{center}'@var{right}'}.  The @samp{%} character is
3901 replaced with the current page number.  This character can be changed
3902 with the @code{pc} request (see below).
3904 @cindex length of title line
3905 @cindex title line, length
3906 @findex lt
3907 @vindex .lt
3908 The title line is printed using its own line length, which is specified
3909 with the @code{lt} request.  The current setting of this is available in
3910 the @code{.lt} number register.
3912 @cindex page number
3913 @cindex number, page
3914 @findex pn
3915 The @code{pn} request will change the page number of the @emph{next}
3916 page.  The only argument is the page number.
3918 @vindex %
3919 @vindex .pn
3920 The current page number is stored in the number register @code{%}.  The
3921 number register @code{.pn} contains the number of the next page: either
3922 the value set by a @code{pn} request, or the number of the current page
3923 plus@w{ }1.
3925 @cindex changing the page number character
3926 @cindex page number character, changing
3927 @findex pc
3928 The @code{pc} request will change the page number character (used by the
3929 @code{tl} request) to a different character.  With no argument, this
3930 mechanism is disabled.
3932 @xref{Traps}.
3935 @node Page Control, Fonts, Page Layout, Programming Tutorial
3936 @section Page Control
3937 @cindex page control
3938 @cindex control, page
3940 @findex bp
3941 @findex pn
3942 To stop processing the current page, and move to the next page, invoke
3943 the @code{bp} request.  This request will also cause a break.  It can
3944 also take an argument of what the next page should be numbered.  The
3945 only difference between @code{bp} and @code{pn} is that @code{pn} does
3946 not cause a break or actually eject a page.
3948 @example
3949 .de newpage
3951 'sp .5i
3952 .tl 'left top'center top'right top'
3953 'sp .3i
3955 @end example
3957 @cindex orphan
3958 @findex ne
3959 It is often necessary to force a certain amount of space before a new
3960 page occurs.  This is most useful to make sure that there is not a
3961 single @dfn{orphan} line left at the bottom of a page.  The @code{ne}
3962 request will ensure that there is a certain distance, specified by the
3963 first argument, before the next page is triggered (@pxref{Traps}, for
3964 further information).  The default unit for @code{ne} is @code{v} and
3965 the default argument is@w{ }1@dmn{v}.
3967 For example, to make sure that no fewer than 2@w{ }lines get orphaned,
3968 do the following before each paragraph:
3970 @example
3971 .ne 2
3972 .ti +5n
3973 text
3974 @end example
3976 @findex sv
3977 @findex os
3978 @findex ne
3979 @code{sv} is similar to the @code{ne} request; it reserves the specified
3980 amount of vertical space.  If the desired amount of space exists before
3981 the next trap (bottom page boundary), the space will be output
3982 immediately.  If there is not enough space, it is stored for later
3983 output via the @code{os} request.  The default argument is@w{ }1@dmn{v}
3984 and the default unit is @code{v}.
3987 @node Fonts, Sizes, Page Control, Programming Tutorial
3988 @section Fonts
3989 @cindex fonts
3991 @findex ft
3992 @findex \f
3993 @code{gtroff} has the ability to switch fonts at any point in the text.
3994 There are two ways to do this, via the @code{ft} request and the
3995 @code{\f} escape.
3997 Fonts are generally specified as upper-case strings, which are usually
3998 1@w{ }to 4 characters representing an abbreviation or acronym of the font
3999 name.
4001 The basic set of fonts are @samp{R}, @samp{I}, @samp{B}, and @samp{BI}.
4002 These are Times Roman, Italic, Bold, and Bold Italic.  There is also at
4003 least one symbol font which contains various special symbols (Greek,
4004 mathematics).  Such symbols fonts cannot be used directly, but should be
4005 used via an escape.
4007 @menu
4008 * Changing Fonts::              
4009 * Font Families::               
4010 * Font Positions::              
4011 * Using Symbols::               
4012 * Artificial Fonts::            
4013 * Ligatures and Kerning::       
4014 @end menu
4016 @node Changing Fonts, Font Families, Fonts, Fonts
4017 @subsection Changing Fonts
4018 @cindex changing fonts
4019 @cindex fonts, changing
4021 @findex ft
4022 @cindex previous font
4023 @cindex font, previous
4024 Font changes can be done either with the @code{ft} request or the
4025 @code{\f} request.  With no arguments it will switch to the previous
4026 font (also known as @samp{P}).
4028 @example
4029 eggs, bacon,
4030 .ft B
4031 spam
4033 and sausage.
4034 @end example
4036 @findex \f
4037 The @code{\f} escape is useful for changing fonts in the middle of
4038 words:
4040 @example
4041 eggs, bacon, \fBspam\fP and sausage.
4042 @end example
4044 @noindent
4045 Both of the above examples will produce the same output.  Note the usage
4046 of @samp{P} to indicate the previous font---using @code{\f} it is not
4047 possible to omit this parameter.
4049 Sometimes when putting letters of different fonts, more or less space at
4050 such boundaries are needed.  There are two escapes to help with this.
4052 @findex \/
4053 @cindex italic correction
4054 @cindex correction, italic
4055 The @code{\/} escape increases the width of the preceding character so
4056 that the spacing between that character and the following character will
4057 be correct if the following character is a Roman character.  For
4058 example, if an italic@w{ }f is immediately followed by a Roman right
4059 parenthesis, then in many fonts the top right portion of the f will
4060 overlap the top left of the right parenthesis.  It is a good idea to use
4061 this escape sequence whenever an italic character is immediately
4062 followed by a Roman character without any intervening space.  This small
4063 amount of space is also called @dfn{italic correction}.
4065 @c XXX example
4066 @c producing @i{f}), which is ugly.  Inserting \/ produces f) and avoids
4067 @c this problem.
4069 @findex \,
4070 @cindex left italic correction
4071 @cindex correction, left italic
4072 The @code{\,} escape modifies the spacing of the following character so
4073 that the spacing between that character and the preceding character will
4074 be correct if the preceding character is a Roman character.  It is a
4075 good idea to use this escape sequence whenever a Roman character is
4076 immediately followed by an italic character without any intervening
4077 space.  In analogy to above, this space could be called @dfn{left italic
4078 correction}, but this term isn't used widely.
4080 @c XXX example
4081 @c For example, inserting \, between the parenthesis and the f changes
4082 @c (f to (f.
4084 @findex ftr
4085 @findex ft
4086 @findex ul
4087 @findex bd
4088 @findex \f
4089 @findex cs
4090 @findex tkf
4091 @findex special
4092 @findex fspecial
4093 @findex fp
4094 @findex code
4095 The @code{ftr} request will translate fonts; its syntax is
4097 @example
4098 .ftr @var{F} @var{G}
4099 @end example
4101 @noindent
4102 which translates font@w{ }@var{F} to font@w{ }@var{G}.  Whenever a font
4103 named @var{F} is referred to in a @code{\f} escape sequence, or in the
4104 @code{ft}, @code{ul}, @code{bd}, @code{cs}, @code{tkf}, @code{special},
4105 @code{fspecial}, @code{fp}, or @code{code} requests, font@w{ }@var{G} will
4106 be used.  If @var{G} is missing, or equal to @var{F} then font@w{
4107 }@var{F} will not be translated.
4109 @node Font Families, Font Positions, Changing Fonts, Fonts
4110 @subsection Font Families
4111 @cindex font families
4112 @cindex families, font
4114 Due to the variety of fonts available, @code{gtroff} has added the
4115 concept of font families.  Each of these families has four styles
4116 (@samp{R}, @samp{I}, @samp{B} and @samp{BI}).
4118 The fonts are specified as the concatenation of the font family and
4119 style.  Specifying a font without the family part will cause
4120 @code{gtroff} to use that style of the current family.  By default,
4121 @code{gtroff} uses the Times family.
4123 This way, it is possible to use the basic four fonts and to select a
4124 different font family on the command line.
4126 @findex fam
4127 @vindex .fam
4128 Font families can be switched with the @code{fam} request.  The current
4129 font family is available in the number register @code{.fam}.  This is a
4130 string-valued register.
4132 @example
4133 spam,
4134 .fam H
4135 spam,
4136 .ft B
4137 spam,
4138 .fam T
4139 spam,
4140 .ft AR
4141 baked beans,
4142 .ft R
4143 and spam.
4144 @end example
4146 @node Font Positions, Using Symbols, Font Families, Fonts
4147 @subsection Font Positions
4148 @cindex font positions
4149 @cindex positions, font
4151 For the sake of old phototypesetters and compatability with old versions
4152 of @code{troff}, @code{gtroff} has the concept of font @dfn{positions},
4153 on which various fonts are mounted.  The last one or two are reserved
4154 for the symbol font(s).
4156 @findex fp
4157 New fonts can be mounted with the @code{fp} request.  These numeric
4158 positions can then be referred to with font changing commands.  When
4159 @code{gtroff} starts it is using font number one.
4161 @example
4162 .fp 1 H
4163 .fp 2 HI
4164 .fp 3 HB
4165 wink, wink,
4166 .ft 2
4167 nudge, nudge,
4169 .ft 3
4170 say no more!
4172 @end example
4174 @noindent
4175 Note that after these font changes have taken place the original font
4176 is restored.
4178 @vindex .f
4179 The current font in use, as a font position, is available in number
4180 register @code{.f}.  This can be useful to remember the current font,
4181 for later recall.
4183 @example
4184 .nr save-font \n(.f
4185 ... lots 'o text ...
4186 .ft \n[save-font]
4187 @end example
4189 @vindex .fp
4190 The number of the next free font position is available in the number
4191 register @code{.fp}.  This is useful when mounting a new font, like so:
4193 @example
4194 .fp \n[.fp] NEATOFONT
4195 @end example
4197 @pindex DESC
4198 Fonts not listed in the @file{DESC} file are automatically mounted on
4199 the next available font position when they are referenced.  If a font is
4200 to be mounted explicitly with the @code{fp} request on an unused font
4201 position, it should be mounted on the first unused font position, which
4202 can be found in the @code{.fp} register.  Although @code{gtroff} does
4203 not enforce this strictly, it will not allow a font to be mounted at a
4204 position whose number is much greater than that of any currently used
4205 position.
4207 @findex fp
4208 The @code{fp} request has an optional third argument.  This argument
4209 gives the external name of the font, which is used for finding the font
4210 description file.  The second argument gives the internal name of the
4211 font which is used to refer to the font in @code{gtroff} after it has
4212 been mounted.  If there is no third argument then the internal name will
4213 be used as the external name.  This feature make it possible to use
4214 fonts with long names in compatibility mode.
4216 @node Using Symbols, Artificial Fonts, Font Positions, Fonts
4217 @subsection Using Symbols
4218 @cindex using symbols
4219 @cindex symbols, using
4221 @findex \(
4222 @findex \[
4223 Symbols can be inserted by using a special escape sequence.  This escape
4224 is simply the escape character (usually a backslash) followed by an
4225 identifier.  The symbol identifiers have to be two or more characters,
4226 since single characters conflict with all the other escapes.  The
4227 identifier can be either preceded by a parenthesis if it is two
4228 characters long, or surrounded by square brackets.  So, the symbol for
4229 the mathematical Greek letter `pi' can be produced either by @code{\(*p}
4230 or @code{\[*p]}.
4232 @example
4233 area = \(*p\fIr\fP\u2\d
4234 @end example
4236 @findex \C
4237 The escape @code{\C'@var{xxx}'} will typeset the character named
4238 @var{xxx}.  Normally it is more convenient to use @code{\[@var{xxx}]}.
4239 But @code{\C} has the advantage that it is compatible with recent
4240 versions of @code{ditroff} and is available in compatibility mode.
4242 @findex \N
4243 @findex char
4244 The escape @code{\N'@var{n}'} will typeset the character with code@w{
4245 }@var{n} in the current font.  @var{n} can be any integer.  Most devices
4246 only have characters with codes between 0 and@w{ }255.  If the current
4247 font does not contain a character with that code, special fonts will
4248 @emph{not} be searched.  The @code{\N} escape sequence can be
4249 conveniently used on conjunction with the @code{char} request:
4251 @example
4252 .char \[phone] \f(ZD\N'37'
4253 @end example
4255 @noindent
4256 @pindex DESC
4257 @cindex unnamed characters
4258 @cindex characters, unnamed
4259 The code of each character is given in the fourth column in the font
4260 description file after the charset command.  It is possible to include
4261 unnamed characters in the font description file by using a name of
4262 @samp{---}; the @code{\N} escape sequence is the only way to use these.
4264 @c XXX should be `glyph', not `character'
4266 @findex cflags
4267 @cindex character properties
4268 @cindex properties of characters
4269 Each character has certain properties associated with it.  These
4270 properties can be modified with the @code{cflags} request.  The first
4271 argument is the the sum of the desired flags and the remaining arguments
4272 are the characters to have those properties.
4274 @table @code
4275 @item 1
4276 @cindex end of sentence characters
4277 @cindex characters, end of sentence
4278 the character ends sentences (initially characters @samp{.?!} have this
4279 property)
4280 @item 2
4281 @cindex hyphenating characters
4282 @cindex characters, hyphenation
4283 lines can be broken before the character (initially no characters have
4284 this property)
4285 @item 4
4286 @glindex hy
4287 @glindex em
4288 lines can be broken after the character (initially the characters
4289 @samp{-\(hy\(em} have this property)
4290 @item 8
4291 @cindex overlapping characters
4292 @cindex characters, overlapping
4293 @glindex ul
4294 @glindex rn
4295 @glindex ru
4296 the character overlaps horizontally (initially the characters
4297 @samp{\(ul\(rn\(ru} have this property)
4298 @item 16
4299 @glindex br
4300 the character overlaps vertically (initially character @samp{\(br} has
4301 this property)
4302 @item 32
4303 @cindex transparent characters
4304 @cindex characters, transparent
4305 @glindex dg
4306 @glindex rq
4307 an end of sentence character followed by any number of characters with
4308 this property will be treated as the end of a sentence if followed by a
4309 newline or two spaces; in other words the character is @dfn{transparent}
4310 for the purposes of end of sentence recognition---this is the same as
4311 having a zero space factor in @TeX{} (initially characters
4312 @samp{"')]*\(dg\(rq} have this property).
4313 @end table
4315 @findex char
4316 @cindex defining characters
4317 @cindex characters, defining
4318 New characters can be created with the @code{char} request.  It is
4319 called as
4321 @example
4322 .char @var{c} @var{string}
4323 @end example
4325 @findex tr
4326 @findex lc
4327 @findex \l
4328 @findex \L
4329 @findex hcode
4330 @noindent
4331 This defines character@w{ }@var{c} to be @var{string}.  Every time
4332 character@w{ }@var{c} needs to be printed, @var{string} will be
4333 processed in a temporary environment and the result will be wrapped up
4334 into a single object.  Compatibility mode will be turned off and the
4335 escape character will be set to @samp{\} while @var{string} is being
4336 processed.  Any emboldening, constant spacing or track kerning will be
4337 applied to this object rather than to individual characters in
4338 @var{string}.  A character defined by this request can be used just like
4339 a normal character provided by the output device.  In particular other
4340 characters can be translated to it with the @code{tr} request; it can be
4341 made the leader character by the @code{lc} request; repeated patterns
4342 can be drawn with the character using the @code{\l} and @code{\L} escape
4343 sequences; words containing the character can be hyphenated correctly,
4344 if the @code{hcode} request is used to give the character a hyphenation
4345 code.  There is a special anti-recursion feature: use of character
4346 within the character's definition will be handled like normal characters
4347 not defined with @code{char}.
4349 @findex rchar
4350 @cindex removing character definition
4351 @cindex character, removing definition
4352 A character definition can be removed with the @code{rchar} request.
4353 Its arguments are the characters to be removed.  This undoes the effect
4354 of a @code{char} request.
4356 @xref{Special Characters}.
4358 @node Artificial Fonts, Ligatures and Kerning, Using Symbols, Fonts
4359 @subsection Artificial Fonts
4360 @cindex artificial fonts
4361 @cindex fonts, artificial
4363 There are a number of requests for artificially creating fonts.  These
4364 are largely vestigial remains from the days when output devices did not
4365 have a wide variety of fonts, and when @code{nroff} and @code{troff}
4366 were separate programs.  These are no longer necessary in GNU
4367 @code{troff}.
4369 @findex ul
4370 @cindex underlining
4371 The @code{ul} request will print subsequent lines in italics on a device
4372 capable of it, or underline the text on an character output device.  The
4373 single argument is the number of lines to be ``underlined,'' with no
4374 argument, the next line will be underlined.
4376 @findex cu
4377 @cindex continuous underlining
4378 @cindex underlining, continuous
4379 The @code{cu} request is similar to @code{ul} ...
4381 @c XXX more info
4383 @findex uf
4384 @cindex underline font
4385 @cindex font for underlining
4386 The @code{uf} request will set the underline font used by @code{ul} and
4387 @code{cu}.
4389 @findex bd
4390 @cindex imitating bold face
4391 @cindex bold face, imitating
4392 The @code{bd} request artificially creates a bold font by printing each
4393 character twice, slightly offset.  The first argument specifies the font
4394 to embolden, and the second is the number of basic units, minus one, by
4395 which the two characters will be offset.  If the second argument is
4396 missing, emboldening will be turned off.
4398 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
4399 @subsection Ligatures and Kerning
4400 @cindex ligatures and kerning
4401 @cindex kerning and ligatures
4403 What are ligatures?
4405 @c XXX more info
4407 @findex lg
4408 @vindex .lg
4409 The ligature mechanism can be switched on or off with the @code{lg}
4410 request; if the parameter is non-zero or missing, ligatures are enabled,
4411 otherwise disabled.  Default is on.  The current ligature mode can be
4412 found in the number register @code{.lg} (set to@w{ }1 if ligatures are
4413 enabled, 0@w{ }otherwise).
4415 What is kerning?
4417 @c XXX more info
4419 @cindex zero width space character
4420 @cindex character, zero width space
4421 @cindex space character, zero width
4422 If the font description file contains pairwise kerning information,
4423 characters from that font will be kerned.  Kerning between two
4424 characters can be inhibited by placing @code{\&} between them.
4426 @findex kern
4427 @vindex .kern
4428 Kerning can be activated with the @code{kern} request.  If the parameter
4429 is non-zero or missing, enable pairwise kerning, otherwise disable it.
4430 The number register @code{.kern} is set to@w{ }1 if pairwise kerning is
4431 enabled, 0@w{ }otherwise.
4433 @findex tkf
4434 @cindex track kerning
4435 @cindex kerning, track
4436 What is track kerning?
4438 @c XXX more info
4440 Track kerning must be used with great care since it is usually
4441 considered bad typography if the reader notices the effect.  The syntax
4442 of the @code{tkf} request is
4444 @example
4445 .tkf @var{f} @var{s1} @var{n1} @var{s2} @var{n2}
4446 @end example
4448 @noindent
4449 Enable track kerning for font@w{ }@var{f}.  If the current font is@w{
4450 }@var{f} the width of every character will be increased by an amount
4451 between @var{n1} and @var{n2}; if the current point size is less than or
4452 equal to @var{s1} the width will be increased by @var{n1}; if it is
4453 greater than or equal to @var{s2} the width will be increased by
4454 @var{n2}; if the point size is greater than or equal to @var{s1} and
4455 less than or equal to @var{s2} the increase in width is a linear
4456 function of the point size.
4459 @node Sizes, Strings, Fonts, Programming Tutorial
4460 @section Sizes
4461 @cindex sizes
4463 @cindex baseline
4464 @cindex type size
4465 @cindex size of type
4466 @cindex vertical spacing
4467 @cindex spacing, vertical
4468 @code{gtroff} uses two dimensions with each line of text, type size and
4469 vertical spacing.  The @dfn{type size} is the height from the text
4470 @dfn{baseline} to the top of the tallest character (descenders may drop
4471 below this baseline).  @dfn{Vertical spacing} is the amount of space
4472 @code{gtroff} allows for a line of text; normally, this is about 20%@w{
4473 }larger than the current type size.  Ratios smaller than this can result
4474 in hard-to-read text; larger that this, it will spread the text out more
4475 vertically (useful for term papers).  By default, @code{gtroff} uses
4476 10@w{ }point type on 12@w{ }point spacing.
4478 @cindex leading
4479 The difference between type size and vertical spacing is known, by
4480 typesetters, as @dfn{leading}.
4482 @menu
4483 * Changing Type Sizes::         
4484 * Fractional Type Sizes::       
4485 @end menu
4487 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
4488 @subsection Changing Type Sizes
4489 @cindex changing type sizes
4490 @cindex type sizes, changing
4492 @findex ps
4493 @findex vs
4494 @findex \s
4495 @vindex .s
4496 @vindex .v
4497 Using the @code{ps} request and the @code{\s} escape the type size can
4498 be changed.  The @code{vs} request will change the vertical spacing.
4499 The default unit for the @code{ps} and @code{vs} requests are points.
4500 The number registers @code{.s} and @code{.v} contain the current type
4501 size and vertical spacing.
4503 These requests take parameters in units of points.  It is possible to
4504 specify sizes as an absolute size, or as a relative change from the
4505 current size.  The size@w{ }0 means go back to the previous size.  With
4506 no argument it will also revert to the previous size.
4508 @example
4509 snap, snap,
4510 .ps +2
4511 grin, grin,
4512 .ps +2
4513 wink, wink, \s+2nudge, nudge,\s+8 say no more!
4514 .ps 10
4515 @end example
4517 The @code{\s} escape may be called in a variety of ways.  Much like
4518 other escapes there must be a way to determine where the argument ends
4519 and the text begins.  Any of the following forms are valid:
4521 @table @code
4522 @item \s@var{n}
4523 Set the point size to @var{n}@w{ }points.  @var{n}@w{ }must be either 0
4524 or in the range 4 to@w{ }39.
4525 @itemx \s+@var{n}
4526 @itemx \s-@var{n}
4527 Increase resp.@: decrease the point size by @var{n}@w{ }points.
4528 @var{n}@w{ }must be exactly one digit.
4529 @item \s(@var{nn}
4530 Set the point size to @var{nn}@w{ }points.  @var{nn} must be exactly two
4531 digits.
4532 @item \s+(@var{nn}
4533 @itemx \s-(@var{nn}
4534 @itemx \s(+@var{nn}
4535 @itemx \s(-@var{nn}
4536 Increase resp.@: decrease the point size by @var{nn}@w{ }points.
4537 @var{nn} must be exactly two digits.
4538 @end table
4540 @xref{Fractional Type Sizes}, for yet another syntactical form of using
4541 the @code{\s} escape.
4543 Some devices may only have certain permissible sizes, in which case
4544 @code{gtroff} will round to the nearest permissible size.
4546 @c XXX example
4548 @example
4549 ... .sz macro example?? ...
4550 @end example
4552 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
4553 @subsection Fractional Type Sizes
4554 @cindex fractional type sizes
4555 @cindex type sizes, fractional
4557 @cindex @code{s} unit
4558 @cindex unit, @code{s}
4559 @cindex @code{z} unit
4560 @cindex unit, @code{z}
4561 @findex ps
4562 @findex cs
4563 @findex tkf
4564 @findex \H
4565 @findex \s
4566 A @dfn{scaled point} is equal to 1/@var{sizescale} points, where
4567 @var{sizescale} is specified in the @file{DESC} file (1@w{ }by default.)
4568 There is a new scale indicator @samp{z} which has the effect of
4569 multiplying by @var{sizescale}.  Requests and escape sequences in
4570 @code{gtroff} interpret arguments that represent a point size as being in
4571 units of scaled points, but they evaluate each such argument using a
4572 default scale indicator of @samp{z}.  Arguments treated in this way are
4573 the argument to the @code{ps} request, the third argument to the
4574 @code{cs} request, the second and fourth arguments to the @code{tkf}
4575 request, the argument to the @code{\H} escape sequence, and those
4576 variants of the @code{\s} escape sequence that take a numeric expression
4577 as their argument (see below).
4579 For example, suppose @var{sizescale} is@w{ }1000; then a scaled point
4580 will be equivalent to a millipoint; the request @w{@samp{.ps 10.25}} is
4581 equivalent to @w{@samp{.ps 10.25z}} and thus sets the point size to 10250
4582 scaled points, which is equal to 10.25@w{ }points.
4584 It would make no sense to use the @samp{z} scale indicator in a numeric
4585 expression whose default scale indicator was neither @samp{u} nor
4586 @samp{z}, and so @code{gtroff} disallows this.  Similarly it would make
4587 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
4588 numeric expression whose default scale indicator was @samp{z}, and so
4589 @code{gtroff} disallows this as well.
4591 There is also new scale indicator @samp{s} which multiplies by the
4592 number of units in a scaled point.  So, for example, @samp{\n[.ps]s} is
4593 equal to @samp{1m}.  Be sure not to confuse the @samp{s} and @samp{z}
4594 scale indicators.
4596 @vindex .s
4597 @vindex .ps
4598 The number register @code{.s} returns the point size in points as decimal
4599 fraction.  There is also a new number register @code{.ps} that returns
4600 the point size in scaled points.
4602 @vindex .psr
4603 @vindex .sr
4604 The last-requested point size in scaled points is contained in the
4605 @code{.psr} number register.  The last requested point size in points as
4606 a decimal fraction can be found in @code{.psr}.  This is a string-valued
4607 register.
4609 @table @code
4610 @item \s[@var{n}]
4611 @itemx \s'@var{n}'
4612 Set the point size to @var{n} scaled points; @var{n}@w{ }is a numeric
4613 expression with a default scale indicator of @samp{z}.
4614 @item \s[+@var{n}]
4615 @itemx \s[-@var{n}]
4616 @itemx \s+[@var{n}]
4617 @itemx \s-[@var{n}]
4618 @itemx \s'+@var{n}'
4619 @itemx \s'-@var{n}'
4620 @itemx \s+'@var{n}'
4621 @itemx \s-'@var{n}'
4622 Increases resp.@: decreases the point size by @var{n} scaled points;
4623 @var{n} is a numeric expression with a default scale indicator of
4624 @samp{z}.
4625 @end table
4627 @xref{Font Files}.
4630 @node Strings, Conditionals and Loops, Sizes, Programming Tutorial
4631 @section Strings
4632 @cindex strings
4634 @findex ds
4635 @code{gtroff} has string variables, which are entirely for user
4636 convenience (i.e.@: there are no built-in strings).  They are defined
4637 via the @code{ds} request.
4639 @example
4640 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
4641 @end example
4643 @findex \*
4644 @cindex string interpolation
4645 @cindex string expansion
4646 @cindex interpolation of strings
4647 @cindex expansion of strings
4648 They are interpolated, or expanded in-place, via the @code{\*} escape:
4650 @example
4651 The \*(UX Operating System
4652 @end example
4654 If the string named by the @code{\*} does not exist, the escape will be
4655 replaced by nothing.
4657 @cindex comments, with @code{ds}
4658 @strong{Caution:} Unlike other requests, the second argument to the
4659 @code{ds} request takes up the entire line including trailing spaces.
4660 This means that comments on a line with such a request can introduce
4661 unwanted space into a string.
4663 @example
4664 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" UNIX trademark
4665 @end example
4667 @noindent
4668 Instead the comment should be put on another line or have the comment
4669 escape adjacent with the end of the string.
4671 @example
4672 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  UNIX trademark
4673 @end example
4675 @cindex trailing quotes
4676 @cindex quotes, trailing
4677 @cindex leading spaces with @code{ds}
4678 @cindex spaces with @code{ds}
4679 To produce leading space the string can be started with a double quote.
4680 No trailing quote is needed; in fact, any trailing quote is included in
4681 your string.
4683 @example
4684 .ds sign "           Yours in a white wine sauce,
4685 @end example
4687 @findex as
4688 @cindex appending to strings
4689 @cindex strings, appending
4690 The @code{as} request will append a string to another string.  It works
4691 similar to the @code{ds} request except that it appends the second
4692 argument onto the string named by the first argument.
4694 @example
4695 .as sign " with shallots, onions and garlic,
4696 @end example
4698 @findex \@key{RET}
4699 @cindex multi-line strings
4700 @cindex strings, multi-line
4701 @cindex newline character, escaping
4702 @cindex escaping newline characters
4703 Strings are not limited to a single line of text.  A string can span
4704 several lines by escaping the newlines with a backslash.  The resulting
4705 string will be stored @emph{without} the newlines.
4707 @example
4708 .ds foo lots and lots \
4709 of text are on these \
4710 next several lines
4711 @end example
4713 @findex substring
4714 @cindex substrings
4715 Rudimentary string manipulation routines are given with the
4716 @code{substring} and @code{length} requests.  The former has the
4717 following syntax:
4719 @example
4720 .substring @var{xx} @var{n1} [@var{n2}]
4721 @end example
4723 @noindent
4724 It replaces the string in register@w{ }@var{xx} with the substring
4725 defined by the indices @var{n1} and@w{ }@var{n2}.  The first character
4726 in the string has index one.  If @var{n2} is omitted, it is taken to be
4727 equal to the string's length.  If the index value @var{n1} or @var{n2}
4728 is negative or zero, it will be counted from the end of the string,
4729 going backwards: The last character has index@w{ }0, the character
4730 before the last character has index@w{ }-1, etc.
4732 @findex length
4733 @cindex length of a string
4734 @cindex string, length of
4735 Here the syntax of the @code{length} request:
4737 @example
4738 .length @var{xx} @var{string}
4739 @end example
4741 @noindent
4742 It computes the length of @var{string} and returns it in the number
4743 register@w{ }@var{xx} (which is not necessarily defined before).
4745 @findex rn
4746 @code{rn}
4748 @c XXX
4750 @findex rm
4751 @code{rm}
4753 @c XXX
4755 @findex als
4756 @code{als}
4758 @c XXX
4760 @findex chop
4761 @code{chop}
4763 @c XXX
4765 @xref{Identifiers}, and @ref{Comments}.
4768 @node Conditionals and Loops, Writing Macros, Strings, Programming Tutorial
4769 @section Conditionals and Loops
4770 @cindex conditionals and loops
4771 @cindex loops and conditionals
4773 @findex if
4774 @findex while
4775 In @code{if} and @code{while} requests, there are several more operators
4776 available:
4778 @table @code
4779 @item e
4780 @itemx o
4781 True if the current page is even or odd numbered (respectively).
4782 @item n
4783 @itemx t
4784 True if the document is being processed by @code{nroff} (or a character
4785 device) resp.@: @code{troff}.
4786 @item '@var{xxx}'@var{yyy}'
4787 True if the string @var{xxx} is equal to the string @var{yyy}.  Other
4788 characters can be used in place of the single quotes.
4789 @c XXX (Which?)
4790 The strings are `formatted' before being compared.
4791 @c XXX (?)
4792 @item r@var{xxx}
4793 True if there is a number register named @var{xxx}.
4794 @item d@var{xxx}
4795 True if there is a string, macro, diversion, or request named @var{xxx}.
4796 @item c@var{ch}
4797 @findex char
4798 True if there is a character @var{ch} available; @var{ch} is either an
4799 @acronym{ASCII} character or a special character (@code{\(@var{ch}} or
4800 @code{\[@var{ch}]}); the condition will also be true if @var{ch} has
4801 been defined by the @code{char} request.
4802 @end table
4804 @menu
4805 * if-else::                     
4806 * while::                       
4807 @end menu
4809 @node if-else, while, Conditionals and Loops, Conditionals and Loops
4810 @subsection if-else
4811 @cindex if-else
4813 @code{gtroff} has if-then-else constructs like other languages, although
4814 the formatting can be painful.
4816 @findex if
4817 The @code{if} request has the following syntax:
4819 @example
4820 .if @var{expr} @var{anything}
4821 @end example
4823 @noindent
4824 where @var{expr} is the expression to be evaluated; @var{anything} (the
4825 remainder of the line) will be executed if @var{expr} evaluates to
4826 non-zero (true).  @var{anything} will be interpreted as though it was on
4827 a line by itself.  @xref{Expressions}, for more info.
4829 Here are some examples:
4831 @example
4832 .if t .ls 2                             \" double spacing in troff
4833 .if 0 .ab how'd this happen?
4834 @end example
4836 @findex ie
4837 @findex el
4838 An if-then-else is written using two requests @code{ie} and @code{el}.
4839 The first request is the `if' part and the latter is the `else' part.
4841 @c XXX example
4843 @example
4846 @end example
4848 @findex \@{
4849 @findex \@}
4850 In many cases more than one request is to be executed as a result of any
4851 of these requests.  This can be done using the @code{\@{} and @code{\@}}
4852 escapes.  The following example shows the possible ways to use these
4853 escapes (note the position of the opening and closing braces).
4855 @example
4856 .ie t \@{\
4857 .    ds lq ``
4858 .    ds rq ''
4859 .\@}
4860 .el \
4861 .\@{\
4862 .    ds lq "
4863 .    ds rq "\@}
4864 .ds qq "
4865 @end example
4867 @xref{Expressions}.
4869 @node while,  , if-else, Conditionals and Loops
4870 @subsection while
4871 @cindex while
4873 @findex while
4874 @code{gtroff} provides a looping construct using the @code{while}
4875 request, which is used much like the @code{if} (and related) requests.
4876 The first argument is an expression which will be evaluated.  The
4877 @code{while} request will interpret the remainder of the line until the
4878 expression evaluates to 0 or false.
4880 @example
4881 .nr a 0 1
4882 .while (\na<9) \&\n+a,
4883 \&\n+a
4884 @end example
4886 @noindent
4887 The preceding example produces:
4889 @example
4890 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
4891 @end example
4893 @cindex zero width space character
4894 @cindex character, zero width space
4895 @cindex space character, zero width
4896 @findex \&
4897 @noindent
4898 Note the usage of the @code{\&} escape to avoid a control character at
4899 the beginning of a line.
4901 @findex break
4902 @findex continue
4903 The @code{break} request will @dfn{break} out of a while loop.  Be sure
4904 not to confuse this with the @code{br} request (causing a line break).
4905 The @code{continue} request will finish the current iteration of a while
4906 loop, immediately restarting the next iteration.
4908 @xref{Expressions}.
4911 @node Writing Macros, Page Motions, Conditionals and Loops, Programming Tutorial
4912 @section Writing Macros
4913 @cindex writing macros
4914 @cindex macros, writing
4916 @findex de
4917 A @dfn{macro} is a collection of text and embedded commands which can be
4918 invoked multiple times.  Macros are used for defining common operations.
4919 Macros are defined using the @code{de} request.  This request takes a
4920 name for the macro as the first argument.  Subsequent lines are copied
4921 into an internal buffer until the line @code{..} is encountered.  The
4922 optional second argument to @code{de} can change this ending token.
4924 Here a small example macro called @samp{P} which will cause a break and
4925 the insertion of some vertical space.  It could be used to separate
4926 paragraphs.
4928 @example
4929 .de P
4931 .sp .8v
4933 @end example
4935 @findex am
4936 The @code{am} request works similarly to @code{de} except it appends
4937 onto the macro named by the first argument.  So, to make the previously
4938 defined @samp{P} macro actually do indented instead of block paragraphs,
4939 is is possible to add the necessary code to the existing macro like
4940 this:
4942 @example
4943 .am P
4944 .ti +5n
4946 @end example
4948 @findex als
4949 @cindex aliases, macro
4950 @cindex macro aliases
4951 Macros can be aliased with the @code{als} request.
4953 @c XXX example
4955 @menu
4956 * Copy-in Mode::                
4957 * Parameters::                  
4958 @end menu
4960 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
4961 @subsection Copy-in Mode
4962 @cindex copy-in mode
4963 @cindex mode, copy-in
4965 @findex \n
4966 @findex \$
4967 @findex \*
4968 @findex \\
4969 @findex \@key{RET}
4970 When @code{gtroff} reads in the text for a macro or diversion it copies
4971 the text (including request lines, but excluding escapes) into an
4972 internal buffer.  Escapes will be converted into an internal form,
4973 except for @code{\n}, @code{\$}, @code{\*}, @code{\\} and
4974 @code{\@key{RET}} which are evaluated and inserted into the text where
4975 the escape was located.  This is known as @dfn{copy-in} mode.
4977 What this means is that you can specify when these escapes are to be
4978 evaluated (either at copy-in time or at the time of use) by insulating
4979 the escapes with an extra backslash.  Compare this to the @code{\def}
4980 and @code{\edef} commands in @TeX{}.
4982 For example, the following will result in the numbers 20 and@c{ }10
4983 being printed:
4985 @example
4986 .nr x 20
4987 .de y
4988 .nr x 10
4989 \&\nx
4990 \&\\nx
4993 @end example
4995 @node Parameters,  , Copy-in Mode, Writing Macros
4996 @subsection Parameters
4997 @cindex parameters
4999 @findex \$
5000 @vindex .$
5001 The arguments to a macro can be examined using a variety of escapes.
5002 The number of arguments is available in the @code{.$} number register.
5003 Any individual argument can be retrieved with one of the following
5004 escapes:
5006 @cindex copy-in mode
5007 The escapes @code{\$@var{n}}, @code{\$(@var{nn}} and
5008 @code{\$[@var{nnn}]} will result in the @var{n}th, @var{nn}th or
5009 @var{nnn}th argument.  As usual, the first form only accepts a single
5010 number (larger than zero), the second only a two-digit number (larger or
5011 equal to@w{ }10), and the third any positive integer value (larger than
5012 zero).  Macros can have an unlimited number of arguments.  Note that due
5013 to copy-in mode, two backslashes should be used on these in actual use
5014 to prevent interpolation until the macro is actually invoked.
5016 @findex shift
5017 The request @code{shift} will shift the arguments 1@w{ }position, or as
5018 many positions as specified by its argument.  After executing this
5019 request, argument@w{ }@var{i} will become argument @var{i}-@var{n};
5020 arguments 1 to@w{ }@var{n} will no longer be available.  Shifting by
5021 negative amounts is currently undefined.
5023 @findex \$*
5024 @findex \$@@
5025 In some cases it is convenient to use all of the arguments at once (for
5026 example, to pass the arguments along to another macro).  The @code{\$*}
5027 escape is the concatenation of all the arguments separated by spaces.  A
5028 similar escape is @code{\$@@}, which is the concatenation of all the
5029 arguments with each surrounded by double quotes, and separated by
5030 spaces.
5032 @findex \$0
5033 @findex als
5034 The @code{\$0} escape is the name by which the current macro was
5035 invoked.  The @code{als} request can make a macro have more than one
5036 name.
5038 @example
5039 .de vl
5040 .ie \\n(.$=1 .ds Vl Pre-Release Version
5041 .el          .ds Vl Version \\$3, \\$4.
5043 @end example
5045 This would be called as
5047 @example
5048 .vl $Id$
5049 @end example
5051 @xref{Request Arguments}.
5054 @node Page Motions, Drawing Requests, Writing Macros, Programming Tutorial
5055 @section Page Motions
5056 @cindex page motions
5057 @cindex motions, page
5059 @findex sp
5060 Motions up and down the page can be done with the @code{sp} request.
5061 However, this causes a break so that the actual effect is to move to the
5062 left margin and then to the specified location.
5064 @findex mk
5065 @findex rt
5066 The request @code{mk} can be used to mark a location on a page, for
5067 movement to later.  This request takes a register name as an argument in
5068 which to store the current page location.  With no argument it will
5069 store the location in an internal register.  The results of this can be
5070 used later by the @code{rt} or the @code{sp} request.  The @code{rt}
5071 request will return @emph{upwards} to the location given in the register
5072 name given as an argument, with no argument it will return to the
5073 location marked with the @code{mk} request
5075 @c XXX example
5077 @example
5078 ... dual column example ...
5079 @end example
5081 The following escapes give fine control of movements about the page.
5083 @findex \v
5084 @cindex vertical motion
5085 @cindex motion, vertical
5086 The @code{\v'@var{e}'} enables arbitrary vertical motion from the
5087 current location on the page.  The argument@w{ }@var{e} specifies the
5088 distance to move; positive is downwards and negative upwards.  The
5089 default unit for this escape is vertical spaces, @code{v}'s.  Beware,
5090 however, that @code{gtroff} will leave text processing to continue
5091 wherever the motion ends, so to avoid interference with text processing,
5092 motions should be balanced.
5094 There are some special case escapes for vertical motion.
5096 @ftable @code
5097 @item \r
5098 move upwards@w{ }1@dmn{v}.
5099 @item \u
5100 move upwards@w{ }.5@dmn{v}.
5101 @item \d
5102 move down@w{ }.5@dmn{v}.
5103 @end ftable
5105 @findex \h
5106 Horizontal motions can be done via the @code{\h'@var{e}'} escape.  The
5107 expression@w{ }@var{e} indicates how far to move: positive is rightwards
5108 and negative leftwards.
5110 There are a number of special case escapes for horizontal motion:
5112 @ftable @code
5113 @item \@key{SP}
5114 an unbreakable and unpaddable (i.e.@: not expanded during filling)
5115 space.  (Note: It is a backslash followed by a space.)
5116 @item \~
5117 an unbreakable space that stretches like a normal inter-word space when a
5118 line is adjusted.
5119 @item \|
5120 a 1/6th em space.
5121 @item \^
5122 a 1/12th em space.
5123 @item \0
5124 a space the size of a digit.
5125 @cindex zero width space character
5126 @cindex character, zero width space
5127 @cindex space character, zero width
5128 @item \&
5129 A zero width space.
5130 @item \)
5131 Like @code{\&} except that it behaves like a character declared with the
5132 @code{cflags} request to be transparent for the purposes of end of
5133 sentence recognition.
5134 @end ftable
5136 @c XXX example
5138 @example
5139 ... tex logo example ...
5140 @end example
5142 @findex \w
5143 @cindex width escape
5144 @cindex escape, width
5145 A frequent need is to do horizontal movement based on the width of some
5146 arbitrary text (e.g.@: given as an argument to a macro).  For that,
5147 there is the escape @code{\w'@var{text}'} which will interpolate to the
5148 width of the given @var{text} in basic units.
5150 @c XXX example
5152 @example
5153 ... strlen example ...
5154 @end example
5156 Font changes may occur in @var{text} which don't affect current
5157 settings.
5159 After use, @code{\w} sets several registers:
5161 @table @code
5162 @vindex st
5163 @vindex sb
5164 @item st
5165 @itemx sb
5166 The highest and lowest point, respectively, in @var{text}.
5167 @vindex rst
5168 @vindex rsb
5169 @item rst
5170 @itemx rsb
5171 Like the @code{st} and @code{sb} registers, but takes account of the
5172 heights and depths of characters.
5173 @vindex ct
5174 @item ct
5175 is set according to what kinds of characters occur in @var{text}:
5176 @table @asis
5177 @item 0
5178 only short characters, no descenders or tall characters.
5179 @item 1
5180 descender
5181 @item 2
5182 tall character
5183 @item 3
5184 both a descender and a tall character
5185 @end table
5186 @vindex ssc
5187 @item ssc
5188 The amount of horizontal space (possibly negative) that should be added
5189 to the last character before a subscript.
5190 @vindex skw
5191 @item skw
5192 How far to right of the center of the last character in the @code{\w}
5193 argument, the center of an accent from a Roman font should be placed
5194 over that character.
5195 @end table
5197 @findex \k
5198 @vindex .k
5199 @code{\k}
5201 @code{.k}
5203 @c XXX documentation
5206 @node Drawing Requests, Traps, Page Motions, Programming Tutorial
5207 @section Drawing Requests
5208 @cindex drawing requests
5209 @cindex requests for drawing
5211 @code{gtroff} provides a number of ways to draw lines and other figures
5212 on the page.  Used in combination with the page motion commands
5213 (@pxref{Page Motions}, for more info), a wide variety of figures can be
5214 drawn.  However, for complex drawings these operations can be quite
5215 cumbersome, and it may be wise to use graphic preprocessors like
5216 @code{gpic} or @code{ggrn}.  @xref{gpic}, and @ref{ggrn}, for more
5217 information.
5219 All drawing is done via escapes.
5221 @findex \l
5222 @cindex horizontal line
5223 @cindex line, horizontal
5224 The @code{\l} escape will draw a line rightwards from the current
5225 location.  The full syntax for this escape is
5227 @example
5228 \l'@var{l}@var{c}'
5229 @end example
5231 @noindent
5232 where @var{l} is the length of the line to be drawn, starting at the
5233 current location; positive numbers will draw to the right, and negative
5234 will draw towards the left.  This can also be specified absolutely
5235 (i.e.@: with a leading @samp{|}) which will draw back to the beginning
5236 of the line.
5238 @cindex underscore character
5239 @cindex character, underscore
5240 @cindex line drawing character
5241 @cindex character for line drawing
5242 The optional second parameter @var{c} is a character to draw the line
5243 with.  If this second argument is not specified, @code{gtroff} will use
5244 the underscore character.
5246 @cindex zero width space character
5247 @cindex character, zero width space
5248 @cindex space character, zero width
5249 @findex \&
5250 To separate the two arguments (to prevent @code{gtroff} from
5251 interpreting a drawing character as a scaling indicator) use @code{\&}.
5253 Here a small useful example:
5255 @example
5256 .de box
5257 \(br\\$*\(br\l'|0\(rn'\l'|0\(ul'
5259 @end example
5261 @noindent
5262 @findex |
5263 Note that this works by outputting a box rule (a vertical line), then
5264 the text given as an argument and then another box rule.  Then the line
5265 drawing escapes both draw from the current location to the beginning of
5266 the @emph{input} line.
5268 @findex \L
5269 @cindex vertical line
5270 @cindex line, vertical
5271 @cindex line drawing character
5272 @cindex character for line drawing
5273 @cindex box rule character
5274 @cindex character, box rule
5275 Vertical lines are drawn using the @code{\L} escape.  Its parameters are
5276 specified similar to the @code{\l} escape.  If the length is positive,
5277 the movement will be downwards, and upwards for negative values.  The
5278 default character is the box rule character.  As with the vertical
5279 motion escapes, text processing will blindly continue where the line
5280 ends.
5282 @c XXX example
5284 @example
5285 ...box macro...
5286 @end example
5288 @findex \D
5289 More flexible drawing functions are available via the @code{\D} escape.
5290 While the previous escapes will work on a character device, these
5291 escapes will not.
5293 @table @code
5294 @item \D'l @var{dx} @var{dy}'
5295 Draw a line from the current location to the relative point specified by
5296 (@var{dx},@var{dy}).
5298 @c XXX example
5300 @example
5301 ...revised box macro...
5302 @end example
5304 @item \D'c @var{d}'
5305 @cindex circles
5306 Draw a circle with a diameter of @var{d} with the leftmost point at the
5307 current position.
5308 @item \D'C @var{d}'
5309 Draw a solid circle with the same parameters as an outlined circle.
5310 @item \D'e @var{dx} @var{dy}'
5311 @cindex ellipses
5312 Draw an ellipse with a horizontal diameter of @var{dx} and a vertical
5313 diameter of @var{dy} with the leftmost point at the current position.
5314 @item \D'E @var{dx} @var{dy}'
5315 Draw a solid ellipse with the same parameters as an outlined ellipse.
5316 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
5317 @cindex arcs
5318 Draw an arc clockwise from the current location through the two
5319 specified locations (@var{dx1},@var{dy1}) and (@var{dx2},@var{dy2}).
5320 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
5321 @cindex splines
5322 Draw a spline from the current location to (@var{dx1},@var{dy1}) and
5323 then to (@var{dx2},@var{dy2}), and so on.
5324 @item \D'f @var{n}'
5325 @cindex gray shading
5326 @cindex shading
5327 Set the shade of gray to be used for filling solid objects to@w{
5328 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
5329 corresponds solid white and 1000 to solid black, and values in between
5330 correspond to intermediate shades of gray.  This applies only to solid
5331 circles, solid ellipses and solid polygons.  By default, a level of@w{
5332 }1000 will be used.
5333 @item \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
5334 @cindex polygons
5335 Draw a polygon from the current location to (@var{dx1},@var{dy1}) and
5336 then to (@var{dx2},@var{dy2}) and so on.  When the specified data points
5337 are exhausted, a line is drawn back to the starting point.
5339 @c XXX example
5341 @example
5342 ... box example (yes, again)...
5343 @end example
5345 @itemx \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
5346 Draw a solid polygon with the same parameters as an outlined polygon.
5348 @c XXX example
5350 @example
5351 ... shaded box example ...
5352 @end example
5354 @item \D't @var{n}'
5355 @cindex line thickness
5356 @cindex thickness of lines
5357 Set the current line thickness to @var{n} machine units.  A value of
5358 zero selects the smallest available line thickness.  A negative value
5359 makes the line thickness proportional to the current point size (this is
5360 the default behaviour of @code{ditroff}).
5361 @end table
5363 @findex \b
5364 @cindex pile, character
5365 @cindex character pile
5366 The @code{\b} escape will @dfn{pile} a sequence of characters
5367 vertically, and center it vertically on the current line.  This can be
5368 used to build large brackets and braces.
5370 @example
5371 \b'\(lt\(bv\(lk\(bv\(lb'
5372 @end example
5374 @xref{Drawing Functions}.
5376 @node Traps, Diversions, Drawing Requests, Programming Tutorial
5377 @section Traps
5378 @cindex traps
5380 @dfn{Traps} are locations, which, when reached, will call a specified
5381 macro.  These traps can occur at a given location on the page, at a
5382 given location in the current diversion, after a certain number of input
5383 lines or at the end of input.
5385 @menu
5386 * Page Location Traps::         
5387 * Diversion Traps::             
5388 * Input Line Traps::            
5389 * End-of-input Traps::          
5390 @end menu
5392 @node Page Location Traps, Diversion Traps, Traps, Traps
5393 @subsection Page Location Traps
5394 @cindex page location traps
5395 @cindex traps, page location
5397 @c XXX definition of wh request
5399 @cindex page headers
5400 @cindex page footers
5401 @cindex headers
5402 @cindex footers
5403 Page location traps are frequently used for page headers and footers.
5404 The following is a simple example of this.
5406 @example
5407 .de hd                \" Page header
5408 'sp .5i
5409 .tl 'Title''date'
5410 'sp .3i
5412 .de fo                \" Page footer
5413 'sp 1v
5414 .tl ''%''
5417 .wh 0   hd            \" trap at top of the page
5418 .wh -1i fo            \" trap one inch from bottom
5419 @end example
5421 @vindex .t
5422 @cindex distance to next trap
5423 @cindex trap, distance
5424 The number register @code{.t} is the distance to the next trap.
5426 @findex ch
5427 @cindex changing trap location
5428 @cindex trap, changing location
5429 The location of a trap can be changed later on with the @code{ch}
5430 request.  The first argument is the name of the macro to be invoked at
5431 the trap, and the second argument is the new location for the trap.
5432 This is useful for building up footnotes in a diversion to allow more
5433 space at the bottom of the page for them.
5435 @c XXX
5437 @example
5438 ... (simplified) footnote example ...
5439 @end example
5441 @findex vpt
5442 @findex wh
5443 @findex dt
5444 @vindex .vpt
5445 The @code{vpt} request will enable vertical position traps if the
5446 argument is non-zero, disable them otherwise.  Vertical position traps
5447 are traps set by the @code{wh} or @code{dt} requests.  Traps set by the
5448 @code{it} request are not vertical position traps.  The parameter that
5449 controls whether vertical position traps are enabled is global.
5450 Initially vertical position traps are enabled.  The current setting of
5451 this is available in the number register @code{.vpt}.
5453 @vindex .trunc
5454 @findex ne
5455 The number register @code{.trunc} contains the amount of vertical space
5456 truncated by the most recently sprung vertical position trap, or, if the
5457 trap was sprung by a @code{ne} request, minus the amount of vertical
5458 motion produced by the @code{ne} request.  In other words, at the point
5459 a trap is sprung, it represents the difference of what the vertical
5460 position would have been but for the trap, and what the vertical
5461 position actually is.
5463 @vindex .ne
5464 The number register @code{.ne} contains the amount of space that was
5465 needed in the last @code{ne} request that caused a trap to be sprung.
5466 Useful in conjunction with the @code{.trunc} register.  @xref{Page
5467 Control}, for more information.
5469 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
5470 @subsection Diversion Traps
5471 @cindex diversion traps
5472 @cindex traps, diversion
5474 @findex dt
5475 @vindex .t
5476 Traps can also be set @emph{within} a diversion using the @code{dt}
5477 request.  Like @code{wh} the first argument is the location of the trap
5478 and the second argument is the name of the macro to be invoked.  The
5479 number register @code{.t} will still work within diversions.
5480 @xref{Diversions}, for more information.
5482 @node Input Line Traps, End-of-input Traps, Diversion Traps, Traps
5483 @subsection Input Line Traps
5484 @cindex input line traps
5485 @cindex traps, input line
5487 @findex it
5488 The @code{it} request will set an input line trap.  The format for
5489 calling this is
5491 @example
5492 .it @var{n} @var{name}
5493 @end example
5495 @noindent
5496 where @var{n} is the number of lines of input which may be read before
5497 @dfn{springing} the trap, @var{name} is the macro to be invoked.
5498 Request lines are not counted as input lines.
5500 For example, one possible use is to have a macro which will print the
5501 next @var{n}@w{ }lines in a bold font.
5503 @example
5504 .de B
5505 .it B-end \\$1
5506 .ft B
5508 .de B-end
5509 .ft R
5511 @end example
5513 @node End-of-input Traps,  , Input Line Traps, Traps
5514 @subsection End-of-input Traps
5515 @cindex end-of-input traps
5516 @cindex traps, end-of-input
5518 @findex em
5519 The @code{em} request will set a trap at the end of input.  The macro
5520 specified as an argument will be executed after the last line of the
5521 input file has been processed.
5523 For example, if the document had to have a section at the bottom of the
5524 last page for someone to approve it, the @code{em} request could be
5525 used.
5527 @example
5528 .de approval
5529 .ne 5v
5530 .sp |(\\n(.t-6v)
5531 .in +4i
5532 .lc _
5534 Approved:\t\a
5536 Date:\t\t\a
5538 .em approval
5539 @end example
5542 @node Diversions, Environments, Traps, Programming Tutorial
5543 @section Diversions
5544 @cindex diversions
5546 In @code{gtroff} it is possible to @dfn{divert} text into a named
5547 storage area.  Due to the similarity to defining macros it is sometimes
5548 said to be stored in a macro.  This is used for saving text for output
5549 at a later time, which is useful for keeping blocks of text on the same
5550 page, footnotes, tables of contents and indices.
5552 @findex di
5553 @findex da
5554 A diversion is initiated by the @code{di} request.  Like the @code{de}
5555 request, it takes an argument of a macro name to divert subsequent text
5556 into.  The @code{da} macro will append to an existing diversion.
5558 @code{di} (resp.@: @code{da}) without an argument ends the diversion.
5560 @c XXX example
5562 @example
5563 ... end-note example ...
5564 @end example
5566 @vindex .z
5567 @vindex .d
5568 @vindex nl
5569 @vindex .h
5570 @cindex nested diversions
5571 @cindex diversion, nested
5572 Diversions may be nested.  The number register @code{.z} contains the
5573 name of the current diversion.  The number register @code{.d} contains
5574 the current vertical place in the diversion.  If not in a diversion it
5575 is the same as the register @code{nl}.
5577 @c XXX more info
5579 @code{.h}
5581 @vindex dn
5582 @vindex dl
5583 After completing a diversion, the built-in number registers @code{dn}
5584 and @code{dl} contain the vertical and horizontal size of the diversion.
5586 @example
5587 .\" Center text both horizontally & vertically
5588 .de (c
5591 .di @@c
5593 .de )c
5596 .nr @@s (((\\n(.tu-\\n(dnu)/2u)-1v)
5597 .sp \\n(@@su
5598 .ce 1000
5602 .ce 0
5603 .sp \\n(@@su
5606 .rr @@s
5608 @end example
5610 @findex \!
5611 @cindex transparent output
5612 @cindex output, transparent
5613 Requests, macros and escapes are interpreted when read into a diversion.
5614 There are two ways to prevent this; either way will take the given text
5615 and @dfn{transparently} embed it into the diversion.  The first method
5616 is to prefix the line with @code{\!}.  This will cause the entire line
5617 to be transparently inserted into the diversion.  This is useful for
5618 macros which shouldn't be invoked until the diverted text is actually
5619 output.
5621 @c XXX anything is read in copy mode. (what about \! ??)
5623 @findex \?
5624 The other way is to surround the text by the @code{\?} escape, i.e.
5626 @example
5627 \?@var{anything}\?
5628 @end example
5630 @noindent
5631 @var{anything} may not contain newlines; use @code{\!}  to embed
5632 newlines in a diversion.  The escape sequence @code{\?} is also
5633 recognized in copy mode and turned into a single internal code; it is
5634 this code that terminates anything.  Thus the following example will
5635 print@w{ }4.
5637 @example
5638 .nr x 1
5640 .di d
5641 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
5643 .nr x 2
5644 .di e
5647 .nr x 3
5648 .di f
5651 .nr x 4
5653 @end example
5655 @findex asciify
5656 @cindex unformatting diversions
5657 @cindex diversion, unformatting
5658 The @code{asciify} request only exists in order to make certain gross
5659 hacks work with GNU @code{troff}.  It @dfn{unformats} the diversion
5660 specified as an argument in such a way that @acronym{ASCII} characters
5661 that were formatted and diverted will be treated like ordinary input
5662 characters when the diversion is reread.  For example, the following
5663 will set register @code{n} to@w{ }1.
5665 @example
5666 .tr @@.
5667 .di x
5668 @@nr\ n\ 1
5671 .tr @@@@
5672 .asciify x
5674 @end example
5676 @xref{Copy-in Mode}.
5679 @node Environments, I/O, Diversions, Programming Tutorial
5680 @section Environments
5681 @cindex environments
5683 It happens frequently that some text should be printed in a certain
5684 format regardless of what may be in effect at the time, for example, in
5685 a trap invoked macro to print headers and footers.  To solve this
5686 @code{gtroff} has @dfn{environments} in which text is processed.  An
5687 environment contains most of the parameters that control text
5688 processing.  It is possible to switch amongst these environments; by
5689 default @code{gtroff} processes text in environment@w{ }0.  The
5690 following is the information kept in an environment.
5692 @itemize @bullet{}
5693 @item
5694 type size
5695 @item
5696 font (family and style)
5697 @item
5698 page parameters
5699 @item
5700 fill/adjust mode
5701 @item
5702 tab stops
5703 @item
5704 partially collected lines
5705 @end itemize
5707 These environments may be given arbitrary names (@pxref{Identifiers},
5708 for more info).  Old versions of @code{troff} only had environments
5709 named @samp{0}, @samp{1} and@w{ }@samp{2}.
5711 @findex ev
5712 @vindex .ev
5713 The @code{ev} request will switch among environments.  The single
5714 argument is the name of the environment to switch to.  With no argument
5715 @code{gtroff} will switch back to the previous environment.  There is no
5716 limit on the number of named environments; they will be created the
5717 first time that they are referenced.  The @code{.ev} register contains
5718 the name or number of the current environment.  This is a string-valued
5719 register.
5721 Note that a call to @code{ev} (with argument) will push the previously
5722 active environment onto a stack.  If, say, environments @samp{foo},
5723 @samp{bar}, and @samp{zap} are called (in that order), the first
5724 @code{ev} request without parameter will switch back to environment
5725 @samp{bar} (which will be popped off the stack), and a second call will
5726 switch back to environment @samp{foo}.
5728 @c XXX example
5730 @example
5731 ... page break macro, revised ...
5732 @end example
5734 Here another example:
5736 @example
5737 .ev footnote-env
5738 .fam N
5739 .ps 6
5740 .vs 8
5741 .ll -.5i
5744 .ev footnote-env
5745 \(dg Note the large, friendly letters.
5747 @end example
5749 @findex evc
5750 To copy an environment into the current one, use the @code{evc} request,
5751 which takes the name of the environment to copy from as an argument.
5754 @node I/O, Postprocessor Access, Environments, Programming Tutorial
5755 @section I/O
5756 @cindex i/o
5757 @cindex input and output requests
5758 @cindex requests for input and output
5759 @cindex output and input requests
5761 @findex so
5762 The @code{so} request will read in the file given as an argument and
5763 include it in place of the @code{so} request.  This is quite useful for
5764 large documents, i.e.@: keeping each chapter in a separate file.
5765 @xref{gsoelim}, for more information.
5767 @findex mso
5768 The @code{mso} request is the same as the @code{so} request except that
5769 the file is searched for in the same way that @file{tmac.@var{name}} is
5770 searched for when the @option{-m@var{name}} option is specified.
5772 @findex cf
5773 @cindex transparent output
5774 @cindex output, transparent
5775 The @code{cf} and @code{trf} requests are to include a file.  It will
5776 transparently output the contents of file filename.  Each line is output
5777 as it were preceded by @code{\!}; however, the lines are not subject to
5778 copy-mode interpretation.  If the file does not end with a newline, then
5779 a newline will be added.  For example, to define a macro@w{ }@code{x}
5780 containing the contents of file@w{ }@file{f}, use
5782 @example
5783 .di x
5784 .trf f
5786 @end example
5788 The request @w{@code{.cf @var{filename}}}, when used in a diversion,
5789 will embed in the diversion an object which, when reread, will cause the
5790 contents of @var{filename} to be transparently copied through to the
5791 output.  In @acronym{UNIX} @code{troff}, the contents of @var{filename}
5792 is immediately copied through to the output regardless of whether there
5793 is a current diversion; this behaviour is so anomalous that it must be
5794 considered a bug.  This request causes a line break.
5796 @findex trf
5797 With @code{trf}, unlike @code{cf}, the file cannot contain characters
5798 such as NUL that are not legal @code{gtroff} input characters.  This
5799 request causes a line break.
5801 @c XXX xref to illegal input characters
5803 @findex nx
5804 The @code{nx} request will force @code{gtroff} to continue processing of
5805 the file specified as an argument.
5807 @findex rd
5808 The @code{rd} request will read from standard input, and include what is
5809 read as though it were part of the input file.  Text is read until a
5810 blank line is encountered.
5812 @cindex form letters
5813 @cindex letters, form
5814 Using these two requests it is easy to set up form letters.  The form
5815 letter template is constructed like this:
5817 @example
5819 \*(td
5820 .sp 2
5826 Body of letter.
5828 .nx repeat.let
5829 @end example
5831 @findex ex
5832 @noindent
5833 When this is run, the following file should be redirected in.  Note that
5834 requests included in this file are executed as though they were part of
5835 the form letter.  The last block of input is the @code{ex} requests
5836 which tells groff to stop processing.  If this was not there, groff
5837 would not know when to stop.
5839 @example
5840 Trent A. Fisher
5841 708 NW 19th Av., #202
5842 Portland, OR  97209
5844 Dear Trent,
5846 Len Adollar
5847 4315 Sierra Vista
5848 San Diego, CA  92103
5850 Dear Mr. Adollar,
5853 @end example
5855 @findex pi
5856 @code{pi}
5858 @c XXX documentation
5860 @findex sy
5861 The @code{sy} request will allow arbitrary system commands to be
5862 executed from within a @code{gtroff} document.  The output is not saved
5863 anyplace, so it is up to the user to do so.
5865 @c XXX add info about safer and unsafe mode
5867 For example, the following example will introduce the current time
5868 into a document:
5870 @cindex time, current
5871 @cindex current time
5872 @pindex perl
5873 @example
5874 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
5875              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
5876 .so /tmp/x\n[$$]
5877 .sy rm /tmp/x\n[$$]
5878 \nH:\nM:\nS
5879 @end example
5881 @noindent
5882 Note that this works by having the @code{perl} script (run by @code{sy})
5883 print out the @code{nr} requests which will set the number registers
5884 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in with
5885 the @code{so} request.
5887 @vindex systat
5888 The @code{systat} number register contains the return value of the
5889 @code{system()} function executed by the last @code{sy} request.
5891 @findex open
5892 The @code{open} request will open a file (specified as the second
5893 argument) for writing and associate the stream (specified as the first
5894 argument) with it.
5896 @findex opena
5897 The @code{opena} is like @code{open}, but if the file exists, append to
5898 it instead of truncating it.
5900 @findex write
5901 @findex ds
5902 @cindex copy-in mode
5903 @cindex mode, copy-in
5904 The @code{write} request will write to the file associated with the
5905 stream specified by the first argument.  The stream must previously have
5906 been the subject of an open request.  The remainder of the line is
5907 interpreted as the @code{ds} request reads its second argument: A
5908 leading @samp{"} will be stripped, and it will be read in copy-in mode.
5910 @findex close
5911 The @code{close} request will close the stream specified by the first
5912 argument; stream will no longer be an acceptable argument to the
5913 @code{write} request.
5915 @c XXX example
5917 @example
5918 ... example of open write &c...
5919 @end example
5921 @findex \V
5922 The @code{\V} escape will interpolate the contents of the specified
5923 environment variable, as returned by @code{getenv()}.  The argument to
5924 @code{\V} is specified as an identifier, i.e.@: @samp{\V@var{x}},
5925 @samp{\V(@var{xx}} or @samp{\V[@var{xxx}]}.  @code{\V} is interpreted in
5926 copy-in mode.
5929 @node Postprocessor Access, Miscellaneous, I/O, Programming Tutorial
5930 @section Postprocessor Access
5931 @cindex postprocessor access
5932 @cindex access of postprocessor
5934 There are two escapes which will allow information to be directly given
5935 to the postprocessor.  This is particularly useful for embedding
5936 @sc{PostScript} into the final document.
5938 @findex \X
5939 The @code{\X} escape will embed its argument into the @code{gtroff}
5940 output preceded with @w{@samp{x X}}.
5942 @findex \Y
5943 The @code{\Y} escape is called with an identifier (i.e.@:
5944 @code{\Y@var{x}}, @code{\Y(@var{xx}} or @code{\Y[@var{xxx}]}).  This is
5945 approximately equivalent to @samp{\X'\*[@var{xxx}]'}.  However, the
5946 contents of the string or macro @var{xxx} are not interpreted; also it
5947 is permitted for @var{xxx} to have been defined as a macro and thus
5948 contain newlines (it is not permitted for the argument to @code{\X} to
5949 contain newlines).  The inclusion of newlines requires an extension to
5950 the @acronym{UNIX} @code{troff} output format, and will confuse drivers
5951 that do not know about this extension.
5953 @xref{Output Devices}.
5956 @node Miscellaneous, Debugging, Postprocessor Access, Programming Tutorial
5957 @section Miscellaneous
5958 @cindex miscellaneous
5960 This section contains parts of @code{gtroff} which cannot (yet) be
5961 categorized elsewhere in this manual.
5963 @findex nm
5964 @cindex line numbers
5965 @cindex numbers, line
5966 Line numbers can be printed in the left margin using the @code{nm}
5967 request.  The first argument is the line number of the @emph{next}
5968 output line; this defaults to@w{ }1.  The second argument indicates on
5969 which lines numbers will be printed, i.e.@: 5 means put line numbers on
5970 every 5@w{ }lines; this defaults to@w{ }1.  The third argument is the
5971 space to be left between the number and the text; this defaults to@w{
5972 }1.  The fourth argument is the indentation of the line numbers.
5973 Without arguments, line numbers are turned off.
5975 @c XXX xref ln register
5977 @findex nn
5978 The @code{nn} request will temporarily turn off line numbering.  The
5979 first argument is the number of lines not to be numbered; this defaults
5980 to@w{ }1.
5982 @c XXX (does this disable incrementing or display?)
5984 @c XXX example
5986 @example
5987 ... line numbering example ...
5988 @end example
5990 @findex mc
5991 @cindex margin characters
5992 @cindex characters for margins
5993 Margin characters can be automatically printed to the right of the text
5994 with the @code{mc} request.  The first argument is the character to be
5995 printed, and the second argument is the distance away from the main body
5996 text.  With no arguments the margin characters are turned off.  If this
5997 occurs before a break, no margin character will be printed.
5999 @pindex nrchbar
6000 @pindex changebar
6001 This is quite useful for indicating text that has changed, and, in fact,
6002 there are programs available for doing this (they are called
6003 @code{nrchbar} and @code{changebar} and can be found in any
6004 @samp{comp.sources.unix} archive.
6006 @c XXX example
6008 @example
6009 ... margin char example ...
6010 @end example
6012 @findex lf
6013 @pindex soelim
6014 @cindex multi-file documents
6015 @cindex documents, multi-file
6016 The primary reason for the existence of @code{lf} is to make debugging
6017 documents which are split into many files, which are then put together
6018 with @code{soelim} and other preprocessors.  The first argument is the
6019 name of the file and the second argument is the input line number in
6020 that file.  This way @code{gtroff} can produce error messages which are
6021 intelligible to the user.
6023 @c XXX example
6025 @example
6026 ... example of soelim'ed doc ...
6027 @end example
6030 @node Debugging, Implementation Differences, Miscellaneous, Programming Tutorial
6031 @section Debugging
6032 @cindex debugging
6034 @code{gtroff} is not easy to debug, but there are some useful features
6035 and strategies for debugging.
6037 @itemize @bullet{}
6038 @item
6039 @findex tm
6040 The @code{tm} request will send output to stderr; this is very useful
6041 for printing debugging output.
6042 @item
6043 When doing something involved it is useful to leave the debugging
6044 statements in the code and have them turned on by a command line flag.
6046 @example
6047 .if \n(DB .tm debugging output
6048 @end example
6050 @noindent
6051 To activate these statements say
6053 @example
6054 groff -rDB=1 file
6055 @end example
6057 @item
6058 @findex ab
6059 @cindex aborting
6060 The @code{ab} request is similar to the @code{tm} request, except that
6061 it will cause @code{gtroff} to stop processing.  With no argument it
6062 will print @samp{User Abort}.
6063 @item
6064 @findex ex
6065 @cindex exiting
6066 The @code{ex} request will also cause @code{gtroff} to stop processing
6067 (if encountered at the topmost level; see also @ref{I/O}.
6068 @item
6069 If it is known in advance that there will be many errors and no useful
6070 output, @code{gtroff} can be forced to suppress formatted output with
6071 the @option{-z} flag.
6072 @item
6073 @findex pm
6074 @cindex dumping symbol table
6075 @cindex symbol table, dumping
6076 The @code{pm} request will dump out the entire symbol table.
6077 @item
6078 @findex pnr
6079 @cindex dumping number registers
6080 @cindex number registers, dumping
6081 The @code{pnr} request will print the names and contents of all
6082 currently defined number registers on stderr.
6083 @item
6084 @findex ptr
6085 @cindex dumping traps
6086 @cindex traps, dumping
6087 The @code{ptr} request will print the names and positions of all traps
6088 (not including input line traps and diversion traps) on stderr.  Empty
6089 slots in the page trap list are printed as well, because they can affect
6090 the priority of subsequently planted traps.
6091 @item
6092 @findex fl
6093 @cindex flush output
6094 @cindex output, flush
6095 @cindex interactive use of @code{gtroff}
6096 @cindex @code{gtroff}, interactive use
6097 The @code{fl} request instructs @code{gtroff} to flush its output
6098 immediately.  The intention is that this be used when using
6099 @code{gtroff} interactively.  There is little other use for it.  This
6100 request causes a line break.
6101 @item
6102 @findex backtrace
6103 @cindex backtrace of input stack
6104 @cindex input stack, backtrace
6105 The @code{backtrace} request will print a backtrace of the input stack
6106 on stderr.
6107 @item
6108 @cindex warnings
6109 @code{gtroff} has command line options for printing out more warnings
6110 (@option{-w}) and for printing backtraces (@option{-b}) when a warning
6111 or an error occurs.  The most verbose level of warnings is @option{-ww}.
6112 @item
6113 @findex warn
6114 @vindex .warn
6115 @cindex level of warnings
6116 @cindex warnings, level
6117 The @code{warn} request controls the level of warnings checked for.  The
6118 only argument is the sum of the numbers associated with each warning
6119 that is to be enabled; all other warnings will be disabled.  The number
6120 associated with each warning is listed below.  For example,
6121 @w{@code{.warn 0}} will disable all warnings, and @w{@code{.warn 1}}
6122 will disable all warnings except that about missing characters.  If an
6123 argument is not given, all warnings will be enabled.  The number
6124 register @code{.warn} contains the current warning level.
6125 @end itemize
6127 @subsection Warnings
6128 @cindex warnings
6130 The warnings that can be given to @code{gtroff} are divided into the
6131 following categories.  The name associated with each warning is used by
6132 the @option{-w} and @option{-W} options; the number is used by the
6133 @code{warn} request and by the @code{.warn} register.
6135 @table @samp
6136 @item char
6137 @itemx 1
6138 Non-existent characters.  This is enabled by default.
6139 @item number
6140 @itemx 2
6141 Invalid numeric expressions.  This is enabled by default.
6142 @xref{Expressions}.
6143 @item break
6144 @itemx 4
6145 In fill mode, lines which could not be broken so that their length was
6146 less than the line length.  This is enabled by default.
6147 @item delim
6148 @itemx 8
6149 Missing or mismatched closing delimiters.
6150 @item el
6151 @itemx 16
6152 @findex ie
6153 @findex el
6154 Use of the @code{el} request with no matching @code{ie} request.
6155 @xref{if-else}.
6156 @item scale
6157 @itemx 32
6158 Meaningless scaling indicators.
6159 @item range
6160 @itemx 64
6161 Out of range arguments.
6162 @item syntax
6163 @itemx 128
6164 Dubious syntax in numeric expressions.
6165 @item di
6166 @itemx 256
6167 @findex di
6168 @findex da
6169 Use of @code{di} or @code{da} without an argument when there is no
6170 current diversion.
6171 @item mac
6172 @itemx 512
6173 @findex de
6174 @c XXX more findex entries
6175 Use of undefined strings, macros and diversions.  When an undefined
6176 string, macro or diversion is used, that string is automatically defined
6177 as empty.  So, in most cases, at most one warning will be given for each
6178 name.
6179 @item  reg
6180 @itemx 1024
6181 @findex nr
6182 @c XXX more findex entries
6183 Use of undefined number registers.  When an undefined number register is
6184 used, that register is automatically defined to have a value of@w{ }0.
6185 A definition is automatically made with a value of@w{ }0.  So, in most
6186 cases, at most one warning will be given for use of a particular name.
6187 @item  tab
6188 @itemx 2048
6189 Use of a tab character where a number was expected.
6190 @item  right-brace
6191 @itemx 4096
6192 @findex \@}
6193 Use of @code{\@}} where a number was expected.
6194 @item  missing
6195 @itemx 8192
6196 Requests that are missing non-optional arguments.
6197 @item  input
6198 @itemx 16384
6199 Illegal input characters.
6200 @item  escape
6201 @itemx 32768
6202 Unrecognized escape sequences.  When an unrecognized escape sequence is
6203 encountered, the escape character is ignored.
6204 @item  space
6205 @itemx 65536
6206 @cindex compatibility mode
6207 Missing space between a request or macro and its argument.  This warning
6208 will be given when an undefined name longer than two characters is
6209 encountered, and the first two characters of the name make a defined
6210 name.  The request or macro will not be invoked.  When this warning is
6211 given, no macro is automatically defined.  This is enabled by default.
6212 This warning will never occur in compatibility mode.
6213 @item  font
6214 @itemx 131072
6215 Non-existent fonts.  This is enabled by default.
6216 @item all
6217 All warnings except @samp{di}, @samp{mac} and @samp{reg}.  It is
6218 intended that this covers all warnings that are useful with traditional
6219 macro packages.
6220 @item w
6221 All warnings.
6222 @end table
6225 @node Implementation Differences, Summary, Debugging, Programming Tutorial
6226 @section Implementation Differences
6227 @cindex implementation differences
6228 @cindex differences in implementation
6229 @cindex compatibility mode
6230 @cindex mode, compatibility
6232 GNU @code{troff} has a number of features which cause incompatibilities
6233 with documents written with old versions of @code{troff}.
6235 @cindex long names
6236 @cindex names, long
6237 Long names cause some incompatibilities.  @acronym{UNIX} @code{troff}
6238 will interpret
6240 @example
6241 .dsabcd
6242 @end example
6244 @findex \*
6245 @findex \n
6246 @findex cp
6247 @vindex .C
6248 @noindent
6249 as defining a string @samp{ab} with contents @samp{cd}.  Normally, GNU
6250 @code{troff} will interpret this as a call of a macro named
6251 @code{dsabcd}.  Also @acronym{UNIX} @code{troff} will interpret
6252 @code{\*[} or @code{\n[} as references to a string or number register
6253 called @samp{[}.  In GNU @code{troff}, however, this will normally be
6254 interpreted as the start of a long name.  In compatibility mode GNU
6255 @code{troff} will interpret these things in the traditional way.  In
6256 compatibility mode, however, long names are not recognized.
6257 Compatibility mode can be turned on with the @option{-C} command line
6258 option, and turned on or off with the @code{cp} request.  The number
6259 register @code{.C} is@w{ }1 if compatibility mode is on, 0@w{
6260 }otherwise.
6262 @findex \A
6263 @findex \|
6264 @findex \^
6265 @findex \&
6266 @findex \@}
6267 @findex \@{
6268 @findex \@key{SP}
6269 @findex \'
6270 @findex \`
6271 @findex \-
6272 @findex \_
6273 @findex \!
6274 @findex \%
6275 @findex \c
6276 GNU @code{troff} does not allow the use of the escape sequences
6277 @code{\|}, @code{\^}, @code{\&}, @code{\@}}, @code{\@{},
6278 @code{\@key{SP}}, @code{\'}, @code{\`}, @code{\-}, @code{\_}, @code{\!},
6279 @code{\%}, and @code{\c} in names of strings, macros, diversions, number
6280 registers, fonts or environments; @acronym{UNIX} @code{troff} does.  The
6281 @code{\A} escape sequence (@pxref{Identifiers}) may be helpful in
6282 avoiding use of these escape sequences in names.
6284 @cindex fractional point sizes
6285 @cindex point sizes, fractional
6286 @findex ps
6287 Fractional point sizes cause one noteworthy incompatibility.  In
6288 @acronym{UNIX} @code{troff} the @code{ps} request ignores scale
6289 indicators and thus
6291 @example
6292 .ps 10u
6293 @end example
6295 @noindent
6296 will set the point size to 10@w{ }points, whereas in GNU @code{troff} it
6297 will set the point size to 10@w{ }scaled points.  @xref{Fractional Type
6298 Sizes}, for more information.
6300 @findex bd
6301 @findex cs
6302 @findex tkf
6303 @findex tr
6304 @findex fp
6305 @cindex input and output characters
6306 @cindex output characters
6307 @cindex characters, input and output
6308 In GNU @code{troff} there is a fundamental difference between
6309 unformatted, input characters, and formatted, output characters.
6310 Everything that affects how an output character will be output is stored
6311 with the character; once an output character has been constructed it is
6312 unaffected by any subsequent requests that are executed, including
6313 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp} requests.
6314 Normally output characters are constructed from input characters at the
6315 moment immediately before the character is added to the current output
6316 line.  Macros, diversions and strings are all, in fact, the same type of
6317 object; they contain lists of input characters and output characters in
6318 any combination.  An output character does not behave like an input
6319 character for the purposes of macro processing; it does not inherit any
6320 of the special properties that the input character from which it was
6321 constructed might have had.  For example,
6323 @example
6324 .di x
6325 \\\\
6329 @end example
6331 @findex \e
6332 @findex \!
6333 @findex \?
6334 @cindex transparent output
6335 @cindex output, transparent
6336 @noindent
6337 will print @samp{\\} in GNU @code{troff}; each pair of input backslashes
6338 is turned into one output backslash and the resulting output backslashes
6339 are not interpreted as escape characters when they are reread.
6340 @acronym{UNIX} @code{troff} would interpret them as escape characters
6341 when they were reread and would end up printing one @samp{\}.  The
6342 correct way to obtain a printable backslash is to use the @code{\e}
6343 escape sequence: This will always print a single instance of the current
6344 escape character, regardless of whether or not it is used in a
6345 diversion; it will also work in both GNU @code{troff} and @acronym{UNIX}
6346 @code{troff}.  To store, for some reason, an escape sequence in a
6347 diversion that will be interpreted when the diversion is reread, either
6348 use the traditional @code{\!} transparent output facility, or, if this
6349 is unsuitable, the new @code{\?} escape sequence.
6351 @xref{Diversions}, for more information.
6354 @node Summary,  , Implementation Differences, Programming Tutorial
6355 @section Summary
6356 @cindex summary
6358 @c XXX documentation
6362 @node Preprocessors, Output Devices, Programming Tutorial, Top
6363 @chapter Preprocessors
6364 @cindex preprocessors
6366 This chapter describes all preprocessors that come with @code{groff} or
6367 which are freely available.
6369 @menu
6370 * geqn::                        
6371 * gtbl::                        
6372 * gpic::                        
6373 * ggrn::                        
6374 * grap::                        
6375 * grefer::                      
6376 * gsoelim::                     
6377 @end menu
6380 @node geqn, gtbl, Preprocessors, Preprocessors
6381 @section @code{geqn}
6382 @cindex @code{eqn}
6383 @cindex @code{geqn}
6385 @c XXX
6387 @menu
6388 * Invoking geqn::               
6389 @end menu
6391 @node Invoking geqn,  , geqn, geqn
6392 @subsection Invoking @code{geqn}
6393 @cindex invoking @code{geqn}
6394 @cindex @code{geqn}, invoking
6396 @c XXX
6399 @node gtbl, gpic, geqn, Preprocessors
6400 @section @code{gtbl}
6401 @cindex @code{tbl}
6402 @cindex @code{gtbl}
6404 @c XXX
6406 @menu
6407 * Invoking gtbl::               
6408 @end menu
6410 @node Invoking gtbl,  , gtbl, gtbl
6411 @subsection Invoking @code{gtbl}
6412 @cindex invoking @code{gtbl}
6413 @cindex @code{gtbl}, invoking
6415 @c XXX
6418 @node gpic, ggrn, gtbl, Preprocessors
6419 @section @code{gpic}
6420 @cindex @code{pic}
6421 @cindex @code{gpic}
6423 @c XXX
6425 @menu
6426 * Invoking gpic::               
6427 @end menu
6429 @node Invoking gpic,  , gpic, gpic
6430 @subsection Invoking @code{gpic}
6431 @cindex invoking @code{gpic}
6432 @cindex @code{gpic}, invoking
6434 @c XXX
6437 @node ggrn, grap, gpic, Preprocessors
6438 @section @code{ggrn}
6439 @cindex @code{grn}
6440 @cindex @code{ggrn}
6442 @c XXX
6444 @menu
6445 * Invoking ggrn::               
6446 @end menu
6448 @node Invoking ggrn,  , ggrn, ggrn
6449 @subsection Invoking @code{ggrn}
6450 @cindex invoking @code{ggrn}
6451 @cindex @code{ggrn}, invoking
6453 @c XXX
6456 @node grap, grefer, ggrn, Preprocessors
6457 @section @code{grap}
6458 @cindex @code{grap}
6460 A freely available implementation of @code{grap}, written by Ted Faber,
6461 is available as an extra package from the following address:
6463 @display
6464 @url{http://www.lunabase.org/~faber/Vault/software/grap/}
6465 @end display
6468 @node grefer, gsoelim, grap, Preprocessors
6469 @section @code{grefer}
6470 @cindex @code{refer}
6471 @cindex @code{grefer}
6473 @c XXX
6475 @menu
6476 * Invoking grefer::             
6477 @end menu
6479 @node Invoking grefer,  , grefer, grefer
6480 @subsection Invoking @code{grefer}
6481 @cindex invoking @code{grefer}
6482 @cindex @code{grefer}, invoking
6484 @c XXX
6487 @node gsoelim,  , grefer, Preprocessors
6488 @section @code{gsoelim}
6489 @cindex @code{soelim}
6490 @cindex @code{gsoelim}
6492 @c XXX
6494 @menu
6495 * Invoking gsoelim::            
6496 @end menu
6498 @node Invoking gsoelim,  , gsoelim, gsoelim
6499 @subsection Invoking @code{gsoelim}
6500 @cindex invoking @code{gsoelim}
6501 @cindex @code{gsoelim}, invoking
6503 @c XXX
6507 @node Output Devices, File formats, Preprocessors, Top
6508 @chapter Output Devices
6509 @cindex output devices
6510 @cindex devices for output
6512 @c XXX
6514 @menu
6515 * Special Characters::          
6516 * grotty::                      
6517 * grops::                       
6518 * grodvi::                      
6519 * grolj4::                      
6520 * grolbp::                      
6521 * grohtml::                     
6522 * gxditview::                   
6523 @end menu
6526 @node Special Characters, grotty, Output Devices, Output Devices
6527 @section Special Characters
6528 @cindex special characters
6529 @cindex characters, special
6531 @c XXX
6533 @xref{Font Files}.
6536 @node grotty, grops, Special Characters, Output Devices
6537 @section @code{grotty}
6538 @cindex @code{grotty}
6540 @c XXX
6542 @menu
6543 * Invoking grotty::             
6544 @end menu
6546 @node Invoking grotty,  , grotty, grotty
6547 @subsection Invoking @code{grotty}
6548 @cindex invoking @code{grotty}
6549 @cindex @code{grotty}, invoking
6551 @c XXX
6554 @node grops, grodvi, grotty, Output Devices
6555 @section @code{grops}
6556 @cindex @code{grops}
6558 @c XXX
6560 @menu
6561 * Invoking grops::              
6562 * Embedding PostScript::        
6563 @end menu
6565 @node Invoking grops, Embedding PostScript, grops, grops
6566 @subsection Invoking @code{grops}
6567 @cindex invoking @code{grops}
6568 @cindex @code{grops}, invoking
6570 @c XXX
6572 @node Embedding PostScript,  , Invoking grops, grops
6573 @subsection Embedding @sc{PostScript}
6574 @cindex embedding postscript
6575 @cindex postscript, embedding
6577 @c XXX
6580 @node grodvi, grolj4, grops, Output Devices
6581 @section @code{grodvi}
6582 @cindex @code{grodvi}
6584 @c XXX
6586 @menu
6587 * Invoking grodvi::             
6588 @end menu
6590 @node Invoking grodvi,  , grodvi, grodvi
6591 @subsection Invoking @code{grodvi}
6592 @cindex invoking @code{grodvi}
6593 @cindex @code{grodvi}, invoking
6595 @c XXX
6598 @node grolj4, grolbp, grodvi, Output Devices
6599 @section @code{grolj4}
6600 @cindex @code{grolj4}
6602 @c XXX
6604 @menu
6605 * Invoking grolj4::             
6606 @end menu
6608 @node Invoking grolj4,  , grolj4, grolj4
6609 @subsection Invoking @code{grolj4}
6610 @cindex invoking @code{grolj4}
6611 @cindex @code{grolj4}, invoking
6613 @c XXX
6616 @node grolbp, grohtml, grolj4, Output Devices
6617 @section @code{grolbp}
6618 @cindex @code{grolbp}
6620 @c XXX
6622 @menu
6623 * Invoking grolbp::             
6624 @end menu
6626 @node Invoking grolbp,  , grolbp, grolbp
6627 @subsection Invoking @code{grolbp}
6628 @cindex invoking @code{grolbp}
6629 @cindex @code{grolbp}, invoking
6631 @c XXX
6634 @node grohtml, gxditview, grolbp, Output Devices
6635 @section @code{grohtml}
6636 @cindex @code{grohtml}
6638 @c XXX
6640 @menu
6641 * Invoking grohtml::            
6642 @end menu
6644 @node Invoking grohtml,  , grohtml, grohtml
6645 @subsection Invoking @code{grohtml}
6646 @cindex invoking @code{grohtml}
6647 @cindex @code{grohtml}, invoking
6649 @c XXX
6652 @node gxditview,  , grohtml, Output Devices
6653 @section @code{gxditview}
6654 @cindex @code{gxditview}
6656 @c XXX
6658 @menu
6659 * Invoking gxditview::          
6660 @end menu
6662 @node Invoking gxditview,  , gxditview, gxditview
6663 @subsection Invoking @code{gxditview}
6664 @cindex invoking @code{gxditview}
6665 @cindex @code{gxditview}, invoking
6667 @c XXX
6668 @c X11's xditview
6672 @node File formats, Installation, Output Devices, Top
6673 @chapter File formats
6674 @cindex file formats
6675 @cindex formats, file
6677 @c XXX
6679 @menu
6680 * gtroff Output::               
6681 * Font Files::                  
6682 @end menu
6685 @node gtroff Output, Font Files, File formats, File formats
6686 @section @code{gtroff} Output
6687 @cindex @code{gtroff} output
6688 @cindex output, @code{gtroff}
6690 This section describes the format output of GNU @code{troff}.  The
6691 output format used by GNU @code{troff} is very similar to that used by
6692 @acronym{UNIX} device-independent @code{troff} (@code{ditroff}).
6694 @menu
6695 * Output Format::               
6696 * Device Control::              
6697 * Drawing Functions::           
6698 * Line Continuation::           
6699 @end menu
6701 @node Output Format, Device Control, gtroff Output, gtroff Output
6702 @subsection Output Format
6703 @cindex output format
6704 @cindex format of output
6706 @cindex 8-bit input
6707 @cindex input, 8-bit
6708 The output format is text based, as opposed to a binary format (like
6709 @TeX{} DVI).  The output format is @w{8-bit} clean, thus single
6710 characters can have the eighth bit set, as can the names of fonts and
6711 special characters.
6713 The output format consists of single command characters with attached
6714 parameters which are separated from subsequent text by whitespace or a
6715 newline.
6717 The names of characters and fonts can be of arbitrary length; drivers
6718 should not assume that they will be only two characters long (as
6719 @code{ditroff} does).
6721 When a character is to be printed, that character will always be in the
6722 current font.  Unlike @code{ditroff}, it is not necessary for drivers to
6723 search special fonts to find a character.
6725 @table @code
6726 @item H@var{n}
6727 @c XXX
6728 @item V@var{n}
6729 @c XXX
6730 @item h@var{n}
6731 @c XXX
6732 @item v@var{n}
6733 @c XXX
6734 @item c@var{n}
6735 @c XXX
6736 @item C@var{n}
6737 @c XXX
6738 @item @var{nn}@var{c}
6739 @c XXX
6740 @item t@var{xxx}
6741 @var{xxx} is any sequence of characters terminated by a space or a
6742 newline; the first character should be printed at the current position,
6743 the the current horizontal position should be increased by the width of
6744 the first character, and so on for each character.  The width of the
6745 character is that given in the font file, appropriately scaled for the
6746 current point size, and rounded so that it is a multiple of the
6747 horizontal resolution.  Special characters cannot be printed using this
6748 command.
6750 @kindex tcommand
6751 @pindex DESC
6752 This command is only allowed if the @samp{tcommand} line is present in
6753 the @file{DESC} file.
6754 @item u@var{n} @var{xxx}
6755 This is same as the @samp{t} command except that after printing each
6756 character, the current horizontal position is increased by the sum of
6757 the width of that character and@w{ }@var{n}.
6759 This command is only allowed if the @samp{tcommand} line is present in
6760 the @file{DESC} file.
6761 @item n@var{a}@var{b}
6762 @c XXX
6763 @item p@var{n}
6764 @c XXX
6765 @item s@var{n}
6766 @kindex sizescale
6767 @pindex DESC
6768 The argument to the @samp{s} command is in scaled points (units of
6769 points/@var{n}, where @var{n} is the argument to the @samp{sizescale}
6770 command in the @file{DESC} file).
6771 @item f@var{n}
6772 @item x @dots{} \n
6773 Device control.
6774 @c XXX more info
6775 @item D@var{c} @var{x}@dots{}\n
6776 @c XXX
6777 @end table
6779 @node Device Control, Drawing Functions, Output Format, gtroff Output
6780 @subsection Device Control
6781 @cindex device control
6782 @cindex control of devices
6784 The @samp{x} command is normally followed by a letter or word indicating
6785 the function to perform, followed by white space separated arguments.
6787 The first argument can be abbreviated to the first letter.
6789 @table @code
6790 @item x init
6791 @c XXX
6792 @item x T
6793 @c XXX
6794 @item x res @var{n} @var{h} @var{v}
6795 @c XXX
6796 @item x H
6797 @c XXX more info
6798 The argument to the @w{@samp{x Height}} command is also in scaled
6799 points.
6800 @end table
6802 The first three output commands are guaranteed to be:
6804 @example
6805 x T device
6806 x res n h v
6807 x init
6808 @end example
6810 @noindent
6811 For example, the input
6813 @example
6814 crunchy \fH\s+2frog\s0\fP!?
6815 @end example
6817 @noindent
6818 will produce
6820 @c XXX example
6822 @example
6823 ... sample output here ...
6824 @end example
6826 @node Drawing Functions, Line Continuation, Device Control, gtroff Output
6827 @subsection Drawing Functions
6828 @cindex drawing functions
6829 @cindex functions for drawing
6831 @pindex gpic
6832 The @samp{D} drawing command has been extended.  These extensions will
6833 only be used by GNU @code{pic} if the @option{-x} option is given.
6835 @xref{Drawing Requests}.
6837 @table @code
6838 @c XXX ...
6839 @item Df @var{n}
6840 Set the shade of gray to be used for filling solid objects to@w{
6841 }@var{n}; @var{n}@w{ }must be an integer between 0 and@w{ }1000, where 0
6842 corresponds solid white and 1000 to solid black, and values in between
6843 correspond to intermediate shades of gray.  This applies only to solid
6844 circles, solid ellipses and solid polygons.  By default, a level of@w{
6845 }1000 will be used.  Whatever color a solid object has, it should
6846 completely obscure everything beneath it.  A value greater than@w{ }1000
6847 or less than@w{ }0 can also be used: this means fill with the shade of
6848 gray that is currently being used for lines and text.  Normally this
6849 will be black, but some drivers may provide a way of changing this.
6850 @item DC @var{d}
6851 Draw a solid circle with a diameter of@w{ }@var{d} with the leftmost
6852 point at the current position.
6853 @item DE @var{dx} @var{dy}
6854 Draw a solid ellipse with a horizontal diameter of@w{ }@var{dx} and a
6855 vertical diameter of@w{ }@var{dy} with the leftmost point at the current
6856 position.
6857 @item Dp @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
6858 Draw a polygon with.  The first vertex is at the current position, the
6859 second vertex at an offset (@var{dx1},@var{dy1}) from the current
6860 position, the second vertex at an offset (@var{dx2},@var{dy2}) from the
6861 first vertex, and so on up to the @var{n}-th vertex.  At the moment, GNU
6862 @code{pic} only uses this command to generate triangles and rectangles.
6863 @item DP @var{dx1} @var{dy1} @var{dx2} @var{dy2} @dots{} @var{dxn} @var{dyn}
6864 Like @code{Dp} but draw a solid rather than outlined polygon.
6865 @item Dt @var{n}
6866 @cindex line thickness
6867 @cindex thickness of lines
6868 Set the current line thickness to @var{n}@w{ }machine units.
6869 Traditionally, @acronym{UNIX} @code{troff} drivers use a line thickness
6870 proportional to the current point size; drivers should continue to do
6871 this if no @code{Dt} command has been given, or if a @code{Dt} command
6872 has been given with a negative value of@w{ }@var{n}.  A zero value of@w{
6873 }@var{n} selects the smallest available line thickness.
6874 @end table
6876 @findex \D
6877 A difficulty arises in how the current position should be changed after
6878 the execution of these commands.  This is not of great importance since
6879 the code generated by GNU @code{pic} does not depend on this.  Given a
6880 drawing command of the form
6882 @example
6883 \D'@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}'
6884 @end example
6886 @findex \w
6887 @vindex st
6888 @findex sb
6889 @noindent
6890 where @var{c} is not one of @samp{c}, @samp{e}, @samp{l}, @samp{a} or
6891 @samp{~}, @acronym{UNIX} @code{troff} will treat each of the x@w{ }value
6892 as a horizontal quantity, and each of the y@w{ }values as a vertical
6893 quantity and will assume that the width of the drawn object is sum if
6894 all x@w{ }values, and that the height is the sum of all y@w{ }values.
6895 (The assumption about the height can be seen by examining the @code{st}
6896 and @code{sb} registers after using such a @code{D}@w{ }command in a
6897 @code{\w} escape sequence.)  This rule also holds for all the original
6898 drawing commands with the exception of @code{De}.  For the sake of
6899 compatibility GNU @code{troff} also follows this rule, even though it
6900 produces an ugly result in the case of the @code{Df}, @code{Dt}, and, to
6901 a lesser extent, @code{DE}@w{ }commands.  Thus after executing a
6902 @code{D}@w{ }command of the form
6904 @example
6905 D@var{c} @var{x1} @var{y1} @var{x2} @var{y2} @dots{} @var{xn} @var{yn}
6906 @end example
6908 @noindent
6909 the current position should be increased horizontally by the sum of all
6910 x@w{ }values and vertically by the sum of all y@w{ }values.
6912 @node Line Continuation,  , Drawing Functions, gtroff Output
6913 @subsection Line Continuation
6914 @cindex line continuation in output commands
6915 @cindex output commands, line continuation
6917 There is a continuation convention which permits the argument to the
6918 @w{@samp{x X}} command to contain newlines: When outputting the argument
6919 to the @w{@samp{x X}} command, GNU @code{troff} will follow each newline
6920 in the argument with a @samp{+} character (as usual, it will terminate
6921 the entire argument with a newline); thus if the line after the line
6922 containing the @w{@samp{x X}} command starts with @samp{+}, then the
6923 newline ending the line containing the @w{@samp{x X}} command should be
6924 treated as part of the argument to the @w{@samp{x X}} command, the
6925 @samp{+} should be ignored, and the part of the line following the
6926 @samp{+} should be treated like the part of the line following the
6927 @w{@samp{x X}} command.
6930 @node Font Files,  , gtroff Output, File formats
6931 @section Font Files
6932 @cindex font files
6933 @cindex files, font
6935 The @code{gtroff} font format is roughly a superset of the
6936 @code{ditroff} font format.  Unlike the @code{ditroff} font format,
6937 there is no associated binary format; all files are text files.  The
6938 font files for device @var{name} are stored in a directory
6939 @file{dev@var{name}}.  There are two types of file: a device description
6940 file called @file{DESC} and for each font@w{ }@samp{F} a font file
6941 called@w{ }@file{F}.
6943 @menu
6944 * DESC file format::            
6945 * Font file format::            
6946 @end menu
6948 @node DESC file format, Font file format, Font Files, Font Files
6949 @subsection @file{DESC} file format
6950 @cindex @file{DESC} file format
6951 @cindex font description file format
6952 @cindex format of font description file
6953 @pindex DESC
6955 The @file{DESC} file can contain the following types of line:
6957 @table @code
6958 @kindex res
6959 @item res @var{n}
6960 There are @var{n} machine units per inch.
6961 @kindex hor
6962 @item hor @var{n}
6963 The horizontal resolution is @var{n} machine units.
6964 @kindex vert
6965 @item vert @var{n}
6966 The vertical resolution is @var{n} machine units.
6967 @kindex sizescale
6968 @item sizescale @var{n}
6969 The scale factor for point sizes.  By default this has a value of@w{ }1.
6970 One scaled point is equal to one point/@var{n}.  The arguments to the
6971 @code{unitwidth} and @code{sizes} commands are given in scaled points.
6972 @xref{Fractional Type Sizes}, for more information.
6973 @kindex unitwidth
6974 @item unitwidth @var{n}
6975 Quantities in the font files are given in machine units for fonts whose
6976 point size is @var{n}@w{ }scaled points.
6977 @kindex tcommand
6978 @item tcommand
6979 This means that the postprocessor can handle the @samp{t} and @samp{u}
6980 output commands.
6981 @kindex sizes
6982 @item sizes @var{s1} @var{s2} @dots{} @var{sn} 0
6983 This means that the device has fonts at @var{s1}, @var{s2}, @dots{}
6984 @var{sn} scaled points.  The list of sizes must be terminated by a@w{
6985 }0.  Each @var{si} can also be a range of sizes @var{m}-@var{n}.  The
6986 list can extend over more than one line.
6987 @kindex styles
6988 @item styles @var{S1} @var{S2} @dots{} @var{Sm}
6989 The first @var{m}@w{ }font positions will be associated with styles
6990 @var{S1} @dots{} @var{Sm}.
6991 @kindex fonts
6992 @item fonts @var{n} @var{F1} @var{F2} @var{F3} @dots{} @var{Fn}
6993 Fonts @var{F1} @dots{} @var{Fn} will be mounted in the font positions
6994 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m} is the number of
6995 styles.  This command may extend over more than one line.  A font name
6996 of@var{ }0 will cause no font to be mounted on the corresponding font
6997 position.
6998 @kindex family
6999 @item family @var{fam}
7000 The default font family is @var{fam}.
7001 @kindex charset
7002 @item charset
7003 This line and everything following in the file are ignored.  It is
7004 allowed for the sake of backwards compatibility.
7005 @end table
7007 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
7008 are compulsory.  Other commands are ignored by @code{gtroff} but may be
7009 used by postprocessors to store arbitrary information about the device
7010 in the @file{DESC} file.
7012 @c XXX add other commands resp. xrefs to output devices
7013 @c XXX add obsolete commands
7015 @node Font file format,  , DESC file format, Font Files
7016 @subsection Font file format
7017 @cindex font file format
7018 @cindex format of font files
7020 A font file has two sections.  The first section is a sequence of lines
7021 each containing a sequence of blank delimited words; the first word in
7022 the line is a key, and subsequent words give a value for that key.
7024 @table @code
7025 @kindex name
7026 @item name @var{F}
7027 The name of the font is@w{ }@var{F}.
7028 @kindex spacewidth
7029 @item spacewidth @var{n}
7030 The normal width of a space is@w{ }@var{n}.
7031 @kindex slant
7032 @item slant @var{n}
7033 The characters of the font have a slant of @var{n}@w{ }degrees.
7034 (Positive means forward.)
7035 @kindex ligatures
7036 @item ligatures @var{lig1} @var{lig2} @dots{} @var{lign} [0]
7037 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
7038 possible ligatures are @samp{ff}, @samp{fi}, @samp{fl}, @samp{ffi} and
7039 @samp{ffl}.  For backwards compatibility, the list of ligatures may be
7040 terminated with a@w{ }0.  The list of ligatures may not extend over more
7041 than one line.
7042 @kindex special
7043 @item special
7044 The font is special; this means that when a character is requested that
7045 is not present in the current font, it will be searched for in any
7046 special fonts that are mounted.
7047 @end table
7049 Other commands are ignored by @code{gtroff} but may be used by
7050 postprocessors to store arbitrary information about the font in the font
7051 file.
7053 @cindex comments in font files
7054 @cindex font files, comments
7055 @kindex #
7056 The first section can contain comments which start with the @samp{#}
7057 character and extend to the end of a line.
7059 The second section contains one or two subsections.  It must contain a
7060 @code{charset} subsection and it may also contain a @code{kernpairs}
7061 subsection.  These subsections can appear in any order.  Each
7062 subsection starts with a word on a line by itself.
7064 @kindex charset
7065 The word @code{charset} starts the character set subsection.  The
7066 @code{charset} line is followed by a sequence of lines.  Each line gives
7067 information for one character.  A line comprises a number of fields
7068 separated by blanks or tabs.  The format is
7070 @c XXX fix it for new HTML additions
7072 @example
7073 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
7074 @end example
7076 @cindex 8-bit input
7077 @cindex input, 8-bit
7078 @findex \N
7079 @kindex ---
7080 @noindent
7081 @var{name} identifies the character: If @var{name} is a single
7082 character@w{ }@var{c} then it corresponds to the @code{gtroff} input
7083 character @var{c}; if it is of the form @samp{\@var{c}} where @var{c} is
7084 a single character, then it corresponds to the @code{gtroff} input
7085 character@w{ }\@var{c}; otherwise it corresponds to the groff input
7086 character @samp{\[@var{name}]}.  (If it is exactly two characters
7087 @var{xx} it can be entered as @samp{\(@var{xx}}.)  @code{gtroff}
7088 supports 8-bit characters; however some utilities have difficulties with
7089 eight-bit characters.  For this reason, there is a convention that the
7090 name @samp{char@var{n}} is equivalent to the single character whose code
7091 is@w{ }@var{n}.  For example, @samp{char163} would be equivalent to the
7092 character with code@w{ }163 which is the pounds sterling sign in @w{ISO
7093 Latin-1} character set.  The name @samp{---} is special and indicates
7094 that the character is unnamed; such characters can only be used by means
7095 of the @code{\N} escape sequence in @code{gtroff}.
7097 @c XXX input encodings vs. output encodings
7099 The @var{type} field gives the character type:
7101 @table @code
7102 @item 1
7103 the character has an descender, for example, `p';
7104 @item 2
7105 the character has an ascender, for example, `b';
7106 @item 3
7107 the character has both an ascender and a descender, for example, `('.
7108 @end table
7110 The @var{code} field gives the code which the postprocessor uses to
7111 print the character.  The character can also be input to @code{gtroff}
7112 using this code by means of the @code{\N} escape sequence.  The code can
7113 be any integer.  If it starts with @samp{0} it will be interpreted as
7114 octal; if it starts with @samp{0x} or @samp{0X} it will be interpreted as
7115 hexadecimal.
7117 Anything on the line after the @var{code} field will be ignored.
7119 The @var{metrics} field has the form:
7121 @example
7122 @var{width}[,@var{height}[,@var{depth}[,@var{italic_correction}
7123   [,@var{left_italic_correction}[,@var{subscript_correction}]]]]]
7124 @end example
7126 @noindent
7127 There must not be any spaces between these subfields (it has been split
7128 here into two lines for better legibility only).  Missing subfields are
7129 assumed to be@w{ }0.  The subfields are all decimal integers.  Since
7130 there is no associated binary format, these values are not required to
7131 fit into a variable of type @samp{char} as they are in @code{ditroff}.
7132 The @var{width} subfield gives the width of the character.  The
7133 @var{height} subfield gives the height of the character (upwards is
7134 positive); if a character does not extend above the baseline, it should
7135 be given a zero height, rather than a negative height.  The @var{depth}
7136 subfield gives the depth of the character, that is, the distance below
7137 the lowest point below the baseline to which the character extends
7138 (downwards is positive); if a character does not extend below above the
7139 baseline, it should be given a zero depth, rather than a negative depth.
7140 The @var{italic_correction} subfield gives the amount of space that
7141 should be added after the character when it is immediately to be
7142 followed by a character from a Roman font.  The
7143 @var{left_italic_correction} subfield gives the amount of space that
7144 should be added before the character when it is immediately to be
7145 preceded by a character from a Roman font.  The
7146 @var{subscript_correction} gives the amount of space that should be
7147 added after a character before adding a subscript.  This should be less
7148 than the italic correction.
7150 A line in the @code{charset} section can also have the format
7152 @example
7153 @var{name} "
7154 @end example
7156 @noindent
7157 This indicates that @var{name} is just another name for the character
7158 mentioned in the preceding line.
7160 @kindex kernpairs
7161 The word @code{kernpairs} starts the kernpairs section.  This contains a
7162 sequence of lines of the form:
7164 @example
7165 @var{c1} @var{c2} @var{n}
7166 @end example
7168 This means that when character @var{c1} appears next to character
7169 @var{c2} the space between them should be increased by@w{ }@var{n}.
7170 Most entries in kernpairs section will have a negative value for@w{
7171 }@var{n}.
7175 @node Installation, Request and Operator Index, File formats, Top
7176 @chapter Installation
7177 @cindex installation
7179 @c XXX
7183 @node Request and Operator Index, Register Index, Installation, Top
7184 @chapter Request and Operator Index
7186 @printindex fn
7190 @node Register Index, Macro and String Index, Request and Operator Index, Top
7191 @chapter Register Index
7193 @printindex vr
7197 @node Macro and String Index, Glyph Name Index, Register Index, Top
7198 @chapter Macro and String Index
7200 In this index, strings are listed with the calling escape sequence
7201 (@samp{\*}) to distinguish them from macros which appear without the
7202 leading control character (normally either @samp{.} or @samp{'}).
7204 @printindex ma
7208 @node Glyph Name Index, Font File Keyword Index, Macro and String Index, Top
7209 @chapter Glyph Name Index
7211 A glyph name @code{xx} consisting of exactly two characters can be
7212 accessed as @samp{\(xx}.  Glyph names @code{xxx} of any length can be
7213 accessed as @samp{\[xxx]}.
7215 @printindex gl
7219 @node Font File Keyword Index, Program and File Index, Glyph Name Index, Top
7220 @chapter Font File Keyword Index
7222 @printindex ky
7226 @node Program and File Index, Concept Index, Font File Keyword Index, Top
7227 @chapter Program  and File Index
7229 @printindex pg
7233 @node Concept Index,  , Program and File Index, Top
7234 @chapter Concept Index
7236 @printindex cp
7240 @summarycontents
7241 @contents
7242 @bye