* src/preproc/grn/main.cc: Introduce BASE_THICKNESS, defining
[s-roff.git] / doc / groff.texinfo
blob9d1cf1bf129139b99f4259c84fe2324716e43ac1
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header (This is for running Texinfo on a region.)
3 @setfilename  groff
4 @settitle The GNU Troff Manual
5 @setchapternewpage odd
6 @footnotestyle separate
7 @c %**end of header (This is for running Texinfo on a region.)
10 @c We use the following indices:
12 @c   cindex: concepts
13 @c   findex: requests
14 @c   vindex: registers
15 @c   pindex: programs
16 @c   tindex: environment variables
18 @c tindex and cindex are merged.
20 @syncodeindex tp cp
23 @dircategory Miscellaneous
24 @direntry
25 * Groff: (groff).   The GNU troff document formatting system.
26 @end direntry
29 @smallbook
32 @iftex
33 @finalout
34 @end iftex
37 @ifinfo
38 This Info file documents GNU troff version 1.16.
40 Published by the Free Software Foundation
41 59 Temple Place, Suite 330
42 Boston, MA  02111-1307  USA
44 Copyright (C) 1994-2000 Free Software Foundation, Inc.
46 Permission is granted to make and distribute verbatim copies of this
47 manual provided the copyright notice and this permission notice are
48 preserved on all copies.
50 @ignore
51 Permission is granted to process this file through TeX and print the
52 results, provided the printed document carries copying permission notice
53 identical to this one except for the removal of this paragraph (this
54 paragraph not being relevant to the printed manual).
56 @end ignore
57 Permission is granted to copy and distribute modified versions of this
58 manual under the conditions for verbatim copying, provided that the
59 entire resulting derived work is distributed under the terms of a
60 permission notice identical to this one.
62 Permission is granted to copy and distribute translations of this manual
63 into another language, under the above conditions for modified versions,
64 except that this permission notice may be stated in a translation
65 approved by the Foundation.
67 Permission is granted to copy and distribute modified versions of this
68 manual under the conditions for verbatim copying, provided also that the
69 section entitled ``GNU General Public License'' is included exactly as
70 in the original, and provided that the entire resulting derived work is
71 distributed under the terms of a permission notice identical to this
72 one.
74 Permission is granted to copy and distribute translations of this manual
75 into another language, under the above conditions for modified versions,
76 except that the section entitled ``GNU General Public License'' may be
77 included in a translation approved by the Free Software Foundation
78 instead of in the original English.
79 @end ifinfo
82 @titlepage
83 @title groff
84 @subtitle The GNU implementation of @code{groff}
85 @subtitle Edition 1.16
86 @subtitle Spring 2000
87 @author by Trent A.@w{ }Fisher
88 @author and the maintainer of groff
90 @c Include the Distribution inside the titlepage environment so
91 @c that headings are turned off.  Headings on and off do not work.
93 @page
94 @vskip 0pt plus 1filll
95 Copyright @copyright@w{ }1994-2000 Free Software Foundation,@w{ }Inc.
96 @sp 2
97 Version 1.16 of @code{groff}, @*
98 Spring 2000
99 @sp 2
100 Published by the Free Software Foundation @*
101 59 Temple Place, Suite 330 @*
102 Boston, MA  02111-1307  USA
105 Permission is granted to make and distribute verbatim copies of this
106 manual provided the copyright notice and this permission notice are
107 preserved on all copies.
109 Permission is granted to copy and distribute modified versions of this
110 manual under the conditions for verbatim copying, provided also that the
111 section entitled ``GNU General Public License'' is included exactly as
112 in the original, and provided that the entire resulting derived work is
113 distributed under the terms of a permission notice identical to this
114 one.
116 Permission is granted to copy and distribute translations of this manual
117 into another language, under the above conditions for modified versions,
118 except that the section entitled ``GNU General Public License'' may be
119 included in a translation approved by the Free Software Foundation
120 instead of in the original English.
122 Cover art by Etienne Suvasa.
123 @end titlepage
124 @page
128 @node Top, Copying, (dir), (dir)
130 @ifinfo
131 This Info file documents groff version 1.16, the GNU implementation of
132 the troff typesetting system.
134 This is an in-progress document; contributions, comments, or
135 contributions are welcome.  Send them to bug-groff@@gnu.org.
136 @end ifinfo
138 @menu
139 * Copying::                     
140 * Introduction::                
141 * Invoking groff::              
142 * Tutorial for Macro Users::    
143 * Macro Packages::              
144 * Programming Tutorial::        
145 * Preprocessors::               
146 * Output Devices::              
147 * File formats::                
148 * Installation::                
149 * Request Index::               
150 * Register Index::              
151 * String Index::                
152 * Macro Index::                 
153 * Program Index::               
154 * Concept Index::               
155 @end menu
159 @node Copying, Introduction, Top, Top
160 @cindex copying
161 @unnumbered GNU GENERAL PUBLIC LICENSE
162 @center Version 2, June 1991
164 @display
165 Copyright @copyright{}@w{ }1989, 1991 Free Software Foundation, Inc.
166 59@w{ }Temple Place, Suite@w{ }330, Boston, MA@w{ }02111, USA
168 Everyone is permitted to copy and distribute verbatim copies of this
169 license document, but changing it is not allowed.
170 @end display
172 @unnumberedsec Preamble
174 The licenses for most software are designed to take away your freedom to
175 share and change it.  By contrast, the GNU General Public License is
176 intended to guarantee your freedom to share and change free software --
177 to make sure the software is free for all its users.  This General
178 Public License applies to most of the Free Software Foundation's
179 software and to any other program whose authors commit to using it.
180 (Some other Free Software Foundation software is covered by the GNU
181 Library General Public License instead.)  You can apply it to your
182 programs, too.
184 When we speak of free software, we are referring to freedom, not price.
185 Our General Public Licenses are designed to make sure that you have the
186 freedom to distribute copies of free software (and charge for this
187 service if you wish), that you receive source code or can get it if you
188 want it, that you can change the software or use pieces of it in new
189 free programs; and that you know you can do these things.
191 To protect your rights, we need to make restrictions that forbid anyone
192 to deny you these rights or to ask you to surrender the rights.  These
193 restrictions translate to certain responsibilities for you if you
194 distribute copies of the software, or if you modify it.
196 For example, if you distribute copies of such a program, whether gratis
197 or for a fee, you must give the recipients all the rights that you have.
198 You must make sure that they, too, receive or can get the source code.
199 And you must show them these terms so they know their rights.
201 We protect your rights with two steps: (1)@w{ }copyright the software,
202 and (2)@w{ }offer you this license which gives you legal permission to
203 copy, distribute and/or modify the software.
205 Also, for each author's protection and ours, we want to make certain
206 that everyone understands that there is no warranty for this free
207 software.  If the software is modified by someone else and passed on, we
208 want its recipients to know that what they have is not the original, so
209 that any problems introduced by others will not reflect on the original
210 authors' reputations.
212 Finally, any free program is threatened constantly by software patents.
213 We wish to avoid the danger that redistributors of a free program will
214 individually obtain patent licenses, in effect making the program
215 proprietary.  To prevent this, we have made it clear that any patent
216 must be licensed for everyone's free use or not licensed at all.
218 The precise terms and conditions for copying, distribution and
219 modification follow.
221 @iftex
222 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
223 @end iftex
224 @ifinfo
225 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
226 @end ifinfo
228 @enumerate 0
229 @item
230 This License applies to any program or other work which contains a
231 notice placed by the copyright holder saying it may be distributed under
232 the terms of this General Public License.  The ``Program'', below,
233 refers to any such program or work, and a ``work based on the Program''
234 means either the Program or any derivative work under copyright law:
235 that is to say, a work containing the Program or a portion of it, either
236 verbatim or with modifications and/or translated into another language.
237 (Hereinafter, translation is included without limitation in the term
238 ``modification''.)  Each licensee is addressed as ``you''.
240 Activities other than copying, distribution and modification are not
241 covered by this License; they are outside its scope.  The act of running
242 the Program is not restricted, and the output from the Program is
243 covered only if its contents constitute a work based on the Program
244 (independent of having been made by running the Program).  Whether that
245 is true depends on what the Program does.
247 @item
248 You may copy and distribute verbatim copies of the Program's source code
249 as you receive it, in any medium, provided that you conspicuously and
250 appropriately publish on each copy an appropriate copyright notice and
251 disclaimer of warranty; keep intact all the notices that refer to this
252 License and to the absence of any warranty; and give any other
253 recipients of the Program a copy of this License along with the Program.
255 You may charge a fee for the physical act of transferring a copy, and
256 you may at your option offer warranty protection in exchange for a fee.
258 @item
259 You may modify your copy or copies of the Program or any portion of it,
260 thus forming a work based on the Program, and copy and distribute such
261 modifications or work under the terms of Section@w{ }1 above, provided
262 that you also meet all of these conditions:
264 @enumerate a
265 @item
266 You must cause the modified files to carry prominent notices stating
267 that you changed the files and the date of any change.
269 @item
270 You must cause any work that you distribute or publish, that in whole or
271 in part contains or is derived from the Program or any part thereof, to
272 be licensed as a whole at no charge to all third parties under the terms
273 of this License.
275 @item
276 If the modified program normally reads commands interactively when run,
277 you must cause it, when started running for such interactive use in the
278 most ordinary way, to print or display an announcement including an
279 appropriate copyright notice and a notice that there is no warranty (or
280 else, saying that you provide a warranty) and that users may
281 redistribute the program under these conditions, and telling the user
282 how to view a copy of this License.  (Exception: if the Program itself
283 is interactive but does not normally print such an announcement, your
284 work based on the Program is not required to print an announcement.)
285 @end enumerate
287 These requirements apply to the modified work as a whole.  If
288 identifiable sections of that work are not derived from the Program, and
289 can be reasonably considered independent and separate works in
290 themselves, then this License, and its terms, do not apply to those
291 sections when you distribute them as separate works.  But when you
292 distribute the same sections as part of a whole which is a work based on
293 the Program, the distribution of the whole must be on the terms of this
294 License, whose permissions for other licensees extend to the entire
295 whole, and thus to each and every part regardless of who wrote it.
297 Thus, it is not the intent of this section to claim rights or contest
298 your rights to work written entirely by you; rather, the intent is to
299 exercise the right to control the distribution of derivative or
300 collective works based on the Program.
302 In addition, mere aggregation of another work not based on the Program
303 with the Program (or with a work based on the Program) on a volume of a
304 storage or distribution medium does not bring the other work under the
305 scope of this License.
307 @item
308 You may copy and distribute the Program (or a work based on it, under
309 Section@w{ }2) in object code or executable form under the terms of
310 Sections@w{ }1 and@w{ }2 above provided that you also do one of the
311 following:
313 @enumerate a
314 @item
315 Accompany it with the complete corresponding machine-readable source
316 code, which must be distributed under the terms of Sections@w{ }1 and@w{
317 }2 above on a medium customarily used for software interchange; or,
319 @item
320 Accompany it with a written offer, valid for at least three years, to
321 give any third party, for a charge no more than your cost of physically
322 performing source distribution, a complete machine-readable copy of the
323 corresponding source code, to be distributed under the terms of
324 Sections@w{ }1 and@w{ }2 above on a medium customarily used for software
325 interchange; or,
327 @item
328 Accompany it with the information you received as to the offer to
329 distribute corresponding source code.  (This alternative is allowed only
330 for noncommercial distribution and only if you received the program in
331 object code or executable form with such an offer, in accord with
332 Subsection@w{ }b above.)
333 @end enumerate
335 The source code for a work means the preferred form of the work for
336 making modifications to it.  For an executable work, complete source
337 code means all the source code for all modules it contains, plus any
338 associated interface definition files, plus the scripts used to control
339 compilation and installation of the executable.  However, as a special
340 exception, the source code distributed need not include anything that is
341 normally distributed (in either source or binary form) with the major
342 components (compiler, kernel, and so on) of the operating system on
343 which the executable runs, unless that component itself accompanies the
344 executable.
346 If distribution of executable or object code is made by offering access
347 to copy from a designated place, then offering equivalent access to copy
348 the source code from the same place counts as distribution of the source
349 code, even though third parties are not compelled to copy the source
350 along with the object code.
352 @item
353 You may not copy, modify, sublicense, or distribute the Program except
354 as expressly provided under this License.  Any attempt otherwise to
355 copy, modify, sublicense or distribute the Program is void, and will
356 automatically terminate your rights under this License.  However,
357 parties who have received copies, or rights, from you under this License
358 will not have their licenses terminated so long as such parties remain
359 in full compliance.
361 @item
362 You are not required to accept this License, since you have not signed
363 it.  However, nothing else grants you permission to modify or distribute
364 the Program or its derivative works.  These actions are prohibited by
365 law if you do not accept this License.  Therefore, by modifying or
366 distributing the Program (or any work based on the Program), you
367 indicate your acceptance of this License to do so, and all its terms and
368 conditions for copying, distributing or modifying the Program or works
369 based on it.
371 @item
372 Each time you redistribute the Program (or any work based on the
373 Program), the recipient automatically receives a license from the
374 original licensor to copy, distribute or modify the Program subject to
375 these terms and conditions.  You may not impose any further restrictions
376 on the recipients' exercise of the rights granted herein.  You are not
377 responsible for enforcing compliance by third parties to this License.
379 @item
380 If, as a consequence of a court judgment or allegation of patent
381 infringement or for any other reason (not limited to patent issues),
382 conditions are imposed on you (whether by court order, agreement or
383 otherwise) that contradict the conditions of this License, they do not
384 excuse you from the conditions of this License.  If you cannot
385 distribute so as to satisfy simultaneously your obligations under this
386 License and any other pertinent obligations, then as a consequence you
387 may not distribute the Program at all.  For example, if a patent license
388 would not permit royalty-free redistribution of the Program by all those
389 who receive copies directly or indirectly through you, then the only way
390 you could satisfy both it and this License would be to refrain entirely
391 from distribution of the Program.
393 If any portion of this section is held invalid or unenforceable under
394 any particular circumstance, the balance of the section is intended to
395 apply and the section as a whole is intended to apply in other
396 circumstances.
398 It is not the purpose of this section to induce you to infringe any
399 patents or other property right claims or to contest validity of any
400 such claims; this section has the sole purpose of protecting the
401 integrity of the free software distribution system, which is implemented
402 by public license practices.  Many people have made generous
403 contributions to the wide range of software distributed through that
404 system in reliance on consistent application of that system; it is up to
405 the author/donor to decide if he or she is willing to distribute
406 software through any other system and a licensee cannot impose that
407 choice.
409 This section is intended to make thoroughly clear what is believed to be
410 a consequence of the rest of this License.
412 @item
413 If the distribution and/or use of the Program is restricted in certain
414 countries either by patents or by copyrighted interfaces, the original
415 copyright holder who places the Program under this License may add an
416 explicit geographical distribution limitation excluding those countries,
417 so that distribution is permitted only in or among countries not thus
418 excluded.  In such case, this License incorporates the limitation as if
419 written in the body of this License.
421 @item
422 The Free Software Foundation may publish revised and/or new versions of
423 the General Public License from time to time.  Such new versions will be
424 similar in spirit to the present version, but may differ in detail to
425 address new problems or concerns.
427 Each version is given a distinguishing version number.  If the Program
428 specifies a version number of this License which applies to it and ``any
429 later version'', you have the option of following the terms and
430 conditions either of that version or of any later version published by
431 the Free Software Foundation.  If the Program does not specify a version
432 number of this License, you may choose any version ever published by the
433 Free Software Foundation.
435 @item
436 If you wish to incorporate parts of the Program into other free programs
437 whose distribution conditions are different, write to the author to ask
438 for permission.  For software which is copyrighted by the Free Software
439 Foundation, write to the Free Software Foundation; we sometimes make
440 exceptions for this.  Our decision will be guided by the two goals of
441 preserving the free status of all derivatives of our free software and
442 of promoting the sharing and reuse of software generally.
444 @iftex
445 @heading NO WARRANTY
446 @end iftex
447 @ifinfo
448 @center NO WARRANTY
449 @end ifinfo
451 @item
452 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
453 THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW@.  EXCEPT WHEN
454 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
455 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER
456 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
457 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE@.
458 THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
459 YOU@.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
460 NECESSARY SERVICING, REPAIR OR CORRECTION.
462 @item
463 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
464 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
465 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
466 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
467 DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
468 (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
469 INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
470 THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
471 OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
472 @end enumerate
474 @iftex
475 @heading END OF TERMS AND CONDITIONS
476 @end iftex
477 @ifinfo
478 @center END OF TERMS AND CONDITIONS
479 @end ifinfo
482 @page
483 @unnumberedsec How to Apply These Terms to Your New Programs
485 If you develop a new program, and you want it to be of the greatest
486 possible use to the public, the best way to achieve this is to make it
487 free software which everyone can redistribute and change under these
488 terms.
490 To do so, attach the following notices to the program.  It is safest to
491 attach them to the start of each source file to most effectively convey
492 the exclusion of warranty; and each file should have at least the
493 ``copyright'' line and a pointer to where the full notice is found.
495 @smallexample
496 @var{one line to give the program's name and an idea of what it does.}
497 Copyright (C) 19@var{yy} @var{name of author}
499 This program is free software; you can redistribute it and/or modify
500 it under the terms of the GNU General Public License as published by
501 the Free Software Foundation; either version 2 of the License, or (at
502 your option) any later version.
504 This program is distributed in the hope that it will be useful, but
505 WITHOUT ANY WARRANTY; without even the implied warranty of
506 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@.  See the GNU
507 General Public License for more details.
509 You should have received a copy of the GNU General Public License
510 along with this program; if not, write to the Free Software
511 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
512 @end smallexample
514 Also add information on how to contact you by electronic and paper mail.
516 If the program is interactive, make it output a short notice like this
517 when it starts in an interactive mode:
519 @smallexample
520 Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
521 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type
522 `show w'.  This is free software, and you are welcome to redistribute
523 it under certain conditions; type `show c' for details.
524 @end smallexample
526 The hypothetical commands @samp{show@w{ }w} and @samp{show@w{ }c} should
527 show the appropriate parts of the General Public License.  Of course,
528 the commands you use may be called something other than @samp{show@w{
529 }w} and @samp{show@w{ }c}; they could even be mouse-clicks or menu
530 items---whatever suits your program.
532 You should also get your employer (if you work as a programmer) or your
533 school, if any, to sign a ``copyright disclaimer'' for the program, if
534 necessary.  Here is a sample; alter the names:
536 @smallexample
537 @group
538 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
539 `Gnomovision' (which makes passes at compilers) written by James
540 Hacker.
542 @var{signature of Ty Coon}, 1 April 1989 Ty Coon, President of Vice
543 @end group
544 @end smallexample
546 This General Public License does not permit incorporating your program
547 into proprietary programs.  If your program is a subroutine library, you
548 may consider it more useful to permit linking proprietary applications
549 with the library.  If this is what you want to do, use the GNU Library
550 General Public License instead of this License.
554 @node Introduction, Invoking groff, Copying, Top
555 @chapter Introduction
556 @cindex introduction
558 GNU @code{troff} (or @code{groff}) is a system for typesetting
559 documents.  @code{troff} is very flexible and has been in existence (and
560 use) for about 3@w{ }decades.  It is quite widespread and firmly
561 entrenched in the @sc{Unix} community.
563 @menu
564 * What Is groff?::              
565 * History::                     
566 * groff Capabilities::          
567 * Macro Package Intro::         
568 * Preprocessor Intro::          
569 * Output device intro::         
570 * Credits::                     
571 @end menu
574 @node What Is groff?, History, Introduction, Introduction
575 @section What Is @code{groff}?
576 @cindex what is @code{groff}?
577 @cindex @code{groff} -- what is it?
579 @code{groff} is of an older generation of document preparation systems,
580 which operate more like compilers than the more recent interactive
581 WYSIWYG@footnote{What You See Is What You Get} systems.  @code{groff}
582 and its contemporary counterpart, @TeX{}, both work using a @dfn{batch}
583 paradigm: The input (or @dfn{source}) files are normal text files with
584 embedded formatting commands.  These files can then be processed by
585 @code{groff} to produce a typeset document on a variety of devices.
587 Likewise, @code{groff} should not be confused with a @dfn{word
588 processor}, since that term connotes an integrated system which includes
589 an editor and a text formatter.  Also, many word processors follow the
590 WYSIWYG paradigm which was discussed earlier.
592 Although WYSIWYG systems may be easier to use, they have a number of
593 disadvantages compared to @code{troff}:
595 @itemize @bullet{}
596 @item
597 They must be used on a bitmapped display to do any operations on your
598 document.
599 @item
600 Most of the WYSIWYG systems are either non-free or are not very
601 portable.
602 @item
603 @code{troff} is firmly entrenched in all @sc{Unix} systems.
604 @item
605 It is difficult to have a wide range of capabilities available within
606 the confines of a GUI/window system.
607 @item
608 It is more difficult to make global changes to a document.
609 @end itemize
611 @quotation
612 ``GUIs normally make it simple to accomplish simple actions and
613 impossible to accomplish complex actions.''  --Doug Gwyn (22/Jun/91 in
614 @code{comp.unix.wizards})
615 @end quotation
618 @node History, groff Capabilities, What Is groff?, Introduction
619 @section History
620 @cindex history
622 @code{troff} can trace its origins back to a formatting program called
623 @code{runoff} which ran on MIT's CTSS system.  This name came from the
624 common phrase of the time ``I'll run off a document.''
626 The first version of @sc{Unix} was developed on a PDP-7 which was
627 sitting around Bell Labs.  In 1971 the developers wanted to get a PDP-11
628 for further work on the operating system.  In order to justify the cost
629 for this system, they proposed that they would implement a document
630 formatting system for the AT&T patents division.  This first formatting
631 program was a reimplementation of @code{runoff}.  In accordance with
632 @sc{Unix}'s penchant for abreviations, it was named @code{roff} (an
633 abreviation of @code{runoff}).
635 When they needed a more flexible language, a new version of @code{roff}
636 called @code{nroff} (Newer @code{roff}) was written.  It had a much more
637 complicated syntax, but provided the basis for all future versions.
638 When they got a Graphic Systems CAT Phototypesetter, J.@w{ }F.@w{
639 }Ossanna wrote a version of @code{nroff} which would drive it.  It was
640 dubbed @code{troff} for typesetter @code{roff}, although many people
641 have speculated that it actually means Times @code{roff} because of
642 @code{troff}'s use of the Times font family by default.  As such, the
643 name @code{troff} is pronounced t-roff rather than trough.
645 With @code{troff} came @code{nroff} (they were actually the same program
646 except for some @samp{#ifdefs}), which was for producing output for line
647 printers and character terminals.  It understood everything @code{troff}
648 did, and ignored the commands which were not aplicable (i.e.@: font
649 changes).
651 Since there are several things which cannot be done easily in
652 @code{troff}, work on several preprocessors began.  These programs would
653 transform certain parts of a document into @code{troff}, which made a
654 very natural use of pipes in @sc{Unix}.
656 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
657 specified in a much simpler and more intuitive manner.  @code{tbl} is a
658 preprocessor for formatting tables.  The @code{refer} preprocessor (and
659 the similar program, @code{bib}) processes citations in a document
660 according to a bibliographic database.
662 Unfortunately, Ossanna's @code{troff} was written in PDP-11 assembly
663 language and produced output specifically for the CAT phototypesetter.
664 He rewrote it in C, although it was now 7000@w{ }lines of uncommented
665 code and still dependent on the CAT.  As the CAT became less common, and
666 was no longer supported by the manufacturer, the need to make it support
667 other devices became a priority.  However, before this could be done, he
668 was killed in an auto accident.
670 @pindex ditroff
671 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
672 newly rewritten version produced a device independent code which was
673 very easy for postprocessors to read and translate to the appropriate
674 printer codes.  Also, this new version of @code{troff} (called
675 @code{ditroff}) had several extentions, which included drawing
676 functions.
678 Due to the additional abilities of the new version of @code{troff},
679 several new preprocessors appeared.  The @code{pic} preprocessor
680 provides a wide range of drawing functions.  Likewise the @code{ideal}
681 preprocessor did the same, although via a much different paradigm.  The
682 @code{grap} preprocessor took specifications for graphs, but, unlike
683 other preprocessors, produced @code{pic} code.
685 James Clark began work on a GNU implementation of @code{ditroff} in
686 early@w{ }1989.  The first version, @code{groff}@w{ }0.3.1, was released
687 June@w{ }1990.  @code{groff} included
689 @itemize @bullet{}
690 @item
691 A replacement for @code{ditroff} with many extentions.
692 @item
693 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
694 @item
695 Postprocessors for character devices, PostScript, @TeX{} DVI, and X@w{
696 }windows.  GNU @code{troff} also eliminated the need for a separate
697 @code{nroff} program with a postprocessor which would produce @sc{ascii}
698 output.
699 @item
700 A version of the @code{-me} macros and an implementation of the
701 @code{-man} macros.
702 @end itemize
704 Also, a front-end was included which could construct the, sometimes
705 painfully long, pipelines required for all the post- and preprocessors.
707 Development of GNU @code{troff} progressed rapidly, and saw the
708 additions of a replacement for @code{refer}, an implementation of the
709 @code{-ms} and @code{-mm} macros, and a program to deduce how to format
710 a document (@code{grog}).
712 It was declared a stable (i.e.@: non beta) package with the release of
713 version@w{ }1.04 around November@w{ }1991.
715 Beginning in@w{ }1999, @code{groff} has new maintainers (the package was
716 an orphan for a few years).  As a result, new features and programs like
717 @code{grn}, a preprocessor for gremlin images, and @code{grohtml}, an
718 output device to produce HTML output, have been added.
721 @node groff Capabilities, Macro Package Intro, History, Introduction
722 @section @code{groff} Capabilities
723 @cindex @code{groff} capabilities
724 @cindex capabilities of @code{groff}
726 So what exactly is @code{groff} capable of doing?  @code{groff} provides
727 a wide range of low-level text formatting operations.  Using these, you
728 can perform a wide range of formatting tasks, such as footnotes, table
729 of contents, multiple columns, etc.
731 @itemize @bullet{}
732 @item
733 Text filling, adjusting, and centering
734 @item
735 Hyphenation
736 @item
737 Page control
738 @item
739 Font and character size control
740 @item
741 Vertical spacing (i.e.@: double spacing)
742 @item
743 Line length and indenting
744 @item
745 Macros, strings, diversions, and traps
746 @item
747 Number registers
748 @item
749 Tabs, leaders, and fields
750 @item
751 Input and output conventions and character translation
752 @item
753 Overstrike, bracket, line drawing, and zero-width functions
754 @item
755 Local horizontal and vertical motions and the width function
756 @item
757 Three-part titles
758 @item
759 Output line numbering
760 @item
761 Conditional acceptance of input
762 @item
763 Environment switching
764 @item
765 Insertions from the standard input
766 @item
767 Input/output file switching
768 @item
769 Output and error messages
770 @end itemize
773 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
774 @section Macro Packages
775 @cindex macro packages
777 Since @code{groff} provides such low level facilities, it can be quite
778 difficult to use by itself.  However, @code{groff} provides a
779 @dfn{macro} facility which allows you to specify how certain routine
780 operations (e.g.@w{ }starting paragraphs, printing headers and footers,
781 etc.)@: should be done.  These macros can be collected together into a
782 @dfn{macro package}.  There are a number of macro packages available;
783 the most common (and the ones described in this manual) are @code{-man},
784 @code{-mdoc}, @code{-me}, @code{-ms}, and @code{-mm}.
787 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
788 @section Preprocessors
789 @cindex preprocessors
791 Although @code{groff} provides most functions needed to format a
792 document, some operations would be unwieldy (i.e.@: drawing pictures).
793 Therefore, programs called preprocessors were written which understand
794 their own language and produce the necessary @code{groff} operations.
795 These preprocessors are able to differentiate their own input from the
796 rest of the document via markers.
798 To use a preprocessor, @sc{Unix} pipes are used to feed the output from
799 the preprocessor into @code{groff}.  Any number of preprocessors may be
800 used on a given document; in this case, the preprocessors are linked
801 together into one pipeline.  However, in @code{groff}, the user does not
802 need to construct the pipe, but only tell @code{groff} what
803 preprocessors to use.
805 @code{groff} currently has preprocessors for producing tables
806 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
807 (@code{pic} and @code{grn}), and for processing bibliographies
808 (@code{refer}).  An associated program which is useful when dealing with
809 preprocessors is @code{soelim}.
811 There are other preprocessors in existence, but there are,
812 unfortunately, no free implementations available.  They are for drawing
813 pictures (@code{ideal}) and chemical structures (@code{chem}).
815 A free implementation of @code{grap}, a preprocessor for drawing graphs,
816 can be obtained as an extra package.
819 @node Output device intro, Credits, Preprocessor Intro, Introduction
820 @section Output Devices
821 @cindex postprocessors
822 @cindex output devices
823 @cindex devices for output
825 @code{groff} actually produces device independent code which may be fed
826 into a postprocessor which will produce output for a particular device.
827 Currently, @code{groff} has postprocessors for PostScript, character
828 terminals, X@w{ }Windows (for previewing), @TeX{} DVI format, HP
829 LaserJet@w{ }4 printers, and HTML.
832 @node Credits,  , Output device intro, Introduction
833 @section Credits
834 @cindex credits
836 Large portions of this manual were taken from existing documents, most
837 notably, the manual pages for the @code{groff} package by James Clark,
838 and Eric Allman's papers on the @code{-me} macro package.
842 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
843 @chapter Invoking @code{groff}
844 @cindex invoking @code{groff}
845 @cindex @code{groff} invocation
847 @pindex groff
848 @pindex gtroff
849 This section focuses on how to invoke the @code{groff} front end.  This
850 front end takes care of the details of constructing the pipeline among
851 the preprocessors, @code{gtroff} and the postprocessor.
853 It has become a tradition that GNU programs get the prefix @dfn{g} to
854 distinguish it from its original counterparts provided by the host
855 (@pxref{Environment}, for more details).  Thus, for example, @code{geqn}
856 is GNU @code{eqn}.  On operating systems like Linux or the Hurd, which
857 don't contain proprietary software, this prefix is omitted since GNU
858 @code{troff} is the only used incarnation of @code{troff}.  Exception:
859 @code{groff} is never replaced by `@code{roff}'.
861 @menu
862 * Options::                     
863 * Environment::                 
864 * Invocation Examples::         
865 @end menu
868 @node Options, Environment, Invoking groff, Invoking groff
869 @section Options
870 @cindex options
872 @pindex groff
873 @pindex gtroff
874 @pindex gpic
875 @pindex geqn
876 @pindex ggrn
877 @pindex gtbl
878 @pindex grefer
879 @pindex gsoelim
880 @code{groff} is a front-end to the groff document formatting system.
881 Normally it runs the @code{gtroff} program and a postprocessor
882 appropriate for the selected device.  The default device is @samp{ps}.
883 It can optionally preprocess with any of @code{gpic}, @code{geqn},
884 @code{gtbl}, @code{ggrn}, @code{grefer}, or @code{gsoelim}.
886 This section only documents options to the @code{groff} front end.  Many
887 of the arguments to @code{groff} are passed on to @code{gtroff},
888 therefore those are also included.  Arguments to pre- or postprocessors
889 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
890 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
891 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
892 grohtml}, @ref{Invoking grodvi}, and @ref{Invoking gxditview}.
894 The command line format for @code{groff} is:
896 @example
897 groff [ -abeghilpstvzCENRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
898       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
899       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
900       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
901       [ @var{files}@dots{} ]
902 @end example
904 The command line format for @code{gtroff} is as follows.  As you can
905 see, many of the options to @code{groff} are actually passed on to
906 @code{gtroff}.
908 @example
909 gtroff [ -abivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
910        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
911        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
912        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
913 @end example
915 Options without an argument can be grouped behind a single @samp{-}.  A
916 filename of @samp{-} denotes the standard input.
918 @pindex grog
919 The @code{grog} command can be used to guess the correct @code{groff}
920 command to use to format a file.
922 @table @samp
923 @item -h
924 Print a help message.
925 @item -e
926 Preprocess with @code{geqn}.
927 @item -t
928 Preprocess with @code{gtbl}.
929 @item -g
930 Preprocess with @code{ggrn}.
931 @item -p
932 Preprocess with @code{gpic}.
933 @item -s
934 Preprocess with @code{gsoelim}.
935 @item -R
936 Preprocess with @code{grefer}.  No mechanism is provided for passing
937 arguments to @code{grefer} because most @code{grefer} options have
938 equivalent commands which can be included in the file.  @xref{grefer},
939 for more details.
941 @pindex troffrc
942 Note that @code{gtroff} also accepts a @samp{-R} option, which is not
943 accessible via @code{groff}.  This option prevents the loading of the
944 @file{troffrc} file.
945 @item -v
946 Make programs run by @code{groff} print out their version number.
947 @item -V
948 Print the pipeline on stdout instead of executing it.
949 @item -z
950 Suppress output from @code{gtroff}.  Only error messages will be
951 printed.
952 @item -Z
953 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
954 will automatically run the appropriate postprocessor.
955 @item -P@var{arg}
956 Pass @var{arg} to the postprocessor.  Each argument should be passed
957 with a separate @samp{-P} option.  Note that @code{groff} does not
958 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
959 @item -l
960 Send the output to a printer.  The command used for this is specified by
961 the print command in the device description file.
962 @item -L@var{arg}
963 Pass @var{arg} to the spooler.  Each argument should be passed with a
964 separate @samp{-L} option.  Note that @code{groff} does not prepend a
965 @samp{-} to @var{arg} before passing it to the postprocessor.
966 @item -T@var{dev}
967 Prepare output for device @var{dev}.  The default device is @samp{ps}.
968 The following are the output devices currently available:
969 @table @samp
970 @item ps
971 For PostScript printers and previewers.
972 @item dvi
973 For @TeX{} dvi format.
974 @item X75
975 For a 75dpi X11 previewer.
976 @item X100
977 For a 100dpi X11 previewer.
978 @item @sc{ascii}
979 For typewriter-like devices.
980 @item latin1
981 For typewriter-like devices using the ISO@w{ }Latin@w{-}1 (ISO@w{
982 }8859@w{-}1) character set.
983 @item utf8
984 For typewriter-like devices using the Unicode (ISO@w{ }10646) character
985 set with UTF@w{-}8 encoding.
986 @item lj4
987 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
988 @item html
989 To produce HTML output.
990 @end table
992 The postprocessor to be used for a device is specified by the
993 @code{postpro} command in the device description file.  (@xref{Font
994 Files}, for more info.)  This can be overridden with the @samp{-X}
995 option.
996 @item -X
997 Preview with @code{gxditview} instead of using the usual postprocessor.
998 This is unlikely to produce good results except with @samp{-Tps}.
999 @item -N
1000 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1001 the @samp{-N} option in @code{geqn}.
1002 @item -S
1003 Safer mode.  Pass the @samp{-S} option to @code{gpic} and use the
1004 @samp{-msafer} macros with @code{gtroff} (enabled by default).
1005 @item -U
1006 Unsafe mode.  Reverts to the old unsafe behaviour.
1007 @item -a
1008 Generate an @sc{ascii} approximation of the typeset output.
1009 @item -b
1010 Print a backtrace with each warning or error message.  This backtrace
1011 should help track down the cause of the error.  The line numbers given
1012 in the backtrace may not always be correct: @code{gtroff}'s idea of line
1013 numbers gets confused by @code{as} or @code{am} requests.
1014 @item -i
1015 Read the standard input after all the named input files have been
1016 processed.
1017 @item -w@var{name}
1018 Enable warning @var{name}.  Available warnings are described in
1019 @ref{Debugging}.  Multiple @samp{-w} options are allowed.
1020 @item -W@var{name}
1021 Inhibit warning @var{name}.  Multiple @samp{-W} options are allowed.
1022 @item -E
1023 Inhibit all error messages.
1024 @item -C
1025 Enable compatibility mode.
1026 @item -d@var{cs}
1027 @itemx -d@var{name}=s
1028 Define @var{c} or @var{name} to be a string @var{s}; @var{c} must be a
1029 one-letter @var{name}.
1030 @item -f@var{fam}
1031 Use @var{fam} as the default font family.
1032 @item -m@var{name}
1033 Read in the file @file{tmac.@var{name}}.  Normally this will be searched
1034 for in @code{groff}'s lib directory.
1035 @item -n@var{num}
1036 Number the first page @var{num}.
1037 @item -o@var{list}
1038 Output only pages in @var{list}, which is a comma-separated list of page
1039 ranges; @var{n} means print page @var{n}, @samp{@var{m}-@var{n}} means
1040 print every page between @var{m} and @var{n}, @samp{-@var{n}} means
1041 print every page up to @var{n}, @samp{@var{n}-} means print every page
1042 from @var{n}.  @code{gtroff} will exit after printing the last page in
1043 the list.
1044 @item -r@var{cn}
1045 @itemx -r@var{name}=@var{n}
1046 Set number register @var{c} or @var{name} to @var{n}; @var{c} must be a
1047 one-letter @var{name}; @var{n} can be any troff numeric expression.
1048 @item -F@var{dir}
1049 Search @var{dir} for subdirectories dev@var{name} (@var{name} is the
1050 name of the device) for the @file{DESC} file and font files before the
1051 normal directory.
1052 @item -M@var{dir}
1053 Search directory @var{dir} for macro files before the normal directory.
1054 @item -I@var{dir}
1055 This option is as described in @ref{gsoelim}.  It implies the @samp{-s}
1056 option.
1057 @end table
1060 @node Environment, Invocation Examples, Options, Invoking groff
1061 @section Environment
1062 @cindex environment variables
1063 @cindex variables in environment
1065 There are also several environment variables which can modify
1066 @code{groff}'s behavior.
1068 @table @code
1069 @item GROFF_COMMAND_PREFIX
1070 @tindex GROFF_COMMAND_PREFIX
1071 If this is set to @var{X}, then @code{groff} will run
1072 @var{X}@code{troff} instead of @code{gtroff}.  This also applies to
1073 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{refer}, and
1074 @code{soelim}.  It does not apply to @code{grops}, @code{grodvi},
1075 @code{grotty}, @code{grohtml}, @code{grolj4}, and @code{gxditview}.
1076 @item GROFF_TMAC_PATH
1077 @tindex GROFF_TMAC_PATH
1078 A colon separated list of directories in which to search for macro
1079 files.
1080 @item GROFF_TYPESETTER
1081 @tindex GROFF_TYPESETTER
1082 The default output device.
1083 @item GROFF_FONT_PATH
1084 @tindex GROFF_FONT_PATH
1085 A colon separated list of directories in which to search for the
1086 @code{dev}@var{name} directory.
1087 @item PATH
1088 @tindex PATH
1089 The search path for commands executed by @code{groff}.
1090 @item GROFF_TMPDIR
1091 @tindex GROFF_TMPDIR
1092 @tindex TMPDIR
1093 The directory in which temporary files will be created.  If this is not
1094 set and @code{TMPDIR} is set, temporary files will be created in that
1095 directory.  Otherwise temporary files will be created in @code{/tmp}.
1096 The @code{grops} and @code{grefer} commands can create temporary files.
1097 @end table
1100 @node Invocation Examples,  , Environment, Invoking groff
1101 @section Invocation Examples
1102 @cindex invocation examples
1103 @cindex examples of invocation
1105 This section will list several common uses of @code{groff} and the
1106 command line which will accomplish it.
1108 @example
1109 groff file
1110 @end example
1112 @noindent
1113 This command processes @var{file} without a macro package or a
1114 preprocessor.  The output device is the default, @var{ps}, and the
1115 output is sent to stdout.
1117 @example
1118 groff -t -mandoc -Tascii file | less
1119 @end example
1121 @noindent
1122 This is basically what a call to @code{man} does.  The manual page
1123 @var{file} is processed with the @code{-mandoc} macros (which in turn
1124 either call the @code{-man} or the @code{-mdoc} macro package), using
1125 the @code{tbl} preprocessor and the @sc{ascii} output device.  Finally,
1126 the result is displayed with the @code{less} pager.
1128 @example
1129 groff -X -me file
1130 @end example
1132 @noindent
1133 Preview @var{file} with @code{gxditview}, using the @code{-me} macro
1134 package.
1136 @example
1137 groff -man -rD1 -z file
1138 @end example
1140 @noindent
1141 Check @var{file} with the @code{-man} macro package, forcing
1142 double-sided printing---don't produce any output.
1144 @subsection @code{grog}
1146 @code{grog} reads files and guesses which of the @code{groff}
1147 preprocessors and/or macro packages are are required for formatting
1148 them, and prints the @code{groff} command including those options on the
1149 standard output.  The options generated are one of @samp{-e},
1150 @samp{-man}, @samp{-me}, @samp{-mm}, @samp{-ms}, @samp{-p}, @samp{-R},
1151 @samp{-g}, @samp{-s}, and @samp{-t}.
1153 A filename of @samp{-} is taken to refer to the standard input.  If no
1154 files are specified the standard input will be read.  Any specified
1155 options will be included in the printed command.  No space is allowed
1156 between options and their arguments.  For example,
1158 @example
1159 grog -Tdvi paper.ms
1160 @end example
1162 @noindent
1163 will guess the appropriate command to print @file{paper.ms} and then
1164 print it to the command line after adding the @samp{-Tdvi} option.  If
1165 you want to directly execute it, enclose the call to @code{grog} in
1166 backquotes on the @sc{Unix} shell prompt:
1168 @example
1169 `grog -Tdvi paper.ms` > paper.dvi
1170 @end example
1172 @noindent
1173 As you can see, it is still necessary to redirect the output to
1174 something meaningful (i.e.@: either a file or a pager program like
1175 @code{less}).
1179 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1180 @chapter Tutorial for Macro Users
1181 @cindex tutorial for macro users
1182 @cindex macro tutorial for users
1183 @cindex user's tutorial for macros
1184 @cindex user's macro tutorial
1186 Most users tend to use a macro package to format their papers.  This
1187 means that the whole breadth of @code{groff} is not neccessary for most
1188 people.  This chapter covers the material needed to efficiently use a
1189 macro package.
1191 @menu
1192 * Basics::                      
1193 * Common Features::             
1194 @end menu
1197 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1198 @section Basics
1199 @cindex basics
1201 This section covers some of the basic concepts you will need to
1202 understand to use a macro package.@footnote{This section is derived from
1203 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1204 References are made throughout to more detailed information, if desired.
1206 @code{groff} reads an input file prepared by the user and outputs a
1207 formatted paper suitable for publication or framing.  The input consists
1208 of text, or words to be printed, and embedded commands (@dfn{requests}
1209 and @dfn{escapes}), which tell @code{groff} how to format the printed
1210 copy.  For more detail on this @pxref{Embedded Commands}.
1212 The word @dfn{argument} is used in this manual to mean a word or number
1213 which appears on the same line as a request which modifies the meaning
1214 of that request.  For example, the request
1216 @example
1218 @end example
1220 @noindent
1221 spaces one line, but
1223 @example
1224 .sp 4
1225 @end example
1227 @noindent
1228 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1229 request which says to space four lines instead of one.  Arguments are
1230 separated from the request and from each other by spaces.  More details
1231 on this can be found in @ref{Request Arguments}.
1233 The primary function of @code{groff} is to collect words from input
1234 lines, fill output lines with those words, justify the right hand margin
1235 by inserting extra spaces in the line, and output the result.  For
1236 example, the input:
1238 @example
1239 Now is the time
1240 for all good men
1241 to come to the aid
1242 of their party.
1243 Four score and seven
1244 years ago,...
1245 @end example
1247 @noindent
1248 will be read, packed onto output lines, and justified to produce:
1250 @quotation
1251 Now is the time for all good men to come to the aid of their party.
1252 Four score and seven years ago,...
1253 @end quotation
1255 @cindex break
1256 @cindex line break
1257 Sometimes you may want to start a new output line even though the line
1258 you are on is not yet full; for example, at the end of a paragraph.  To
1259 do this you can cause a @dfn{break}, which starts a new output line.
1260 Some requests cause a break automatically, as do blank input lines and
1261 input lines beginning with a space.
1263 Not all input lines are text to be formatted.  Some of the input lines
1264 are requests which describe how to format the text.  Requests always
1265 have a period or an apostrophe (@samp{'}) as the first character of the
1266 input line.
1268 The text formatter also does more complex things, such as automatically
1269 numbering pages, skipping over page boundaries putting footnotes in the
1270 correct place, and so forth.
1272 Here a few hints for preparing text for input to @code{groff}.  First,
1273 keep the input lines short.  Short input lines are easier to edit, and
1274 @code{groff} will pack words onto longer lines for you anyhow.  In
1275 keeping with this, it is helpful to begin a new line after every period,
1276 comma, or phrase, since common corrections are to add or delete
1277 sentences or phrases.  Secondly, do not hyphenate words at the end of
1278 lines---@code{groff} is smart enough to hyphenate words for you as
1279 needed, but is not smart enough to take hyphens out and join a word back
1280 together.  Also, words such as ``mother-in-law'' should not be broken
1281 over a line, since then you will get a space where not wanted, such as
1282 ``@w{mother- in}-law''.
1284 @findex ls
1285 @cindex double spacing
1286 @cindex spacing
1287 @code{groff} will double space output text automatically if you use the
1288 request @w{@samp{.ls 2}}.  You can revert to single spaced mode by
1289 typing @w{@samp{.ls 1}}.
1291 A number of requests allow you to change the way the printed copy looks,
1292 sometimes called the @dfn{layout} of the output page.  Most of these
1293 requests adjust the placing of @dfn{white space} (blank lines or
1294 spaces).
1296 @findex bp
1297 @cindex new page
1298 The @samp{.bp} request starts a new page.
1300 @findex sp
1301 @cindex blank lines
1302 @cindex empty lines
1303 @cindex lines, empty
1304 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1305 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1306 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1307 @var{N}@w{ }centimeters).  For example, the input:
1309 @example
1310 .sp 1.5i
1311 My thoughts on the subject
1313 @end example
1315 @noindent
1316 leaves one and a half inches of space, followed by the line ``My
1317 thoughts on the subject'', followed by a single blank line.
1319 @findex ce
1320 @cindex centering lines
1321 @cindex lines, centering
1322 Text lines can be centered by using the @samp{.ce} request.  The line
1323 after @samp{.ce} is centered (horizontally) on the page.  To center more
1324 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1325 of lines to center), followed by the @var{N}@w{ }lines.  If you want to
1326 center many lines but don't want to count them, type:
1328 @example
1329 .ce 1000
1330 lines to center
1331 .ce 0
1332 @end example
1334 @noindent
1335 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1336 lines, in other words, stop centering.
1338 @findex br
1339 @cindex line break
1340 @cindex break
1341 All of these requests cause a break; that is, they always start a new
1342 line.  If you want to start a new line without performing any other
1343 action, use @samp{.br}.
1346 @node Common Features,  , Basics, Tutorial for Macro Users
1347 @section Common Features
1348 @cindex common features
1349 @cindex features, common
1351 @code{groff} provides very low level operations for formatting a
1352 document.  There are many common routine operations which are done in
1353 all documents.  These common operations are written into @dfn{macros}
1354 and collected into a @dfn{macro package}.
1356 All macro packages provide certain common capabilities which fall into
1357 the following categories.
1359 @subsection Paragraphs
1360 @cindex paragraphs
1362 One of the most common and most used capability is starting a paragraph.
1363 There are a number of different types of paragraphs, any of which can be
1364 initiated with macros supplied by the macro package.  Normally,
1365 paragraphs start with a blank line and the first line indented, like the
1366 text in this manual.  There are also block style paragraphs, which omit
1367 the indentation:
1369 @example
1370 Some   men  look   at  constitutions   with  sanctimonious
1371 reverence, and deem them like the ark of the covenant, too
1372 sacred to be touched.
1373 @end example
1375 @noindent
1376 And there are also indented paragraphs which begin with a tag or label
1377 at the margin and the remaining text indented.
1379 @example
1380 one   This is  the first paragraph.  Notice  how the first
1381       line of  the resulting  paragraph lines up  with the
1382       other lines in the paragraph.
1383 longlabel
1384       This  paragraph   had  a  long   label.   The  first
1385       character of text on the first line will not line up
1386       with  the  text  on  second  and  subsequent  lines,
1387       although they will line up with each other.
1388 @end example
1390 A variation of this is a bulleted list.
1391 @c XXX description
1393 @subsection Sections and Chapters
1395 Most macro packages supply some form of section headers.  The simplest
1396 kind is simply the heading on a line by itself in bold type.  Others
1397 supply automatically numbered section heading or different heading
1398 styles at different levels.  Some, more sophisticated, macro packages
1399 supply macros for starting chapters and appendicies.
1401 @subsection Headers and Footers
1403 Every macro packages gives you some way to manipulate the headers and
1404 footers (or @dfn{titles}) on each page.  Some packages will allow you to
1405 have different ones on the even and odd pages (for material printed in a
1406 book form).
1408 The titles are called three-part titles, that is, there is a
1409 left-justified part, a centered part, and a right-justified part.  An
1410 automatically generated page number may be put in any of these fields
1411 with the @samp{%} character (@pxref{Page Layout} for more details).
1413 @subsection Page Layout
1415 Most macro packages let you specify top and bottom margins and other
1416 details about the appearance of the printed pages.
1418 @subsection Displays
1419 @cindex displays
1421 Displays are sections of text to be set off from the body of the paper.
1422 Major quotes, tables, and figures are types of displays, as are all the
1423 examples used in this document.
1425 @cindex quotes, major
1426 @cindex major quotes
1427 @dfn{Major quotes} are quotes which are several lines long, and hence
1428 are set in from the rest of the text without quote marks around them.
1430 @cindex list
1431 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
1432 should be used when the material to be printed should not be filled and
1433 justified like normal text, such as columns of figures or the examples
1434 used in this paper.
1436 @cindex keep
1437 A @dfn{keep} is a display of lines which are kept on a single page if
1438 possible.  An example of where you would use a keep might be a diagram.
1439 Keeps differ from lists in that lists may be broken over a page boundary
1440 whereas keeps will not.
1442 @cindex keep, floating
1443 @cindex floating keep
1444 Floating keeps move relative to the text.  Hence, they are good for
1445 things which will be referred to by name, such as ``See figure@w{ }3''.
1446 A floating keep will appear at the bottom of the current page if it will
1447 fit; otherwise, it will appear at the top of the next page.  Meanwhile,
1448 the surrounding text will `flow' around the keep, thus leaving now blank
1449 areas.
1451 @subsection Footnotes and annotations
1452 @cindex footnotes
1453 @cindex annotations
1455 There are a number of requests to save text for later printing.
1456 @dfn{Footnotes} are printed at the bottom of the current page.  Delayed
1457 text is intended to be a variant form of footnote; the text is printed
1458 only when explicitly called for, such as at the end of each chapter.
1460 @cindex delayed text
1461 @dfn{Delayed text} is very similar to a footnote except that it is
1462 printed when called for explicitly.  This allows a list of references to
1463 appear (for example) at the end of each chapter, as is the convention in
1464 some disciplines.
1466 Most macro packages which supply this functionality also supply a means
1467 of automatically numbering either type of annotation.
1469 @subsection Table of Contents
1470 @cindex table of contents
1471 @cindex contents, table of
1473 @dfn{Tables of contents} are a type of delayed text having a tag
1474 (usually the page number) attached to each entry after a row of dots.
1475 The table accumulates throughout the paper until printed, usually after
1476 the paper has ended.  Many macro packages will provide the ability to
1477 have several tables of contents (i.e.@: one standard one, one for
1478 tables, etc).
1480 @subsection Indices
1481 @cindex index
1483 While some macro packages will use the term @dfn{index}, none actually
1484 provide that functionality.  The facilities they call indices are
1485 actually more appropriate for tables of contents.
1487 @subsection Paper formats
1488 @cindex paper formats
1490 Some macro packages provide stock formats for various kinds of
1491 documents.  Many of them provide a common format for the title and
1492 opening pages of a technical paper.  The @code{-mm} macros in particular
1493 provide formats for letters and memoranda.
1495 @subsection Multiple Columns
1497 Some macro packages (except @code{-man}) provide the ability to have two
1498 or more columns on a page.
1500 @subsection Font and Size changes
1502 The builtin font and size functions are not always intuitive, so all
1503 macro packages provide macros to make these operations simpler.
1505 @subsection Predefined Strings
1507 Most macro packages provide various predefined strings for a variety of
1508 uses, examples are sub- and superscripts, printable dates, quotes and
1509 various special characters.
1511 @subsection Preprocessor Support
1513 All macro packages provide support for the various preprocessors.
1515 @subsection Configuration and Customization
1517 Some macro packages provide means of customizing many of details of how
1518 the package behaves.  This ranges from setting the default type size to
1519 changing the appearance of section headers.
1523 @node Macro Packages, Programming Tutorial, Tutorial for Macro Users, Top
1524 @chapter Macro Packages
1525 @cindex macro packages
1526 @cindex packages, macros
1528 This chapter documents the main macro packages that come with
1529 @code{groff}.
1531 @menu
1532 * -man::                        
1533 * -mdoc::                       
1534 * -ms::                         
1535 * -me::                         
1536 * -mm::                         
1537 @end menu
1540 @node -man, -mdoc, Macro Packages, Macro Packages
1541 @section -man
1542 @cindex @code{-man}
1544 @c XXX documentation
1547 @node -mdoc, -ms, -man, Macro Packages
1548 @section -mdoc
1549 @cindex @code{-mdoc}
1551 @c XXX documentation
1554 @node -ms, -me, -mdoc, Macro Packages
1555 @section -ms
1556 @cindex @code{-ms}
1558 @c XXX documentation
1561 @node -me, -mm, -ms, Macro Packages
1562 @section -me
1563 @cindex @code{-me}
1565 @c XXX documentation
1568 @node -mm,  , -me, Macro Packages
1569 @section -mm
1570 @cindex @code{-mm}
1572 @c XXX documentation
1576 @node Programming Tutorial, Preprocessors, Macro Packages, Top
1577 @chapter Programming Tutorial
1578 @cindex programming tutorial
1579 @cindex tutorial for programming
1581 This chapter covers @strong{all} of the facilities of @code{groff}.  If
1582 you are intending to use a macro package, you probably do not want to
1583 read this chapter.
1585 @menu
1586 * Text::                        
1587 * Input Conventions::           
1588 * Measurements::                
1589 * Expressions::                 
1590 * Identifiers::                 
1591 * Embedded Commands::           
1592 * Registers::                   
1593 * Manipulating Filling and Adjusting::  
1594 * Manipulating Hyphenation::    
1595 * Manipulating Spacing::        
1596 * Tabs and Fields::             
1597 * Character Translations::      
1598 * Line Layout::                 
1599 * Page Layout::                 
1600 * Page Control::                
1601 * Fonts::                       
1602 * Sizes::                       
1603 * Strings::                     
1604 * Conditionals and Loops::      
1605 * Writing Macros::              
1606 * Page Motions::                
1607 * Drawing Functions::           
1608 * Traps::                       
1609 * Diversions::                  
1610 * Environments::                
1611 * I/O::                         
1612 * Postprocessor Access::        
1613 * Miscellany::                  
1614 * Debugging::                   
1615 * Implementation Differences::  
1616 * Summary::                     
1617 @end menu
1620 @node Text, Input Conventions, Programming Tutorial, Programming Tutorial
1621 @section Text
1622 @cindex text
1624 @code{groff} input files contain text with control commands interspersed
1625 throughout.  But, even without control codes, @code{groff} will still do
1626 several things with your text: filling and adjusting, adding additional
1627 space after sentences, hyphenating and inserting implicit line breaks.
1629 @menu
1630 * Filling and Adjusting::       
1631 * Hyphenation::                 
1632 * Sentences::                   
1633 * Tab Stops::                   
1634 * Implicit Line Breaks::        
1635 @end menu
1637 @node Filling and Adjusting, Hyphenation, Text, Text
1638 @subsection Filling and Adjusting
1639 @cindex filling and adjusting
1640 @cindex adjusting and filling
1642 When @code{gtroff} reads in text it collects words from input and fits
1643 as many of them together on one output line as it can.  This is known as
1644 @dfn{filling}.
1646 Once @code{gtroff} has a @dfn{filled} line it will try to @dfn{adjust}
1647 it.  which means it will widen the spacing between words until the text
1648 reaches the right margin (in the default adjustment mode).  Extra spaces
1649 between words are preserved, but spaces at the end of lines are ignored.
1650 Spaces at the front of a line will cause a @dfn{break} (breaks will be
1651 explained in @ref{Implicit Line Breaks})
1653 @xref{Manipulating Filling and Adjusting}.
1655 @node Hyphenation, Sentences, Filling and Adjusting, Text
1656 @subsection Hyphenation
1657 @cindex hyphenation
1659 Since the odds of finding a set of words, for every output line, which
1660 will fit nicely on a line without inserting excessive amounts of space
1661 between words is not great, @code{gtroff} will hyphenate words so that
1662 lines can be justified without there being too much space between words.
1663 It uses an internal hyphenation algorithm, to indicate which words can
1664 be hyphenated and how to do so.  When a word is hyphenated the first
1665 part of the word will be added to the current filled line being output
1666 (with an attached hyphen), and the other portion will be added to the
1667 next line to be filled.
1669 @xref{Manipulating Hyphenation}.
1671 @node Sentences, Tab Stops, Hyphenation, Text
1672 @subsection Sentences
1673 @cindex sentences
1675 Although it is often debated, some typesetting rules say there should be
1676 different amounts of space after various puctuation marks.  For example,
1677 a period at the end of a sentence should have twice as much space
1678 following it as would a comma or a period as part of an abbreviation.
1680 @cindex sentence spaces
1681 @cindex spaces between sentences
1682 @cindex french-spacing
1683 @code{gtroff} does this by flagging certain characters (normally
1684 @samp{!}, @samp{?} and @samp{.}) as @dfn{end of sentence} characters.
1685 When @code{gtroff} encounters one of these characters at the end of a
1686 line it will append two @dfn{sentence spaces} in the formatted output.
1687 (Thus, one of the conventions mentioned in @ref{Input Conventions}).
1689 @c XXX also describe how characters like ) are treated here -jjc
1690 @c gotta do some research on this -trent
1692 @node Tab Stops, Implicit Line Breaks, Sentences, Text
1693 @subsection Tab Stops
1694 @cindex tab stops
1695 @cindex stops, tabulator
1697 @code{gtroff} translates @dfn{tabulator stops}, also called @dfn{tabs},
1698 in the input into movements to the next tab stop.  These tab stops are
1699 initially located every half inch across the page.  Using this you can
1700 make simple tables.  However, this can often be deceptive as the
1701 appearance (and width) of your text on a terminal and the results from
1702 @code{gtroff} can vary greatly.
1704 Also, a possible sticking point is that lines beginning with tab
1705 characters will still be filled, again producing unexpected results.
1706 For example, the following input
1708 @multitable {12345678} {12345678} {12345678} {12345678}
1709 @item
1710 @tab 1 @tab 2 @tab 3
1711 @item
1712 @tab   @tab 4 @tab 5
1713 @end multitable
1715 @noindent
1716 will produce
1718 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
1719 @item
1720 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
1721 @end multitable
1723 @xref{Tabs and Fields}.
1725 @node Implicit Line Breaks,  , Tab Stops, Text
1726 @subsection Implicit Line Breaks
1727 @cindex implicit line breaks
1728 @cindex implicit breaks of lines
1729 @cindex line, implicit breaks
1730 @cindex break
1731 @cindex break, implicit
1732 @cindex line break
1734 An important concept in @code{gtroff} is the @dfn{break}.  When a break
1735 occurs, @code{gtroff} will output the partially filled line
1736 (unadjusted), and resume collecting and filling text on the next output
1737 line.
1739 @cindex blank line
1740 @cindex empty line
1741 @cindex line, blank
1742 There are several ways to cause a break in @code{gtroff}.  A blank line
1743 will not only cause a break, but it will also cause a one line vertical
1744 space (effectively a blank line) to be output.
1746 A line which begins with a space will cause a break and the space will
1747 be output at the beginning of the next line.  Note that this space isn't
1748 adjusted, even in fill mode.
1750 The end of file will also cause a break (otherwise the last line of your
1751 document may vanish!)
1753 Certain requests also cause breaks, implicitly or explicity.  This will
1754 be discussed later.
1756 @xref{Manipulating Filling and Adjusting}.
1759 @node Input Conventions, Measurements, Text, Programming Tutorial
1760 @section Input Conventions
1761 @cindex input conventions
1762 @cindex conventions for input
1764 Since @code{gtroff} does filling automatically, it is traditional in
1765 @code{groff} not to try and type things in as nicely formatted
1766 paragraphs.  These are some conventions commonly used when typing
1767 @code{groff} text:
1769 @itemize @bullet{}
1770 @item
1771 Break lines after punctuation, particularily at the end of sentences,
1772 and in other logical places.  Keep separate phrases on lines by
1773 themselves, as entire phrases are often added or deleted when editing.
1774 @item
1775 Try to keep lines less than 40-60@w{ }characters, to allow space for
1776 inserting more text.
1777 @item
1778 Do not try to do any formatting in a WYSIWYG manner (i.e.@: don't try
1779 and use spaces to get proper indentation).
1780 @end itemize
1783 @node Measurements, Expressions, Input Conventions, Programming Tutorial
1784 @section Measurements
1785 @cindex measurements
1787 @cindex units of measurement
1788 @cindex basic units
1789 @cindex machine units
1790 @cindex measurement units
1791 @code{gtroff} (like any other programs) requires numeric parameters to
1792 specify various measurements.  Most numeric parameters@footnote{those
1793 that specify vertical or horizontal motion or a type size} may have a
1794 @dfn{measurement unit} attached.  These units are specified as a single
1795 character which immediately follows the number or expression.  Each of
1796 these units are understood, by @code{gtroff}, to be a multiple of its
1797 @dfn{basic unit}.  So, whenever a different measurement unit is
1798 specified @code{gtroff} converts this into its @dfn{basic units}.  This
1799 basic unit, represented by a @samp{u}, is a device dependent measurement
1800 which is quite small, ranging from 1/75th to 1/72000th of an inch; all
1801 other units are converted eventually to basic units.  The values may be
1802 given as fractional numbers---nevertheless, fractional basic units are
1803 always rounded to integers.
1805 Some of the measurement units are completely independent of any of the
1806 current settings (e.g.@: type size) of @code{gtroff}.
1808 @table @samp
1809 @item i
1810 @cindex inch
1811 @cindex @code{i} unit
1812 @cindex unit, @code{i}
1813 Inches.  An antiquated measurement unit still in use in certain
1814 backwards countries.  One inch is equal to 2.54@dmn{cm}.
1815 @item c
1816 @cindex centimeter
1817 @cindex @code{c} unit
1818 @cindex unit, @code{c}
1819 Centimeters.  One centimeter is equal to 0.3937@dmn{in}.
1820 @item p
1821 @cindex points
1822 @cindex @code{p} unit
1823 @cindex unit, @code{p}
1824 Points.  This is a typesetter's measurement used for measure type size.
1825 It is 72@w{ }points to an inch.
1826 @item P
1827 @cindex pica
1828 @cindex @code{P} unit
1829 @cindex unit, @code{P}
1830 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
1831 12@w{ }points to a pica).
1832 @item s
1833 @itemx z
1834 @cindex @code{s} unit
1835 @cindex unit, @code{s}
1836 @cindex @code{z} unit
1837 @cindex unit, @code{z}
1838 @xref{Fractional Type Sizes}, for a discussion of these units.
1839 @end table
1841 The other measurements understood by @code{gtroff} are dependent on
1842 settings currently in effect in @code{gtroff}.  These are very useful
1843 for specifying measurements which should look proper with any size of
1844 text.
1846 @table @samp
1847 @item m
1848 @cindex em unit
1849 @cindex @code{m} unit
1850 @cindex unit, @code{m}
1851 Ems.  This unit is equal to the current font size in points.  So called
1852 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
1853 in the current font.
1854 @item n
1855 @cindex en unit
1856 @cindex @code{n} unit
1857 @cindex unit, @code{n}
1858 Ens.  This is half of an em.
1859 @item v
1860 @cindex vertical space
1861 @cindex space, vertical
1862 @cindex @code{v} unit
1863 @cindex unit, @code{v}
1864 Vertical space.  This is equivalent to the current line spacing.
1865 @xref{Sizes}, for more information about this.
1866 @item M
1867 @cindex @code{M} unit
1868 @cindex unit, @code{M}
1869 100ths of an em.
1870 @end table
1872 @xref{Fractional Type Sizes}.
1874 @menu
1875 * Default Units::               
1876 @end menu
1878 @node Default Units,  , Measurements, Measurements
1879 @subsection Default Units
1880 @cindex default units
1881 @cindex units, default
1883 Many requests take a default unit.  While this can be helpful at times,
1884 it can cause strange errors in some expressions.  For example, the line
1885 length request expects em's.  Here are several attempts to get a line
1886 length of 3.5@w{ }inches and the results:
1888 @example
1889 3.5i      @result{}   3.5i
1890 7/2       @result{}   0i
1891 7/2i      @result{}   0i
1892 7i/2      @result{}   .1i
1893 7i/2u     @result{}   3.5i
1894 @end example
1896 @noindent
1897 As you can see, the safest way to specify measurements is to always
1898 attach a scaling indicator.
1901 @node Expressions, Identifiers, Measurements, Programming Tutorial
1902 @section Expressions
1903 @cindex expressions
1905 @code{gtroff} has most of operators common to other languages:
1907 @itemize @bullet
1908 @item
1909 Arithmetic: +, -, /, *, %
1910 @item
1911 Comparison: <, >, >=, <=, =, ==  (the last two are the same)
1912 @item
1913 Logical: &, :
1914 @item
1915 Unary operators: -, +, ! (if/while only??)
1916 @item
1917 Maximum and minimum: >?, <?
1918 @item
1919 Scaling: (@var{c};@var{e})
1920 Evaluate @var{e} using @var{c} as the default scaling indicator.
1921 If @var{c} is missing, ignore scaling indicators in the
1922 evaluation of @var{e}.
1923 @end itemize
1925 Parenthesis may be used as in any other language.
1926 However, in groff they are necessary to ensure order of evaluation.
1927 Groff has no operator precedence,
1928 expressions are evaluated left to right.
1929 This means that @samp{3+5*4} is evaluated as if it were parenthesized
1930 like @samp{(3+5)*4}, not as @samp{3+(5*4)}, like you may expect.
1932 For many requests which cause a motion on the page, the unary
1933 operators work differently.
1934 The @samp{+} and @samp{-} operators indicate a motion relative to the
1935 current position (down or up, respectively).  The @samp{|} operator
1936 indicates an absolute position on the page or input line. (????)
1937 @code{+} and @code{-} are also treated differently by @code{nr} (?)
1939 Due to the way arguments are parsed, spaces are not allowed in
1940 expressions, unless the entire expression is surrounded by parenthesis.
1942 @c distribute these through the text
1943 @xref{Request Arguments}
1944 @c distribute these through the text
1945 @xref{Conditionals and Loops}
1948 @node Identifiers, Embedded Commands, Expressions, Programming Tutorial
1949 @section Identifiers
1950 @cindex identifiers
1952 Like any other language troff, has rules for properly formed
1953 identifiers.
1954 In troff an identifier can be made up of most any printable
1955 character.
1956 The only exception is characters which are interpreted by troff
1957 (backslash, square bracket and ?).  So, for example, any of the following
1958 are valid.
1960 @example
1964 end-list
1966 @end example
1968 You can test whether an identifier is valid in groff with the
1969 @code{\A} escape.  It expands to 1 or 0 according whether its argument
1970 (given in quotes) is or is not acceptable as the name of a string,
1971 macro, diversion, number register, environment or font. It will return
1972 0 if no argument is given. This is useful if you want to lookup user
1973 input in some sort of associative table.
1975 Identifiers in groff can be any length, but, in some contexts,
1976 groff needs to told
1977 where identifiers end and text begins (and in different ways
1978 depending on their length)
1980 @itemize @bullet{}
1981 @item
1982 Single character
1983 @item
1984 Two characters
1985 Must be prefixed with @samp{(} in some situations.
1986 @item
1987 Arbitrary length (groff only)
1988 Must be bracketed with @samp{[}, @samp{]} in some situations.
1989 Any length identifier can be put in brackets.
1990 @end itemize
1992 Unlike many other programming languages, undefined identifiers are
1993 silently ignored or expanded to nothing.
1996 @c distribute these through the text
1997 @xref{Interpolating Registers}
1998 @c distribute these through the text
1999 @xref{Strings}
2002 @node Embedded Commands, Registers, Identifiers, Programming Tutorial
2003 @section Embedded Commands
2004 @cindex embedded commands
2005 @cindex commands, embedded
2007 With most documents you need more funtionality beyond filling,
2008 adjusting and implicit line breaking.
2009 In order to gain further functionality, groff allows commands to be
2010 embeded into your text, in two ways.
2012 The first is a @dfn{request} which takes up an entire line, and does
2013 some large scale operation (e.g. break lines, start new pages).
2015 The other is an @dfn{escape} which can be embedded anywhere
2016 in your text, or even as an argument to a request. (Not always?)
2017 Escapes generally do more minor operations like sub- and super-
2018 scripts, print a symbol, &c.
2020 @menu
2021 * Requests::                    
2022 * Macros::                      
2023 * Escapes::                     
2024 @end menu
2026 @node Requests, Macros, Embedded Commands, Embedded Commands
2027 @subsection Requests
2028 @cindex requests
2030 @cindex control character
2031 @cindex character, control
2032 A request line begins with a control character,
2033 which is either a single quote (@samp{'}) or a period (@samp{.}).
2034 These can be changed @pxref{Character Translations}, for details.
2035 After this there may be optional tabs or spaces followed by an
2036 identifier which is the name of the request.
2037 This may be followed by any number of space separated arguments.
2039 @findex \&
2040 If you want to begin a line with a control character without it being
2041 interpreted, precede it with a @code{\&}.  This represents a zero
2042 width space, which means it will not affect you output.
2044 In most cases you will use the period as a control character.
2045 Several requests will cause a break, using the single quote control
2046 character will prevent this.
2048 @menu
2049 * Request Arguments::           
2050 @end menu
2052 @node Request Arguments,  , Requests, Requests
2053 @subsubsection Request Arguments
2054 @cindex request arguments
2055 @cindex arguments to requests
2057 Argument to requests (and macros) are processed much like the shell:
2058 The line is split into arguments according to spaces.
2059 An argument which is intended to contain spaces can either be enclosed
2060 in quotes (single or double), or have the spaces @dfn{escaped} with
2061 backslashes.
2063 So, for example:
2065 @example
2066 .uh The Mouse Problem
2067 .uh "The Mouse Problem"
2068 .uh The\ Mouse\ Problem
2069 @end example
2071 The first line is the @code{.uh} macro being called with 3 arguments,
2072 @samp{The}, @samp{Mouse}, and @samp{Problem}.
2073 The latter two have the same effect or calling the @code{.uh} macro
2074 with one argument @samp{The Mouse Problem}.
2076 Note, however, that the @code{.ds} request works differently.
2078 @c distribute these through the text
2079 @xref{Strings}
2081 @node Macros, Escapes, Requests, Embedded Commands
2082 @subsection Macros
2083 @cindex macros
2085 Troff has a @dfn{macro} facility for defining a series of lines which
2086 can be invoked by name.
2087 They are called in the same manner as requests
2088 and arguments may be passed in the same manner.
2091 @c distribute these through the text
2092 @xref{Writing Macros}
2093 @c distribute these through the text
2094 @xref{Request Arguments}
2096 @node Escapes,  , Macros, Embedded Commands
2097 @subsection Escapes
2098 @cindex escapes
2100 @findex \e
2101 @findex \\
2102 Escapes may occur anywhere in the input to groff.
2103 They begin with a backslash and are followed by a single character
2104 which indicates the function to be performed.
2105 If you want to have a backslash appear in your document, you should
2106 use the escape sequence @code{\e}.  Merely escaping the backslash
2107 with another backslash will work in @emph{some} curcumstances.
2109 Many escapes have no parameters, those that do, do so in one of two
2110 ways.  For escapes which require an identifier there must be a way for
2111 groff to tell where the identifier ends and the text begins.
2112 It assumes that the next single character is the identifier, but if
2113 that character is an open parenthesis, it takes the next two
2114 characters as the identifier; and if the next character is an open
2115 bracket, all characters until a close bracket are taken as the
2116 identifier.  Note that in the second case there is no closing
2117 parenthesis.  For example:
2119 @example
2121 \n(XX
2122 \*[TeX]
2123 @end example
2125 Other escapes may require several arguments and/or some special
2126 format.  In these cases the @dfn{argument} is enclosed in single
2127 quotes (not required??) and the enclosing text is decoded according
2128 to what that escape expects.
2130 @example
2131 \l'1.5i\(bu'
2132 @end example
2134 @findex \\
2135 @findex \e
2136 @findex \E
2137 If you want to have a backslash appear in your output, you can use several
2138 escapes: @code{\\}, @code{\e} or @code{\E}.
2139 These are very similar, and only differ with respect to being used in
2140 macros or diversions (@xref{Copy-in Mode}, and @ref{Diversions}, for
2141 more information)
2145 @c distribute these through the text
2146 @xref{Identifiers}
2148 @menu
2149 * Comments::                    
2150 @end menu
2152 @node Comments,  , Escapes, Escapes
2153 @subsubsection Comments
2154 @cindex comments
2156 @findex \"
2157 Probably one of the most@footnote{Unfortunately, this is a lie.  But
2158 hopefully future troff hackers will believe it :-)}
2159 common forms of escapes is the comment.
2160 They begin with the @code{\"} escape and end at the end of the input
2161 line.
2163 This may sound simple, but it can be tricky to keep the comments from
2164 interfering with the apperarance of your final outupt.
2166 If the escape is to the right of some text or a request, that portion
2167 of the line will be ignored, but the space leading up to it will be
2168 noticed by groff.  This only affects the @code{.ds} request (any
2169 others?).
2171 One possibly irritating idiosyncracy is that you mustn't use tabs to
2172 line up your comments.
2173 Tabs are not treated as white space between request and macro
2174 arguments.
2176 If you have a comment on a line by itself, it will be treated as a
2177 blank line, because after eliminating the comment, that is all that
2178 remains.  So, it is common to start the line with @code{.\"} which
2179 will cause the line to be treated as an undefined request.
2181 Another commenting scheme seen sometimes is three consecutive single
2182 quotes (@code{'''}) at the begining of a line.  This works, but groff
2183 will give a warning about an undefined macro, which is harmless, but
2184 irritating.
2186 @findex \#
2187 Now to avoid all this groff has a new comment mechanism using the
2188 @code{\#} escape.  This escape works the same as @code{\"} except
2189 that the newline is also ignored.
2191 @findex ig
2192 For large blocks of text, the @code{ig} request may be useful.
2193 @c distribute these through the text
2194 @xref{Strings}
2197 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, Programming Tutorial
2198 @section Registers
2199 @cindex registers
2201 Registers are groff's numeric variables.  groff has a number of
2202 builtin registers, supplying anything from the date to details of
2203 formatting parameters.
2205 @c distribute these through the text
2206 @xref{Identifiers}
2208 @menu
2209 * Setting Registers::           
2210 * Interpolating Registers::     
2211 * Auto-increment::              
2212 * Assigning Formats::           
2213 * Builtin Registers::           
2214 @end menu
2216 @node Setting Registers, Interpolating Registers, Registers, Registers
2217 @subsection Setting Registers
2218 @cindex setting registers
2219 @cindex registers, setting
2221 @findex nr
2222 @findex \R
2223 Registers are defined/set via the @code{nr}
2224 request or the @code{\R} escape, for example, the following two lines
2225 are equivalent:
2227 @example
2228 .nr a 1
2229 \R'a 1'
2230 @end example
2232 @findex rr
2233 The @code{rr} request will
2234 remove the register specified by the argument.
2236 @findex rnn
2237 The @code{rnn} request will rename a number register.
2238 The format is @samp{.rnn @var{x} @var{y}}, which will
2239 rename number register  @var{x} to @var{y}.
2241 @findex aln
2242 Aliases can be created for a number register.  The format is
2243 @samp{.aln @var{xx} @var{yy}}, which will create an alias @var{xx} for
2244 number register object named @var{yy}.  The new name and the old name
2245 will be exactly equivalent.  If @var{yy} is undefined, a warning of
2246 type @samp{reg} will be generated, and the request will be ignored.
2247 @xref{Debugging}, for information about warnings.
2249 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
2250 @subsection Interpolating Registers
2251 @cindex interpolating registers
2252 @cindex registers, interpolating
2254 @findex \n
2255 Numeric registers are @dfn{interpolated} via the @code{\n} escape.
2256 @c the following is wrong.  Should I say any more than the above??
2257 @c This means that the value of the number register in expanded in-place
2258 @c on the input line before any other actions, i.e. before requests and
2259 @c escapes are interpreted.
2261 @example
2262 .nr as \na+\na
2263 \n(as
2264 @end example
2266 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
2267 @subsection Auto-increment
2268 @cindex auto-increment
2269 @cindex increment, automatic
2271 Number registers can also be auto incremented/decremented.  You can
2272 specify the increment/decrement factor with third argument to the
2273 @code{nr} request.  The default value is 0.  For example:
2275 @example
2276 .nr a 0 1
2277 .nr xx 0 5
2278 \n+a, \n+a, \n+a, \n+a, \n+a
2280 \n+(xx, \n+(xx, \n+(xx, \n+(xx, \n+(xx
2281 @end example
2283 Produces:
2285 @example
2286 1, 2, 3, 4, 5
2287 5, 10, 15, 20, 25
2288 @end example
2290 If you want to change the increment factor without changing the value
2291 of a register, the following can be used.
2293 @example
2294 .nr a \na 10
2295 @end example
2297 @node Assigning Formats, Builtin Registers, Auto-increment, Registers
2298 @subsection Assigning Formats
2299 @cindex assigning formats
2300 @cindex formats, assigning
2302 @findex af
2303 When a register is used in the text of an input file
2304 (as opposed to part of an expression)
2305 it is textually replaced (or interpolated) with a representation of
2306 that number.
2307 This output format can be changed to a variety of formats
2308 (numbers, roman numerals, etc)
2309 This is done using the @code{af} request.
2310 The first argument to @code{af} is the name of the number register to
2311 be changed,
2312 and the second argument is the output format.
2313 The following output formats are available:
2315 @table @samp
2316 @item 1
2317 This is the default format, decimal numbers:
2318 1, 2, 3, @dots{}
2319 @item 001
2320 Decimal numbers with as many leading zeros as specified.
2321 So, @samp{001} would result in 001, 002, 003, @dots{}
2322 @item I
2323 @cindex roman numerals
2324 @cindex numerals, roman
2325 Upper-case roman numerals:
2326 0, I, II, III, IV, @dots{}
2327 @item i
2328 Lower-case roman numerals:
2329 0, i, ii, iii, iv, @dots{}
2330 @item A
2331 Upper-case letters:
2332 A, B, C, @dots{}, Z, AA, AB, @dots{}
2333 @item a
2334 Lower-case letters:
2335 a, b, c, @dots{}, z, aa, ab, @dots{}
2336 @end table
2338 The following example will produce @samp{10, X, j, 010}.
2340 @example
2341 .nr a 10
2342 .af a 1           \" the default format
2343 \na,
2344 .af a I
2345 \na,
2346 .af a a
2347 \na,
2348 .af a 001
2350 @end example
2352 @findex \g
2353 The @code{\g} escape returns the current format of the specified
2354 register.  For example, @samp{\ga} after the following example would
2355 produce @samp{001}.
2357 @node Builtin Registers,  , Assigning Formats, Registers
2358 @subsection Builtin Registers
2359 @cindex builtin registers
2360 @cindex registers, builtin
2362 The following are some builtin registers, which are not listed
2363 elsewhere in this manual.  Any registers which begin with a @samp{.}
2364 are read-only.  A compleat listing of all builtin registers can be
2365 found in @ref{Register Index}.
2367 @table @code
2368 @item .H
2369 @vindex .H
2370 Horizontal resolution in basic units.
2371 @item .V
2372 @vindex .V
2373 Vertical resolution in basic units.
2374 @item dw
2375 @vindex dw
2376 Day of the week (1-7).
2377 @item dy
2378 @vindex dy
2379 Day of the year (1-31).
2380 @item mo
2381 @vindex mo
2382 Current month (1-12).
2383 @item year
2384 @vindex year
2385 The year.
2386 @item yr
2387 @vindex yr
2388 The year minus 1900.  Unfortunately, the Unix Version 7 troff
2389 documentation had a year 2000 bug: it incorrectly claimed that
2390 @samp{\n(yr} was the last two digits of the year.  That claim has never
2391 been true of either traditional troff or GNU troff.  If you see old
2392 troff input that looks like this:
2394 @example
2395 '\" (The following line stopped working after 1999.)
2396 This document was formatted in 19\n(yr.
2397 @end example
2399 you can correct it as follows:
2401 @example
2402 This document was formatted in \n[year].
2403 @end example
2405 or, if you want to be portable to older troff versions, as follows:
2407 @example
2408 .nr y4 1900+\n(yr
2409 This document was formatted in \n(y4.
2410 @end example
2412 @item .c
2413 @vindex .c
2414 @itemx c.
2415 @vindex c.
2416 The current @emph{input} line number.
2417 @item ln
2418 @vindex ln
2419 The current @emph{output} line number.
2420 @item .x
2421 @vindex .x
2422 The  major  version  number.  For example, if the version number is 1.03
2423 then @code{.x} will contain 1.
2424 @item .y
2425 @vindex .y
2426 The minor version number.  For example, if the version number is 1.03
2427 then @code{.y} will contain 03.
2428 @item .Y
2429 @vindex .Y
2430 The revision number of groff.
2431 @item .g
2432 @vindex .g
2433 Always 1.
2434 Macros should use this to determine whether they are running
2435 under GNU troff.
2436 @item .A
2437 @vindex .A
2438 If the current output device is @sc{ascii}, this is set to 1, zero
2439 otherwise.
2440 @item .P
2441 @vindex .P
2442 This register indicates whether the current page is actualy being
2443 printed, i.e. if the @samp{-o} option is being used to only print
2444 selected pages.
2445 @xref{Options}, for more information.
2446 @end table
2449 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, Programming Tutorial
2450 @section Manipulating Filling and Adjusting
2451 @cindex manipulating filling and adjusting
2452 @cindex filling and adjusting, manipulating
2453 @cindex adjusting and filling, manipulating
2455 @findex br
2456 @cindex break
2457 @cindex line break
2458 Several ways of causing @dfn{breaks} were given in
2459 @ref{Implicit Line Breaks}.
2460 The @code{br} request will likewise cause a break.
2461 Several other requests will also cause breaks, implicitly.
2462 They are
2463 @code{bp},
2464 @code{ce},
2465 @code{fi},
2466 @code{fl},
2467 @code{in},
2468 @code{nf},
2469 @code{sp} and
2470 @code{ti}.
2472 @findex nf
2473 @findex fi
2474 @vindex .u
2475 Initially, groff will fill and ajust text to both margins.
2476 Filling can be disabled via the @code{nf} request
2477 and re-enabled with the @code{fi} request.
2478 These implicitly disable and re-enable adjusting.
2479 Both of these will cause break in text currently being filled.
2480 The number register @code{.u} is equal to 1 in fill mode and 0 in
2481 no-fill mode.
2483 @findex ad
2484 @findex na
2485 @vindex .j
2486 Adjusting can be disabled with the @code{ad} request and re-enabled
2487 with the @code{na} request.
2488 The @code{ad} request takes a single argument to indicate how to
2489 adjust text.
2490 The current adjustment mode is available in the number register
2491 @code{.j}.
2493 @table @samp
2494 @item l
2495 @cindex ragged-right
2496 Adjust text to the left margin.  This produces what is traditionally
2497 called ragged-right text.
2498 @item r
2499 Adjust text to the right margin.
2500 @item c
2501 Center filled text.
2502 @item b
2503 @itemx n
2504 Justify to both margins.  This is groff's default.
2505 @end table
2507 With no argument to @code{ad}, troff will adjust lines the same way
2508 it was the last time it was filling.  For example:
2510 @example
2511 text
2512 .ad r
2513 text
2514 .ad c
2515 text
2517 text
2518 .ad  \" back to centering
2519 text
2520 @end example
2522 @findex \p
2523 The escape @code{\p} will cause a break and cause the remaining text
2524 to be adjusted.
2526 @findex ss
2527 The @code{ss} request allows you to change the minimum size of a
2528 space between filled words.
2529 This request takes it's units as one twelfth of the
2530 spacewidth parameter for the current font.  Initially both the word
2531 space size and the sentence space size are 12.
2533 When two arguments are given to the @code{ss} request, the second argument
2534 gives the sentence space size. If the second argument is not given, the
2535 sentence space size will be the same as the word space size.
2536 The sentence space size
2537 is used in two circumstances: if the end of a sentence occurs at the end
2538 of a line in fill mode, then both an inter-word space and a sentence
2539 space will be added; if two spaces follow the end of a sentence in the
2540 middle of a line, then the second space will be a sentence space. Note
2541 that the behaviour of @sc{Unix} troff will be exactly that exhibited by GNU
2542 troff if a second argument is never given to the @code{ss} request. In GNU
2543 troff, as in @sc{Unix} troff, you should always follow a sentence with either
2544 a newline or two spaces.
2546 @vindex .ss
2547 @vindex .sss
2548 The number registers @code{.ss} and @code{.sss} are
2549 the values of the parameters set by the first and second
2550 arguments of the @code{ss} request.
2552 @findex ce
2553 The @code{ce} request will center text.
2554 While the @samp{ad c} request will also center text, it has the side
2555 effect of filling the text.  The @code{.ce} request will not fill the
2556 text it affects.
2557 This request causes a break.
2559 With no arguments, @code{ce} will fill the next line of text.
2560 The single argument @code{ce} takes is a number indicating the
2561 number of lines to be centered.  With no argument centering is
2562 disabled.
2564 A common idiom is to turn on centering for a large number of lines,
2565 and then turn off centering when you are done with the centered text.
2566 This is useful for any request which takes a number of lines as an
2567 argument.
2569 @example
2570 .ce 1000
2571 replace this
2572 with
2573 something
2574 more interesting
2575 @dots{}
2576 .ce 0
2577 @end example
2579 @vindex .ce
2580 The @code{.ce} number register contains the number of lines remaining
2581 to be centered, as set by the @code{ce} request.
2584 @findex rj
2585 @vindex .rj
2586 A similar request is @code{rj} request which will justify unfilled
2587 text to the right margin.  Its arguments are identical to the
2588 @code{ce} request.
2589 The @code{.rj} number register is
2590 the number of lines to be right-justified as set by the @code{rj}
2591 request.
2594 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, Programming Tutorial
2595 @section Manipulating Hyphenation
2596 @cindex manipulating hyphenation
2597 @cindex hyphenation, manipulating
2599 As discussed in @ref{Hyphenation}, groff will hyphenate words.
2600 There are a number of ways to modify the how hyphenation is done.
2602 @findex nh
2603 @findex hy
2604 @vindex .hy
2605 This hyphenation can be turned off with the @code{nh} request, and
2606 turned back on with the @code{hy} request.  However, troff's
2607 hyphenation facilities are far more flexible than this.  The @code{hy}
2608 request can be used to tell troff to restrict hypenation to certain
2609 cases.  The request takes a single numeric argument.
2610 The current hyphenation restrictions can be found in the number
2611 register @code{.hy}
2613 @table @samp
2614 @item 1
2615 The default argument, which
2616 indicates to hyphenate without restrictions.
2617 @item 2
2618 Do not hyphenate the last word on a page or column.
2619 @item 4
2620 Do not hyphenate the last two characters of a word.
2621 @item 8
2622 Do not hyphenate the first two characters of a word.
2623 @end table
2625 @findex hlm
2626 @vindex .hlc
2627 @vindex .hlm
2628 The @code{hlm} request will
2629 set the maximum number of consecutive hyphenated lines to the value
2630 given as the first argument.
2631 If this number is
2632 negative, there is no maximum.  The default value is -1.
2633 This value is
2634 associated with the current environment.  Only lines output from an
2635 environment count towards the maximum associated with that environment.
2636 Hyphens resulting from @code{\%} are counted; explicit hyphens are not.
2637 The current setting of this is available in the @code{.hlm} request.
2638 Also the number of immediately preceding consecutive hyphenated lines
2639 are available in the number register @code{.hlc}.
2641 @findex hw
2642 The @code{hw} request allows you to specify how a specific word is
2643 to be hyphenated.  It takes only one argument which is the word with
2644 hyphens at the hyphenation points.  For example:
2645 @samp{.hw in-sa-lub-rious}.
2646 @c In old versions of troff there was a
2647 @c limited amount of space to store such information, fortunately,
2648 @c with groff, this is no longer a restriction.
2650 @findex \%
2651 @cindex hyphenation character
2652 @cindex character, hyphenation
2653 You can also tell troff how to hyphenate words on the fly with the
2654 use of the @code{\%} escape, also known as the @dfn{hyphenation
2655 character}.  Preceding a word with this character will prevent it
2656 from being hyphenated, putting it in a word will indicate to troff
2657 that the word may be hyphenated at that point.  Note that this
2658 mechanism will only affect one word, if you want to change the
2659 hyphenation of a word for the entire document, use the @code{hw}
2660 request.
2662 @findex hc
2663 The @code{hc} request allows you to change the hyphenation character.
2664 The character specified as an argument will then work the same as the
2665 @code{\%} escape, and, thus, no longer appear in the output.  Without
2666 an argument it will return the hyphenation character to @code{\%}.
2668 @findex hpf
2669 To further customize hyphenation the @code{hpf} request will read in
2670 a file of hyphenation patterns.
2671 This file will be searched for in the
2672 same way that @file{tmac.@var{name}} is searched for when the
2673 @samp{-m@var{name}} option is specified.
2675 It should have the same format as the argument to the
2676 \patterns primitive in @TeX{}; the letters appearing in this file are
2677 interpreted as hyphenation codes.
2678 A @samp{%} character in the patterns file
2679 introduces a comment that continues to the end of the line.
2681 @findex hla
2682 @findex hpf
2683 @pindex troffrc
2684 The set of
2685 hyphenation patterns is associated with the current language set by the
2686 @code{hla} request.  The @code{hpf} request is usually invoked by the
2687 @file{troffrc} file.
2689 @findex hcode
2690 @code{.hcode @var{c1 code1 c2 code2...}}
2691 Set the hyphenation code of character @var{c1} to code1 and that of
2692 @var{c2} to @var{code2}.
2693 A hyphenation code must be a single input character (not a
2694 special character) other than a digit or a space.  Initially each
2695 lower-case letter has a hyphenation code, which is itself, and each
2696 upper-case letter has a hyphenation code which is the lower case
2697 version of itself.
2699 @findex hym
2700 @vindex .hym
2701 The @code{hym} request will set the hyphenation margin to the value
2702 given as the first argument: when the current adjustment mode is not
2703 @samp{b}, the line will not be hyphenated if the line is no more than
2704 that amount short.
2705 The default hyphenation margin is 0.  The default scaling
2706 indicator for this request is m.  The hyphenation margin is associated
2707 with the current environment.  The current hyphenation margin is
2708 available in the @code{.hym} register.
2710 @findex hys
2711 @vindex .hys
2712 The @code{hys} request set the hyphenation space to the value given as
2713 the first argument: when the current adjustment mode is b, don't
2714 hyphenate the line if the line can be justified by adding no more than
2715 that amount of extra space to each word space.  The default
2716 hyphenation space is 0.  The default scaling indicator for this
2717 request is m.  The hyphenation space is associated with the current
2718 environment.  The current hyphenation space is available in the
2719 @code{.hys} register.
2721 @findex shc
2722 The @code{shc} request will set the soft hyphen character to the
2723 argument given as an argument.  If the argument is omitted, the soft
2724 hyphen character will be set to the default @code{\(hy}. The soft
2725 hyphen character is the character which will be inserted when a word
2726 is hyphenated at a line break.  If the soft hyphen character does not
2727 exist in the font of the character immediately preceding a potential
2728 break point, then the line will not be broken at that point.  Neither
2729 definitions (specified with the @code{char} request) nor translations
2730 (specified with the @code{tr} request) are considered when finding the soft
2731 hyphen character.
2733 @findex hla
2734 @vindex .hla
2735 @pindex troffrc
2736 The @code{hla} request will set the current hyphenation language to
2737 that given by the first argument.  Hyphenation exceptions specified
2738 with the @code{hw} request and hyphenation patterns specified with the
2739 @code{hpf} request are both associated with the current hyphenation
2740 language.  The @code{hla} request is usually invoked by the
2741 @file{troffrc} file.  The current hyphenation language is available
2742 in the number register @code{.hla}.
2745 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, Programming Tutorial
2746 @section Manipulating Spacing
2747 @cindex manipulating spacing
2748 @cindex spacing, manipulating
2750 @findex sp
2751 The @code{sp} request will cause troff to space downwards the
2752 distance specified as the first argument.  With no argument it will
2753 advance 1 line.
2754 A negative argument will cause troff to move up the page the
2755 specified distance.
2756 If the argument is preceded by a @samp{|} troff will move that
2757 distance from the top of the page.
2759 @findex ls
2760 @vindex .L
2761 Often you may want your output to be double or triple spaced.
2762 The @code{ls} request will cause troff to output @var{n}-1 blank
2763 lines after each line of text, where @var{n} is the argument given to
2764 the @code{ls} request.  With no argument troff will go back to single
2765 spacing.  The number register @code{.L} contains the current line
2766 spacing setting.
2768 @findex \x
2769 @vindex .a
2770 Sometimes, extra vertical spacing is only needed occasionaly,
2771 i.e. to allow space for a tall construct (like an equation).
2772 The @code{\x} escape will do this.
2773 The escape is given a numerical argument (like @samp{\x'3p'}).
2774 If this number is positive extra vertical space will be inserted
2775 below the current line.  A negative number will add space above.
2776 If this escape is used multiple times on the same line, the maximum
2777 values are used.
2778 The @code{.a} number register contains the most recent
2779 extra vertical @strong{emph} line space.
2781 @example
2782 ... example of inline equation ...
2783 @end example
2785 @findex ns
2786 @findex rs
2787 @cindex no-space mode
2788 @cindex mode, no-space
2789 Spacing (via either @code{sp} or via blank lines) can be disabled
2790 with the @code{ns} request.  This will enable @dfn{no-space mode}.
2791 This mode will end when actual text is output or the @code{rs}
2792 request is encountered.  No-space mode will also prevent requests to
2793 advance to the next page unless they are accompanied by a page number
2794 (@pxref{Page Control}, for more information.)
2797 @node Tabs and Fields, Character Translations, Manipulating Spacing, Programming Tutorial
2798 @section Tabs and Fields
2799 @cindex tabs and fields
2800 @cindex fields and tabs
2802 @findex \t
2803 Tab stops are much like those on a typewriter: a tab character (or the
2804 @code{\t} escape) on input will cause horizontal motion to the next
2805 tab stop.
2807 @findex ta
2808 Tab stops can be changed with the @code{ta} request.
2809 This request takes a series of numbers as arguments which indicate
2810 where each tab stop is to be (overriding any previous settings).
2811 These can be specified absolutely,
2812 i.e. as the distance from the left margin.
2813 For example, the following wil set tab stops every one inch.
2815 @example
2816 .ta 1i 2i 3i 4i 5i 6i
2817 @end example
2819 Tab stops can also be specified relatively (using a leading @samp{+})
2820 which means that the specified tab stop will be set that distance
2821 from the previous tab stop.  For example the following is equivalent
2822 to the previous example.
2824 @example
2825 .ta 1i +1i +1i +1i +1i +1i
2826 @end example
2828 After the specified tab stops repeat values may be set for tabs beyond
2829 the last one specified.  This is most commonly used to specify tabs
2830 set at equal intervals.  The compleat syntax for setting tabs is
2831 @code{ta @var{n1} @var{n2} @dots{} @var{nn} T @var{r1} @var{r2}
2832 @dots{} @var{rn}} This will set tabs at positions @var{n1}, @var{n2},
2833 @dots{}, @var{nn} and then set tabs at @var{nn}+@var{r1},
2834 @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn} and then at
2835 @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2}, @dots{},
2836 @var{nn}+@var{rn}+@var{rn}, and so on.  For example the following is,
2837 yet again, the same as the previous examples.
2839 @example
2840 .ta T 1i
2841 @end example
2843 The material in each tab column may be justified to the right or left
2844 or centered in the column.  This is specified by appending an
2845 @samp{R}, @samp{L} or @samp{C} to the number specifying that tab stop.
2846 The default justification is @samp{L}.
2848 @example
2849 .ta 1i 2iC 2iR
2850 @end example
2852 @vindex .tabs
2853 The number register @code{.tabs} contains
2854 a string representation of the current tab settings suitable for use as
2855 an argument to the @code{ta} request.
2857 @findex tc
2858 Normally troff will fill the space to the next tab stop with spaces.
2859 In some cases you may wish to change this.  The @code{tc} request
2860 will do this.  With no argument troff will revert to using spaces.
2862 @subsection Leaders
2863 @cindex leaders
2865 @findex lc
2866 Sometimes you may wish to use the @code{tc} request to fill a tab
2867 stop with a given character, but also, you want to use normal tab
2868 stops on the rest of the line.  For this groff provides an alternate
2869 tab mechanism, called @dfn{leaders} which will do just that.
2870 They are used exclusively to produce a repeated run of characters to
2871 the next tab stop.
2873 You can declare what character will be repeated with the @code{lc}
2874 request.  If you do not give it an argument, the leaders will act the
2875 same as tabs.
2877 @findex \a
2878 The difference is that a leader is invoked by using the @code{\a}
2879 escape.
2881 @cindex table of contents
2882 @cindex contents, table of
2883 So for a table of contents you may want to have tab stops defined so
2884 that the section number is one tab stop, the title is the second with
2885 the remaining space being filled with a line of dots and then the
2886 page number slightly separated from the dots.
2888 @example
2889 .lc .
2890 .ta .5iR 5i +.25i
2891 1.1\tFoo\a\t12
2892 @end example
2894 @subsection Fields
2895 @cindex fields
2897 @findex fc
2898 Fields are a more general way of laying out tabular data.
2899 @code{fc}
2901 @node Character Translations, Line Layout, Tabs and Fields, Programming Tutorial
2902 @section Character Translations
2903 @cindex character translations
2904 @cindex translations of characters
2906 @findex cc
2907 @findex c2
2908 The control character (@samp{.}) and the no-break control character
2909 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
2910 respectively.
2911 The single argument is the new character to be used, with no argument
2912 the normal control character is restored.
2914 @findex ec
2915 @findex eo
2916 The @code{eo} request will compleatly disable the escape mechanism.
2917 The @code{ec} request can be used to change the escape character from
2918 the default @samp{\} to what is specified as an argument.
2920 @findex tr
2921 The @code{tr} request will translate characters.
2923 @findex trnt
2924 @findex \!
2925 @code{trnt}
2926 This is the same as the @code{tr} request except that the
2927 translations do not
2928 apply to text that is transparently throughput into a diversion with
2929 @code{\!}.  @xref{Diversions}, for more information.
2930 For example,
2932 @example
2933 .tr ab
2934 .di x
2935 \!.tm a
2938 @end example
2940 will print @samp{b}; if @code{trnt} is used instead of @code{tr} it
2941 will print @samp{a}.
2944 @node Line Layout, Page Layout, Character Translations, Programming Tutorial
2945 @section Line Layout
2946 @cindex line layout
2947 @cindex layout, line
2949 @cindex dimensions, line
2950 @cindex line dimensions
2951 The following drawing shows the dimensions which troff uses for
2952 placing a line of output onto the page.  They are labeled with the
2953 request which manipulates that dimension.
2955 @example
2956 @group
2957               | -->| in |<--                   |
2958            -->| po |<-----------ll------------>|
2959               +----+----+----------------------+----+
2960               |    :    :                      :    |
2961               +----+----+----------------------+----+
2962 @end group
2963 @end example
2965 These dimensions are:
2967 @ftable @code
2968 @item po
2969 @vindex .o
2970 @dfn{Page offset}--This is the leftmost postition of text on the final
2971 output.  This can be adjusted with the @code{po} request, and the
2972 current setting can be found in the builtin number register @code{.o}
2973 Note, that this request does not cause a break, so changing the page
2974 offset in the middle of text being filled may not do what you expect.
2975 @item in
2976 @vindex .i
2977 @dfn{Indentation}--This is the distance from the left margin where text
2978 will be printed.  This can be adjusted with the @code{in} request, and
2979 the current setting can be found in the builtin number register.
2980 @code{.i}
2981 This request causes a break.
2983 @findex ti
2984 @findex .in
2985 There is also the request @code{ti} which will cause one output line
2986 to be indented, after which the indentation returns to 0.
2987 This request causes a break.
2988 The number register @code{.in} is the indent that applies to the
2989 current output line.
2990 @item ll
2991 @findex .l
2992 @findex .ll
2993 @dfn{Line length}--This is the distance from the left margin to right
2994 margin.  This can be adjusted with the @code{.ll} request, and the
2995 current setting can be found in the builtin number register @code{.l}
2996 Note, as the figure implies, line length is not affected by the current
2997 indentation.
2998 The number register @code{.ll} is
2999 the line length that applies to the current output line.
3000 @end ftable
3002 @example
3003 .in +.5i
3004 .ll -.5i
3005 A bunch of really boring text which should
3006 be indented from both margins.
3007 replace me with a better (and more) example!
3008 .in -.5i
3009 .ll +.5i
3010 @end example
3013 @node Page Layout, Page Control, Line Layout, Programming Tutorial
3014 @section Page Layout
3015 @cindex page layout
3016 @cindex layout, page
3018 Troff provides some very primitive operations for controlling page
3019 layout.
3021 @findex pl
3022 @vindex .p
3023 Troff lets you specify the @dfn{page length} via the @code{pl} request.
3024 This is the length of the physical output page.
3025 The current setting can
3026 be found in the builtin number register @code{.p}.  Note that this only
3027 specifies the size of the page, not the not the top and bottom margins.
3028 Those are not done by groff directly, @xref{Traps}, for further
3029 information on how to do this.
3031 @cindex headers
3032 @cindex footers
3033 @cindex titles
3034 Troff provides several operations which help in setting up top and
3035 bottom titles (or headers and footers)
3037 @findex tl
3038 The @code{tl} request will print a @dfn{title line}, which consists
3039 of three parts: a left justified portion, a centered portion and a
3040 right justified portion.  The argument to @code{tl} is specified as
3041 @code{'@var{left}'@var{center}'@var{right}'}
3042 The @samp{%} character is replaced with the current page number.
3044 @findex lt
3045 @vindex .lt
3046 The title line is printed using its own line length, which is
3047 specified with the @code{lt} request.  The current setting of this is
3048 available in the @code{.lt} number register.
3050 @findex pn
3051 The @code{pn} request will change the page number of the @emph{next}
3052 page.  The only argument is the page number.
3054 @vindex %
3055 @vindex .pn
3056 The current page number is stored in the number register @code{%}.
3057 The number register @code{.pn} contains the
3058 number of the next page:
3059 either the value set by a @code{pn} request, or
3060 the number of the current page plus 1.
3062 @findex pc
3063 The @code{pc} request will change the page number character (used by
3064 the @code{tl} request) to a different character.  With no argument,
3065 this mechanism is disabled.
3068 @c distribute these through the text
3069 @xref{Traps}
3072 @node Page Control, Fonts, Page Layout, Programming Tutorial
3073 @section Page Control
3074 @cindex page control
3075 @cindex control, page
3077 @findex bp
3078 To stop processing the current page, and move to the next page, you
3079 can invoke the @code{bp} request.  This request will also cause a
3080 break.  This request can also take an argument of what the next page
3081 should be numbered.
3082 The only difference
3083 between @code{bp} and @code{pn} is that @code{pn} does not cause a
3084 break or actually eject a page.
3086 @example
3087 .de newpage
3089 'sp .5i
3090 .tl 'left top'center top'right top'
3091 'sp .3i
3093 @end example
3095 @cindex orphan
3096 @findex ne
3097 Often you may want to make sure that you have a certain amount of
3098 space before a new page occurs.  This is most useful to make sure
3099 that there is not a single @dfn{orphan} line left at the bottom of a
3100 page.  The @code{ne} request will ensure that there is a certain
3101 distance, specified by the first argument, before the next page is
3102 triggered (@pxref{Traps}, for further information).
3103 The default unit for @code{ne} is v's and the default argument
3104 is 1v.
3106 For example, to make sure that no fewer than 2 lines get orphaned,
3107 you can do the following before each paragraph.
3109 @example
3110 .ne 2
3111 .ti +5n
3112 text
3113 @end example
3115 @findex sv
3116 @findex os
3117 The @code{sv} is similar to the @code{ne} request, it reserves the
3118 specified amount of vertical space.  If the desired amount of space
3119 exists before the next trap (bottom page boundary), the space will be
3120 output immediately.  If there is not enough space, it is stored for
3121 later output via the @code{os} request.
3122 The default argument is 1v and the default units are v's.
3125 @node Fonts, Sizes, Page Control, Programming Tutorial
3126 @section Fonts
3127 @cindex fonts
3129 @findex ft
3130 @findex \f
3131 Groff gives you the ability to switch fonts at any point in your
3132 text.  There are two ways to do this, via the @code{ft} request and
3133 the @code{\f} escape.
3135 Fonts are generaly specified as uppercase strings, which are usually
3136 1 to 4 characters representing an abreviation of acronym of the font
3137 name.
3139 The basic set of fonts are R, I, B, and BI.  These are Times Roman,
3140 Italic, Bold, and Bold Italic.  There is also at least one symbol
3141 font which contains various special symbols (greek, mathematics).
3142 These latter fonts cannot be used directly, but should be used via an
3143 escape.
3145 @menu
3146 * Changing Fonts::              
3147 * Font Families::               
3148 * Font Positions::              
3149 * Using Symbols::               
3150 * Artificial Fonts::            
3151 * Ligatures and Kerning::       
3152 @end menu
3154 @node Changing Fonts, Font Families, Fonts, Fonts
3155 @subsection Changing Fonts
3156 @cindex changing fonts
3157 @cindex fonts, changing
3159 @findex ft
3160 You can change fonts with both the @code{ft} request.
3161 With no arguments it
3162 will switch to the previous font (also known as P).
3164 @example
3165 eggs, bacon,
3166 .ft B
3167 spam
3169 and sausage.
3170 @end example
3172 @findex \f
3173 The @code{\f} escape is useful for changing fonts in the middle of words
3175 @example
3176 eggs, bacon, \fBspam\fP and sausage.
3177 @end example
3179 Both of the above examples will produce the same output.
3181 Sometimes when putting letters of different fonts, you need more or
3182 less space at such boundaries.  There are two escapes to help with
3183 this.
3185 @findex \/
3186 The @code{\/} escape
3187 increases the width of the preceding character so that the spacing
3188 between that character and the following character will be correct if
3189 the following character is a roman character.  For example, if an italic
3190 f is immediately followed by a roman right parenthesis,  then in many
3191 fonts the top right portion of the f will overlap the top left of the
3192 right parenthesis.
3193 It is a good idea to use this escape sequence
3194 whenever an italic character is immediately followed by a roman
3195 character without any intervening space.
3197 @c producing @i{f}), which is ugly.  Inserting \/ produces f) and avoids this problem.
3199 @findex \,
3200 The @code{\,} escape
3201 modifies the spacing of the following character so that the spacing
3202 between that character and the preceding character will correct if the
3203 preceding character is a roman character.
3204 It is a good idea
3205 to use this escape sequence whenever a roman character is immediately
3206 followed by an italic character without any intervening space.
3208 @c For example, inserting \, between the parenthesis and the f changes (f to (f.
3210 @findex ftr
3211 The @code{ftr} request will translate fonts, it is called as
3212 @samp{.ftr @var{F G}}, which
3213 Translate font @var{F} to @var{G}.
3214 Whenever a font named @var{F} is referred to in @code{\f}
3215 escape sequence,
3216 or in the @code{ft}, @var{ul}, @var{bd}, @var{cs}, @var{tkf},
3217 @var{special}, @var{fspecial}, @var{fp},
3218 or @var{sty} requests, font @var{G} will be used.  If @var{G} is
3219 missing, or equal to @var{F} then font @var{F} will not be translated.
3222 @node Font Families, Font Positions, Changing Fonts, Fonts
3223 @subsection Font Families
3224 @cindex font families
3225 @cindex families, font
3227 Due to the variety of fonts available, groff has added the concept of
3228 font families.  Each of these families has four styles (R, I, B and BI),
3230 The fonts are specified as the concatenation of the font family and
3231 style.  Specifying a font without the family part will cause groff to
3232 use that style of the current family.
3233 By default, groff uses the Times family.
3235 This way, you can just use the basic four fonts and select a
3236 different font family on the command line.
3238 @findex fam
3239 @vindex .fam
3240 You can also switch font families with the @code{fam} request
3241 The current font family is available in the number register
3242 @code{.fam}.
3243 This is a string-valued register.
3245 @example
3246 spam,
3247 .fam H
3248 spam,
3249 .ft B
3250 spam,
3251 .fam T
3252 spam,
3253 .ft AR
3254 baked beans,
3255 .ft R
3256 and spam.
3257 @end example
3259 @node Font Positions, Using Symbols, Font Families, Fonts
3260 @subsection Font Positions
3261 @cindex font positions
3262 @cindex positions, font
3264 For the sake of old phototypesetters and compatability with old
3265 versions of troff, groff has the concept of font
3266 @dfn{positions}, on which various fonts are mounted.
3267 The last one or two are reserved for the symbol font(s).
3269 @findex fp
3270 New fonts can be mounted with the @code{fp} request.
3271 These numeric positions can then be referred to with font changing commands.
3272 When groff starts it is using font number one.
3274 @example
3275 .fp 1 H
3276 .fp 2 HI
3277 .fp 3 HB
3278 wink, wink,
3279 .ft 2
3280 nudge, nudge,
3282 .ft 3
3283 say no more!
3285 @end example
3287 (note that after these font changes have taken place the original
3288 font is restored.)
3290 @vindex .f
3291 The current font in use, as a font position.
3292 This can be useful to remember the current font, for later recall.
3294 @example
3295 .nr save-font \n(.f
3296 ... lots 'o text ...
3297 .ft \n[save-font]
3298 @end example
3300 @vindex .fp
3301 The number of the next free font position is available in the number
3302 register @code{.fp}.  This is useful when mounting a new font, like so:
3304 @example
3305 .fp \n[.fp] NEATOFONT
3306 @end example
3308 @pindex DESC
3309 Fonts not listed in the @file{DESC} file are automatically mounted on
3310 the next available font position when they are referenced.
3311 If a font is to be
3312 mountfed explicitly with the @code{fp} request on an unused font position, it
3313 should be mounted on the first unused font position, which can be found
3314 in the @code{.fp} register; although troff does not enforce this strictly,
3315 it will not allow a font to be mounted at a position whose number is
3316 much greater than that of any currently used position.
3318 The @code{fp} request has an optional third argument.
3319 This argument gives the
3320 external name of the font, which is used for finding the font
3321 description file.  The second argument gives the internal name of the
3322 font which is used to refer to the font in troff after it has been
3323 mounted.  If there is no third argument then the internal name will be
3324 used as the external name.  This feature allows you to use fonts with
3325 long names in compatibility mode.
3327 @node Using Symbols, Artificial Fonts, Font Positions, Fonts
3328 @subsection Using Symbols
3329 @cindex using symbols
3330 @cindex symbols, using
3332 @findex \(
3333 @findex \[
3334 Symbols can be inserted by using a special escape sequence.
3335 This escape is simply the escape character (a backslash) followed by
3336 an identifier.  The symbol identifiers have to be two or more
3337 characters, since single characters conflict with all the other
3338 escapes.  The identifier can be either preceded by a parenthesis if
3339 it is two character, or surrounded by square brackets.
3340 So, the symbol for pi can be produced either by @code{\(*p} or
3341 @code{\[*p]}.
3343 @example
3344 area = \(*p\fIr\fP\u2\d
3345 @end example
3347 @findex \C
3348 The escape @code{\C'@var{xxx}'} will typeset character named
3349 @var{xxx}.  Normally it is more convenient to use @code{\[@var{xxx}]}.
3350 But @code{\C} has the advantage that it is compatible with recent
3351 versions of ditroff and is available in compatibility mode.
3353 @findex \N
3354 The escape @code{\N'@var{n}'} will typeset the character with code
3355 @var{n} in the current font.  @var{n} can be any integer.  Most devices only
3356 have characters with codes between 0 and 255.  If the current font
3357 does not contain a character with that code, special fonts will not be
3358 searched.  The @code{\N} escape sequence can be conveniently used on
3359 conjunction with the @code{char} request:
3361 @example
3362 .char \[phone] \f(ZD\N'37'
3363 @end example
3365 The code of each character is given in the fourth column in the font
3366 description file after the charset command.  It is possible to include
3367 unnamed characters in the font description file by using a name of
3368 @samp{---}; the @code{\N} escape sequence is the only way to use these.
3370 @findex cflags
3371 Each character has certain properties associated with it.
3372 These properties can be modified with the @code{cflags} request.
3373 The first argument is the the sum of the desired flags and the
3374 remaining arguments are the characters to have those properties.
3375 @table @code
3376 @item 1
3377 the character ends sentences (initially characters @samp{.?!} have this
3378 property);
3379 @item 2
3380 lines can be broken before the character (initially no characters have
3381 this property);
3382 @item 4
3383 lines can be broken after the character (initially characters
3384 @samp{-\(hy\(em} have this property);
3385 @item 8
3386 the character overlaps horizontally (initially characters
3387 @samp{\(ul\(rn\(ru} have this property);
3388 @item 16
3389 the character overlaps vertically (initially character @samp{\(br} has
3390 this property);
3391 @item 32
3392 an end of sentence character followed by any number of characters with
3393 this property will be treated as the end of a sentence if followed by a
3394 newline or two spaces; in other words the character is transparent for
3395 the purposes of end of sentence recognition; this is the same as having
3396 a zero space factor in @TeX{} (initially characters
3397 @samp{"')]*\(dg\(rq} have this property).
3398 @end table
3400 @findex char
3401 You can create new characters with the @code{char} request.  It is
3402 called as @samp{.char @var{c} @var{string}} Define character @var{c}
3403 to be @var{string}. Every time character @var{c} needs to be printed,
3404 @var{string} will be processed in a temporary environment and the
3405 result will be wrapped up into a single object.  Compatibility mode
3406 will be turned off and the escape character will be set to \ while
3407 @var{string} is being processed.  Any emboldening, constant spacing or
3408 track kerning will be applied to this object rather than to individual
3409 characters in @var{string}.  A character defined by this request can
3410 be used just like a normal character provided by the output device.
3411 In particular other characters can be translated to it with the
3412 @code{tr} request; it can be made the leader character by the
3413 @code{lc} request; repeated patterns can be drawn with the character
3414 using the @code{\l} and @code{\L} escape sequences;  words containing
3415 the character can be hyphenated correctly, if the @code{hcode} request
3416 is used to give the character a hyphenation code. There is a special
3417 anti-recursion feature: use of character within the character's
3418 definition will be handled like normal characters not defined with
3419 @code{char}.
3421 @findex rchar
3422 A character definition can be removed with the @code{rchar} request.  Its
3423 arguments are the characters to be removed.  This undoes the effect of
3424 a @code{char} request.
3426 @c distribute these through the text
3427 @xref{Special Characters}
3429 @node Artificial Fonts, Ligatures and Kerning, Using Symbols, Fonts
3430 @subsection Artificial Fonts
3431 @cindex artificial fonts
3432 @cindex fonts, artificial
3434 There are a number of requests for artificially creating fonts.
3435 These are largely vestigal remains from the days when output devices
3436 did not have a wide variety of fonts, and when nroff and troff were
3437 separate programs.
3438 These are no longer necessary in GNU Troff.
3440 @findex ul
3441 The @code{ul} request will print subsequent lines in italics on a device
3442 capable of it, or underline the text on an character output device.  The
3443 single argument is the number of lines to be ``underlined,'' with no
3444 argument, the next line will be underlined.
3446 @findex cu
3447 The @code{cu} request is similar to @code{ul} ...
3449 @findex uf
3450 The @code{uf} request will set the underline font used by @code{ul}
3451 and @code{cu}.
3453 @findex bd
3454 The @code{bd} request artificially creates a bold font by printing
3455 each character twice, slightly offset.
3456 The first argument specifies the font to embolden, and the second is
3457 the number of basic units, minus one, by which the two characters
3458 will be offset.  If the second argument is missing, emboldening will
3459 be turned off.
3461 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
3462 @subsection Ligatures and Kerning
3463 @cindex ligatures and kerning
3464 @cindex kerning and ligatures
3466 @findex lg
3467 @vindex .lg
3468 @code{lg}
3469 @code{.lg}
3470 The current ligature mode.
3472 What is kerning??
3474 If the font description file contains pairwise kerning information,
3475 characters from that font will be kerned.  Kerning between two
3476 characters can be inhibited by placing a @code{\&} between them.
3478 @findex kern
3479 @vindex .kern
3480 @code{kern}
3481 If n is non-zero or missing, enable pairwise kerning, otherwise disable
3483 @code{.kern}
3484 1 if pairwise kerning is enabled, 0 otherwise.
3486 @findex tkf
3487 .tkf f s1 n1 s2 n2
3488 Enable track kerning for font f.  When the current font is f the width
3489 of every character will be increased by an amount between n1 and n2;
3490 when the current point size is less than or equal to s1 the width will
3491 be increased by n1; when it is greater than or equal to s2 the width
3492 will be increased by n2; when the point size is greater than or equal to
3493 s1 and less than or equal to s2 the increase in width is a linear
3494 function of the point size.
3497 @node Sizes, Strings, Fonts, Programming Tutorial
3498 @section Sizes
3499 @cindex sizes
3501 @cindex baseline
3502 Groff uses two dimensions with each line of text, type size and
3503 vertical spacing.  The type size is the height from the text
3504 @dfn{baseline} to the top of the tallest character (decenders may drop
3505 below this baseline).  Vertical spacing is the amount of space groff
3506 allows for a line of text, normally, this is about 20% larger than the
3507 current type size.  Ratios smaller than this can result in
3508 hard-to-read text, larger that this, it will spread your text out more
3509 vertically (useful for term papers).  By default, troff uses 10 point
3510 type on 12 point spacing.
3512 @cindex leading
3513 The difference between type size and vertical spacing is known, by
3514 typesetters, as @dfn{leading}.
3516 @menu
3517 * Changing Type Sizes::         
3518 * Fractional Type Sizes::       
3519 @end menu
3521 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
3522 @subsection Changing Type Sizes
3523 @cindex changing type sizes
3524 @cindex type sizes, changing
3526 @findex ps
3527 @findex vs
3528 @findex \s
3529 @vindex .s
3530 @vindex .v
3531 Using the @code{ps} request and the @code{\s} escape you can change
3532 the type size.  The @code{vs} request will change the vertical
3533 spacing. The default unit for the @code{ps} and @code{vs} requests are
3534 points.
3535 The number registers @code{.s} and @code{.v} contain the current
3536 type size and vertical spacing.
3538 These requests take parameters in units of points.  You can specify
3539 sizes as an absolute size, or as a relative change from the current
3540 size.  The size 0 means go back to the previous size.  With no
3541 argument it will revert to the previous size.
3543 @example
3544 snap, snap,
3545 .ps +2
3546 grin, grin,
3547 .ps +2
3548 wink, wink, \s+2nudge, nudge,\s+8 say no more!
3549 .ps 10
3550 @end example
3552 The @code{\s} escape may be called in a variety of ways.
3553 Much like other escapes there must be a way to determine where the
3554 argument ends and the text begins.
3555 Any of the following forms are valid:
3556 @code{\s@var{n}},
3557 @code{\s+@var{n}},
3558 @code{\s-@var{n}},
3559 @code{\s(@var{nn}},
3560 @code{\s+(@var{nn}},
3561 @code{\s-(@var{nn}},
3562 @code{\s[+@var{nnn}]},
3563 @code{\s[-@var{nnn}]},
3564 @code{\s+[@var{nnn}]},
3565 @code{\s-[@var{nnn}]}.
3567 Some devices may only have certain permissible sizes, in which case
3568 groff will round to the nearest permissible size.
3570 @example
3571 ... .sz macro example?? ...
3572 @end example
3574 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
3575 @subsection Fractional Type Sizes
3576 @cindex fractional type sizes
3577 @cindex type sizes, fractional
3579 @cindex @code{s} unit
3580 @cindex unit, @code{s}
3581 @cindex @code{z} unit
3582 @cindex unit, @code{z}
3583 A @dfn{scaled point} is equal to 1/@var{sizescale} points, where
3584 @var{sizescale} is specified in the @file{DESC} file (1 by default.)
3585 There is a new scale indicator @samp{z} which has the effect of
3586 multiplying by @var{sizescale}.  Requests and escape sequences in
3587 troff interpret arguments that represent a pointsize as being in units
3588 of scaled points, but they evaluate each such argument using a default
3589 scale indicator of @samp{z}.  Arguments treated in this way are the
3590 argument to the @code{ps} request, the third argument to the @code{cs}
3591 request, the second and fourth arguments to the @code{tkf} request,
3592 the argument to the @code{\H} escape sequence, and those variants of
3593 the @code{\s} escape sequence that take a numeric expression as their
3594 argument.
3596 For example, suppose @var{sizescale} is 1000; then a scaled point will be
3597 equivalent to a millipoint; the request @samp{.ps 10.25} is equivalent to
3598 @samp{.ps 10.25z} and so sets the pointsize to 10250 scaled points, which is
3599 equal to 10.25 points.
3601 The number register @code{\n(.s} returns the pointsize in points as
3602 decimal fraction.  There is also a new number register @code{\n[.ps]}
3603 that returns the pointsize in scaled points.
3605 It would make no sense to use the @samp{z} scale indicator in a
3606 numeric expression whose default scale indicator was neither @samp{u}
3607 nor @samp{z}, and so troff disallows this.  Similarily it would make
3608 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
3609 numeric expression whose default scale indicator was @samp{z}, and so
3610 troff disallows this as well.
3612 There is also new scale indicator @samp{s} which multiplies by the
3613 number of units in a scaled point.  So, for example, @samp{\n[.ps]s}
3614 is equal to 1m.  Be sure not to confuse the @samp{s} and @samp{z}
3615 scale indicators.
3617 @code{\s'+@var{n}'}
3618 @code{\s'-@var{n}'}
3619 @code{\s+'@var{n}'}
3620 @code{\s-'@var{n}'}
3621 Set the point size to @var{n} scaled points; @var{n} is a numeric
3622 expression with a default scale indicator of @samp{z}.
3624 @code{\n[.ps]}
3625 The current pointsize in scaled points.
3627 @code{\n[.psr]}
3628 The last-requested pointsize in scaled points.
3630 @code{\n[.sr]}
3631 The last requested pointsize in points as a decimal fraction.  This is a
3632 string-valued register.
3635 @c distribute these through the text
3636 @xref{Font Files}
3639 @node Strings, Conditionals and Loops, Sizes, Programming Tutorial
3640 @section Strings
3641 @cindex strings
3643 @findex ds
3644 Groff has string variables, which are entirely for user convenience
3645 (i.e. there are no builtin strings).  They are defined via the
3646 @code{ds} request.
3648 @example
3649 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
3650 @end example
3652 @findex \*
3653 They are interpolated, or expanded in-place, via the @code{\*} escape:
3655 @example
3656 The \*(UX Operating System
3657 @end example
3659 Will produce:
3661 @example
3662 The UNIXtm Operating System
3663 @end example
3665 If the string named by the @code{\*} does not exist, the escape will
3666 be replaced by nothing.
3668 @cindex comments, with @code{ds}
3669 NOTE:  Unlike other requests the third argument takes up the entire
3670 line including trailing spaces.  This means that comments on a line
3671 with such a request can introduce unwanted space into a string.
3673 @example
3674 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" trademark of you-know-who
3675 @end example
3677 Instead you should either put the comment on another line or
3678 have the comment escape adjacent with the end of the string.
3680 @example
3681 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  trademark of you-know-who
3682 @end example
3684 If you need leading space you can start the string with a double
3685 quote.  No trailing quote is needed, in fact any trailing quote is
3686 included in your string.
3688 @cindex canibalism
3689 @example
3690 .ds sign "           Yours in a white wine sauce,
3691 @end example
3693 @findex as
3694 @cindex appending to strings
3695 @cindex strings, appending
3696 You can also append onto a string with the @code{as} request.
3697 It works the same as the @code{ds} request except that it appends the
3698 second argument onto the string named by the first argument.
3700 @example
3701 .as sign " with shallots, onions and garlic,
3702 @end example
3704 @findex \@key{ret}
3705 Strings are not limited to a sigle line of text.  A string can span
3706 several lines by escaping the newlines with a backslash.  The
3707 resulting string will be stored @emph{without} the newlines.
3709 @example
3710 .ds foo lots and lots \
3711 of text are on these \
3712 next several lines
3713 @end example
3715 @findex substring
3716 @cindex substrings
3717 @code{.substring xx n1 [n2]}
3718 Replace the string in register@w{ }xx with the substring defined by the
3719 indices n1 and@w{ }n2.  The first character in the string has index one.
3720 If n2 is omitted, it is taken to be equal to the string's length.  If
3721 the index value n1 or n2 is negative or zero, it will be counted from
3722 the end of the string, going backwards: The last character has index@w{
3723 }0, the character before the last character has index@w{ }-1, etc.
3725 @findex length
3726 @cindex length of a string
3727 @cindex string, length of
3728 @code{.length xx string}
3729 Compute the length of string and return it in the number register@w{ }xx
3730 (which is not necessarily defined before).
3732 @findex rn
3733 @code{rn}
3735 @findex rm
3736 @code{rm}
3738 @findex als
3739 @code{als}
3741 @findex chop
3742 @code{chop}
3744 @c distribute these through the text
3745 @xref{Identifiers}
3746 @c distribute these through the text
3747 @xref{Comments}
3750 @node Conditionals and Loops, Writing Macros, Strings, Programming Tutorial
3751 @section Conditionals and Loops
3752 @cindex conditionals and loops
3753 @cindex loops and conditionals
3755 @findex if
3756 @findex while
3757 In @code{if} and @code{while} requests, there are several more operators
3758 available:
3760 @table @code
3761 @item e
3762 @itemx o
3763 True if the current page is even or odd numbered (respectively)
3764 @item n
3765 @itemx t
3766 True if the document is being processed by
3767 nroff (or a character device) or troff.
3768 @item '@var{xxx}'@var{yyy}'
3769 True if the string @var{xxx} is equal to the string @var{yyy}.
3770 Other characters can be used in place of the single quotes.
3771 (Which?)
3772 The strings are `formatted' before being compared. (?)
3773 @item r@var{xxx}
3774 True if there is a number register named @var{xxx}.
3775 @item d@var{xxx}
3776 True if there is a string, macro, diversion, or request named @var{xxx}.
3777 @item c@var{ch}
3778 True if there is a character @var{ch} available;  @var{ch} is
3779 either an @sc{ascii} character or a special character @code{\(@var{ch}} or
3780 @code{\[@var{ch}]}; the condition will also be true if @var{ch} has been
3781 defined by the @code{char} request.
3782 @end table
3784 @menu
3785 * if-else::                     
3786 * while::                       
3787 @end menu
3789 @node if-else, while, Conditionals and Loops, Conditionals and Loops
3790 @subsection if-else
3791 @cindex if-else
3793 Troff has if-then-else constructs like other languages, although
3794 the formatting can be painful.
3796 @findex if
3797 The @code{if} request is troff's if statement, it is called as
3798 @samp{.if @var{expr} @var{anything}}, where @var{expr} is the
3799 expression to be evaluated,
3800 and @var{anything} (the remainder of the line)
3801 which will be executed if
3802 the @var{expr} evaluates to non-zero (true).
3803 @var{anything} will be interpreted as though it was on a line by
3804 itself.
3805 @xref{Expressions}, for more info.
3807 Here are some examples:
3809 @example
3810 .if t .ls 2                             \" double spacing in troff
3811 .if 0 .ab how'd this happen??
3812 @end example
3814 @findex ie
3815 @findex el
3816 An if-then-else is written using two requests @code{ie} and @code{el}
3817 the first request is the if part and the latter is the else part.
3819 @example
3822 @end example
3824 @findex \@{
3825 @findex \@}
3826 In many cases you will want more than one request to be executed as a
3827 result of any of these requests, this can be done using the \@{ and
3828 \@} escapes.
3829 The following example shows the possible ways to use these escapes.
3831 @example
3832 .ie t \@{\
3833 .    ds lq ``
3834 .    ds rq ''
3835 .\@}
3836 .el \
3837 .\@{\
3838 .    ds lq "
3839 .    ds rq "\@}
3840 .ds qq "
3841 @end example
3844 @c distribute these through the text
3845 @xref{Expressions}
3847 @node while,  , if-else, Conditionals and Loops
3848 @subsection while
3849 @cindex while
3851 @findex while
3852 Groff provides a looping construct using the @code{while} request,
3853 which is used much like the @code{if} (and related) requests.
3854 The first argument is an expression which will be evaluated.
3855 The @code{while} request will interpret the remainder of the line
3856 until the expression evaluates to 0 or false.
3858 @example
3859 .nr a 0 1
3860 .while (\na<9) \&\n+a,
3861 \&\n+a
3862 @end example
3864 The preceding example produces:
3866 @example
3867 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
3868 @end example
3870 @findex break
3871 @findex continue
3872 The @code{break} request will
3873 @dfn{break} out of a while loop.
3874 Be sure not to confuse this with the @code{.br} request.
3875 The @code{continue} request will
3876 finish the current iteration of a while loop.
3878 @c distribute these through the text
3879 @xref{Expressions}
3882 @node Writing Macros, Page Motions, Conditionals and Loops, Programming Tutorial
3883 @section Writing Macros
3884 @cindex writing macros
3885 @cindex macros, writing
3887 @findex de
3888 A macro is a collection of text and embedded commands which can be
3889 invoked multiple times.  Macros are used for defining common operations.
3890 Macros are defined using the @code{de} request.  This request takes
3891 a name for the macro as the first argument.  Subsequent lines are
3892 copied into an internal buffer until the line @code{..} is
3893 encountered.  The optional second argument to @code{de} can change
3894 this ending token.
3896 For example, suppose at the beginning of each paragraph, you want
3897 cause a break, move down a partial line and indent the first line.
3898 Such a macro could be defined as follows:
3900 @example
3901 .de P
3903 .sp .8v
3905 @end example
3907 @findex am
3908 The @code{am} request works similarily to @code{de} except it appends
3909 onto the macro named by the first argument.  So, if we decide we want
3910 our previously @code{P} macro to actually do indented instead of
3911 block paragraphs we can add the necessary code to our existing macro.
3913 @example
3914 .am P
3915 .ti +5n
3917 @end example
3919 @findex als
3920 @cindex aliases, macro
3921 @cindex macro aliases
3922 Macros can be aliased with the @code{als} request.
3924 @findex rn
3925 @code{rn}
3927 @findex rm
3928 @code{rm}
3930 @findex chop
3931 @code{chop}
3933 @menu
3934 * Copy-in Mode::                
3935 * Parameters::                  
3936 @end menu
3938 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
3939 @subsection Copy-in Mode
3940 @cindex copy-in mode
3941 @cindex mode, copy-in
3943 @findex \n
3944 @findex \$
3945 @findex \*
3946 @findex \\
3947 @findex \@key{RET}
3948 When troff reads in the test for a macro or diversion it copies the
3949 text (including request lines) into an internal buffer, except for
3950 escapes.  Escapes will be converted into an internal form, except for
3951 @code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}} which
3952 are evaluated and inserted into the text where the escape was located.
3953 This is known as @dfn{copy-in} mode.
3955 What this means is that you can specify when these escapes are to be
3956 evaluated (copy-in time or time of use) by insulating the escapes
3957 with an extra backslash.
3959 For example, the following will result in the numbers 20 and 10 being
3960 printed.
3962 @example
3963 .nr x 20
3964 .de y
3965 .nr x 10
3966 \&\nx
3967 \&\\nx
3970 @end example
3972 @node Parameters,  , Copy-in Mode, Writing Macros
3973 @subsection Parameters
3974 @cindex parameters
3976 @findex \$
3977 @vindex .$
3978 The arguments to a macro can be examined using a variety of escapes.
3979 The number of arguments is available in the @code{.$} number register.
3980 Any individual argument can be retrieved with one of the following
3981 escapes:
3983 The escapes @code{\$@var{n}}, @code{\$(@var{nn}}
3984 and @code{\$[@var{nnn}]}
3985 will result in the @var{n}th, @var{nn}th or @var{nnn}th
3986 argument.  Macros can have a unlimited number of arguments.
3987 Note that due to copy-in mode, you will want to have two backslashes
3988 on these in actual use, since you do not want them interpolated until
3989 the macro is actually invoked.
3991 @findex shift
3992 The request @code{shift} will shift the arguments 1 position, or as
3993 many positions as specified by the first argument.
3994 After executing this request, argument
3995 @var{i} will become argument @var{i}-@var{n}; arguments 1 to @var{n}
3996 will no longer be available.
3997 Shifting by negative amounts is currently undefined.
3999 @findex \$*
4000 @findex \$@@
4001 In some cases you will want to just use all of the arguments at once.
4002 For example if you pass the arguments along to another macro.
4003 The @code{\$*} escape is
4004 the concatenation of all the arguments separated by spaces.
4005 A similar escape is @code{\$@@},
4006 which is
4007 the concatenation of all the arguments with each surrounded
4008 by double quotes, and separated by spaces.
4010 @findex \$0
4011 @findex als
4012 The @code{\$0} escape is 
4013 the name by which the current macro was invoked.  The @code{als}
4014 request can make a macro have more than one name.
4016 @example
4017 .de vl
4018 .ie \\n(.$=1 .ds Vl Pre-Release Version
4019 .el          .ds Vl Version \\$3, \\$4.
4021 @end example
4023 This would be called as
4025 @example
4026 .vl $Id$
4027 @end example
4030 @c distribute these through the text
4031 @xref{Request Arguments}
4034 @node Page Motions, Drawing Functions, Writing Macros, Programming Tutorial
4035 @section Page Motions
4036 @cindex page motions
4037 @cindex motions, page
4039 @findex sp
4040 Motions up and down the page can be done with the @code{sp} request.
4041 However, this causes a break so that the actual effect is to move to
4042 the left margin and then to the specified location.
4044 @findex mk
4045 @findex rt
4046 The request @code{mk} can be used to mark a location on a page, for
4047 movement to later.  This request takes a register name as an
4048 argument in which to store the current page location, with no
4049 argument it will store the location in an internal register.
4050 The results of this can be used later by the @code{rt} or the
4051 @code{sp} request.  The @code{rt} request will return
4052 @strong{upwards} to the location given in the register name given as
4053 an argument, with no argument it will return to the location marked
4054 with the @code{mk} request
4056 @example
4057 ... dual column example ...
4058 @end example
4060 There are escapes which will give you much finer control of movements
4061 about the page.
4063 @findex \v
4064 The @code{\v'@var{e}'} will let you do arbitrary vertical motion from
4065 the current location on the page.  The argument @var{e} specifies the
4066 distance to move, positive is downwards and negative upwards.  The
4067 default unit for this escape is vertical spaces, @code{v}'s.  Beware,
4068 however, that troff will leave text processing to continue wherever
4069 the motion ends, so if you don't want to interfere with text
4070 processing, make sure your motions are balanced.
4072 There are some special case escapes for vertical motion.
4074 @ftable @code
4075 @item \r
4076 move upwards 1v.
4077 @item \u
4078 move upwards .5v.
4079 @item \d
4080 move down .5v.
4081 @end ftable
4083 @findex \h
4084 Horizontal motions can be done via the @code{\h'@var{e}'} escape.
4085 The expression @var{e} indicates how far to move: positive is
4086 rightwards and negative leftwards.
4088 There are a number of special case escapes for horizontal motion:
4090 @ftable @code
4091 @item \@key{SP}
4092 An unbreakable and unpadable (i.e. not expanded during filling) space.
4093 (Note: it is a backslash followed by a space.)
4094 @item \~
4095 This produces an unbreakable space that stretches like a normal
4096 interword space when a line is adjusted.
4097 @item \|
4098 a 1/6th em space.
4099 @item \^
4100 a 1/12th em space.
4101 @item \0
4102 a space the size of a digit.
4103 @item \&
4104 A zero width space.
4105 @item \)
4106 Like @code{\&} except that it behaves like a character declared with
4107 the @code{cflags} request to be transparent for the purposes of end
4108 of sentence recognition.
4109 @end ftable
4111 @example
4112 ... tex logo example ...
4113 @end example
4115 @findex \w
4116 @cindex width escape
4117 @cindex escape, width
4118 Often you will want to do horizontal movement based on the width of
4119 some arbitrary text (e.g. given as an argument to a macro).
4120 For that, there is the escape @code{\w'@var{text}'} which will
4121 interpolate to the width of the given @var{text} in basic units.
4123 @example
4124 ... strlen example ...
4125 @end example
4127 Font changes may occur in @var{text} and not affect current settings.
4129 Also after use, @code{\w} sets several registers:
4131 @table @code
4132 @item st
4133 @vindex st
4134 @itemx sb
4135 @vindex sb
4136 The highest and lowest point, respectively, in @var{text}.
4137 @item rst
4138 @vindex rst
4139 @itemx rsb
4140 @vindex rsb
4141 Like the @code{st} and @code{sb} registers, but takes account of the
4142 heights and depths of characters.
4143 @item ct
4144 @vindex ct
4145 is set according to what kinds of characters occur in @var{text}.
4146 @table @asis
4147 @item 0
4148 all short characters, no decenders or tall characters.
4149 @item 1
4150 decender
4151 @item 2
4152 tall character
4153 @item 3
4154 both a decender and a tall character
4155 @end table
4156 @item ssc
4157 @vindex ssc
4158 The amount of horizontal space (possibly negative) that should be
4159 added to the last character before a subscript.
4160 @item skw
4161 @vindex skw
4162 How far to right of the center of the last character in the @code{\w}
4163 argument, the center of an accent from a roman font should  be
4164 placed over that character.
4165 @end table
4167 @findex \k
4168 @vindex .k
4169 @code{\k}
4170 @code{.k}
4173 @node Drawing Functions, Traps, Page Motions, Programming Tutorial
4174 @section Drawing Functions
4175 @cindex drawing functions
4176 @cindex functions for drawing
4178 Groff provides a number of ways to draw lines, and other figures on
4179 the page.  Used in combination with the page motion commands
4180 (@pxref{Page Motions}, for more info) you can draw a wide variety of
4181 figures.  However, for complex drawings these operations can be quite
4182 cumbersome, and it may be wise to use the pic preprocessor.
4183 @xref{gpic}, for more information.
4185 All drawing is done via escapes.
4187 @findex \l
4188 The @code{\l} will draw a line rightwards from the current location.
4189 The full syntax for this escape is @samp{\l'@var{l}@var{c}'}, where
4190 @var{l} is the length of the line to be drawn, starting at the
4191 current location, positive numbers will draw to the right, and
4192 negative will draw towards the left.  This can also be specified
4193 absolutely (i.e. with a leading |) which will draw back to the
4194 begining of the line.
4196 The optional second parameter @var{c} is a character to draw the line
4197 with.  If this second argument is not specified, troff will use the
4198 underscore character.
4200 If you need to separate the two arguments (to prevent troff from
4201 interpreting a drawing character as a scaling indicator), you can
4202 separate them with @code{\&}.
4204 And now, for a useful example:
4206 @example
4207 .de box
4208 \(br\\$*\(br\l'|0\(rn'\l'|0\(ul'
4210 @end example
4212 Note that this works by outputing a box rule (a vertical line), then
4213 the text given as an argument and then another box rule.
4214 Then the line drawing escapes both draw from the current location to
4215 the beginning of the @emph{input} line.
4217 @findex \L
4218 Vertical lines are drawn using the @code{\L} escape.  It's parameters
4219 are specified the same as the @code{\l} escape.  If the length is
4220 positive, the movement will be downwards, and upwards for negative.
4221 The default character is the box rule character.
4222 As with the vertical motion escapes, text processing will blindly
4223 continue where the line ends.
4225 @example
4226 ...box macro...
4227 @end example
4229 @findex \D
4230 More flexible drawing functions are available via the @code{\D}
4231 escape.  While the previous escapes will work on a character device,
4232 these escapes will not.
4234 @table @code
4235 @item \D'l @var{x} @var{y}'
4236 Draw a line from the current location to the relative point specified
4237 by @var{x}, @var{y}.
4239 @example
4240 ...revised box macro...
4241 @end example
4243 @item \D'c @var{d}'
4244 Draw a circle with a diameter of @var{d} with the leftmost point at
4245 the current position.
4246 @item \D'C @var{d}'
4247 Draw a solid circle with the same parameters as an outlined circle.
4248 @item \D'e @var{dx} @var{dy}'
4249 Draw an ellipse with a horizontal diameter of @var{dx} and a vertical
4250 diameter of @var{dy} with the leftmost point at the current position.
4251 @item \D'E @var{dx} @var{dy}'
4252 Draw a solid elipse with the same parameters as an outlined elipse.
4253 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
4254 Draw an arc clockwise from the current location through the two
4255 specified locations.
4256 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4257 Draw a spline from the current location to
4258 @var{dx1}, @var{dy1} and then to @var{dx2}, @var{dy2}, and so on.
4259 @item \D'f @var{n}'
4260 Set the shade of gray to be used for filling solid objects to @var{n};
4261 @var{n} must be an integer between 0 and 1000, where 0 corresponds
4262 solid white and 1000 to solid black, and values in between correspond
4263 to intermediate shades of gray.  This applies only to solid circles,
4264 solid ellipses and solid polygons.  By default, a level of 1000 will
4265 be used.
4266 @item  \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4267 Draw a polygon from the current location to @var{dx1}, @var{dy1}
4268 and then to @var{dx2}, @var{dy2} and so on.  When the specified data
4269 points are exhausted, a line is drawn back to the starting point.
4271 @example
4272 ... box example (yes, again)...
4273 @end example
4275 @itemx \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4276 Draw a solid polygon with the same parameters as an outlined polygon.
4278 @example
4279 ... shaded box example ...
4280 @end example
4282 @item \D't @var{n}'
4283 Set the current line thickness to @var{n} machine units.
4284 A value of zero selects the smallest available line thickness.
4286 @end table
4288 Current position
4290 @findex \b
4291 @cindex pile, character
4292 @cindex character pile
4293 The @code{\b} escape will @dfn{pile} a sequence of characters
4294 vertically, and center it vertically on the current line.
4295 This can be used to build large brackets and braces.
4297 @example
4298 \b'\(lt\(bv\(lk\(bv\(lb'
4299 @end example
4302 @node Traps, Diversions, Drawing Functions, Programming Tutorial
4303 @section Traps
4304 @cindex traps
4306 Traps are locations, which, when reached, will call a specified macro.
4307 These traps can occur at a given location on the page, at a given
4308 location in the current diversion, after a certain number of input
4309 lines or at the end of input.
4311 @findex ch
4312 Any of these traps can be changed after they have been set with the
4313 @code{ch} request.  The first arguemnt is the name of the trap or
4314 macro, and the second is the new value for that trap.
4316 @menu
4317 * Page Location Traps::         
4318 * Diversion Traps::             
4319 * Input Line Traps::            
4320 * End-of-input Traps::          
4321 @end menu
4323 @node Page Location Traps, Diversion Traps, Traps, Traps
4324 @subsection Page Location Traps
4325 @cindex page location traps
4326 @cindex traps, page location
4328 Page location traps are frequently used for page headers and
4329 footers.  The following is a simple example of this.
4331 @example
4332 .de hd                          \" Page header
4333 'sp .5i
4334 .tl 'Title''date'
4335 'sp .3i
4337 .de fo                          \" Page footer
4338 'sp 1v
4339 .tl ''%''
4342 .wh 0   hd                      \" top of the page
4343 .wh -1i fo                      \" one inch from bottom
4344 @end example
4346 @vindex .t
4347 The number register @code{.t} is the distance to the next trap.
4349 @findex ch
4350 The location of a trap can be changed later on with the @code{ch}
4351 request.
4352 The first argument is the name of the macro to be invoked at the trap
4353 and the second argument is the new location for the trap.
4354 This is useful when you are building up footnotes in a diversion, and
4355 you need to allow more space at the bottom of the page for them.
4357 @example
4358 ... (simplified) footnote example ...
4359 @end example
4361 @findex vpt
4362 @findex wh
4363 @findex dt
4364 @vindex .vpt
4365 The @code{vpt} request will enable vertical position traps if the argment is
4366 non-zero, disable them otherwise.  Vertical position traps are traps
4367 set by the @code{wh} or @code{dt} requests.  Traps set by the
4368 @code{it} request are not vertical position traps.  The parameter that
4369 controls whether vertical position traps are enabled is global.
4370 Initially vertical position traps are enabled.  The current setting of
4371 this is available in the number register @code{.vpt}.
4373 @vindex .trunc
4374 @findex ne
4375 The number register @code{.trunc} contains
4376 the amount of vertical space truncated by the most recently
4377 sprung vertical position trap, or, if the trap was sprung by a
4378 @code{ne} request, minus the amount of vertical motion produced by
4379 the @code{ne} request.  In other words, at the point a trap is
4380 sprung, it represents the difference of what the vertical position
4381 would have been but for the trap, and what the vertical position
4382 actually is.
4384 @vindex .ne
4385 The number register @code{.ne} contains
4386 the amount of space that was needed in the last @code{ne} request that caused
4387 a trap to be sprung.  Useful in conjunction with the @code{.trunc}
4388 register.  @xref{Page Control}, for more information.
4390 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
4391 @subsection Diversion Traps
4392 @cindex diversion traps
4393 @cindex traps, diversion
4395 @findex dt
4396 @vindex .t
4397 Traps can also be set @emph{within} a diversion using the @code{dt}
4398 request.  Like @code{wh} the first argument is the location of the
4399 trap and the second argument is the name of the macro to be invoked.
4400 The number register @code{.t} will still work within diversions.
4401 @xref{Diversions}, for more information.
4403 @node Input Line Traps, End-of-input Traps, Diversion Traps, Traps
4404 @subsection Input Line Traps
4405 @cindex input line traps
4406 @cindex traps, input line
4408 @findex it
4409 The @code{it} request will set an input line trap.  The format for
4410 calling this is @samp{.it @var{n} @var{name}}, where @var{n} is the
4411 number of lines of input which may be read before @dfn{springing} the
4412 trap, @var{name} is the macro to be invoked.  Request lines are not
4413 counted as input lines.
4415 For example, one possible use is to have a macro which will print the
4416 next @var{n} lines in a bold font.
4418 @example
4419 .de B
4420 .it B-end \\$1
4421 .ft B
4423 .de B-end
4424 .ft R
4426 @end example
4428 @node End-of-input Traps,  , Input Line Traps, Traps
4429 @subsection End-of-input Traps
4430 @cindex end-of-input traps
4431 @cindex traps, end-of-input
4433 @findex em
4434 The @code{em} request will set a trap at the end of input.
4435 The macro specified as an arguement will be executed after the last
4436 line of the input file has been processed.
4438 For example, if your document had to have a section at the bottom of
4439 the last page for someone to approve you document, you could set it
4440 up with @code{em}.
4442 @example
4443 .de approval
4444 .ne 5v
4445 .sp |(\\n(.t-6v)
4446 .in +4i
4447 .lc _
4449 Approved:\t\a
4451 Date:\t\t\a
4453 .em approval
4454 @end example
4457 @node Diversions, Environments, Traps, Programming Tutorial
4458 @section Diversions
4459 @cindex diversions
4461 In Troff you can divert text into a named storage area, due to the
4462 similarity to defining macros it is sometimes said to be stored in a
4463 macro.  This is used for saving text for output at a later time,
4464 which is useful for keeping blocks of text on the same page,
4465 footnotes, tables of contents and indexes.
4467 @findex di
4468 @findex da
4469 Diversion is initiated by the @code{di} request, like the @code{de}
4470 request it takes an argument of a macro name to divert subsequent
4471 text to into.  The @code{da} macro will append to an existing diversion.
4473 @example
4474 ... end-note example ...
4475 @end example
4477 @vindex .z
4478 @vindex .d
4479 @vindex nl
4480 @vindex .h
4481 Diversions may be nested.
4482 The number register @code{.z} contains the name of the current diversion.
4483 The number register @code{.d} contains the current vertical place in
4484 the diversion.  If not in a diversion it is the same as the register
4485 @code{nl}.
4486 @code{.h}
4488 @vindex dn
4489 @vindex dl
4490 After compleating a diversion, the builtin number registers @code{dn}
4491 and @code{dl} contain the vertical and horizontal size of the diversion.
4493 @example
4494 .\" Center text both horizontally & vertically
4495 .de (c
4498 .di @@c
4500 .de )c
4503 .nr @@s (((\\n(.tu-\\n(dnu)/2u)-1v)
4504 .sp \\n(@@su
4505 .ce 1000
4509 .ce 0
4510 .sp \\n(@@su
4513 .rr @@s
4515 @end example
4517 @findex \!
4518 Requests, macros and escapes are interpreted when read into a
4519 diversion.
4520 There are two ways to prevent this, either way will take the given
4521 text and @dfn{transparently} embed it into the diversion.
4522 The first method is to prefix the line with @code{\!}.  This will
4523 cause the entire line to be transparently inserted into the diversion.
4524 This is useful for macros you do not want invoked until the diverted
4525 text is actually output.
4527 @c anything  is  read  in  copy  mode. (what about \! ??)
4529 @findex \?
4530 The other way is to surround the text by the @code{\?} escape, i.e.
4531 @samp{\?@var{anything}\?}.
4532 @var{anything} may not  contain
4533 newlines; use @code{\!} if you want to embed newlines in a diversion.  The
4534 escape sequence @code{\?} is also recognised in copy mode and turned into a
4535 single internal code; it is this code that terminates anything.  Thus
4536 the followin example will print 4.
4538 @example
4539 .nr x 1
4541 .di d
4542 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
4544 .nr x 2
4545 .di e
4548 .nr x 3
4549 .di f
4552 .nr x 4
4554 @end example
4556 @findex rn
4557 @code{rn}
4559 @findex rm
4560 @code{rm}
4562 @findex als
4563 @code{als}
4565 @findex chop
4566 @code{chop}
4568 @findex asciify
4569 @code{asciify}
4570 This request only exists in order to make it possible to make certain
4571 gross hacks work with GNU troff.  It @dfn{unformats} the diversion
4572 specified as an argument in
4573 such a way that @sc{ascii} characters that were formatted and diverted
4574 will be treated like ordinary input characters when the diversion is
4575 reread.  For example, the following will set register @code{n} to 1.
4577 @example
4578 .tr  @@.
4579 .di  x
4580 @@nr\  n\  1
4583 .tr  @@@@
4584 .asciify  x
4586 @end example
4589 @c distribute these through the text
4590 @xref{Copy-in Mode}
4593 @node Environments, I/O, Diversions, Programming Tutorial
4594 @section Environments
4595 @cindex environments
4597 Often you will need to print some text in a certain format regardless
4598 of what may be in effect at the time, for example, in a trap invoked
4599 macro to print headers and footers.
4600 To solve this groff has @dfn{environments} in which text is processed.
4601 An environment contains most of the parameters that control
4602 text processing.  You can switch amongst these environments, by
4603 default groff processes text in environment 0.
4604 The following is the information kept in an environment.
4606 @itemize @bullet{}
4607 @item
4608 Type size
4609 @item
4610 Font (family and style)
4611 @item
4612 Page parameters
4613 @item
4614 Fill/adjust mode
4615 @item
4616 Tab stops
4617 @item
4618 Partially collected lines
4619 @end itemize
4621 These environments may be given arbitrary names
4622 (@pxref{Identifiers}, for more info.)
4623 Old versions of troff only had environments named 0, 1 and 2.
4625 @findex ev
4626 @vindex .ev
4627 The @code{ev} request will switch among these environments.
4628 The single argument is the name of the environment to switch to, with
4629 no argument groff will switch back to the previous enviroment.
4630 There is no limit on the number of named environments;
4631 they will be created the first time that they are referenced.
4632 The @code{.ev} number register contains
4633 the name or number of the current environment.  This is a string-valued
4634 register.
4636 @example
4637 ... page break macro, revised ...
4638 @end example
4640 @example
4641 .ev footnote-env
4642 .fam N
4643 .ps 6
4644 .vs 8
4645 .ll -.5i
4648 .ev footnote-env
4649 \(dg Note the large, friendly letters.
4651 @end example
4654 @node I/O, Postprocessor Access, Environments, Programming Tutorial
4655 @section I/O
4656 @cindex i/o
4658 @findex so
4659 The @code{so} request will read in the file given as an argument and
4660 include it in place of the @code{so} request.  This is quite useful
4661 for large documents, i.e. keeping each chapter in a separate file.
4662 @xref{gsoelim}, for more information.
4664 @findex mso
4665 The @code{mso} request is
4666 the same as the @code{so} request except that file is searched for in
4667 the same way that @file{tmac.@var{name}} is searched for when the
4668 @samp{-m@var{name}} option is specified.
4670 @findex cf
4671 @findex trf
4672 The @code{cf} and @code{trf} requests are to include a file.
4673 It will transparently output the contents of file filename.  Each
4674 line is output
4675 as it would be were it preceded by @code{\!}; however, the lines are not
4676 subject to copy-mode interpretation.  If the file does not end with a
4677 newline, then a newline will be added.  For example, you can define a
4678 macro @code{x} containing the contents of file @file{f}, using
4680 @example
4681 .di x
4682 .trf f
4684 @end example
4686 .cf filename
4687 When  used  in  a  diversion, this will embed in the diversion an object
4688 which,  when  reread,  will  cause  the  contents  of  filename  to   be
4689 transparently copied through to the output.  In @sc{Unix} troff, the contents
4690 of filename is immediately copied through to the  output  regardless  of
4691 whether  there  is  a  current diversion; this behaviour is so anomalous
4692 that it must be considered a bug.
4695 With @code{trf}, unlike @code{cf}, the file cannot contain characters
4696 such as NUL that are not legal troff input characters.
4698 @findex nx
4699 The @code{nx} request will force groff to continue processing of the
4700 file specified as an argument.
4702 @findex rd
4703 The @code{rd} request will read from standard input, and include what
4704 is read as though it were part of the input file.  Text is read until
4705 a blank line is encountered.
4707 @cindex form letters
4708 @cindex letters, form
4709 Using these two requests you can set up form letters.
4710 The form letter template is constructed like this:
4712 @example
4714 \*(td
4715 .sp 2
4721 Body of letter.
4723 .nx repeat.let
4724 @end example
4726 @findex ex
4727 When this is run, the following file should be redirected in.
4728 Note that requests included in this file are executed as though they
4729 were part of the form letter.  The last block of input is the
4730 @code{ex} requests which tells groff to stop processing.  If this was
4731 not there, groff would not know when to stop.
4733 @cindex Beagle Brothers
4734 @example
4735 Trent A. Fisher
4736 708 NW 19th Av., #202
4737 Portland, OR  97209
4739 Dear Trent,
4741 Len Adollar
4742 4315 Sierra Vista
4743 San Diego, CA  92103
4745 Dear Mr. Adollar,
4748 @end example
4750 @findex pi
4751 @code{pi}
4753 @findex sy
4754 The @code{sy} request will allow arbitrary system commands to be
4755 executed from within a groff document.  The output is not saved
4756 anyplace, so it is up to you to do so.
4758 For example, the following example will introduce the current time
4759 into your document:
4761 @cindex time
4762 @pindex perl
4763 @example
4764 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
4765              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
4766 .so /tmp/x\n[$$]
4767 .sy rm /tmp/x\n[$$]
4768 \nH:\nM:\nS
4769 @end example
4771 Note that this works by having the perl script (run by @code{sy})
4772 print out the @code{nr} requests which will set the number registers
4773 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in
4774 with the @code{so} request.
4776 @vindex systat
4777 The @code{systat} number register contains
4778 The return value of the @code{system()} function executed by the last
4779 @code{sy} request.
4781 @findex open
4782 The @code{open} request will open
4783 a file (specified as the second argument) for writing and associate
4784 the stream (specified as the first argument) with it.
4786 @findex opena
4787 The @code{opena} is
4788 like open, but if filename exists, append to it instead of truncating
4791 @findex write
4792 @findex ds
4793 @cindex copy-in mode
4794 @cindex mode, copy-in
4795 The @code{write} request will write to the file associated with the
4796 stream specified by the first argument.  The stream must previously
4797 have been the subject of an open request.  The remainder of the line
4798 in interpreted as the @code{ds} request reads its second argument: a
4799 leading @code{"} will be stripped, and it will be read in copy-in mode.
4801 @findex close
4802 The @code{close} request will
4803 close the stream specified by the first argument; stream will no
4804 longer be an acceptable argument to the @code{write} request.
4806 @example
4807 ... example of open write &c...
4808 @end example
4810 @findex \v
4811 The @code{\V} escape will
4812 interpolate the contents of the specified environment variable, as returned
4813 by getenv(3).
4814 The argument to @code{\V} is specified as an identifier, i.e.
4815 @samp{\V@var{x}}, @samp{\V(@var{xx}} or @samp{\V[@var{xxx}]}.
4816 @code{\V} is interpreted in copy-in mode.
4819 @node Postprocessor Access, Miscellany, I/O, Programming Tutorial
4820 @section Postprocessor Access
4821 @cindex postprocessor access
4822 @cindex access of postprocessor
4824 There are two escapes which will allow you to give information
4825 directly to the postprocessor.  This is particularly useful for
4826 embedding PostScript into your final document.
4828 @findex \X
4829 The @code{\X} escape will embed its argument into the gtroff output
4830 preceded with @samp{x X}.
4832 @findex \Y
4833 The @code{\Y} escape is called with an identifier (i.e.
4834 @code{\Y@var{x}},
4835 @code{\Y(@var{xx}} or
4836 @code{\Y[@var{xxx}]}).
4837 This is approximately equivalent to @samp{\X'\*[@var{xxx}]'}.
4838 However the contents
4839 of the string or macro @var{xxx} are not interpreted; also it is
4840 permitted for
4841 @var{xxx} to have been defined as a macro and thus contain newlines
4842 (it is not permitted for the argument to @code{\X} to contain newlines).
4843 The inclusion of
4844 newlines requires an extension to the @sc{Unix} troff output format, and will
4845 confuse drivers that do not know about this extension.
4848 @c distribute these through the text
4849 @xref{Output Devices}
4852 @node Miscellany, Debugging, Postprocessor Access, Programming Tutorial
4853 @section Miscellany
4854 @cindex miscellany
4856 This section contains parts of troff which cannot (yet) be
4857 categorized elsewhere in this manual.
4859 @findex nm
4860 Line numbers can be printed in the left margin
4861 using the @code{nm} request.
4862 The first argument is the line number of the @emph{next} output line,
4863 this defaults to 1.
4864 The second argument indicates on which lines numbers will be printed,
4865 i.e. 5 means put line numbers on every 5 lines, this defaults to 1.
4866 The third argument is the space to be left between the number and
4867 your text, this defaults to 1.
4868 The fourth argument is the indentation of the line numbers.
4869 Without arguments, line numbers are turned off.
4871 @findex nn
4872 The @code{nn} request will temporarily turn off line numbering.
4873 The first argument is the number of lines not to be numbered,
4874 this defaults to 1. (does this disable incrementing or display?)
4876 @example
4877 ... line numbering example ...
4878 @end example
4880 @findex mc
4881 margin characters can be automatically printed to the right of your
4882 text with the @code{mc} request.
4883 The first argument is the character to be printed and the second
4884 argument is the distance away from your text.
4885 With no arguments the margin characters are turned off.
4886 If this occurs before a break, no margin character will be printed.
4888 This is quite useful for indicating text that has changed, and, in
4889 fact, there are programs available for doing this (they are called
4890 @code{nrchbar} and @code{changebar} and can be found in any
4891 @samp{comp.sources.unix} archive.
4893 @example
4894 ... margin char example ...
4895 @end example
4897 @findex lf
4898 @pindex soelim
4899 The @code{lf} primary reason for existence is to make debugging
4900 documents which are split into many files, which are then put
4901 together with @code{soelim} and other preprocessors.
4902 The first argument is the name of the file and the second argument is
4903 the input line number in that file.
4904 This way troff can produce error messages which are intelligible to
4905 the user.
4907 @example
4908 ... example of soelim'ed doc ...
4909 @end example
4912 @node Debugging, Implementation Differences, Miscellany, Programming Tutorial
4913 @section Debugging
4914 @cindex debugging
4916 Troff is not easy to debug, but there are some useful features and
4917 strategies for debugging.
4919 @itemize @bullet{}
4920 @item
4921 @findex tm
4922 The @code{tm} request will send output to stderr, this is very useful for
4923 printing debugging output.
4924 @item
4925 When doing something involved it is useful to leave the debugging
4926 statements in the code and have them turned on by a command line
4927 flag.
4929 @example
4930 .if \n(DB .tm debugging output
4931 @end example
4933 Then you can activate these statements with:
4935 @example
4936 groff -rDB=1 file
4937 @end example
4939 @item
4940 @findex ab
4941 The @code{ab} request is similar to the @code{tm} request,
4942 except that it will cause groff to stop processing.
4943 With no argument it will print @samp{User Abort}.
4944 @item
4945 @findex ex
4946 The @code{ex} request will also cause groff to stop processing.
4947 @item
4948 If you know you are going to get many errors and no useful output,
4949 you can tell groff to suppress formatted output with the @samp{-z}
4950 flag.
4951 @item
4952 @findex pm
4953 The @code{pm} request will dump out the entire symbol table.
4954 @item
4955 @findex pnr
4956 The @code{pnr} request will print the names and contents of all
4957 currently defined number registers on stderr.
4958 @item
4959 @findex ptr
4960 The @code{ptr} request will
4961 print the names and positions of all traps (not including input line
4962 traps and diversion traps) on stderr.  Empty slots in the page trap list
4963 are printed as well, because they can affect the priority of
4964 subsequently planted traps.
4965 @item
4966 @findex fl
4967 The @code{fl} request instructs groff to flush its output immediately.
4968 The intention is that this be used when using troff interactively.
4969 There is little other use for it.
4970 @item
4971 @findex backtrace
4972 The @code{backtrace} request will
4973 print a backtrace of the input stack on stderr.
4974 @item
4975 Groff has command line options for printing out more warnings
4976 (@samp{-w}) and for printing backtraces (@samp{-b}) when a warning or
4977 an error occurs.  The most verbose level of warnings is @samp{-ww}.
4978 @item
4979 @findex warn
4980 @vindex .warn
4981 The @code{warn} request controls the level of warnings checked for.
4982 The one argument is the sum of the numbers associated with each
4983 warning that is to be enabled; all other warnings will be disabled.
4984 The number associated with each warning is listed below.
4985 For example, @code{.warn 0} will disable all warnings, and
4986 @code{.warn 1} will disable
4987 all warnings except that about missing characters.  If an argument
4988 is not given, all warnings will be enabled.
4989 The number register @code{.warn} contains the current warning level.
4990 @end itemize
4992 @subsection Warnings
4993 @cindex warnings
4995 The warnings that can be given by troff are divided into the
4996 following categories.  The name associated with each warning is used
4997 by the @samp{-w} and @samp{-W} options; the number is used by the
4998 @code{warn} request, and by the @code{.warn} register.
5000 @table @samp
5001 @item  char
5002 @itemx 1
5003 Non-existent characters.  This is enabled by default.
5004 @item  number
5005 @itemx 2
5006 Invalid numeric expressions.  This is enabled by default.
5007 @item  break
5008 @itemx 4
5009 In fill mode, lines which could not be broken so that
5010 their length was less than the line length.  This is
5011 enabled by default.
5012 @item  delim
5013 @itemx 8
5014 Missing or mismatched closing delimiters.
5015 @item  el
5016 @itemx 16
5017 Use of the @code{el} request with no matching @code{ie} request.
5018 @xref{if-else}, for more information.
5019 @item  scale
5020 @itemx 32
5021 Meaningless scaling indicators.
5022 @item  range
5023 @itemx 64
5024 Out of range arguments.
5025 @item  syntax
5026 @itemx 128
5027 Dubious syntax in numeric expressions.
5028 @item  di
5029 @itemx 256
5030 @findex di
5031 @findex da
5032 Use of @code{di} or @code{da} without an argument when there is no
5033 current diversion.
5034 @item  mac
5035 @itemx 512
5036 Use of undefined strings, macros and diversions.
5037 When an undefined string, macro or diversion is used,
5038 that string is automatically defined as empty.  So,
5039 in most cases, at most one warning will be given for
5040 each name.
5041 @item  reg
5042 @itemx 1024
5043 Use of undefined number registers.  When an undefined
5044 number register is used, that register is
5045 automatically defined to have a value of 0.  a
5046 definition is automatically made with a value of 0.
5047 So, in most cases, at most one warning will be given
5048 for use of a particular name.
5049 @item  tab
5050 @itemx 2048
5051 Use of a tab character where a number was expected.
5052 @item  right-brace
5053 @itemx 4096
5054 @findex \@}
5055 Use of @code{\@}} where a number was expected.
5056 @item  missing
5057 @itemx 8192
5058 Requests that are missing non-optional arguments.
5059 @item  input
5060 @itemx 16384
5061 Illegal input characters.
5062 @item  escape
5063 @itemx 32768
5064 Unrecognized escape sequences.  When an unrecognized
5065 escape sequence is encountered, the escape character
5066 is ignored.
5067 @item  space
5068 @itemx 65536
5069 Missing space between a request or macro and its
5070 argument.  This warning will be given when  an
5071 undefined name longer than two characters is
5072 encountered, and the first two characters of the name
5073 make a defined name.  The request or macro will not
5074 be invoked. When this warning is given, no macro is
5075 automatically defined.  This is enabled by default.
5076 This warning will never occur in compatibility mode.
5077 @item  font
5078 @itemx 131072
5079 Non-existent fonts. This is enabled by default.
5080 @item all
5081 All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
5082 intended that this covers
5083 all warnings that are useful with traditional macro packages.
5084 @item w
5085 All warnings.
5086 @end table
5089 @node Implementation Differences, Summary, Debugging, Programming Tutorial
5090 @section Implementation Differences
5091 @cindex implementation differences
5092 @cindex differences in implementation
5094 GNU troff has a number of features which cause incompatibilites with
5095 documents written with old versions of troff.
5097 Long names cause some incompatibilities.  @sc{Unix} troff will interpret
5099 @example
5100 .dsabcd
5101 @end example
5103 @findex \*
5104 @findex \n
5105 @findex cp
5106 @vindex .C
5107 as defining a string @samp{ab} with contents @samp{cd}.
5108 Normally, GNU troff will interpret this as a call of a macro named
5109 @code{dsabcd}.  Also @sc{Unix} troff will interpret @code{\*[} or
5110 @code{\n[} as references to a string or number register called
5111 @samp{[}.  In GNU troff, however, this will normally be interpreted as the
5112 start of a long name.  In compatibility mode GNU troff will interpret
5113 these things in the traditional way.  In compatibility mode, however,
5114 long names are not recognised.  Compatibility mode can be turned on with
5115 the @samp{-C} command line option, and turned on or off with the
5116 @code{cp} request.
5117 The number register @code{.C} is 1 if compatibility mode is on, 0 otherwise.
5119 @findex \A
5120 GNU troff does not allow the use of the escape sequences
5121 @samp{\| \^ \& \@} \@{ \@key{SP} \' \` \- \_ \! \% \c} in names of
5122 strings, macros,
5123 diversions, number registers, fonts or environments; @sc{Unix} troff does.
5124 The @code{\A} escape sequence may be helpful in avoiding use of these escape
5125 sequences in names.
5127 @cindex fractional point sizes
5128 @cindex point sizes, fractional
5129 @findex ps
5130 Fractional pointsizes cause one noteworthy incompatibility.  In @sc{Unix}
5131 troff the @code{ps} request ignores scale indicators and so
5133 @example
5134 .ps 10u
5135 @end example
5137 will set the pointsize to 10 points, whereas in GNU troff it will set
5138 the pointsize to 10 scaled points.
5139 @xref{Fractional Type Sizes}, for more information.
5141 @findex bd
5142 @findex cs
5143 @findex tkf
5144 @findex tr
5145 @findex fp
5146 In GNU troff there is a fundamental difference between unformatted,
5147 input characters, and formatted, output characters.  Everything that
5148 affects how an output character will be output is stored with the
5149 character; once an output character has been constructed it  is
5150 unaffected by any subsequent requests that are executed, including
5151 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp}
5152 requests.  Normally output characters are constructed
5153 from input characters at the moment immediately before the character is
5154 added to the current output line.  Macros, diversions and strings are
5155 all, in fact, the same type of object; they contain lists of input
5156 characters and output characters in any combination.  An  output
5157 character does not behave like an input character for the purposes of
5158 macro processing; it does not inherit any of the special properties that
5159 the input character from which it was constructed might have had. For
5160 example,
5162 @example
5163 .di x
5164 \\\\
5168 @end example
5170 @findex \e
5171 @findex \!
5172 @findex \?
5173 will print @samp{\\} in GNU troff; each pair of input backslashes is
5174 turned into one
5175 output backslash and the resulting output backslashes are not
5176 interpreted as escape
5177 characters when they are reread. @sc{Unix} troff would interpret them as
5178 escape characters when they were reread and would end up printing one
5179 @samp{\}.
5180 The correct way to obtain a printable backslash is to use the
5181 @code{\e} escape
5182 sequence: this will always print a single instance of the current escape
5183 character, regardless of whether or not it is used in a diversion; it
5184 will also work in both GNU troff and @sc{Unix} troff. If you wish for some
5185 reason to store in a diversion an escape sequence that will be
5186 interpreted when the diversion is reread, you can either use the
5187 traditional @code{\!} transparent output facility, or, if this is unsuitable,
5188 the new @code{\?} escape sequence.  @xref{Diversions}, for more information.
5191 @node Summary,  , Implementation Differences, Programming Tutorial
5192 @section Summary
5193 @cindex summary
5197 @node Preprocessors, Output Devices, Programming Tutorial, Top
5198 @chapter Preprocessors
5199 @cindex preprocessors
5201 This chapter covers describes all preprocessors that come with
5202 @code{groff} or which are freely available.
5204 @menu
5205 * geqn::                        
5206 * gtbl::                        
5207 * gpic::                        
5208 * ggrn::                        
5209 * grap::                        
5210 * grefer::                      
5211 * gsoelim::                     
5212 @end menu
5215 @node geqn, gtbl, Preprocessors, Preprocessors
5216 @section @code{geqn}
5217 @cindex @code{eqn}
5218 @cindex @code{geqn}
5220 @menu
5221 * Invoking geqn::               
5222 @end menu
5224 @node Invoking geqn,  , geqn, geqn
5225 @subsection Invoking @code{geqn}
5226 @cindex invoking @code{geqn}
5227 @cindex @code{geqn}, invoking
5230 @node gtbl, gpic, geqn, Preprocessors
5231 @section @code{gtbl}
5232 @cindex @code{tbl}
5233 @cindex @code{gtbl}
5235 @menu
5236 * Invoking gtbl::               
5237 @end menu
5239 @node Invoking gtbl,  , gtbl, gtbl
5240 @subsection Invoking @code{gtbl}
5241 @cindex invoking @code{gtbl}
5242 @cindex @code{gtbl}, invoking
5245 @node gpic, ggrn, gtbl, Preprocessors
5246 @section @code{gpic}
5247 @cindex @code{pic}
5248 @cindex @code{gpic}
5250 @menu
5251 * Invoking gpic::               
5252 @end menu
5254 @node Invoking gpic,  , gpic, gpic
5255 @subsection Invoking @code{gpic}
5256 @cindex invoking @code{gpic}
5257 @cindex @code{gpic}, invoking
5260 @node ggrn, grap, gpic, Preprocessors
5261 @section @code{ggrn}
5262 @cindex @code{grn}
5263 @cindex @code{ggrn}
5265 @menu
5266 * Invoking ggrn::               
5267 @end menu
5269 @node Invoking ggrn,  , ggrn, ggrn
5270 @subsection Invoking @code{ggrn}
5271 @cindex invoking @code{ggrn}
5272 @cindex @code{ggrn}, invoking
5275 @node grap, grefer, ggrn, Preprocessors
5276 @section @code{grap}
5277 @cindex @code{grap}
5279 @code{grap} is available as an extra package, written by Ted Faber.
5282 @node grefer, gsoelim, grap, Preprocessors
5283 @section @code{grefer}
5284 @cindex @code{refer}
5285 @cindex @code{grefer}
5287 @menu
5288 * Invoking grefer::             
5289 @end menu
5291 @node Invoking grefer,  , grefer, grefer
5292 @subsection Invoking @code{grefer}
5293 @cindex invoking @code{grefer}
5294 @cindex @code{grefer}, invoking
5297 @node gsoelim,  , grefer, Preprocessors
5298 @section @code{gsoelim}
5299 @cindex @code{soelim}
5300 @cindex @code{gsoelim}
5302 @menu
5303 * Invoking gsoelim::            
5304 @end menu
5306 @node Invoking gsoelim,  , gsoelim, gsoelim
5307 @subsection Invoking @code{gsoelim}
5308 @cindex invoking @code{gsoelim}
5309 @cindex @code{gsoelim}, invoking
5313 @node Output Devices, File formats, Preprocessors, Top
5314 @chapter Output Devices
5315 @cindex output devices
5316 @cindex devices for output
5318 @menu
5319 * Special Characters::          
5320 * grotty::                      
5321 * grops::                       
5322 * grodvi::                      
5323 * grolj4::                      
5324 * grohtml::                     
5325 * gxditview::                   
5326 @end menu
5329 @node Special Characters, grotty, Output Devices, Output Devices
5330 @section Special Characters
5331 @cindex special characters
5332 @cindex characters, special
5334 @c distribute these through the text
5335 @xref{Font Files}
5338 @node grotty, grops, Special Characters, Output Devices
5339 @section @code{grotty}
5340 @cindex @code{grotty}
5342 @menu
5343 * Invoking grotty::             
5344 @end menu
5346 @node Invoking grotty,  , grotty, grotty
5347 @subsection Invoking @code{grotty}
5348 @cindex invoking @code{grotty}
5349 @cindex @code{grotty}, invoking
5352 @node grops, grodvi, grotty, Output Devices
5353 @section @code{grops}
5354 @cindex @code{grops}
5356 @menu
5357 * Invoking grops::              
5358 * Embedding PostScript::        
5359 @end menu
5361 @node Invoking grops, Embedding PostScript, grops, grops
5362 @subsection Invoking @code{grops}
5363 @cindex invoking @code{grops}
5364 @cindex @code{grops}, invoking
5366 @node Embedding PostScript,  , Invoking grops, grops
5367 @subsection Embedding PostScript
5368 @cindex embedding postscript
5369 @cindex postscript, embedding
5372 @node grodvi, grolj4, grops, Output Devices
5373 @section @code{grodvi}
5374 @cindex @code{grodvi}
5376 @menu
5377 * Invoking grodvi::             
5378 @end menu
5380 @node Invoking grodvi,  , grodvi, grodvi
5381 @subsection Invoking @code{grodvi}
5382 @cindex invoking @code{grodvi}
5383 @cindex @code{grodvi}, invoking
5386 @node grolj4, grohtml, grodvi, Output Devices
5387 @section @code{grolj4}
5388 @cindex @code{grolj4}
5390 @menu
5391 * Invoking grolj4::             
5392 @end menu
5394 @node Invoking grolj4,  , grolj4, grolj4
5395 @subsection Invoking @code{grolj4}
5396 @cindex invoking @code{grolj4}
5397 @cindex @code{grolj4}, invoking
5400 @node grohtml, gxditview, grolj4, Output Devices
5401 @section @code{grohtml}
5402 @cindex @code{grohtml}
5404 @menu
5405 * Invoking grohtml::            
5406 @end menu
5408 @node Invoking grohtml,  , grohtml, grohtml
5409 @subsection Invoking @code{grohtml}
5410 @cindex invoking @code{grohtml}
5411 @cindex @code{grohtml}, invoking
5414 @node gxditview,  , grohtml, Output Devices
5415 @section @code{gxditview}
5416 @cindex @code{gxditview}
5418 @menu
5419 * Invoking gxditview::          
5420 @end menu
5422 @node Invoking gxditview,  , gxditview, gxditview
5423 @subsection Invoking @code{gxditview}
5424 @cindex invoking @code{gxditview}
5425 @cindex @code{gxditview}, invoking
5429 @node File formats, Installation, Output Devices, Top
5430 @chapter File formats
5431 @cindex file formats
5432 @cindex formats, file
5434 @menu
5435 * gtroff Output::               
5436 * Font Files::                  
5437 @end menu
5440 @node gtroff Output, Font Files, File formats, File formats
5441 @section @code{gtroff} Output
5442 @cindex @code{gtroff} output
5443 @cindex output, @code{gtroff}
5446 This section describes the format output by GNU troff.  The output
5447 format used by GNU troff is very similar to that used by @sc{Unix}
5448 device-independent troff.
5450 The output format is text based, as opposed to a binary format (like
5451 @TeX{} dvi).
5452 The output format is 8 bit clean, thus single characters can have the
5453 eighth bit set, as can the names of fonts and special characters.
5455 The output format consists of single command characters with attached
5456 parameters which are separated from subsequent text by whitespace, or
5457 a newline.
5459 The names of characters and fonts an be of arbitrary length; drivers
5460 should not assume that they will be only two characters long (as
5461 device-independent troff did).
5463 When a character is to be printed, that character will always be in the
5464 current font.
5465 Unlike device-independent troff, it is not necessary for
5466 drivers to search special fonts to find a character.
5468 @table @code
5469 @item H@var{n}
5470 @item V@var{n}
5471 @item h@var{n}
5472 @item v@var{n}
5473 @item c@var{n}
5474 @item C@var{n}
5475 @item @var{nn}@var{c}
5476 @item t@var{xxx}
5477 @var{xxx} is any sequence of characters terminated by a space or a
5478 newline; the first character should be printed at the current
5479 position, the the current horizontal position should be increased by
5480 the width of the first character, and so on for each character.
5481 The width of the character is that given in the font file,
5482 appropriately scaled for the current point size,
5483 and rounded so that it is a multiple of the horizontal resolution.
5484 Special characters cannot be printed using this command.
5486 This command is only allowed if the @samp{tcommand} line is present
5487 in the @file{DESC} file.
5488 @item u@var{n} @var{xxx}
5489 @pindex DESC
5490 This is same as the @code{t} command except that after printing each
5491 character, the current horizontal position is increased by the sum of
5492 the width of that character and @code{n}.
5494 This command is only allowed if the @samp{tcommand} line is present
5495 in the @file{DESC} file.
5496 @item n@var{a}@var{b}
5497 @item p@var{n}
5498 @item s@var{n}
5499 The argument to the s command is in scaled points (units of points/n,
5500 where n is the argument to the sizescale command  in the DESC file.)
5501 @item f@var{n}
5502 @item x @dots{} \n
5503 Device control.
5504 @item D@var{c} @var{x}@dots{}\n
5505 @end table
5507 @subsection Device Control
5509 The @code{x} command is normally followed by a letter or word
5510 indicating the function to perform, followed by white space separated
5511 arguments.
5513 The first argument can be abreviated to the first letter.
5515 @table @code
5516 @item x init
5517 @item x T
5518 @item x res @var{n} @var{h} @var{v}
5519 @item x H
5520 The argument to the x Height command is also in scaled points.
5521 @end table
5523 The first three output commands are guaranteed to be:
5525 @example
5526 x T device
5527 x res n h v
5528 x init
5529 @end example
5531 For example, the input @samp{crunchy \fH\s+2frog\s0\fP!?} will produce:
5533 @example
5534 ... sample output here ...
5535 @end example
5537 @subsection Drawing Functions
5539 The D drawing command has been extended.  These extensions will only be
5540 used by GNU pic if the -x option is given.
5542 @table @code
5544 @item Df n\n
5545 Set the shade of gray to be used for filling solid objects to n; n must
5546 be an integer between 0 and 1000, where 0 corresponds solid white and
5547 1000 to solid black, and values in between correspond to intermediate
5548 shades of gray.  This applies only to solid circles, solid ellipses and
5549 solid polygons.  By default, a level of 1000 will be used.  Whatever
5550 color a solid object has, it should completely obscure everything
5551 beneath it. A value greater than 1000 or less than 0 can also be used:
5552 this means fill with the shade of gray that is currently being used for
5553 lines and text.  Normally this will be black, but some drivers may
5554 provide a way of changing this.
5555 @item DC d\n
5556 Draw a solid circle with a diameter of d with the leftmost point at the
5557 current position.
5558 @item DE dx dy\n
5559 Draw a solid ellipse with a horizontal diameter of dx and a vertical
5560 diameter of dy with the leftmost point at the current position.
5561 @item Dp $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub
5562 n$\n
5563 Draw a polygon with, for $i = 1 ,..., n+1$, the i-th vertex at the
5564 current position $+ sum from j=1 to i-1 ( dx sub j , dy sub j )$. At
5565 the moment, GNU pic only uses this command to generate triangles and
5566 rectangles.
5567 @item DP $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub
5568 n$\n
5569 Like Dp but draw a solid rather than outlined polygon.
5570 @item Dt n\n
5571 Set the current line thickness to n machine units.  Traditionally @sc{Unix}
5572 troff drivers use a line thickness proportional to the current point
5573 size; drivers should continue to do this if no Dt command has been
5574 given, or if a Dt command has been given with a negative value of n.  A
5575 zero value of n selects the smallest available line thickness.
5576 @end table
5578 A difficulty arises in how the current position should be changed after
5579 the execution of these commands. This is not of great importance since
5580 the code generated by GNU pic does not depend on this. Given a drawing
5581 command of the form
5583 \D'c $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$'
5585 where c is not one of c, e, l, a or ~, @sc{Unix} troff will treat each of the
5586 $x sub i$ as a horizontal quantity, and each of the $y sub i$ as a
5587 vertical quantity and will assume that the width of the drawn object is
5588 $sum from i=1 to n x sub i$, and that the height is $sum from i=1 to n y
5589 sub i$.  (The assumption about the height can be seen by examining the
5590 st and sb registers after using such a D command in a \w escape
5591 sequence.)  This rule also holds for all the original drawing commands
5592 with the exception of De.  For the sake of compatibility GNU troff also
5593 follows this rule, even though it produces an ugly result in the case of
5594 the Df, Dt, and, to a lesser extent, DE commands.  Thus after executing
5595 a D command of the form
5597 Dc $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$\n
5599 the current position should be increased by $( sum from i=1 to n x sub i
5600 , sum from i=1 to n y sub i )$.
5602 @subsection Line Continuation
5604 There is a continuation convention which permits the argument to the x X
5605 command to contain newlines: when outputting the argument to the x X
5606 command,  GNU troff will follow each newline in the argument with a +
5607 character (as usual, it will terminate the entire argument with a
5608 newline); thus if the line after the line containing the x X command
5609 starts with +, then the newline ending the line containing the x X
5610 command should be treated as part of the argument to the x X command,
5611 the + should be ignored, and the part of the line following the + should
5612 be treated like the part of the line following the x X command.
5615 @node Font Files,  , gtroff Output, File formats
5616 @section Font Files
5617 @cindex font files
5618 @cindex files, font
5620 The groff font format is roughly a superset of the ditroff font
5621 format.  Unlike the ditroff font format, there is no associated binary
5622 format.  The font files for device name are stored in a directory
5623 @file{dev@var{name}}.  There are two types of file: a device
5624 description file called @file{DESC} and for each font @samp{F} a font
5625 file called @file{F}.  These are text files; there is no associated
5626 binary format.
5628 @subsection @file{DESC} file format
5629 @pindex DESC
5631 The @file{DESC} file can contain the following types of line:
5633 @table @code
5634 @item res @var{n}
5635 There are @var{n} machine units per inch.
5636 @item hor @var{n}
5637 The horizontal resolution is @var{n} machine units.
5638 @item vert @var{n}
5639 The vertical resolution is @var{n} machine units.
5640 @item sizescale @var{n}
5641 The scale factor for pointsizes.  By default this has a value of 1.  One
5642 scaled point is equal to one point/@var{n}.  The arguments to the
5643 @code{unitwidth} and @code{sizes} commands are given in scaled points.
5644 @xref{Fractional Type Sizes}, for more information.
5645 @item unitwidth @var{n}
5646 Quantities in the font files are given in machine units for fonts  whose
5647 point size is @var{n} scaled points.
5648 @item tcommand
5649 This means that the postprocessor can handle the @code{t} and
5650 @code{u} output commands.
5651 @item sizes @var{s1} @var{s2}@dots{}@var{sn} 0
5652 This means that the device has fonts at @var{s1}, @var{s2},
5653 @dots{}@var{sn} scaled points.  The list of sizes must be terminated
5654 by a 0.  Each @var{si} can also be a range of
5655 sizes @var{m}-@var{n}.  The list can extend over more than one line.
5656 @item styles @var{S1 S2@dots{}Sm}
5657 The first @var{m} font positions will be associated with styles
5658 @var{S1}@dots{}@var{Sm}.
5659 @item fonts @var{n} @var{F1 F2 F3@dots{}Fn}
5660 Fonts @var{F1@dots{}Fn} will be mounted in the font positions
5661 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m}
5662 is the number of styles.  This command may extend over more than one
5663 line. A font name of 0 will cause no font to be mounted on the
5664 corresponding font position.
5665 @item family @var{fam}
5666 The default font family is @var{fam}.
5667 @item charset
5668 This line and everything following in the file are ignored.  It is
5669 allowed for the sake of backwards compatibility.
5670 @end table
5672 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
5673 are compulsory.  Other commands are ignored by troff but may be used
5674 by postprocessors to store arbitrary information about the device in
5675 the @file{DESC} file.
5678 @subsection Font file format
5680 A font file has two sections.  The first section is a sequence of lines
5681 each containing a sequence of blank delimited words; the first word in
5682 the line is a key, and subsequent words give a value for that key.
5684 @table @code
5685 @item name @var{F}
5686 The name of the font is @var{F}.
5687 @item spacewidth @var{n}
5688 The normal width of a space is @var{n}.
5689 @item slant @var{n}
5690 The characters of the font have a slant of @var{n} degrees.
5691 (Positive means forward.)
5692 @item ligatures @var{lig1} @var{lig2}@dots{}@var{lign} [0]
5693 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
5694 possible ligatures are ff, fi, fl and ffl.  For backwards
5695 compatibiliy, the list of ligatures may be terminated with a 0.  The
5696 list of ligatures may not extend over more than one line.
5697 @item special
5698 The font is special; this means that when a character is requested that
5699 is not present in the current font, it will be searched for in any
5700 special fonts that are mounted.
5701 @end table
5703 Other commands are ignored by troff but may be used by postprocessors to
5704 store arbitrary information about the font in the font file.
5706 The first section can contain comments which start with the # character
5707 and extend to the end of a line.
5709 The second section contains one or two subsections.  It must contain a
5710 @code{charset} subsection and it may also contain a @code{kernpairs}
5711 subsection.  These subsections can appear in any order.  Each
5712 subsection starts with a word on a line by itself.
5714 The word @code{charset} starts the @code{charset} subsection. The
5715 @code{charset} line is followed by a sequence of lines. Each line
5716 gives information for one character.  A line comprises a number of
5717 fields separated by blanks or tabs. The format is
5719 @display
5720 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
5721 @end display
5723 @var{name} identifies the character: if @var{name} is a single
5724 character @var{c} then it corresponds to the groff input character
5725 @var{c}; if it is of the form @samp{\@var{c}} where @var{c} is a
5726 single character, then it corresponds to the groff input character
5727 @samp{\@var{c}}; otherwise it corresponds to the groff input character
5728 @samp{\[@var{name}]} (if it is exactly two characters @var{xx} it can
5729 be entered as @samp{\(@var{xx}}.) Groff supports eight bit characters;
5730 however some utilities has difficulties with eight bit characters.
5731 For this reason, there is a convention that the @var{name}
5732 @samp{char@var{n}} is equivalent to the single character whose code is
5733 @var{n}. For example, @samp{char163} would be equivalent to the
5734 character with @var{code} 163 which is the pounds sterling sign in ISO
5735 Latin-1 character set.  The name @samp{---} is special and indicates
5736 that the character is unnamed; such characters can only be used by
5737 means of the @code{\N} escape sequence in troff.
5739 The @var{type} field gives the character type:
5741 @table @code
5742 @item 1
5743 means the character has an descender, for example, p;
5744 @item 2
5745 means the character has an ascender, for example, b;
5746 @item 3
5747 means the character has both an ascender and a descender, for example,
5748 @samp{(}.
5749 @end table
5751 The @var{code} field gives the code which the postprocessor uses to
5752 print the character.  The character can also be input to groff using
5753 this code by means of the @code{\N} escape sequence. The code can be any
5754 integer.  If it starts with a 0 it will be interpreted as octal; if it
5755 starts with 0x or 0X it will be intepreted as hexdecimal.
5757 Anything on the line after the @var{code} field will be ignored.
5759 The @var{metrics} field has the form:
5761 @smallexample
5762 @var{width[,height[,depth[,italic_correction[,left_italic_correction[,subscript_correction]]]]]}
5763 @end smallexample
5765 There must not be any spaces between these subfields.  Missing
5766 subfields are assumed to be 0.  The subfields are all decimal
5767 integers.  Since there is no associated binary format, these values
5768 are not required to fit into a variable of type @samp{char} as they
5769 are in ditroff.  The @var{width} subfields gives the width of the
5770 character.  The @var{height} subfield gives the height of the
5771 character (upwards is positive); if a character does not extend above
5772 the baseline, it should be given a zero height, rather than a negative
5773 height.  The @var{depth} subfield gives the depth of the character,
5774 that is, the distance below the lowest point below the baseline to
5775 which the character extends (downwards is positive); if a character
5776 does not extend below above the baseline, it should be given a zero
5777 depth, rather than a negative depth.  The @var{italic_correction}
5778 subfield gives the amount of space that should be added after the
5779 character when it is immediately to be followed by a character from a
5780 roman font.  The @var{left_italic_correction} subfield gives the
5781 amount of space that should be added before the character when it is
5782 immediately to be preceded by a character from a roman font.  The
5783 @var{subscript_correction} gives the amount of space that should be
5784 added after a character before adding a subscript. This should be less
5785 than the italic correction.
5787 A line in the @code{charset} section can also have the format
5789 @example
5790 @var{name} "
5791 @end example
5793 This indicates that @var{name} is just another name for the character
5794 mentioned in the preceding line.
5796 The word @code{kernpairs} starts the kernpairs section.  This contains a
5797 sequence of lines of the form:
5799 @display
5800 @var{c1 c2 n}
5801 @end display
5803 This means that when character @var{c1} appears next to character
5804 @var{c2} the space between them should be increased by @var{n}.  Most
5805 entries in kernpairs section will have a negative value for @var{n}.
5809 @node Installation, Request Index, File formats, Top
5810 @chapter Installation
5811 @cindex installation
5815 @node Request Index, Register Index, Installation, Top
5816 @chapter Request Index
5818 @printindex fn
5822 @node Register Index, String Index, Request Index, Top
5823 @chapter Register Index
5825 @printindex vr
5828 @node String Index, Macro Index, Register Index, Top
5829 @chapter String Index
5833 @node Macro Index, Program Index, String Index, Top
5834 @chapter Macro Index
5838 @node Program Index, Concept Index, Macro Index, Top
5839 @chapter Program Index
5841 @printindex pg
5845 @node Concept Index,  , Program Index, Top
5846 @chapter Concept Index
5848 @printindex cp
5852 @summarycontents
5853 @contents
5854 @bye