* doc/groff.texinfo: Further checking/updating. Adding more index entries.
[s-roff.git] / doc / groff.texinfo
blobfe6a1aac76ac0d27a276481397713830420466c0
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, escapes, and functions
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 @cindex @code{runoff}
623 @code{troff} can trace its origins back to a formatting program called
624 @code{runoff} which ran on MIT's CTSS system.  This name came from the
625 common phrase of the time ``I'll run off a document.''
627 @cindex @code{roff}
628 The first version of @sc{Unix} was developed on a PDP-7 which was
629 sitting around Bell Labs.  In 1971 the developers wanted to get a PDP-11
630 for further work on the operating system.  In order to justify the cost
631 for this system, they proposed that they would implement a document
632 formatting system for the AT&T patents division.  This first formatting
633 program was a reimplementation of @code{runoff}.  In accordance with
634 @sc{Unix}'s penchant for abreviations, it was named @code{roff} (an
635 abreviation of @code{runoff}).
637 @cindex @code{nroff}
638 When they needed a more flexible language, a new version of @code{roff}
639 called @code{nroff} (Newer @code{roff}) was written.  It had a much more
640 complicated syntax, but provided the basis for all future versions.
641 When they got a Graphic Systems CAT Phototypesetter, J.@w{ }F.@w{
642 }Ossanna wrote a version of @code{nroff} which would drive it.  It was
643 dubbed @code{troff} for typesetter @code{roff}, although many people
644 have speculated that it actually means Times @code{roff} because of
645 @code{troff}'s use of the Times font family by default.  As such, the
646 name @code{troff} is pronounced t-roff rather than trough.
648 With @code{troff} came @code{nroff} (they were actually the same program
649 except for some @samp{#ifdefs}), which was for producing output for line
650 printers and character terminals.  It understood everything @code{troff}
651 did, and ignored the commands which were not aplicable (i.e.@: font
652 changes).
654 Since there are several things which cannot be done easily in
655 @code{troff}, work on several preprocessors began.  These programs would
656 transform certain parts of a document into @code{troff}, which made a
657 very natural use of pipes in @sc{Unix}.
659 The @code{eqn} preprocessor allowed mathematical formul@ae{} to be
660 specified in a much simpler and more intuitive manner.  @code{tbl} is a
661 preprocessor for formatting tables.  The @code{refer} preprocessor (and
662 the similar program, @code{bib}) processes citations in a document
663 according to a bibliographic database.
665 Unfortunately, Ossanna's @code{troff} was written in PDP-11 assembly
666 language and produced output specifically for the CAT phototypesetter.
667 He rewrote it in C, although it was now 7000@w{ }lines of uncommented
668 code and still dependent on the CAT.  As the CAT became less common, and
669 was no longer supported by the manufacturer, the need to make it support
670 other devices became a priority.  However, before this could be done, he
671 was killed in an auto accident.
673 @pindex ditroff
674 @cindex @code{ditroff}
675 So, Brian Kernighan took on the task of rewriting @code{troff}.  The
676 newly rewritten version produced a device independent code which was
677 very easy for postprocessors to read and translate to the appropriate
678 printer codes.  Also, this new version of @code{troff} (called
679 @code{ditroff}) had several extentions, which included drawing
680 functions.
682 Due to the additional abilities of the new version of @code{troff},
683 several new preprocessors appeared.  The @code{pic} preprocessor
684 provides a wide range of drawing functions.  Likewise the @code{ideal}
685 preprocessor did the same, although via a much different paradigm.  The
686 @code{grap} preprocessor took specifications for graphs, but, unlike
687 other preprocessors, produced @code{pic} code.
689 James Clark began work on a GNU implementation of @code{ditroff} in
690 early@w{ }1989.  The first version, @code{groff}@w{ }0.3.1, was released
691 June@w{ }1990.  @code{groff} included
693 @itemize @bullet{}
694 @item
695 A replacement for @code{ditroff} with many extentions.
696 @item
697 The @code{soelim}, @code{pic}, @code{tbl}, and @code{eqn} preprocessors.
698 @item
699 Postprocessors for character devices, PostScript, @TeX{} DVI, and X@w{
700 }windows.  GNU @code{troff} also eliminated the need for a separate
701 @code{nroff} program with a postprocessor which would produce @sc{ascii}
702 output.
703 @item
704 A version of the @code{-me} macros and an implementation of the
705 @code{-man} macros.
706 @end itemize
708 Also, a front-end was included which could construct the, sometimes
709 painfully long, pipelines required for all the post- and preprocessors.
711 Development of GNU @code{troff} progressed rapidly, and saw the
712 additions of a replacement for @code{refer}, an implementation of the
713 @code{-ms} and @code{-mm} macros, and a program to deduce how to format
714 a document (@code{grog}).
716 It was declared a stable (i.e.@: non beta) package with the release of
717 version@w{ }1.04 around November@w{ }1991.
719 Beginning in@w{ }1999, @code{groff} has new maintainers (the package was
720 an orphan for a few years).  As a result, new features and programs like
721 @code{grn}, a preprocessor for gremlin images, and @code{grohtml}, an
722 output device to produce HTML output, have been added.
725 @node groff Capabilities, Macro Package Intro, History, Introduction
726 @section @code{groff} Capabilities
727 @cindex @code{groff} capabilities
728 @cindex capabilities of @code{groff}
730 So what exactly is @code{groff} capable of doing?  @code{groff} provides
731 a wide range of low-level text formatting operations.  Using these, you
732 can perform a wide range of formatting tasks, such as footnotes, table
733 of contents, multiple columns, etc.
735 @itemize @bullet{}
736 @item
737 Text filling, adjusting, and centering
738 @item
739 Hyphenation
740 @item
741 Page control
742 @item
743 Font and character size control
744 @item
745 Vertical spacing (i.e.@: double spacing)
746 @item
747 Line length and indenting
748 @item
749 Macros, strings, diversions, and traps
750 @item
751 Number registers
752 @item
753 Tabs, leaders, and fields
754 @item
755 Input and output conventions and character translation
756 @item
757 Overstrike, bracket, line drawing, and zero-width functions
758 @item
759 Local horizontal and vertical motions and the width function
760 @item
761 Three-part titles
762 @item
763 Output line numbering
764 @item
765 Conditional acceptance of input
766 @item
767 Environment switching
768 @item
769 Insertions from the standard input
770 @item
771 Input/output file switching
772 @item
773 Output and error messages
774 @end itemize
777 @node Macro Package Intro, Preprocessor Intro, groff Capabilities, Introduction
778 @section Macro Packages
779 @cindex macro packages
781 Since @code{groff} provides such low level facilities, it can be quite
782 difficult to use by itself.  However, @code{groff} provides a
783 @dfn{macro} facility which allows you to specify how certain routine
784 operations (e.g.@w{ }starting paragraphs, printing headers and footers,
785 etc.)@: should be done.  These macros can be collected together into a
786 @dfn{macro package}.  There are a number of macro packages available;
787 the most common (and the ones described in this manual) are @code{-man},
788 @code{-mdoc}, @code{-me}, @code{-ms}, and @code{-mm}.
791 @node Preprocessor Intro, Output device intro, Macro Package Intro, Introduction
792 @section Preprocessors
793 @cindex preprocessors
795 Although @code{groff} provides most functions needed to format a
796 document, some operations would be unwieldy (i.e.@: drawing pictures).
797 Therefore, programs called preprocessors were written which understand
798 their own language and produce the necessary @code{groff} operations.
799 These preprocessors are able to differentiate their own input from the
800 rest of the document via markers.
802 To use a preprocessor, @sc{Unix} pipes are used to feed the output from
803 the preprocessor into @code{groff}.  Any number of preprocessors may be
804 used on a given document; in this case, the preprocessors are linked
805 together into one pipeline.  However, in @code{groff}, the user does not
806 need to construct the pipe, but only tell @code{groff} what
807 preprocessors to use.
809 @code{groff} currently has preprocessors for producing tables
810 (@code{tbl}), typesetting equations (@code{eqn}), drawing pictures
811 (@code{pic} and @code{grn}), and for processing bibliographies
812 (@code{refer}).  An associated program which is useful when dealing with
813 preprocessors is @code{soelim}.
815 There are other preprocessors in existence, but there are,
816 unfortunately, no free implementations available.  They are for drawing
817 pictures (@code{ideal}) and chemical structures (@code{chem}).
819 A free implementation of @code{grap}, a preprocessor for drawing graphs,
820 can be obtained as an extra package.
823 @node Output device intro, Credits, Preprocessor Intro, Introduction
824 @section Output Devices
825 @cindex postprocessors
826 @cindex output devices
827 @cindex devices for output
829 @code{groff} actually produces device independent code which may be fed
830 into a postprocessor which will produce output for a particular device.
831 Currently, @code{groff} has postprocessors for PostScript, character
832 terminals, X@w{ }Windows (for previewing), @TeX{} DVI format, HP
833 LaserJet@w{ }4 printers, and HTML.
836 @node Credits,  , Output device intro, Introduction
837 @section Credits
838 @cindex credits
840 Large portions of this manual were taken from existing documents, most
841 notably, the manual pages for the @code{groff} package by James Clark,
842 and Eric Allman's papers on the @code{-me} macro package.
846 @node Invoking groff, Tutorial for Macro Users, Introduction, Top
847 @chapter Invoking @code{groff}
848 @cindex invoking @code{groff}
849 @cindex @code{groff} invocation
851 @pindex groff
852 @pindex gtroff
853 This section focuses on how to invoke the @code{groff} front end.  This
854 front end takes care of the details of constructing the pipeline among
855 the preprocessors, @code{gtroff} and the postprocessor.
857 It has become a tradition that GNU programs get the prefix @dfn{g} to
858 distinguish it from its original counterparts provided by the host
859 (@pxref{Environment}, for more details).  Thus, for example, @code{geqn}
860 is GNU @code{eqn}.  On operating systems like Linux or the Hurd, which
861 don't contain proprietary software, this prefix is omitted since GNU
862 @code{troff} is the only used incarnation of @code{troff}.  Exception:
863 @code{groff} is never replaced by `@code{roff}'.
865 @menu
866 * Options::                     
867 * Environment::                 
868 * Invocation Examples::         
869 @end menu
872 @node Options, Environment, Invoking groff, Invoking groff
873 @section Options
874 @cindex options
876 @pindex groff
877 @pindex gtroff
878 @pindex gpic
879 @pindex geqn
880 @pindex ggrn
881 @pindex gtbl
882 @pindex grefer
883 @pindex gsoelim
884 @code{groff} is a front-end to the groff document formatting system.
885 Normally it runs the @code{gtroff} program and a postprocessor
886 appropriate for the selected device.  The default device is @samp{ps}.
887 It can optionally preprocess with any of @code{gpic}, @code{geqn},
888 @code{gtbl}, @code{ggrn}, @code{grefer}, or @code{gsoelim}.
890 This section only documents options to the @code{groff} front end.  Many
891 of the arguments to @code{groff} are passed on to @code{gtroff},
892 therefore those are also included.  Arguments to pre- or postprocessors
893 can be found in @ref{Invoking gpic}, @ref{Invoking geqn}, @ref{Invoking
894 gtbl}, @ref{Invoking ggrn}, @ref{Invoking grefer}, @ref{Invoking
895 gsoelim}, @ref{Invoking grotty}, @ref{Invoking grops}, @ref{Invoking
896 grohtml}, @ref{Invoking grodvi}, and @ref{Invoking gxditview}.
898 The command line format for @code{groff} is:
900 @example
901 groff [ -abeghilpstvzCENRSUVXZ ] [ -F@var{dir} ] [ -m@var{name} ]
902       [ -T@var{def} ] [ -f@var{fam} ] [ -w@var{name} ] [ -W@var{name} ]
903       [ -M@var{dir} ] [ -d@var{cs} ] [ -r@var{cn} ] [ -n@var{num} ]
904       [ -o@var{list} ] [ -P@var{arg} ] [ -L@var{arg} ] [ -I@var{dir} ]
905       [ @var{files}@dots{} ]
906 @end example
908 The command line format for @code{gtroff} is as follows.  As you can
909 see, many of the options to @code{groff} are actually passed on to
910 @code{gtroff}.
912 @example
913 gtroff [ -abivzCERU ] [ -w@var{name} ] [ -W@var{name} ] [ -d@var{cs} ]
914        [ -f@var{fam} ] [ -m@var{name} ] [ -n@var{num} ]
915        [ -o@var{list} ] [ -r@var{cn} ] [ -T@var{name} ]
916        [ -F@var{dir} ] [ -M@var{dir} ] [ @var{files}@dots{} ]
917 @end example
919 Options without an argument can be grouped behind a single @samp{-}.  A
920 filename of @samp{-} denotes the standard input.
922 @pindex grog
923 The @code{grog} command can be used to guess the correct @code{groff}
924 command to use to format a file.
926 @table @samp
927 @item -h
928 Print a help message.
929 @item -e
930 Preprocess with @code{geqn}.
931 @item -t
932 Preprocess with @code{gtbl}.
933 @item -g
934 Preprocess with @code{ggrn}.
935 @item -p
936 Preprocess with @code{gpic}.
937 @item -s
938 Preprocess with @code{gsoelim}.
939 @item -R
940 Preprocess with @code{grefer}.  No mechanism is provided for passing
941 arguments to @code{grefer} because most @code{grefer} options have
942 equivalent commands which can be included in the file.  @xref{grefer},
943 for more details.
945 @pindex troffrc
946 Note that @code{gtroff} also accepts a @samp{-R} option, which is not
947 accessible via @code{groff}.  This option prevents the loading of the
948 @file{troffrc} file.
949 @item -v
950 Make programs run by @code{groff} print out their version number.
951 @item -V
952 Print the pipeline on stdout instead of executing it.
953 @item -z
954 Suppress output from @code{gtroff}.  Only error messages will be
955 printed.
956 @item -Z
957 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
958 will automatically run the appropriate postprocessor.
959 @item -P@var{arg}
960 Pass @var{arg} to the postprocessor.  Each argument should be passed
961 with a separate @samp{-P} option.  Note that @code{groff} does not
962 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
963 @item -l
964 Send the output to a printer.  The command used for this is specified by
965 the print command in the device description file.
966 @item -L@var{arg}
967 Pass @var{arg} to the spooler.  Each argument should be passed with a
968 separate @samp{-L} option.  Note that @code{groff} does not prepend a
969 @samp{-} to @var{arg} before passing it to the postprocessor.
970 @item -T@var{dev}
971 Prepare output for device @var{dev}.  The default device is @samp{ps}.
972 The following are the output devices currently available:
973 @table @samp
974 @item ps
975 For PostScript printers and previewers.
976 @item dvi
977 For @TeX{} dvi format.
978 @item X75
979 For a 75dpi X11 previewer.
980 @item X100
981 For a 100dpi X11 previewer.
982 @item @sc{ascii}
983 For typewriter-like devices.
984 @item latin1
985 For typewriter-like devices using the ISO@w{ }Latin@w{-}1 (ISO@w{
986 }8859@w{-}1) character set.
987 @item utf8
988 For typewriter-like devices using the Unicode (ISO@w{ }10646) character
989 set with UTF@w{-}8 encoding.
990 @item lj4
991 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
992 @item html
993 To produce HTML output.
994 @end table
996 The postprocessor to be used for a device is specified by the
997 @code{postpro} command in the device description file.  (@xref{Font
998 Files}, for more info.)  This can be overridden with the @samp{-X}
999 option.
1000 @item -X
1001 Preview with @code{gxditview} instead of using the usual postprocessor.
1002 This is unlikely to produce good results except with @samp{-Tps}.
1003 @item -N
1004 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1005 the @samp{-N} option in @code{geqn}.
1006 @item -S
1007 Safer mode.  Pass the @samp{-S} option to @code{gpic} and use the
1008 @samp{-msafer} macros with @code{gtroff} (enabled by default).
1009 @item -U
1010 Unsafe mode.  Reverts to the old unsafe behaviour.
1011 @item -a
1012 Generate an @sc{ascii} approximation of the typeset output.
1013 @item -b
1014 Print a backtrace with each warning or error message.  This backtrace
1015 should help track down the cause of the error.  The line numbers given
1016 in the backtrace may not always be correct: @code{gtroff}'s idea of line
1017 numbers gets confused by @code{as} or @code{am} requests.
1018 @item -i
1019 Read the standard input after all the named input files have been
1020 processed.
1021 @item -w@var{name}
1022 Enable warning @var{name}.  Available warnings are described in
1023 @ref{Debugging}.  Multiple @samp{-w} options are allowed.
1024 @item -W@var{name}
1025 Inhibit warning @var{name}.  Multiple @samp{-W} options are allowed.
1026 @item -E
1027 Inhibit all error messages.
1028 @item -C
1029 Enable compatibility mode.
1030 @item -d@var{cs}
1031 @itemx -d@var{name}=s
1032 Define @var{c} or @var{name} to be a string @var{s}; @var{c} must be a
1033 one-letter @var{name}.
1034 @item -f@var{fam}
1035 Use @var{fam} as the default font family.
1036 @item -m@var{name}
1037 Read in the file @file{tmac.@var{name}}.  Normally this will be searched
1038 for in @code{groff}'s lib directory.
1039 @item -n@var{num}
1040 Number the first page @var{num}.
1041 @item -o@var{list}
1042 Output only pages in @var{list}, which is a comma-separated list of page
1043 ranges; @var{n} means print page @var{n}, @samp{@var{m}-@var{n}} means
1044 print every page between @var{m} and @var{n}, @samp{-@var{n}} means
1045 print every page up to @var{n}, @samp{@var{n}-} means print every page
1046 from @var{n}.  @code{gtroff} will exit after printing the last page in
1047 the list.
1048 @item -r@var{cn}
1049 @itemx -r@var{name}=@var{n}
1050 Set number register @var{c} or @var{name} to @var{n}; @var{c} must be a
1051 one-letter @var{name}; @var{n} can be any troff numeric expression.
1052 @item -F@var{dir}
1053 Search @var{dir} for subdirectories dev@var{name} (@var{name} is the
1054 name of the device) for the @file{DESC} file and font files before the
1055 normal directory.
1056 @item -M@var{dir}
1057 Search directory @var{dir} for macro files before the normal directory.
1058 @item -I@var{dir}
1059 This option is as described in @ref{gsoelim}.  It implies the @samp{-s}
1060 option.
1061 @end table
1064 @node Environment, Invocation Examples, Options, Invoking groff
1065 @section Environment
1066 @cindex environment variables
1067 @cindex variables in environment
1069 There are also several environment variables which can modify
1070 @code{groff}'s behavior.
1072 @table @code
1073 @item GROFF_COMMAND_PREFIX
1074 @tindex GROFF_COMMAND_PREFIX
1075 If this is set to @var{X}, then @code{groff} will run
1076 @var{X}@code{troff} instead of @code{gtroff}.  This also applies to
1077 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{refer}, and
1078 @code{soelim}.  It does not apply to @code{grops}, @code{grodvi},
1079 @code{grotty}, @code{grohtml}, @code{grolj4}, and @code{gxditview}.
1080 @item GROFF_TMAC_PATH
1081 @tindex GROFF_TMAC_PATH
1082 A colon separated list of directories in which to search for macro
1083 files.
1084 @item GROFF_TYPESETTER
1085 @tindex GROFF_TYPESETTER
1086 The default output device.
1087 @item GROFF_FONT_PATH
1088 @tindex GROFF_FONT_PATH
1089 A colon separated list of directories in which to search for the
1090 @code{dev}@var{name} directory.
1091 @item PATH
1092 @tindex PATH
1093 The search path for commands executed by @code{groff}.
1094 @item GROFF_TMPDIR
1095 @tindex GROFF_TMPDIR
1096 @tindex TMPDIR
1097 The directory in which temporary files will be created.  If this is not
1098 set and @code{TMPDIR} is set, temporary files will be created in that
1099 directory.  Otherwise temporary files will be created in @code{/tmp}.
1100 The @code{grops} and @code{grefer} commands can create temporary files.
1101 @end table
1104 @node Invocation Examples,  , Environment, Invoking groff
1105 @section Invocation Examples
1106 @cindex invocation examples
1107 @cindex examples of invocation
1109 This section will list several common uses of @code{groff} and the
1110 command line which will accomplish it.
1112 @example
1113 groff file
1114 @end example
1116 @noindent
1117 This command processes @var{file} without a macro package or a
1118 preprocessor.  The output device is the default, @var{ps}, and the
1119 output is sent to stdout.
1121 @example
1122 groff -t -mandoc -Tascii file | less
1123 @end example
1125 @noindent
1126 This is basically what a call to @code{man} does.  The manual page
1127 @var{file} is processed with the @code{-mandoc} macros (which in turn
1128 either call the @code{-man} or the @code{-mdoc} macro package), using
1129 the @code{tbl} preprocessor and the @sc{ascii} output device.  Finally,
1130 the result is displayed with the @code{less} pager.
1132 @example
1133 groff -X -me file
1134 @end example
1136 @noindent
1137 Preview @var{file} with @code{gxditview}, using the @code{-me} macro
1138 package.
1140 @example
1141 groff -man -rD1 -z file
1142 @end example
1144 @noindent
1145 Check @var{file} with the @code{-man} macro package, forcing
1146 double-sided printing---don't produce any output.
1148 @subsection @code{grog}
1150 @code{grog} reads files and guesses which of the @code{groff}
1151 preprocessors and/or macro packages are are required for formatting
1152 them, and prints the @code{groff} command including those options on the
1153 standard output.  The options generated are one of @samp{-e},
1154 @samp{-man}, @samp{-me}, @samp{-mm}, @samp{-ms}, @samp{-p}, @samp{-R},
1155 @samp{-g}, @samp{-s}, and @samp{-t}.
1157 A filename of @samp{-} is taken to refer to the standard input.  If no
1158 files are specified the standard input will be read.  Any specified
1159 options will be included in the printed command.  No space is allowed
1160 between options and their arguments.  For example,
1162 @example
1163 grog -Tdvi paper.ms
1164 @end example
1166 @noindent
1167 will guess the appropriate command to print @file{paper.ms} and then
1168 print it to the command line after adding the @samp{-Tdvi} option.  If
1169 you want to directly execute it, enclose the call to @code{grog} in
1170 backquotes on the @sc{Unix} shell prompt:
1172 @example
1173 `grog -Tdvi paper.ms` > paper.dvi
1174 @end example
1176 @noindent
1177 As you can see, it is still necessary to redirect the output to
1178 something meaningful (i.e.@: either a file or a pager program like
1179 @code{less}).
1183 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1184 @chapter Tutorial for Macro Users
1185 @cindex tutorial for macro users
1186 @cindex macro tutorial for users
1187 @cindex user's tutorial for macros
1188 @cindex user's macro tutorial
1190 Most users tend to use a macro package to format their papers.  This
1191 means that the whole breadth of @code{groff} is not neccessary for most
1192 people.  This chapter covers the material needed to efficiently use a
1193 macro package.
1195 @menu
1196 * Basics::                      
1197 * Common Features::             
1198 @end menu
1201 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1202 @section Basics
1203 @cindex basics
1205 This section covers some of the basic concepts you will need to
1206 understand to use a macro package.@footnote{This section is derived from
1207 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1208 References are made throughout to more detailed information, if desired.
1210 @code{gtroff} reads an input file prepared by the user and outputs a
1211 formatted paper suitable for publication or framing.  The input consists
1212 of text, or words to be printed, and embedded commands (@dfn{requests}
1213 and @dfn{escapes}), which tell @code{gtroff} how to format the printed
1214 copy.  For more detail on this @pxref{Embedded Commands}.
1216 The word @dfn{argument} is used in this manual to mean a word or number
1217 which appears on the same line as a request which modifies the meaning
1218 of that request.  For example, the request
1220 @example
1222 @end example
1224 @noindent
1225 spaces one line, but
1227 @example
1228 .sp 4
1229 @end example
1231 @noindent
1232 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1233 request which says to space four lines instead of one.  Arguments are
1234 separated from the request and from each other by spaces.  More details
1235 on this can be found in @ref{Request Arguments}.
1237 The primary function of @code{gtroff} is to collect words from input
1238 lines, fill output lines with those words, justify the right hand margin
1239 by inserting extra spaces in the line, and output the result.  For
1240 example, the input:
1242 @example
1243 Now is the time
1244 for all good men
1245 to come to the aid
1246 of their party.
1247 Four score and seven
1248 years ago,...
1249 @end example
1251 @noindent
1252 will be read, packed onto output lines, and justified to produce:
1254 @quotation
1255 Now is the time for all good men to come to the aid of their party.
1256 Four score and seven years ago,...
1257 @end quotation
1259 @cindex break
1260 @cindex line break
1261 Sometimes you may want to start a new output line even though the line
1262 you are on is not yet full; for example, at the end of a paragraph.  To
1263 do this you can cause a @dfn{break}, which starts a new output line.
1264 Some requests cause a break automatically, as do blank input lines and
1265 input lines beginning with a space.
1267 Not all input lines are text to be formatted.  Some of the input lines
1268 are requests which describe how to format the text.  Requests always
1269 have a period or an apostrophe (@samp{'}) as the first character of the
1270 input line.
1272 The text formatter also does more complex things, such as automatically
1273 numbering pages, skipping over page boundaries putting footnotes in the
1274 correct place, and so forth.
1276 Here a few hints for preparing text for input to @code{gtroff}.  First,
1277 keep the input lines short.  Short input lines are easier to edit, and
1278 @code{gtroff} will pack words onto longer lines for you anyhow.  In
1279 keeping with this, it is helpful to begin a new line after every period,
1280 comma, or phrase, since common corrections are to add or delete
1281 sentences or phrases.  Secondly, do not hyphenate words at the end of
1282 lines---@code{gtroff} is smart enough to hyphenate words for you as
1283 needed, but is not smart enough to take hyphens out and join a word back
1284 together.  Also, words such as ``mother-in-law'' should not be broken
1285 over a line, since then you will get a space where not wanted, such as
1286 ``@w{mother- in}-law''.
1288 @findex ls
1289 @cindex double spacing
1290 @cindex spacing
1291 @code{gtroff} will double space output text automatically if you use the
1292 request @w{@samp{.ls 2}}.  You can revert to single spaced mode by
1293 typing @w{@samp{.ls 1}}.
1295 A number of requests allow you to change the way the printed copy looks,
1296 sometimes called the @dfn{layout} of the output page.  Most of these
1297 requests adjust the placing of @dfn{white space} (blank lines or
1298 spaces).
1300 @findex bp
1301 @cindex new page
1302 The @samp{.bp} request starts a new page.
1304 @findex sp
1305 @cindex blank lines
1306 @cindex empty lines
1307 @cindex lines, empty
1308 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1309 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1310 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1311 @var{N}@w{ }centimeters).  For example, the input:
1313 @example
1314 .sp 1.5i
1315 My thoughts on the subject
1317 @end example
1319 @noindent
1320 leaves one and a half inches of space, followed by the line ``My
1321 thoughts on the subject'', followed by a single blank line.
1323 @findex ce
1324 @cindex centering lines
1325 @cindex lines, centering
1326 Text lines can be centered by using the @samp{.ce} request.  The line
1327 after @samp{.ce} is centered (horizontally) on the page.  To center more
1328 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1329 of lines to center), followed by the @var{N}@w{ }lines.  If you want to
1330 center many lines but don't want to count them, type:
1332 @example
1333 .ce 1000
1334 lines to center
1335 .ce 0
1336 @end example
1338 @noindent
1339 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1340 lines, in other words, stop centering.
1342 @findex br
1343 @cindex line break
1344 @cindex break
1345 All of these requests cause a break; that is, they always start a new
1346 line.  If you want to start a new line without performing any other
1347 action, use @samp{.br}.
1350 @node Common Features,  , Basics, Tutorial for Macro Users
1351 @section Common Features
1352 @cindex common features
1353 @cindex features, common
1355 @code{gtroff} provides very low level operations for formatting a
1356 document.  There are many common routine operations which are done in
1357 all documents.  These common operations are written into @dfn{macros}
1358 and collected into a @dfn{macro package}.
1360 All macro packages provide certain common capabilities which fall into
1361 the following categories.
1363 @subsection Paragraphs
1364 @cindex paragraphs
1366 One of the most common and most used capability is starting a paragraph.
1367 There are a number of different types of paragraphs, any of which can be
1368 initiated with macros supplied by the macro package.  Normally,
1369 paragraphs start with a blank line and the first line indented, like the
1370 text in this manual.  There are also block style paragraphs, which omit
1371 the indentation:
1373 @example
1374 Some   men  look   at  constitutions   with  sanctimonious
1375 reverence, and deem them like the ark of the covenant, too
1376 sacred to be touched.
1377 @end example
1379 @noindent
1380 And there are also indented paragraphs which begin with a tag or label
1381 at the margin and the remaining text indented.
1383 @example
1384 one   This is  the first paragraph.  Notice  how the first
1385       line of  the resulting  paragraph lines up  with the
1386       other lines in the paragraph.
1387 longlabel
1388       This  paragraph   had  a  long   label.   The  first
1389       character of text on the first line will not line up
1390       with  the  text  on  second  and  subsequent  lines,
1391       although they will line up with each other.
1392 @end example
1394 A variation of this is a bulleted list.
1395 @c XXX description
1397 @subsection Sections and Chapters
1399 Most macro packages supply some form of section headers.  The simplest
1400 kind is simply the heading on a line by itself in bold type.  Others
1401 supply automatically numbered section heading or different heading
1402 styles at different levels.  Some, more sophisticated, macro packages
1403 supply macros for starting chapters and appendicies.
1405 @subsection Headers and Footers
1407 Every macro packages gives you some way to manipulate the headers and
1408 footers (or @dfn{titles}) on each page.  Some packages will allow you to
1409 have different ones on the even and odd pages (for material printed in a
1410 book form).
1412 The titles are called three-part titles, that is, there is a
1413 left-justified part, a centered part, and a right-justified part.  An
1414 automatically generated page number may be put in any of these fields
1415 with the @samp{%} character (@pxref{Page Layout} for more details).
1417 @subsection Page Layout
1419 Most macro packages let you specify top and bottom margins and other
1420 details about the appearance of the printed pages.
1422 @subsection Displays
1423 @cindex displays
1425 Displays are sections of text to be set off from the body of the paper.
1426 Major quotes, tables, and figures are types of displays, as are all the
1427 examples used in this document.
1429 @cindex quotes, major
1430 @cindex major quotes
1431 @dfn{Major quotes} are quotes which are several lines long, and hence
1432 are set in from the rest of the text without quote marks around them.
1434 @cindex list
1435 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
1436 should be used when the material to be printed should not be filled and
1437 justified like normal text, such as columns of figures or the examples
1438 used in this paper.
1440 @cindex keep
1441 A @dfn{keep} is a display of lines which are kept on a single page if
1442 possible.  An example of where you would use a keep might be a diagram.
1443 Keeps differ from lists in that lists may be broken over a page boundary
1444 whereas keeps will not.
1446 @cindex keep, floating
1447 @cindex floating keep
1448 Floating keeps move relative to the text.  Hence, they are good for
1449 things which will be referred to by name, such as ``See figure@w{ }3''.
1450 A floating keep will appear at the bottom of the current page if it will
1451 fit; otherwise, it will appear at the top of the next page.  Meanwhile,
1452 the surrounding text will `flow' around the keep, thus leaving now blank
1453 areas.
1455 @subsection Footnotes and annotations
1456 @cindex footnotes
1457 @cindex annotations
1459 There are a number of requests to save text for later printing.
1460 @dfn{Footnotes} are printed at the bottom of the current page.  Delayed
1461 text is intended to be a variant form of footnote; the text is printed
1462 only when explicitly called for, such as at the end of each chapter.
1464 @cindex delayed text
1465 @dfn{Delayed text} is very similar to a footnote except that it is
1466 printed when called for explicitly.  This allows a list of references to
1467 appear (for example) at the end of each chapter, as is the convention in
1468 some disciplines.
1470 Most macro packages which supply this functionality also supply a means
1471 of automatically numbering either type of annotation.
1473 @subsection Table of Contents
1474 @cindex table of contents
1475 @cindex contents, table of
1477 @dfn{Tables of contents} are a type of delayed text having a tag
1478 (usually the page number) attached to each entry after a row of dots.
1479 The table accumulates throughout the paper until printed, usually after
1480 the paper has ended.  Many macro packages will provide the ability to
1481 have several tables of contents (i.e.@: one standard one, one for
1482 tables, etc).
1484 @subsection Indices
1485 @cindex index
1487 While some macro packages will use the term @dfn{index}, none actually
1488 provide that functionality.  The facilities they call indices are
1489 actually more appropriate for tables of contents.
1491 @subsection Paper formats
1492 @cindex paper formats
1494 Some macro packages provide stock formats for various kinds of
1495 documents.  Many of them provide a common format for the title and
1496 opening pages of a technical paper.  The @code{-mm} macros in particular
1497 provide formats for letters and memoranda.
1499 @subsection Multiple Columns
1501 Some macro packages (except @code{-man}) provide the ability to have two
1502 or more columns on a page.
1504 @subsection Font and Size changes
1506 The builtin font and size functions are not always intuitive, so all
1507 macro packages provide macros to make these operations simpler.
1509 @subsection Predefined Strings
1511 Most macro packages provide various predefined strings for a variety of
1512 uses, examples are sub- and superscripts, printable dates, quotes and
1513 various special characters.
1515 @subsection Preprocessor Support
1517 All macro packages provide support for the various preprocessors.
1519 @subsection Configuration and Customization
1521 Some macro packages provide means of customizing many of details of how
1522 the package behaves.  This ranges from setting the default type size to
1523 changing the appearance of section headers.
1527 @node Macro Packages, Programming Tutorial, Tutorial for Macro Users, Top
1528 @chapter Macro Packages
1529 @cindex macro packages
1530 @cindex packages, macros
1532 This chapter documents the main macro packages that come with
1533 @code{groff}.
1535 @menu
1536 * -man::                        
1537 * -mdoc::                       
1538 * -ms::                         
1539 * -me::                         
1540 * -mm::                         
1541 @end menu
1544 @node -man, -mdoc, Macro Packages, Macro Packages
1545 @section -man
1546 @cindex @code{-man}
1548 @c XXX documentation
1551 @node -mdoc, -ms, -man, Macro Packages
1552 @section -mdoc
1553 @cindex @code{-mdoc}
1555 @c XXX documentation
1558 @node -ms, -me, -mdoc, Macro Packages
1559 @section -ms
1560 @cindex @code{-ms}
1562 @c XXX documentation
1565 @node -me, -mm, -ms, Macro Packages
1566 @section -me
1567 @cindex @code{-me}
1569 @c XXX documentation
1572 @node -mm,  , -me, Macro Packages
1573 @section -mm
1574 @cindex @code{-mm}
1576 @c XXX documentation
1580 @node Programming Tutorial, Preprocessors, Macro Packages, Top
1581 @chapter Programming Tutorial
1582 @cindex programming tutorial
1583 @cindex tutorial for programming
1585 This chapter covers @strong{all} of the facilities of @code{gtroff}.  If
1586 you are intending to use a macro package, you probably do not want to
1587 read this chapter.
1589 @menu
1590 * Text::                        
1591 * Input Conventions::           
1592 * Measurements::                
1593 * Expressions::                 
1594 * Identifiers::                 
1595 * Embedded Commands::           
1596 * Registers::                   
1597 * Manipulating Filling and Adjusting::  
1598 * Manipulating Hyphenation::    
1599 * Manipulating Spacing::        
1600 * Tabs and Fields::             
1601 * Character Translations::      
1602 * Line Layout::                 
1603 * Page Layout::                 
1604 * Page Control::                
1605 * Fonts::                       
1606 * Sizes::                       
1607 * Strings::                     
1608 * Conditionals and Loops::      
1609 * Writing Macros::              
1610 * Page Motions::                
1611 * Drawing Functions::           
1612 * Traps::                       
1613 * Diversions::                  
1614 * Environments::                
1615 * I/O::                         
1616 * Postprocessor Access::        
1617 * Miscellany::                  
1618 * Debugging::                   
1619 * Implementation Differences::  
1620 * Summary::                     
1621 @end menu
1624 @node Text, Input Conventions, Programming Tutorial, Programming Tutorial
1625 @section Text
1626 @cindex text
1628 @code{gtroff} input files contain text with control commands
1629 interspersed throughout.  But, even without control codes, @code{gtroff}
1630 will still do several things with your text: filling and adjusting,
1631 adding additional space after sentences, hyphenating and inserting
1632 implicit line breaks.
1634 @menu
1635 * Filling and Adjusting::       
1636 * Hyphenation::                 
1637 * Sentences::                   
1638 * Tab Stops::                   
1639 * Implicit Line Breaks::        
1640 @end menu
1642 @node Filling and Adjusting, Hyphenation, Text, Text
1643 @subsection Filling and Adjusting
1644 @cindex filling and adjusting
1645 @cindex adjusting and filling
1647 When @code{gtroff} reads in text it collects words from input and fits
1648 as many of them together on one output line as it can.  This is known as
1649 @dfn{filling}.
1651 Once @code{gtroff} has a @dfn{filled} line it will try to @dfn{adjust}
1652 it.  which means it will widen the spacing between words until the text
1653 reaches the right margin (in the default adjustment mode).  Extra spaces
1654 between words are preserved, but spaces at the end of lines are ignored.
1655 Spaces at the front of a line will cause a @dfn{break} (breaks will be
1656 explained in @ref{Implicit Line Breaks})
1658 @xref{Manipulating Filling and Adjusting}.
1660 @node Hyphenation, Sentences, Filling and Adjusting, Text
1661 @subsection Hyphenation
1662 @cindex hyphenation
1664 Since the odds of finding a set of words, for every output line, which
1665 will fit nicely on a line without inserting excessive amounts of space
1666 between words is not great, @code{gtroff} will hyphenate words so that
1667 lines can be justified without there being too much space between words.
1668 It uses an internal hyphenation algorithm, to indicate which words can
1669 be hyphenated and how to do so.  When a word is hyphenated the first
1670 part of the word will be added to the current filled line being output
1671 (with an attached hyphen), and the other portion will be added to the
1672 next line to be filled.
1674 @xref{Manipulating Hyphenation}.
1676 @node Sentences, Tab Stops, Hyphenation, Text
1677 @subsection Sentences
1678 @cindex sentences
1680 Although it is often debated, some typesetting rules say there should be
1681 different amounts of space after various puctuation marks.  For example,
1682 a period at the end of a sentence should have twice as much space
1683 following it as would a comma or a period as part of an abbreviation.
1685 @cindex sentence spaces
1686 @cindex spaces between sentences
1687 @cindex french-spacing
1688 @code{gtroff} does this by flagging certain characters (normally
1689 @samp{!}, @samp{?} and @samp{.}) as @dfn{end of sentence} characters.
1690 When @code{gtroff} encounters one of these characters at the end of a
1691 line it will append two @dfn{sentence spaces} in the formatted output.
1692 (Thus, one of the conventions mentioned in @ref{Input Conventions}).
1694 @c XXX also describe how characters like ) are treated here -jjc
1695 @c gotta do some research on this -trent
1697 @node Tab Stops, Implicit Line Breaks, Sentences, Text
1698 @subsection Tab Stops
1699 @cindex tab stops
1700 @cindex stops, tabulator
1702 @code{gtroff} translates @dfn{tabulator stops}, also called @dfn{tabs},
1703 in the input into movements to the next tab stop.  These tab stops are
1704 initially located every half inch across the page.  Using this you can
1705 make simple tables.  However, this can often be deceptive as the
1706 appearance (and width) of your text on a terminal and the results from
1707 @code{gtroff} can vary greatly.
1709 Also, a possible sticking point is that lines beginning with tab
1710 characters will still be filled, again producing unexpected results.
1711 For example, the following input
1713 @multitable {12345678} {12345678} {12345678} {12345678}
1714 @item
1715 @tab 1 @tab 2 @tab 3
1716 @item
1717 @tab   @tab 4 @tab 5
1718 @end multitable
1720 @noindent
1721 will produce
1723 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
1724 @item
1725 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
1726 @end multitable
1728 @xref{Tabs and Fields}.
1730 @node Implicit Line Breaks,  , Tab Stops, Text
1731 @subsection Implicit Line Breaks
1732 @cindex implicit line breaks
1733 @cindex implicit breaks of lines
1734 @cindex line, implicit breaks
1735 @cindex break
1736 @cindex break, implicit
1737 @cindex line break
1739 An important concept in @code{gtroff} is the @dfn{break}.  When a break
1740 occurs, @code{gtroff} will output the partially filled line
1741 (unadjusted), and resume collecting and filling text on the next output
1742 line.
1744 @cindex blank line
1745 @cindex empty line
1746 @cindex line, blank
1747 There are several ways to cause a break in @code{gtroff}.  A blank line
1748 will not only cause a break, but it will also cause a one line vertical
1749 space (effectively a blank line) to be output.
1751 A line which begins with a space will cause a break and the space will
1752 be output at the beginning of the next line.  Note that this space isn't
1753 adjusted, even in fill mode.
1755 The end of file will also cause a break (otherwise the last line of your
1756 document may vanish!)
1758 Certain requests also cause breaks, implicitly or explicity.  This will
1759 be discussed later.
1761 @xref{Manipulating Filling and Adjusting}.
1764 @node Input Conventions, Measurements, Text, Programming Tutorial
1765 @section Input Conventions
1766 @cindex input conventions
1767 @cindex conventions for input
1769 Since @code{gtroff} does filling automatically, it is traditional in
1770 @code{groff} not to try and type things in as nicely formatted
1771 paragraphs.  These are some conventions commonly used when typing
1772 @code{gtroff} text:
1774 @itemize @bullet{}
1775 @item
1776 Break lines after punctuation, particularily at the end of sentences,
1777 and in other logical places.  Keep separate phrases on lines by
1778 themselves, as entire phrases are often added or deleted when editing.
1779 @item
1780 Try to keep lines less than 40-60@w{ }characters, to allow space for
1781 inserting more text.
1782 @item
1783 Do not try to do any formatting in a WYSIWYG manner (i.e.@: don't try
1784 and use spaces to get proper indentation).
1785 @end itemize
1788 @node Measurements, Expressions, Input Conventions, Programming Tutorial
1789 @section Measurements
1790 @cindex measurements
1792 @cindex units of measurement
1793 @cindex basic units
1794 @cindex machine units
1795 @cindex measurement units
1796 @code{gtroff} (like any other programs) requires numeric parameters to
1797 specify various measurements.  Most numeric parameters@footnote{those
1798 that specify vertical or horizontal motion or a type size} may have a
1799 @dfn{measurement unit} attached.  These units are specified as a single
1800 character which immediately follows the number or expression.  Each of
1801 these units are understood, by @code{gtroff}, to be a multiple of its
1802 @dfn{basic unit}.  So, whenever a different measurement unit is
1803 specified @code{gtroff} converts this into its @dfn{basic units}.  This
1804 basic unit, represented by a @samp{u}, is a device dependent measurement
1805 which is quite small, ranging from 1/75th to 1/72000th of an inch; all
1806 other units are converted eventually to basic units.  The values may be
1807 given as fractional numbers---nevertheless, fractional basic units are
1808 always rounded to integers.
1810 Some of the measurement units are completely independent of any of the
1811 current settings (e.g.@: type size) of @code{gtroff}.
1813 @table @samp
1814 @item i
1815 @cindex inch
1816 @cindex @code{i} unit
1817 @cindex unit, @code{i}
1818 Inches.  An antiquated measurement unit still in use in certain
1819 backwards countries.  One inch is equal to 2.54@dmn{cm}.
1820 @item c
1821 @cindex centimeter
1822 @cindex @code{c} unit
1823 @cindex unit, @code{c}
1824 Centimeters.  One centimeter is equal to 0.3937@dmn{in}.
1825 @item p
1826 @cindex points
1827 @cindex @code{p} unit
1828 @cindex unit, @code{p}
1829 Points.  This is a typesetter's measurement used for measure type size.
1830 It is 72@w{ }points to an inch.
1831 @item P
1832 @cindex pica
1833 @cindex @code{P} unit
1834 @cindex unit, @code{P}
1835 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
1836 12@w{ }points to a pica).
1837 @item s
1838 @itemx z
1839 @cindex @code{s} unit
1840 @cindex unit, @code{s}
1841 @cindex @code{z} unit
1842 @cindex unit, @code{z}
1843 @xref{Fractional Type Sizes}, for a discussion of these units.
1844 @end table
1846 The other measurements understood by @code{gtroff} are dependent on
1847 settings currently in effect in @code{gtroff}.  These are very useful
1848 for specifying measurements which should look proper with any size of
1849 text.
1851 @table @samp
1852 @item m
1853 @cindex em unit
1854 @cindex @code{m} unit
1855 @cindex unit, @code{m}
1856 Ems.  This unit is equal to the current font size in points.  So called
1857 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
1858 in the current font.
1859 @item n
1860 @cindex en unit
1861 @cindex @code{n} unit
1862 @cindex unit, @code{n}
1863 Ens.  This is half of an em.
1864 @item v
1865 @cindex vertical space
1866 @cindex space, vertical
1867 @cindex @code{v} unit
1868 @cindex unit, @code{v}
1869 Vertical space.  This is equivalent to the current line spacing.
1870 @xref{Sizes}, for more information about this.
1871 @item M
1872 @cindex @code{M} unit
1873 @cindex unit, @code{M}
1874 100ths of an em.
1875 @end table
1877 @xref{Fractional Type Sizes}.
1879 @menu
1880 * Default Units::               
1881 @end menu
1883 @node Default Units,  , Measurements, Measurements
1884 @subsection Default Units
1885 @cindex default units
1886 @cindex units, default
1888 Many requests take a default unit.  While this can be helpful at times,
1889 it can cause strange errors in some expressions.  For example, the line
1890 length request expects em's.  Here are several attempts to get a line
1891 length of 3.5@w{ }inches and the results:
1893 @example
1894 3.5i      @result{}   3.5i
1895 7/2       @result{}   0i
1896 7/2i      @result{}   0i
1897 7i/2      @result{}   .1i
1898 7i/2u     @result{}   3.5i
1899 @end example
1901 @noindent
1902 As you can see, the safest way to specify measurements is to always
1903 attach a scaling indicator.
1906 @node Expressions, Identifiers, Measurements, Programming Tutorial
1907 @section Expressions
1908 @cindex expressions
1910 @code{gtroff} has most of operators common to other languages:
1912 @c XXX more details; examples
1914 @itemize @bullet
1915 @item
1916 @cindex arithmetic operators
1917 @cindex operators, arithmetic
1918 @findex +
1919 @findex -
1920 @findex /
1921 @findex *
1922 @findex %
1923 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
1924 (division), @samp{*} (multiplication), @samp{%} (modulo).
1925 @item
1926 @cindex comparison operators
1927 @cindex operators, comparison
1928 @findex <
1929 @findex >
1930 @findex >=
1931 @findex <=
1932 @findex =
1933 @findex ==
1934 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
1935 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
1936 (equal), @samp{==} (the same as @samp{=}).
1937 @item
1938 @cindex logical operators
1939 @cindex operators, logical
1940 @findex &
1941 @findex :
1942 Logical: @samp{&} (logical and), @samp{:} (logical or).
1943 @item
1944 @cindex unary operators
1945 @cindex operators, unary
1946 @findex -
1947 @findex +
1948 @findex !
1949 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
1950 (just for completeness; does nothing in expressions), @samp{!} (logical
1951 not).  See below for the use of unary operators in motion requests.
1952 @c XXX (if/while only??)
1953 @item
1954 @cindex extremum operators
1955 @cindex operators, extremum
1956 @findex >?
1957 @findex <?
1958 Extremum: @samp{>?} (maximum), @samp{<?} (minimum).  For example,
1959 @samp{5>?3} yields@w{ }@samp{5}.
1960 @c XXX add example
1961 @item
1962 @cindex scaling operator
1963 @cindex operator, scaling
1964 Scaling: @code{(@var{c};@var{e})}.  Evaluate @var{e} using @var{c} as
1965 the default scaling indicator.  If @var{c} is missing, ignore scaling
1966 indicators in the evaluation of @var{e}.
1967 @end itemize
1969 @cindex parentheses
1970 @findex (
1971 @findex )
1972 Parentheses may be used as in any other language.  However, in
1973 @code{gtroff} they are necessary to ensure order of evaluation.
1974 @code{gtroff} has no operator precedence; expressions are evaluated left
1975 to right.  This means that @samp{3+5*4} is evaluated as if it were
1976 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, like you may
1977 expect.
1979 @findex +
1980 @findex -
1981 @findex |
1982 @cindex motion operators
1983 @cindex operators, motion
1984 For many requests which cause a motion on the page, the unary operators
1985 work differently.  The @samp{+} and @samp{-} operators indicate a motion
1986 relative to the current position (down or up, respectively).  The
1987 @samp{|} operator indicates an absolute position on the page or input
1988 line.
1989 @c XXX (????)
1990 @samp{+} and @samp{-} are also treated differently by the @code{nr}
1991 request.
1992 @c XXX (?), add xref
1994 @cindex space characters in expressions
1995 @cindex expressions and space characters
1996 Due to the way arguments are parsed, spaces are not allowed in
1997 expressions, unless the entire expression is surrounded by parentheses.
1999 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
2002 @node Identifiers, Embedded Commands, Expressions, Programming Tutorial
2003 @section Identifiers
2004 @cindex identifiers
2006 @findex \
2007 @findex [
2008 @findex ]
2009 @findex ?
2010 Like any other language, @code{gtroff} has rules for properly formed
2011 @dfn{identifiers}.  In @code{gtroff} an identifier can be made up of
2012 almost any printable character.  The only exception are characters which
2013 are interpreted by @code{gtroff} (backslash, square brackets, and
2014 @samp{?}).  So, for example, any of the following is valid.
2016 @example
2020 end-list
2022 @end example
2024 @findex \A
2025 You can test whether an identifier is valid in @code{gtroff} with the
2026 @code{\A} escape.  It expands to@w{ }1 or@w{ }0 according to whether its
2027 argument (given in quotes) is or is not acceptable as the name of a
2028 string, macro, diversion, number register, environment, or font.  It
2029 will return@w{ }0 if no argument is given.  This is useful if you want
2030 to look up user input in some sort of associative table.
2032 @c XXX add xrefs above
2034 Identifiers in @code{gtroff} can be any length, but, in some contexts,
2035 @code{gtroff} needs to be told where identifiers end and text begins
2036 (and in different ways depending on their length).
2038 @findex (
2039 @findex [
2040 @findex ]
2041 @itemize @bullet{}
2042 @item
2043 Single character.
2044 @item
2045 Two characters.  Must be prefixed with @samp{(} in some situations.
2046 @item
2047 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
2048 and@w{ }@samp{]} in some situations.  Any length identifier can be put
2049 in brackets.
2050 @end itemize
2052 Unlike many other programming languages, undefined identifiers are
2053 silently ignored or expanded to nothing.
2055 @c XXX add info about -ww command line option.
2057 @xref{Interpolating Registers}, and @ref{Strings}.
2060 @node Embedded Commands, Registers, Identifiers, Programming Tutorial
2061 @section Embedded Commands
2062 @cindex embedded commands
2063 @cindex commands, embedded
2065 With most documents you need more funtionality beyond filling, adjusting
2066 and implicit line breaking.  In order to gain further functionality,
2067 @code{gtroff} allows commands to be embedded into your text, in two
2068 ways.
2070 The first is a @dfn{request} which takes up an entire line, and does
2071 some large scale operation (e.g.@: break lines, start new pages).
2073 The other is an @dfn{escape} which can be embedded anywhere in your
2074 text, or even as an argument to a request.
2075 @c XXX (Not always?)
2076 Escapes generally do more minor operations like sub- and superscripts,
2077 print a symbol, etc.
2079 @menu
2080 * Requests::                    
2081 * Macros::                      
2082 * Escapes::                     
2083 @end menu
2085 @node Requests, Macros, Embedded Commands, Embedded Commands
2086 @subsection Requests
2087 @cindex requests
2089 @cindex control character
2090 @cindex character, control
2091 @findex '
2092 @findex .
2093 A request line begins with a control character, which is either a single
2094 quote (@samp{'}) or a period (@samp{.}).  These can be changed;
2095 @xref{Character Translations}, for details.  After this there may be
2096 optional tabs or spaces followed by an identifier which is the name of
2097 the request.  This may be followed by any number of space separated
2098 arguments.
2100 @findex \&
2101 If you want to begin a line with a control character without it being
2102 interpreted, precede it with @samp{\&}.  This represents a zero width
2103 space, which means it will not affect your output.
2105 In most cases you will use the period as a control character.  Several
2106 requests will cause a break; using the single quote control character
2107 will prevent this.
2109 @menu
2110 * Request Arguments::           
2111 @end menu
2113 @node Request Arguments,  , Requests, Requests
2114 @subsubsection Request Arguments
2115 @cindex request arguments
2116 @cindex arguments to requests
2118 Argument to requests (and macros) are processed much like the shell:
2119 The line is split into arguments according to spaces.
2120 An argument which is intended to contain spaces can either be enclosed
2121 in quotes (single or double), or have the spaces @dfn{escaped} with
2122 backslashes.
2124 So, for example:
2126 @example
2127 .uh The Mouse Problem
2128 .uh "The Mouse Problem"
2129 .uh The\ Mouse\ Problem
2130 @end example
2132 The first line is the @code{.uh} macro being called with 3 arguments,
2133 @samp{The}, @samp{Mouse}, and @samp{Problem}.
2134 The latter two have the same effect or calling the @code{.uh} macro
2135 with one argument @samp{The Mouse Problem}.
2137 Note, however, that the @code{.ds} request works differently.
2139 @c distribute these through the text
2140 @xref{Strings}
2142 @node Macros, Escapes, Requests, Embedded Commands
2143 @subsection Macros
2144 @cindex macros
2146 Troff has a @dfn{macro} facility for defining a series of lines which
2147 can be invoked by name.
2148 They are called in the same manner as requests
2149 and arguments may be passed in the same manner.
2152 @c distribute these through the text
2153 @xref{Writing Macros}
2154 @c distribute these through the text
2155 @xref{Request Arguments}
2157 @node Escapes,  , Macros, Embedded Commands
2158 @subsection Escapes
2159 @cindex escapes
2161 @findex \e
2162 @findex \\
2163 Escapes may occur anywhere in the input to groff.
2164 They begin with a backslash and are followed by a single character
2165 which indicates the function to be performed.
2166 If you want to have a backslash appear in your document, you should
2167 use the escape sequence @code{\e}.  Merely escaping the backslash
2168 with another backslash will work in @emph{some} curcumstances.
2170 Many escapes have no parameters, those that do, do so in one of two
2171 ways.  For escapes which require an identifier there must be a way for
2172 groff to tell where the identifier ends and the text begins.
2173 It assumes that the next single character is the identifier, but if
2174 that character is an open parenthesis, it takes the next two
2175 characters as the identifier; and if the next character is an open
2176 bracket, all characters until a close bracket are taken as the
2177 identifier.  Note that in the second case there is no closing
2178 parenthesis.  For example:
2180 @example
2182 \n(XX
2183 \*[TeX]
2184 @end example
2186 Other escapes may require several arguments and/or some special
2187 format.  In these cases the @dfn{argument} is enclosed in single
2188 quotes (not required??) and the enclosing text is decoded according
2189 to what that escape expects.
2191 @example
2192 \l'1.5i\(bu'
2193 @end example
2195 @findex \\
2196 @findex \e
2197 @findex \E
2198 If you want to have a backslash appear in your output, you can use several
2199 escapes: @code{\\}, @code{\e} or @code{\E}.
2200 These are very similar, and only differ with respect to being used in
2201 macros or diversions (@xref{Copy-in Mode}, and @ref{Diversions}, for
2202 more information)
2206 @c distribute these through the text
2207 @xref{Identifiers}
2209 @menu
2210 * Comments::                    
2211 @end menu
2213 @node Comments,  , Escapes, Escapes
2214 @subsubsection Comments
2215 @cindex comments
2217 @findex \"
2218 Probably one of the most@footnote{Unfortunately, this is a lie.  But
2219 hopefully future troff hackers will believe it :-)}
2220 common forms of escapes is the comment.
2221 They begin with the @code{\"} escape and end at the end of the input
2222 line.
2224 This may sound simple, but it can be tricky to keep the comments from
2225 interfering with the apperarance of your final outupt.
2227 If the escape is to the right of some text or a request, that portion
2228 of the line will be ignored, but the space leading up to it will be
2229 noticed by groff.  This only affects the @code{.ds} request (any
2230 others?).
2232 One possibly irritating idiosyncracy is that you mustn't use tabs to
2233 line up your comments.
2234 Tabs are not treated as white space between request and macro
2235 arguments.
2237 If you have a comment on a line by itself, it will be treated as a
2238 blank line, because after eliminating the comment, that is all that
2239 remains.  So, it is common to start the line with @code{.\"} which
2240 will cause the line to be treated as an undefined request.
2242 Another commenting scheme seen sometimes is three consecutive single
2243 quotes (@code{'''}) at the begining of a line.  This works, but groff
2244 will give a warning about an undefined macro, which is harmless, but
2245 irritating.
2247 @findex \#
2248 Now to avoid all this groff has a new comment mechanism using the
2249 @code{\#} escape.  This escape works the same as @code{\"} except
2250 that the newline is also ignored.
2252 @findex ig
2253 For large blocks of text, the @code{ig} request may be useful.
2254 @c distribute these through the text
2255 @xref{Strings}
2258 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, Programming Tutorial
2259 @section Registers
2260 @cindex registers
2262 Registers are groff's numeric variables.  groff has a number of
2263 builtin registers, supplying anything from the date to details of
2264 formatting parameters.
2266 @c distribute these through the text
2267 @xref{Identifiers}
2269 @menu
2270 * Setting Registers::           
2271 * Interpolating Registers::     
2272 * Auto-increment::              
2273 * Assigning Formats::           
2274 * Builtin Registers::           
2275 @end menu
2277 @node Setting Registers, Interpolating Registers, Registers, Registers
2278 @subsection Setting Registers
2279 @cindex setting registers
2280 @cindex registers, setting
2282 @findex nr
2283 @findex \R
2284 Registers are defined/set via the @code{nr}
2285 request or the @code{\R} escape, for example, the following two lines
2286 are equivalent:
2288 @example
2289 .nr a 1
2290 \R'a 1'
2291 @end example
2293 @findex rr
2294 The @code{rr} request will
2295 remove the register specified by the argument.
2297 @findex rnn
2298 The @code{rnn} request will rename a number register.
2299 The format is @samp{.rnn @var{x} @var{y}}, which will
2300 rename number register  @var{x} to @var{y}.
2302 @findex aln
2303 Aliases can be created for a number register.  The format is
2304 @samp{.aln @var{xx} @var{yy}}, which will create an alias @var{xx} for
2305 number register object named @var{yy}.  The new name and the old name
2306 will be exactly equivalent.  If @var{yy} is undefined, a warning of
2307 type @samp{reg} will be generated, and the request will be ignored.
2308 @xref{Debugging}, for information about warnings.
2310 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
2311 @subsection Interpolating Registers
2312 @cindex interpolating registers
2313 @cindex registers, interpolating
2315 @findex \n
2316 Numeric registers are @dfn{interpolated} via the @code{\n} escape.
2317 @c the following is wrong.  Should I say any more than the above??
2318 @c This means that the value of the number register in expanded in-place
2319 @c on the input line before any other actions, i.e. before requests and
2320 @c escapes are interpreted.
2322 @example
2323 .nr as \na+\na
2324 \n(as
2325 @end example
2327 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
2328 @subsection Auto-increment
2329 @cindex auto-increment
2330 @cindex increment, automatic
2332 Number registers can also be auto incremented/decremented.  You can
2333 specify the increment/decrement factor with third argument to the
2334 @code{nr} request.  The default value is 0.  For example:
2336 @example
2337 .nr a 0 1
2338 .nr xx 0 5
2339 \n+a, \n+a, \n+a, \n+a, \n+a
2341 \n+(xx, \n+(xx, \n+(xx, \n+(xx, \n+(xx
2342 @end example
2344 Produces:
2346 @example
2347 1, 2, 3, 4, 5
2348 5, 10, 15, 20, 25
2349 @end example
2351 If you want to change the increment factor without changing the value
2352 of a register, the following can be used.
2354 @example
2355 .nr a \na 10
2356 @end example
2358 @node Assigning Formats, Builtin Registers, Auto-increment, Registers
2359 @subsection Assigning Formats
2360 @cindex assigning formats
2361 @cindex formats, assigning
2363 @findex af
2364 When a register is used in the text of an input file
2365 (as opposed to part of an expression)
2366 it is textually replaced (or interpolated) with a representation of
2367 that number.
2368 This output format can be changed to a variety of formats
2369 (numbers, roman numerals, etc)
2370 This is done using the @code{af} request.
2371 The first argument to @code{af} is the name of the number register to
2372 be changed,
2373 and the second argument is the output format.
2374 The following output formats are available:
2376 @table @samp
2377 @item 1
2378 This is the default format, decimal numbers:
2379 1, 2, 3, @dots{}
2380 @item 001
2381 Decimal numbers with as many leading zeros as specified.
2382 So, @samp{001} would result in 001, 002, 003, @dots{}
2383 @item I
2384 @cindex roman numerals
2385 @cindex numerals, roman
2386 Upper-case roman numerals:
2387 0, I, II, III, IV, @dots{}
2388 @item i
2389 Lower-case roman numerals:
2390 0, i, ii, iii, iv, @dots{}
2391 @item A
2392 Upper-case letters:
2393 A, B, C, @dots{}, Z, AA, AB, @dots{}
2394 @item a
2395 Lower-case letters:
2396 a, b, c, @dots{}, z, aa, ab, @dots{}
2397 @end table
2399 The following example will produce @samp{10, X, j, 010}.
2401 @example
2402 .nr a 10
2403 .af a 1           \" the default format
2404 \na,
2405 .af a I
2406 \na,
2407 .af a a
2408 \na,
2409 .af a 001
2411 @end example
2413 @findex \g
2414 The @code{\g} escape returns the current format of the specified
2415 register.  For example, @samp{\ga} after the following example would
2416 produce @samp{001}.
2418 @node Builtin Registers,  , Assigning Formats, Registers
2419 @subsection Builtin Registers
2420 @cindex builtin registers
2421 @cindex registers, builtin
2423 The following are some builtin registers, which are not listed
2424 elsewhere in this manual.  Any registers which begin with a @samp{.}
2425 are read-only.  A compleat listing of all builtin registers can be
2426 found in @ref{Register Index}.
2428 @table @code
2429 @item .H
2430 @vindex .H
2431 Horizontal resolution in basic units.
2432 @item .V
2433 @vindex .V
2434 Vertical resolution in basic units.
2435 @item dw
2436 @vindex dw
2437 Day of the week (1-7).
2438 @item dy
2439 @vindex dy
2440 Day of the year (1-31).
2441 @item mo
2442 @vindex mo
2443 Current month (1-12).
2444 @item year
2445 @vindex year
2446 The year.
2447 @item yr
2448 @vindex yr
2449 The year minus 1900.  Unfortunately, the Unix Version 7 troff
2450 documentation had a year 2000 bug: it incorrectly claimed that
2451 @samp{\n(yr} was the last two digits of the year.  That claim has never
2452 been true of either traditional troff or GNU troff.  If you see old
2453 troff input that looks like this:
2455 @example
2456 '\" (The following line stopped working after 1999.)
2457 This document was formatted in 19\n(yr.
2458 @end example
2460 you can correct it as follows:
2462 @example
2463 This document was formatted in \n[year].
2464 @end example
2466 or, if you want to be portable to older troff versions, as follows:
2468 @example
2469 .nr y4 1900+\n(yr
2470 This document was formatted in \n(y4.
2471 @end example
2473 @item .c
2474 @vindex .c
2475 @itemx c.
2476 @vindex c.
2477 The current @emph{input} line number.
2478 @item ln
2479 @vindex ln
2480 The current @emph{output} line number.
2481 @item .x
2482 @vindex .x
2483 The  major  version  number.  For example, if the version number is 1.03
2484 then @code{.x} will contain 1.
2485 @item .y
2486 @vindex .y
2487 The minor version number.  For example, if the version number is 1.03
2488 then @code{.y} will contain 03.
2489 @item .Y
2490 @vindex .Y
2491 The revision number of groff.
2492 @item .g
2493 @vindex .g
2494 Always 1.
2495 Macros should use this to determine whether they are running
2496 under GNU troff.
2497 @item .A
2498 @vindex .A
2499 If the current output device is @sc{ascii}, this is set to 1, zero
2500 otherwise.
2501 @item .P
2502 @vindex .P
2503 This register indicates whether the current page is actualy being
2504 printed, i.e. if the @samp{-o} option is being used to only print
2505 selected pages.
2506 @xref{Options}, for more information.
2507 @end table
2510 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, Programming Tutorial
2511 @section Manipulating Filling and Adjusting
2512 @cindex manipulating filling and adjusting
2513 @cindex filling and adjusting, manipulating
2514 @cindex adjusting and filling, manipulating
2516 @findex br
2517 @cindex break
2518 @cindex line break
2519 Several ways of causing @dfn{breaks} were given in
2520 @ref{Implicit Line Breaks}.
2521 The @code{br} request will likewise cause a break.
2522 Several other requests will also cause breaks, implicitly.
2523 They are
2524 @code{bp},
2525 @code{ce},
2526 @code{fi},
2527 @code{fl},
2528 @code{in},
2529 @code{nf},
2530 @code{sp} and
2531 @code{ti}.
2533 @findex nf
2534 @findex fi
2535 @vindex .u
2536 Initially, groff will fill and ajust text to both margins.
2537 Filling can be disabled via the @code{nf} request
2538 and re-enabled with the @code{fi} request.
2539 These implicitly disable and re-enable adjusting.
2540 Both of these will cause break in text currently being filled.
2541 The number register @code{.u} is equal to 1 in fill mode and 0 in
2542 no-fill mode.
2544 @findex ad
2545 @findex na
2546 @vindex .j
2547 Adjusting can be disabled with the @code{ad} request and re-enabled
2548 with the @code{na} request.
2549 The @code{ad} request takes a single argument to indicate how to
2550 adjust text.
2551 The current adjustment mode is available in the number register
2552 @code{.j}.
2554 @table @samp
2555 @item l
2556 @cindex ragged-right
2557 Adjust text to the left margin.  This produces what is traditionally
2558 called ragged-right text.
2559 @item r
2560 Adjust text to the right margin.
2561 @item c
2562 Center filled text.
2563 @item b
2564 @itemx n
2565 Justify to both margins.  This is groff's default.
2566 @end table
2568 With no argument to @code{ad}, troff will adjust lines the same way
2569 it was the last time it was filling.  For example:
2571 @example
2572 text
2573 .ad r
2574 text
2575 .ad c
2576 text
2578 text
2579 .ad  \" back to centering
2580 text
2581 @end example
2583 @findex \p
2584 The escape @code{\p} will cause a break and cause the remaining text
2585 to be adjusted.
2587 @findex ss
2588 The @code{ss} request allows you to change the minimum size of a
2589 space between filled words.
2590 This request takes it's units as one twelfth of the
2591 spacewidth parameter for the current font.  Initially both the word
2592 space size and the sentence space size are 12.
2594 When two arguments are given to the @code{ss} request, the second argument
2595 gives the sentence space size. If the second argument is not given, the
2596 sentence space size will be the same as the word space size.
2597 The sentence space size
2598 is used in two circumstances: if the end of a sentence occurs at the end
2599 of a line in fill mode, then both an inter-word space and a sentence
2600 space will be added; if two spaces follow the end of a sentence in the
2601 middle of a line, then the second space will be a sentence space. Note
2602 that the behaviour of @sc{Unix} troff will be exactly that exhibited by GNU
2603 troff if a second argument is never given to the @code{ss} request. In GNU
2604 troff, as in @sc{Unix} troff, you should always follow a sentence with either
2605 a newline or two spaces.
2607 @vindex .ss
2608 @vindex .sss
2609 The number registers @code{.ss} and @code{.sss} are
2610 the values of the parameters set by the first and second
2611 arguments of the @code{ss} request.
2613 @findex ce
2614 The @code{ce} request will center text.
2615 While the @samp{ad c} request will also center text, it has the side
2616 effect of filling the text.  The @code{.ce} request will not fill the
2617 text it affects.
2618 This request causes a break.
2620 With no arguments, @code{ce} will fill the next line of text.
2621 The single argument @code{ce} takes is a number indicating the
2622 number of lines to be centered.  With no argument centering is
2623 disabled.
2625 A common idiom is to turn on centering for a large number of lines,
2626 and then turn off centering when you are done with the centered text.
2627 This is useful for any request which takes a number of lines as an
2628 argument.
2630 @example
2631 .ce 1000
2632 replace this
2633 with
2634 something
2635 more interesting
2636 @dots{}
2637 .ce 0
2638 @end example
2640 @vindex .ce
2641 The @code{.ce} number register contains the number of lines remaining
2642 to be centered, as set by the @code{ce} request.
2645 @findex rj
2646 @vindex .rj
2647 A similar request is @code{rj} request which will justify unfilled
2648 text to the right margin.  Its arguments are identical to the
2649 @code{ce} request.
2650 The @code{.rj} number register is
2651 the number of lines to be right-justified as set by the @code{rj}
2652 request.
2655 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, Programming Tutorial
2656 @section Manipulating Hyphenation
2657 @cindex manipulating hyphenation
2658 @cindex hyphenation, manipulating
2660 As discussed in @ref{Hyphenation}, groff will hyphenate words.
2661 There are a number of ways to modify the how hyphenation is done.
2663 @findex nh
2664 @findex hy
2665 @vindex .hy
2666 This hyphenation can be turned off with the @code{nh} request, and
2667 turned back on with the @code{hy} request.  However, troff's
2668 hyphenation facilities are far more flexible than this.  The @code{hy}
2669 request can be used to tell troff to restrict hypenation to certain
2670 cases.  The request takes a single numeric argument.
2671 The current hyphenation restrictions can be found in the number
2672 register @code{.hy}
2674 @table @samp
2675 @item 1
2676 The default argument, which
2677 indicates to hyphenate without restrictions.
2678 @item 2
2679 Do not hyphenate the last word on a page or column.
2680 @item 4
2681 Do not hyphenate the last two characters of a word.
2682 @item 8
2683 Do not hyphenate the first two characters of a word.
2684 @end table
2686 @findex hlm
2687 @vindex .hlc
2688 @vindex .hlm
2689 The @code{hlm} request will
2690 set the maximum number of consecutive hyphenated lines to the value
2691 given as the first argument.
2692 If this number is
2693 negative, there is no maximum.  The default value is -1.
2694 This value is
2695 associated with the current environment.  Only lines output from an
2696 environment count towards the maximum associated with that environment.
2697 Hyphens resulting from @code{\%} are counted; explicit hyphens are not.
2698 The current setting of this is available in the @code{.hlm} request.
2699 Also the number of immediately preceding consecutive hyphenated lines
2700 are available in the number register @code{.hlc}.
2702 @findex hw
2703 The @code{hw} request allows you to specify how a specific word is
2704 to be hyphenated.  It takes only one argument which is the word with
2705 hyphens at the hyphenation points.  For example:
2706 @samp{.hw in-sa-lub-rious}.
2707 @c In old versions of troff there was a
2708 @c limited amount of space to store such information, fortunately,
2709 @c with groff, this is no longer a restriction.
2711 @findex \%
2712 @cindex hyphenation character
2713 @cindex character, hyphenation
2714 You can also tell troff how to hyphenate words on the fly with the
2715 use of the @code{\%} escape, also known as the @dfn{hyphenation
2716 character}.  Preceding a word with this character will prevent it
2717 from being hyphenated, putting it in a word will indicate to troff
2718 that the word may be hyphenated at that point.  Note that this
2719 mechanism will only affect one word, if you want to change the
2720 hyphenation of a word for the entire document, use the @code{hw}
2721 request.
2723 @findex hc
2724 The @code{hc} request allows you to change the hyphenation character.
2725 The character specified as an argument will then work the same as the
2726 @code{\%} escape, and, thus, no longer appear in the output.  Without
2727 an argument it will return the hyphenation character to @code{\%}.
2729 @findex hpf
2730 To further customize hyphenation the @code{hpf} request will read in
2731 a file of hyphenation patterns.
2732 This file will be searched for in the
2733 same way that @file{tmac.@var{name}} is searched for when the
2734 @samp{-m@var{name}} option is specified.
2736 It should have the same format as the argument to the
2737 \patterns primitive in @TeX{}; the letters appearing in this file are
2738 interpreted as hyphenation codes.
2739 A @samp{%} character in the patterns file
2740 introduces a comment that continues to the end of the line.
2742 @findex hla
2743 @findex hpf
2744 @pindex troffrc
2745 The set of
2746 hyphenation patterns is associated with the current language set by the
2747 @code{hla} request.  The @code{hpf} request is usually invoked by the
2748 @file{troffrc} file.
2750 @findex hcode
2751 @code{.hcode @var{c1 code1 c2 code2...}}
2752 Set the hyphenation code of character @var{c1} to code1 and that of
2753 @var{c2} to @var{code2}.
2754 A hyphenation code must be a single input character (not a
2755 special character) other than a digit or a space.  Initially each
2756 lower-case letter has a hyphenation code, which is itself, and each
2757 upper-case letter has a hyphenation code which is the lower case
2758 version of itself.
2760 @findex hym
2761 @vindex .hym
2762 The @code{hym} request will set the hyphenation margin to the value
2763 given as the first argument: when the current adjustment mode is not
2764 @samp{b}, the line will not be hyphenated if the line is no more than
2765 that amount short.
2766 The default hyphenation margin is 0.  The default scaling
2767 indicator for this request is m.  The hyphenation margin is associated
2768 with the current environment.  The current hyphenation margin is
2769 available in the @code{.hym} register.
2771 @findex hys
2772 @vindex .hys
2773 The @code{hys} request set the hyphenation space to the value given as
2774 the first argument: when the current adjustment mode is b, don't
2775 hyphenate the line if the line can be justified by adding no more than
2776 that amount of extra space to each word space.  The default
2777 hyphenation space is 0.  The default scaling indicator for this
2778 request is m.  The hyphenation space is associated with the current
2779 environment.  The current hyphenation space is available in the
2780 @code{.hys} register.
2782 @findex shc
2783 The @code{shc} request will set the soft hyphen character to the
2784 argument given as an argument.  If the argument is omitted, the soft
2785 hyphen character will be set to the default @code{\(hy}. The soft
2786 hyphen character is the character which will be inserted when a word
2787 is hyphenated at a line break.  If the soft hyphen character does not
2788 exist in the font of the character immediately preceding a potential
2789 break point, then the line will not be broken at that point.  Neither
2790 definitions (specified with the @code{char} request) nor translations
2791 (specified with the @code{tr} request) are considered when finding the soft
2792 hyphen character.
2794 @findex hla
2795 @vindex .hla
2796 @pindex troffrc
2797 The @code{hla} request will set the current hyphenation language to
2798 that given by the first argument.  Hyphenation exceptions specified
2799 with the @code{hw} request and hyphenation patterns specified with the
2800 @code{hpf} request are both associated with the current hyphenation
2801 language.  The @code{hla} request is usually invoked by the
2802 @file{troffrc} file.  The current hyphenation language is available
2803 in the number register @code{.hla}.
2806 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, Programming Tutorial
2807 @section Manipulating Spacing
2808 @cindex manipulating spacing
2809 @cindex spacing, manipulating
2811 @findex sp
2812 The @code{sp} request will cause troff to space downwards the
2813 distance specified as the first argument.  With no argument it will
2814 advance 1 line.
2815 A negative argument will cause troff to move up the page the
2816 specified distance.
2817 If the argument is preceded by a @samp{|} troff will move that
2818 distance from the top of the page.
2820 @findex ls
2821 @vindex .L
2822 Often you may want your output to be double or triple spaced.
2823 The @code{ls} request will cause troff to output @var{n}-1 blank
2824 lines after each line of text, where @var{n} is the argument given to
2825 the @code{ls} request.  With no argument troff will go back to single
2826 spacing.  The number register @code{.L} contains the current line
2827 spacing setting.
2829 @findex \x
2830 @vindex .a
2831 Sometimes, extra vertical spacing is only needed occasionaly,
2832 i.e. to allow space for a tall construct (like an equation).
2833 The @code{\x} escape will do this.
2834 The escape is given a numerical argument (like @samp{\x'3p'}).
2835 If this number is positive extra vertical space will be inserted
2836 below the current line.  A negative number will add space above.
2837 If this escape is used multiple times on the same line, the maximum
2838 values are used.
2839 The @code{.a} number register contains the most recent
2840 extra vertical @strong{emph} line space.
2842 @example
2843 ... example of inline equation ...
2844 @end example
2846 @findex ns
2847 @findex rs
2848 @cindex no-space mode
2849 @cindex mode, no-space
2850 Spacing (via either @code{sp} or via blank lines) can be disabled
2851 with the @code{ns} request.  This will enable @dfn{no-space mode}.
2852 This mode will end when actual text is output or the @code{rs}
2853 request is encountered.  No-space mode will also prevent requests to
2854 advance to the next page unless they are accompanied by a page number
2855 (@pxref{Page Control}, for more information.)
2858 @node Tabs and Fields, Character Translations, Manipulating Spacing, Programming Tutorial
2859 @section Tabs and Fields
2860 @cindex tabs and fields
2861 @cindex fields and tabs
2863 @findex \t
2864 Tab stops are much like those on a typewriter: a tab character (or the
2865 @code{\t} escape) on input will cause horizontal motion to the next
2866 tab stop.
2868 @findex ta
2869 Tab stops can be changed with the @code{ta} request.
2870 This request takes a series of numbers as arguments which indicate
2871 where each tab stop is to be (overriding any previous settings).
2872 These can be specified absolutely,
2873 i.e. as the distance from the left margin.
2874 For example, the following wil set tab stops every one inch.
2876 @example
2877 .ta 1i 2i 3i 4i 5i 6i
2878 @end example
2880 Tab stops can also be specified relatively (using a leading @samp{+})
2881 which means that the specified tab stop will be set that distance
2882 from the previous tab stop.  For example the following is equivalent
2883 to the previous example.
2885 @example
2886 .ta 1i +1i +1i +1i +1i +1i
2887 @end example
2889 After the specified tab stops repeat values may be set for tabs beyond
2890 the last one specified.  This is most commonly used to specify tabs
2891 set at equal intervals.  The compleat syntax for setting tabs is
2892 @code{ta @var{n1} @var{n2} @dots{} @var{nn} T @var{r1} @var{r2}
2893 @dots{} @var{rn}} This will set tabs at positions @var{n1}, @var{n2},
2894 @dots{}, @var{nn} and then set tabs at @var{nn}+@var{r1},
2895 @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn} and then at
2896 @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2}, @dots{},
2897 @var{nn}+@var{rn}+@var{rn}, and so on.  For example the following is,
2898 yet again, the same as the previous examples.
2900 @example
2901 .ta T 1i
2902 @end example
2904 The material in each tab column may be justified to the right or left
2905 or centered in the column.  This is specified by appending an
2906 @samp{R}, @samp{L} or @samp{C} to the number specifying that tab stop.
2907 The default justification is @samp{L}.
2909 @example
2910 .ta 1i 2iC 2iR
2911 @end example
2913 @vindex .tabs
2914 The number register @code{.tabs} contains
2915 a string representation of the current tab settings suitable for use as
2916 an argument to the @code{ta} request.
2918 @findex tc
2919 Normally troff will fill the space to the next tab stop with spaces.
2920 In some cases you may wish to change this.  The @code{tc} request
2921 will do this.  With no argument troff will revert to using spaces.
2923 @subsection Leaders
2924 @cindex leaders
2926 @findex lc
2927 Sometimes you may wish to use the @code{tc} request to fill a tab
2928 stop with a given character, but also, you want to use normal tab
2929 stops on the rest of the line.  For this groff provides an alternate
2930 tab mechanism, called @dfn{leaders} which will do just that.
2931 They are used exclusively to produce a repeated run of characters to
2932 the next tab stop.
2934 You can declare what character will be repeated with the @code{lc}
2935 request.  If you do not give it an argument, the leaders will act the
2936 same as tabs.
2938 @findex \a
2939 The difference is that a leader is invoked by using the @code{\a}
2940 escape.
2942 @cindex table of contents
2943 @cindex contents, table of
2944 So for a table of contents you may want to have tab stops defined so
2945 that the section number is one tab stop, the title is the second with
2946 the remaining space being filled with a line of dots and then the
2947 page number slightly separated from the dots.
2949 @example
2950 .lc .
2951 .ta .5iR 5i +.25i
2952 1.1\tFoo\a\t12
2953 @end example
2955 @subsection Fields
2956 @cindex fields
2958 @findex fc
2959 Fields are a more general way of laying out tabular data.
2960 @code{fc}
2962 @node Character Translations, Line Layout, Tabs and Fields, Programming Tutorial
2963 @section Character Translations
2964 @cindex character translations
2965 @cindex translations of characters
2967 @findex cc
2968 @findex c2
2969 The control character (@samp{.}) and the no-break control character
2970 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
2971 respectively.
2972 The single argument is the new character to be used, with no argument
2973 the normal control character is restored.
2975 @findex ec
2976 @findex eo
2977 The @code{eo} request will compleatly disable the escape mechanism.
2978 The @code{ec} request can be used to change the escape character from
2979 the default @samp{\} to what is specified as an argument.
2981 @findex tr
2982 The @code{tr} request will translate characters.
2984 @findex trnt
2985 @findex \!
2986 @code{trnt}
2987 This is the same as the @code{tr} request except that the
2988 translations do not
2989 apply to text that is transparently throughput into a diversion with
2990 @code{\!}.  @xref{Diversions}, for more information.
2991 For example,
2993 @example
2994 .tr ab
2995 .di x
2996 \!.tm a
2999 @end example
3001 will print @samp{b}; if @code{trnt} is used instead of @code{tr} it
3002 will print @samp{a}.
3005 @node Line Layout, Page Layout, Character Translations, Programming Tutorial
3006 @section Line Layout
3007 @cindex line layout
3008 @cindex layout, line
3010 @cindex dimensions, line
3011 @cindex line dimensions
3012 The following drawing shows the dimensions which troff uses for
3013 placing a line of output onto the page.  They are labeled with the
3014 request which manipulates that dimension.
3016 @example
3017 @group
3018               | -->| in |<--                   |
3019            -->| po |<-----------ll------------>|
3020               +----+----+----------------------+----+
3021               |    :    :                      :    |
3022               +----+----+----------------------+----+
3023 @end group
3024 @end example
3026 These dimensions are:
3028 @ftable @code
3029 @item po
3030 @vindex .o
3031 @dfn{Page offset}--This is the leftmost postition of text on the final
3032 output.  This can be adjusted with the @code{po} request, and the
3033 current setting can be found in the builtin number register @code{.o}
3034 Note, that this request does not cause a break, so changing the page
3035 offset in the middle of text being filled may not do what you expect.
3036 @item in
3037 @vindex .i
3038 @dfn{Indentation}--This is the distance from the left margin where text
3039 will be printed.  This can be adjusted with the @code{in} request, and
3040 the current setting can be found in the builtin number register.
3041 @code{.i}
3042 This request causes a break.
3044 @findex ti
3045 @findex .in
3046 There is also the request @code{ti} which will cause one output line
3047 to be indented, after which the indentation returns to 0.
3048 This request causes a break.
3049 The number register @code{.in} is the indent that applies to the
3050 current output line.
3051 @item ll
3052 @findex .l
3053 @findex .ll
3054 @dfn{Line length}--This is the distance from the left margin to right
3055 margin.  This can be adjusted with the @code{.ll} request, and the
3056 current setting can be found in the builtin number register @code{.l}
3057 Note, as the figure implies, line length is not affected by the current
3058 indentation.
3059 The number register @code{.ll} is
3060 the line length that applies to the current output line.
3061 @end ftable
3063 @example
3064 .in +.5i
3065 .ll -.5i
3066 A bunch of really boring text which should
3067 be indented from both margins.
3068 replace me with a better (and more) example!
3069 .in -.5i
3070 .ll +.5i
3071 @end example
3074 @node Page Layout, Page Control, Line Layout, Programming Tutorial
3075 @section Page Layout
3076 @cindex page layout
3077 @cindex layout, page
3079 Troff provides some very primitive operations for controlling page
3080 layout.
3082 @findex pl
3083 @vindex .p
3084 Troff lets you specify the @dfn{page length} via the @code{pl} request.
3085 This is the length of the physical output page.
3086 The current setting can
3087 be found in the builtin number register @code{.p}.  Note that this only
3088 specifies the size of the page, not the not the top and bottom margins.
3089 Those are not done by groff directly, @xref{Traps}, for further
3090 information on how to do this.
3092 @cindex headers
3093 @cindex footers
3094 @cindex titles
3095 Troff provides several operations which help in setting up top and
3096 bottom titles (or headers and footers)
3098 @findex tl
3099 The @code{tl} request will print a @dfn{title line}, which consists
3100 of three parts: a left justified portion, a centered portion and a
3101 right justified portion.  The argument to @code{tl} is specified as
3102 @code{'@var{left}'@var{center}'@var{right}'}
3103 The @samp{%} character is replaced with the current page number.
3105 @findex lt
3106 @vindex .lt
3107 The title line is printed using its own line length, which is
3108 specified with the @code{lt} request.  The current setting of this is
3109 available in the @code{.lt} number register.
3111 @findex pn
3112 The @code{pn} request will change the page number of the @emph{next}
3113 page.  The only argument is the page number.
3115 @vindex %
3116 @vindex .pn
3117 The current page number is stored in the number register @code{%}.
3118 The number register @code{.pn} contains the
3119 number of the next page:
3120 either the value set by a @code{pn} request, or
3121 the number of the current page plus 1.
3123 @findex pc
3124 The @code{pc} request will change the page number character (used by
3125 the @code{tl} request) to a different character.  With no argument,
3126 this mechanism is disabled.
3129 @c distribute these through the text
3130 @xref{Traps}
3133 @node Page Control, Fonts, Page Layout, Programming Tutorial
3134 @section Page Control
3135 @cindex page control
3136 @cindex control, page
3138 @findex bp
3139 To stop processing the current page, and move to the next page, you
3140 can invoke the @code{bp} request.  This request will also cause a
3141 break.  This request can also take an argument of what the next page
3142 should be numbered.
3143 The only difference
3144 between @code{bp} and @code{pn} is that @code{pn} does not cause a
3145 break or actually eject a page.
3147 @example
3148 .de newpage
3150 'sp .5i
3151 .tl 'left top'center top'right top'
3152 'sp .3i
3154 @end example
3156 @cindex orphan
3157 @findex ne
3158 Often you may want to make sure that you have a certain amount of
3159 space before a new page occurs.  This is most useful to make sure
3160 that there is not a single @dfn{orphan} line left at the bottom of a
3161 page.  The @code{ne} request will ensure that there is a certain
3162 distance, specified by the first argument, before the next page is
3163 triggered (@pxref{Traps}, for further information).
3164 The default unit for @code{ne} is v's and the default argument
3165 is 1v.
3167 For example, to make sure that no fewer than 2 lines get orphaned,
3168 you can do the following before each paragraph.
3170 @example
3171 .ne 2
3172 .ti +5n
3173 text
3174 @end example
3176 @findex sv
3177 @findex os
3178 The @code{sv} is similar to the @code{ne} request, it reserves the
3179 specified amount of vertical space.  If the desired amount of space
3180 exists before the next trap (bottom page boundary), the space will be
3181 output immediately.  If there is not enough space, it is stored for
3182 later output via the @code{os} request.
3183 The default argument is 1v and the default units are v's.
3186 @node Fonts, Sizes, Page Control, Programming Tutorial
3187 @section Fonts
3188 @cindex fonts
3190 @findex ft
3191 @findex \f
3192 Groff gives you the ability to switch fonts at any point in your
3193 text.  There are two ways to do this, via the @code{ft} request and
3194 the @code{\f} escape.
3196 Fonts are generaly specified as uppercase strings, which are usually
3197 1 to 4 characters representing an abreviation of acronym of the font
3198 name.
3200 The basic set of fonts are R, I, B, and BI.  These are Times Roman,
3201 Italic, Bold, and Bold Italic.  There is also at least one symbol
3202 font which contains various special symbols (greek, mathematics).
3203 These latter fonts cannot be used directly, but should be used via an
3204 escape.
3206 @menu
3207 * Changing Fonts::              
3208 * Font Families::               
3209 * Font Positions::              
3210 * Using Symbols::               
3211 * Artificial Fonts::            
3212 * Ligatures and Kerning::       
3213 @end menu
3215 @node Changing Fonts, Font Families, Fonts, Fonts
3216 @subsection Changing Fonts
3217 @cindex changing fonts
3218 @cindex fonts, changing
3220 @findex ft
3221 You can change fonts with both the @code{ft} request.
3222 With no arguments it
3223 will switch to the previous font (also known as P).
3225 @example
3226 eggs, bacon,
3227 .ft B
3228 spam
3230 and sausage.
3231 @end example
3233 @findex \f
3234 The @code{\f} escape is useful for changing fonts in the middle of words
3236 @example
3237 eggs, bacon, \fBspam\fP and sausage.
3238 @end example
3240 Both of the above examples will produce the same output.
3242 Sometimes when putting letters of different fonts, you need more or
3243 less space at such boundaries.  There are two escapes to help with
3244 this.
3246 @findex \/
3247 The @code{\/} escape
3248 increases the width of the preceding character so that the spacing
3249 between that character and the following character will be correct if
3250 the following character is a roman character.  For example, if an italic
3251 f is immediately followed by a roman right parenthesis,  then in many
3252 fonts the top right portion of the f will overlap the top left of the
3253 right parenthesis.
3254 It is a good idea to use this escape sequence
3255 whenever an italic character is immediately followed by a roman
3256 character without any intervening space.
3258 @c producing @i{f}), which is ugly.  Inserting \/ produces f) and avoids this problem.
3260 @findex \,
3261 The @code{\,} escape
3262 modifies the spacing of the following character so that the spacing
3263 between that character and the preceding character will correct if the
3264 preceding character is a roman character.
3265 It is a good idea
3266 to use this escape sequence whenever a roman character is immediately
3267 followed by an italic character without any intervening space.
3269 @c For example, inserting \, between the parenthesis and the f changes (f to (f.
3271 @findex ftr
3272 The @code{ftr} request will translate fonts, it is called as
3273 @samp{.ftr @var{F G}}, which
3274 Translate font @var{F} to @var{G}.
3275 Whenever a font named @var{F} is referred to in @code{\f}
3276 escape sequence,
3277 or in the @code{ft}, @var{ul}, @var{bd}, @var{cs}, @var{tkf},
3278 @var{special}, @var{fspecial}, @var{fp},
3279 or @var{sty} requests, font @var{G} will be used.  If @var{G} is
3280 missing, or equal to @var{F} then font @var{F} will not be translated.
3283 @node Font Families, Font Positions, Changing Fonts, Fonts
3284 @subsection Font Families
3285 @cindex font families
3286 @cindex families, font
3288 Due to the variety of fonts available, groff has added the concept of
3289 font families.  Each of these families has four styles (R, I, B and BI),
3291 The fonts are specified as the concatenation of the font family and
3292 style.  Specifying a font without the family part will cause groff to
3293 use that style of the current family.
3294 By default, groff uses the Times family.
3296 This way, you can just use the basic four fonts and select a
3297 different font family on the command line.
3299 @findex fam
3300 @vindex .fam
3301 You can also switch font families with the @code{fam} request
3302 The current font family is available in the number register
3303 @code{.fam}.
3304 This is a string-valued register.
3306 @example
3307 spam,
3308 .fam H
3309 spam,
3310 .ft B
3311 spam,
3312 .fam T
3313 spam,
3314 .ft AR
3315 baked beans,
3316 .ft R
3317 and spam.
3318 @end example
3320 @node Font Positions, Using Symbols, Font Families, Fonts
3321 @subsection Font Positions
3322 @cindex font positions
3323 @cindex positions, font
3325 For the sake of old phototypesetters and compatability with old
3326 versions of troff, groff has the concept of font
3327 @dfn{positions}, on which various fonts are mounted.
3328 The last one or two are reserved for the symbol font(s).
3330 @findex fp
3331 New fonts can be mounted with the @code{fp} request.
3332 These numeric positions can then be referred to with font changing commands.
3333 When groff starts it is using font number one.
3335 @example
3336 .fp 1 H
3337 .fp 2 HI
3338 .fp 3 HB
3339 wink, wink,
3340 .ft 2
3341 nudge, nudge,
3343 .ft 3
3344 say no more!
3346 @end example
3348 (note that after these font changes have taken place the original
3349 font is restored.)
3351 @vindex .f
3352 The current font in use, as a font position.
3353 This can be useful to remember the current font, for later recall.
3355 @example
3356 .nr save-font \n(.f
3357 ... lots 'o text ...
3358 .ft \n[save-font]
3359 @end example
3361 @vindex .fp
3362 The number of the next free font position is available in the number
3363 register @code{.fp}.  This is useful when mounting a new font, like so:
3365 @example
3366 .fp \n[.fp] NEATOFONT
3367 @end example
3369 @pindex DESC
3370 Fonts not listed in the @file{DESC} file are automatically mounted on
3371 the next available font position when they are referenced.
3372 If a font is to be
3373 mountfed explicitly with the @code{fp} request on an unused font position, it
3374 should be mounted on the first unused font position, which can be found
3375 in the @code{.fp} register; although troff does not enforce this strictly,
3376 it will not allow a font to be mounted at a position whose number is
3377 much greater than that of any currently used position.
3379 The @code{fp} request has an optional third argument.
3380 This argument gives the
3381 external name of the font, which is used for finding the font
3382 description file.  The second argument gives the internal name of the
3383 font which is used to refer to the font in troff after it has been
3384 mounted.  If there is no third argument then the internal name will be
3385 used as the external name.  This feature allows you to use fonts with
3386 long names in compatibility mode.
3388 @node Using Symbols, Artificial Fonts, Font Positions, Fonts
3389 @subsection Using Symbols
3390 @cindex using symbols
3391 @cindex symbols, using
3393 @findex \(
3394 @findex \[
3395 Symbols can be inserted by using a special escape sequence.
3396 This escape is simply the escape character (a backslash) followed by
3397 an identifier.  The symbol identifiers have to be two or more
3398 characters, since single characters conflict with all the other
3399 escapes.  The identifier can be either preceded by a parenthesis if
3400 it is two character, or surrounded by square brackets.
3401 So, the symbol for pi can be produced either by @code{\(*p} or
3402 @code{\[*p]}.
3404 @example
3405 area = \(*p\fIr\fP\u2\d
3406 @end example
3408 @findex \C
3409 The escape @code{\C'@var{xxx}'} will typeset character named
3410 @var{xxx}.  Normally it is more convenient to use @code{\[@var{xxx}]}.
3411 But @code{\C} has the advantage that it is compatible with recent
3412 versions of ditroff and is available in compatibility mode.
3414 @findex \N
3415 The escape @code{\N'@var{n}'} will typeset the character with code
3416 @var{n} in the current font.  @var{n} can be any integer.  Most devices only
3417 have characters with codes between 0 and 255.  If the current font
3418 does not contain a character with that code, special fonts will not be
3419 searched.  The @code{\N} escape sequence can be conveniently used on
3420 conjunction with the @code{char} request:
3422 @example
3423 .char \[phone] \f(ZD\N'37'
3424 @end example
3426 The code of each character is given in the fourth column in the font
3427 description file after the charset command.  It is possible to include
3428 unnamed characters in the font description file by using a name of
3429 @samp{---}; the @code{\N} escape sequence is the only way to use these.
3431 @findex cflags
3432 Each character has certain properties associated with it.
3433 These properties can be modified with the @code{cflags} request.
3434 The first argument is the the sum of the desired flags and the
3435 remaining arguments are the characters to have those properties.
3436 @table @code
3437 @item 1
3438 the character ends sentences (initially characters @samp{.?!} have this
3439 property);
3440 @item 2
3441 lines can be broken before the character (initially no characters have
3442 this property);
3443 @item 4
3444 lines can be broken after the character (initially characters
3445 @samp{-\(hy\(em} have this property);
3446 @item 8
3447 the character overlaps horizontally (initially characters
3448 @samp{\(ul\(rn\(ru} have this property);
3449 @item 16
3450 the character overlaps vertically (initially character @samp{\(br} has
3451 this property);
3452 @item 32
3453 an end of sentence character followed by any number of characters with
3454 this property will be treated as the end of a sentence if followed by a
3455 newline or two spaces; in other words the character is transparent for
3456 the purposes of end of sentence recognition; this is the same as having
3457 a zero space factor in @TeX{} (initially characters
3458 @samp{"')]*\(dg\(rq} have this property).
3459 @end table
3461 @findex char
3462 You can create new characters with the @code{char} request.  It is
3463 called as @samp{.char @var{c} @var{string}} Define character @var{c}
3464 to be @var{string}. Every time character @var{c} needs to be printed,
3465 @var{string} will be processed in a temporary environment and the
3466 result will be wrapped up into a single object.  Compatibility mode
3467 will be turned off and the escape character will be set to \ while
3468 @var{string} is being processed.  Any emboldening, constant spacing or
3469 track kerning will be applied to this object rather than to individual
3470 characters in @var{string}.  A character defined by this request can
3471 be used just like a normal character provided by the output device.
3472 In particular other characters can be translated to it with the
3473 @code{tr} request; it can be made the leader character by the
3474 @code{lc} request; repeated patterns can be drawn with the character
3475 using the @code{\l} and @code{\L} escape sequences;  words containing
3476 the character can be hyphenated correctly, if the @code{hcode} request
3477 is used to give the character a hyphenation code. There is a special
3478 anti-recursion feature: use of character within the character's
3479 definition will be handled like normal characters not defined with
3480 @code{char}.
3482 @findex rchar
3483 A character definition can be removed with the @code{rchar} request.  Its
3484 arguments are the characters to be removed.  This undoes the effect of
3485 a @code{char} request.
3487 @c distribute these through the text
3488 @xref{Special Characters}
3490 @node Artificial Fonts, Ligatures and Kerning, Using Symbols, Fonts
3491 @subsection Artificial Fonts
3492 @cindex artificial fonts
3493 @cindex fonts, artificial
3495 There are a number of requests for artificially creating fonts.
3496 These are largely vestigal remains from the days when output devices
3497 did not have a wide variety of fonts, and when nroff and troff were
3498 separate programs.
3499 These are no longer necessary in GNU Troff.
3501 @findex ul
3502 The @code{ul} request will print subsequent lines in italics on a device
3503 capable of it, or underline the text on an character output device.  The
3504 single argument is the number of lines to be ``underlined,'' with no
3505 argument, the next line will be underlined.
3507 @findex cu
3508 The @code{cu} request is similar to @code{ul} ...
3510 @findex uf
3511 The @code{uf} request will set the underline font used by @code{ul}
3512 and @code{cu}.
3514 @findex bd
3515 The @code{bd} request artificially creates a bold font by printing
3516 each character twice, slightly offset.
3517 The first argument specifies the font to embolden, and the second is
3518 the number of basic units, minus one, by which the two characters
3519 will be offset.  If the second argument is missing, emboldening will
3520 be turned off.
3522 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
3523 @subsection Ligatures and Kerning
3524 @cindex ligatures and kerning
3525 @cindex kerning and ligatures
3527 @findex lg
3528 @vindex .lg
3529 @code{lg}
3530 @code{.lg}
3531 The current ligature mode.
3533 What is kerning??
3535 If the font description file contains pairwise kerning information,
3536 characters from that font will be kerned.  Kerning between two
3537 characters can be inhibited by placing a @code{\&} between them.
3539 @findex kern
3540 @vindex .kern
3541 @code{kern}
3542 If n is non-zero or missing, enable pairwise kerning, otherwise disable
3544 @code{.kern}
3545 1 if pairwise kerning is enabled, 0 otherwise.
3547 @findex tkf
3548 .tkf f s1 n1 s2 n2
3549 Enable track kerning for font f.  When the current font is f the width
3550 of every character will be increased by an amount between n1 and n2;
3551 when the current point size is less than or equal to s1 the width will
3552 be increased by n1; when it is greater than or equal to s2 the width
3553 will be increased by n2; when the point size is greater than or equal to
3554 s1 and less than or equal to s2 the increase in width is a linear
3555 function of the point size.
3558 @node Sizes, Strings, Fonts, Programming Tutorial
3559 @section Sizes
3560 @cindex sizes
3562 @cindex baseline
3563 Groff uses two dimensions with each line of text, type size and
3564 vertical spacing.  The type size is the height from the text
3565 @dfn{baseline} to the top of the tallest character (decenders may drop
3566 below this baseline).  Vertical spacing is the amount of space groff
3567 allows for a line of text, normally, this is about 20% larger than the
3568 current type size.  Ratios smaller than this can result in
3569 hard-to-read text, larger that this, it will spread your text out more
3570 vertically (useful for term papers).  By default, troff uses 10 point
3571 type on 12 point spacing.
3573 @cindex leading
3574 The difference between type size and vertical spacing is known, by
3575 typesetters, as @dfn{leading}.
3577 @menu
3578 * Changing Type Sizes::         
3579 * Fractional Type Sizes::       
3580 @end menu
3582 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
3583 @subsection Changing Type Sizes
3584 @cindex changing type sizes
3585 @cindex type sizes, changing
3587 @findex ps
3588 @findex vs
3589 @findex \s
3590 @vindex .s
3591 @vindex .v
3592 Using the @code{ps} request and the @code{\s} escape you can change
3593 the type size.  The @code{vs} request will change the vertical
3594 spacing. The default unit for the @code{ps} and @code{vs} requests are
3595 points.
3596 The number registers @code{.s} and @code{.v} contain the current
3597 type size and vertical spacing.
3599 These requests take parameters in units of points.  You can specify
3600 sizes as an absolute size, or as a relative change from the current
3601 size.  The size 0 means go back to the previous size.  With no
3602 argument it will revert to the previous size.
3604 @example
3605 snap, snap,
3606 .ps +2
3607 grin, grin,
3608 .ps +2
3609 wink, wink, \s+2nudge, nudge,\s+8 say no more!
3610 .ps 10
3611 @end example
3613 The @code{\s} escape may be called in a variety of ways.
3614 Much like other escapes there must be a way to determine where the
3615 argument ends and the text begins.
3616 Any of the following forms are valid:
3617 @code{\s@var{n}},
3618 @code{\s+@var{n}},
3619 @code{\s-@var{n}},
3620 @code{\s(@var{nn}},
3621 @code{\s+(@var{nn}},
3622 @code{\s-(@var{nn}},
3623 @code{\s[+@var{nnn}]},
3624 @code{\s[-@var{nnn}]},
3625 @code{\s+[@var{nnn}]},
3626 @code{\s-[@var{nnn}]}.
3628 Some devices may only have certain permissible sizes, in which case
3629 groff will round to the nearest permissible size.
3631 @example
3632 ... .sz macro example?? ...
3633 @end example
3635 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
3636 @subsection Fractional Type Sizes
3637 @cindex fractional type sizes
3638 @cindex type sizes, fractional
3640 @cindex @code{s} unit
3641 @cindex unit, @code{s}
3642 @cindex @code{z} unit
3643 @cindex unit, @code{z}
3644 A @dfn{scaled point} is equal to 1/@var{sizescale} points, where
3645 @var{sizescale} is specified in the @file{DESC} file (1 by default.)
3646 There is a new scale indicator @samp{z} which has the effect of
3647 multiplying by @var{sizescale}.  Requests and escape sequences in
3648 troff interpret arguments that represent a pointsize as being in units
3649 of scaled points, but they evaluate each such argument using a default
3650 scale indicator of @samp{z}.  Arguments treated in this way are the
3651 argument to the @code{ps} request, the third argument to the @code{cs}
3652 request, the second and fourth arguments to the @code{tkf} request,
3653 the argument to the @code{\H} escape sequence, and those variants of
3654 the @code{\s} escape sequence that take a numeric expression as their
3655 argument.
3657 For example, suppose @var{sizescale} is 1000; then a scaled point will be
3658 equivalent to a millipoint; the request @samp{.ps 10.25} is equivalent to
3659 @samp{.ps 10.25z} and so sets the pointsize to 10250 scaled points, which is
3660 equal to 10.25 points.
3662 The number register @code{\n(.s} returns the pointsize in points as
3663 decimal fraction.  There is also a new number register @code{\n[.ps]}
3664 that returns the pointsize in scaled points.
3666 It would make no sense to use the @samp{z} scale indicator in a
3667 numeric expression whose default scale indicator was neither @samp{u}
3668 nor @samp{z}, and so troff disallows this.  Similarily it would make
3669 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
3670 numeric expression whose default scale indicator was @samp{z}, and so
3671 troff disallows this as well.
3673 There is also new scale indicator @samp{s} which multiplies by the
3674 number of units in a scaled point.  So, for example, @samp{\n[.ps]s}
3675 is equal to 1m.  Be sure not to confuse the @samp{s} and @samp{z}
3676 scale indicators.
3678 @code{\s'+@var{n}'}
3679 @code{\s'-@var{n}'}
3680 @code{\s+'@var{n}'}
3681 @code{\s-'@var{n}'}
3682 Set the point size to @var{n} scaled points; @var{n} is a numeric
3683 expression with a default scale indicator of @samp{z}.
3685 @code{\n[.ps]}
3686 The current pointsize in scaled points.
3688 @code{\n[.psr]}
3689 The last-requested pointsize in scaled points.
3691 @code{\n[.sr]}
3692 The last requested pointsize in points as a decimal fraction.  This is a
3693 string-valued register.
3696 @c distribute these through the text
3697 @xref{Font Files}
3700 @node Strings, Conditionals and Loops, Sizes, Programming Tutorial
3701 @section Strings
3702 @cindex strings
3704 @findex ds
3705 Groff has string variables, which are entirely for user convenience
3706 (i.e. there are no builtin strings).  They are defined via the
3707 @code{ds} request.
3709 @example
3710 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
3711 @end example
3713 @findex \*
3714 They are interpolated, or expanded in-place, via the @code{\*} escape:
3716 @example
3717 The \*(UX Operating System
3718 @end example
3720 Will produce:
3722 @example
3723 The UNIXtm Operating System
3724 @end example
3726 If the string named by the @code{\*} does not exist, the escape will
3727 be replaced by nothing.
3729 @cindex comments, with @code{ds}
3730 NOTE:  Unlike other requests the third argument takes up the entire
3731 line including trailing spaces.  This means that comments on a line
3732 with such a request can introduce unwanted space into a string.
3734 @example
3735 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" trademark of you-know-who
3736 @end example
3738 Instead you should either put the comment on another line or
3739 have the comment escape adjacent with the end of the string.
3741 @example
3742 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  trademark of you-know-who
3743 @end example
3745 If you need leading space you can start the string with a double
3746 quote.  No trailing quote is needed, in fact any trailing quote is
3747 included in your string.
3749 @cindex canibalism
3750 @example
3751 .ds sign "           Yours in a white wine sauce,
3752 @end example
3754 @findex as
3755 @cindex appending to strings
3756 @cindex strings, appending
3757 You can also append onto a string with the @code{as} request.
3758 It works the same as the @code{ds} request except that it appends the
3759 second argument onto the string named by the first argument.
3761 @example
3762 .as sign " with shallots, onions and garlic,
3763 @end example
3765 @findex \@key{ret}
3766 Strings are not limited to a sigle line of text.  A string can span
3767 several lines by escaping the newlines with a backslash.  The
3768 resulting string will be stored @emph{without} the newlines.
3770 @example
3771 .ds foo lots and lots \
3772 of text are on these \
3773 next several lines
3774 @end example
3776 @findex substring
3777 @cindex substrings
3778 @code{.substring xx n1 [n2]}
3779 Replace the string in register@w{ }xx with the substring defined by the
3780 indices n1 and@w{ }n2.  The first character in the string has index one.
3781 If n2 is omitted, it is taken to be equal to the string's length.  If
3782 the index value n1 or n2 is negative or zero, it will be counted from
3783 the end of the string, going backwards: The last character has index@w{
3784 }0, the character before the last character has index@w{ }-1, etc.
3786 @findex length
3787 @cindex length of a string
3788 @cindex string, length of
3789 @code{.length xx string}
3790 Compute the length of string and return it in the number register@w{ }xx
3791 (which is not necessarily defined before).
3793 @findex rn
3794 @code{rn}
3796 @findex rm
3797 @code{rm}
3799 @findex als
3800 @code{als}
3802 @findex chop
3803 @code{chop}
3805 @c distribute these through the text
3806 @xref{Identifiers}
3807 @c distribute these through the text
3808 @xref{Comments}
3811 @node Conditionals and Loops, Writing Macros, Strings, Programming Tutorial
3812 @section Conditionals and Loops
3813 @cindex conditionals and loops
3814 @cindex loops and conditionals
3816 @findex if
3817 @findex while
3818 In @code{if} and @code{while} requests, there are several more operators
3819 available:
3821 @table @code
3822 @item e
3823 @itemx o
3824 True if the current page is even or odd numbered (respectively)
3825 @item n
3826 @itemx t
3827 True if the document is being processed by
3828 nroff (or a character device) or troff.
3829 @item '@var{xxx}'@var{yyy}'
3830 True if the string @var{xxx} is equal to the string @var{yyy}.
3831 Other characters can be used in place of the single quotes.
3832 (Which?)
3833 The strings are `formatted' before being compared. (?)
3834 @item r@var{xxx}
3835 True if there is a number register named @var{xxx}.
3836 @item d@var{xxx}
3837 True if there is a string, macro, diversion, or request named @var{xxx}.
3838 @item c@var{ch}
3839 True if there is a character @var{ch} available;  @var{ch} is
3840 either an @sc{ascii} character or a special character @code{\(@var{ch}} or
3841 @code{\[@var{ch}]}; the condition will also be true if @var{ch} has been
3842 defined by the @code{char} request.
3843 @end table
3845 @menu
3846 * if-else::                     
3847 * while::                       
3848 @end menu
3850 @node if-else, while, Conditionals and Loops, Conditionals and Loops
3851 @subsection if-else
3852 @cindex if-else
3854 Troff has if-then-else constructs like other languages, although
3855 the formatting can be painful.
3857 @findex if
3858 The @code{if} request is troff's if statement, it is called as
3859 @samp{.if @var{expr} @var{anything}}, where @var{expr} is the
3860 expression to be evaluated,
3861 and @var{anything} (the remainder of the line)
3862 which will be executed if
3863 the @var{expr} evaluates to non-zero (true).
3864 @var{anything} will be interpreted as though it was on a line by
3865 itself.
3866 @xref{Expressions}, for more info.
3868 Here are some examples:
3870 @example
3871 .if t .ls 2                             \" double spacing in troff
3872 .if 0 .ab how'd this happen??
3873 @end example
3875 @findex ie
3876 @findex el
3877 An if-then-else is written using two requests @code{ie} and @code{el}
3878 the first request is the if part and the latter is the else part.
3880 @example
3883 @end example
3885 @findex \@{
3886 @findex \@}
3887 In many cases you will want more than one request to be executed as a
3888 result of any of these requests, this can be done using the \@{ and
3889 \@} escapes.
3890 The following example shows the possible ways to use these escapes.
3892 @example
3893 .ie t \@{\
3894 .    ds lq ``
3895 .    ds rq ''
3896 .\@}
3897 .el \
3898 .\@{\
3899 .    ds lq "
3900 .    ds rq "\@}
3901 .ds qq "
3902 @end example
3905 @c distribute these through the text
3906 @xref{Expressions}
3908 @node while,  , if-else, Conditionals and Loops
3909 @subsection while
3910 @cindex while
3912 @findex while
3913 Groff provides a looping construct using the @code{while} request,
3914 which is used much like the @code{if} (and related) requests.
3915 The first argument is an expression which will be evaluated.
3916 The @code{while} request will interpret the remainder of the line
3917 until the expression evaluates to 0 or false.
3919 @example
3920 .nr a 0 1
3921 .while (\na<9) \&\n+a,
3922 \&\n+a
3923 @end example
3925 The preceding example produces:
3927 @example
3928 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
3929 @end example
3931 @findex break
3932 @findex continue
3933 The @code{break} request will
3934 @dfn{break} out of a while loop.
3935 Be sure not to confuse this with the @code{.br} request.
3936 The @code{continue} request will
3937 finish the current iteration of a while loop.
3939 @c distribute these through the text
3940 @xref{Expressions}
3943 @node Writing Macros, Page Motions, Conditionals and Loops, Programming Tutorial
3944 @section Writing Macros
3945 @cindex writing macros
3946 @cindex macros, writing
3948 @findex de
3949 A macro is a collection of text and embedded commands which can be
3950 invoked multiple times.  Macros are used for defining common operations.
3951 Macros are defined using the @code{de} request.  This request takes
3952 a name for the macro as the first argument.  Subsequent lines are
3953 copied into an internal buffer until the line @code{..} is
3954 encountered.  The optional second argument to @code{de} can change
3955 this ending token.
3957 For example, suppose at the beginning of each paragraph, you want
3958 cause a break, move down a partial line and indent the first line.
3959 Such a macro could be defined as follows:
3961 @example
3962 .de P
3964 .sp .8v
3966 @end example
3968 @findex am
3969 The @code{am} request works similarily to @code{de} except it appends
3970 onto the macro named by the first argument.  So, if we decide we want
3971 our previously @code{P} macro to actually do indented instead of
3972 block paragraphs we can add the necessary code to our existing macro.
3974 @example
3975 .am P
3976 .ti +5n
3978 @end example
3980 @findex als
3981 @cindex aliases, macro
3982 @cindex macro aliases
3983 Macros can be aliased with the @code{als} request.
3985 @findex rn
3986 @code{rn}
3988 @findex rm
3989 @code{rm}
3991 @findex chop
3992 @code{chop}
3994 @menu
3995 * Copy-in Mode::                
3996 * Parameters::                  
3997 @end menu
3999 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
4000 @subsection Copy-in Mode
4001 @cindex copy-in mode
4002 @cindex mode, copy-in
4004 @findex \n
4005 @findex \$
4006 @findex \*
4007 @findex \\
4008 @findex \@key{RET}
4009 When troff reads in the test for a macro or diversion it copies the
4010 text (including request lines) into an internal buffer, except for
4011 escapes.  Escapes will be converted into an internal form, except for
4012 @code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}} which
4013 are evaluated and inserted into the text where the escape was located.
4014 This is known as @dfn{copy-in} mode.
4016 What this means is that you can specify when these escapes are to be
4017 evaluated (copy-in time or time of use) by insulating the escapes
4018 with an extra backslash.
4020 For example, the following will result in the numbers 20 and 10 being
4021 printed.
4023 @example
4024 .nr x 20
4025 .de y
4026 .nr x 10
4027 \&\nx
4028 \&\\nx
4031 @end example
4033 @node Parameters,  , Copy-in Mode, Writing Macros
4034 @subsection Parameters
4035 @cindex parameters
4037 @findex \$
4038 @vindex .$
4039 The arguments to a macro can be examined using a variety of escapes.
4040 The number of arguments is available in the @code{.$} number register.
4041 Any individual argument can be retrieved with one of the following
4042 escapes:
4044 The escapes @code{\$@var{n}}, @code{\$(@var{nn}}
4045 and @code{\$[@var{nnn}]}
4046 will result in the @var{n}th, @var{nn}th or @var{nnn}th
4047 argument.  Macros can have a unlimited number of arguments.
4048 Note that due to copy-in mode, you will want to have two backslashes
4049 on these in actual use, since you do not want them interpolated until
4050 the macro is actually invoked.
4052 @findex shift
4053 The request @code{shift} will shift the arguments 1 position, or as
4054 many positions as specified by the first argument.
4055 After executing this request, argument
4056 @var{i} will become argument @var{i}-@var{n}; arguments 1 to @var{n}
4057 will no longer be available.
4058 Shifting by negative amounts is currently undefined.
4060 @findex \$*
4061 @findex \$@@
4062 In some cases you will want to just use all of the arguments at once.
4063 For example if you pass the arguments along to another macro.
4064 The @code{\$*} escape is
4065 the concatenation of all the arguments separated by spaces.
4066 A similar escape is @code{\$@@},
4067 which is
4068 the concatenation of all the arguments with each surrounded
4069 by double quotes, and separated by spaces.
4071 @findex \$0
4072 @findex als
4073 The @code{\$0} escape is 
4074 the name by which the current macro was invoked.  The @code{als}
4075 request can make a macro have more than one name.
4077 @example
4078 .de vl
4079 .ie \\n(.$=1 .ds Vl Pre-Release Version
4080 .el          .ds Vl Version \\$3, \\$4.
4082 @end example
4084 This would be called as
4086 @example
4087 .vl $Id$
4088 @end example
4091 @c distribute these through the text
4092 @xref{Request Arguments}
4095 @node Page Motions, Drawing Functions, Writing Macros, Programming Tutorial
4096 @section Page Motions
4097 @cindex page motions
4098 @cindex motions, page
4100 @findex sp
4101 Motions up and down the page can be done with the @code{sp} request.
4102 However, this causes a break so that the actual effect is to move to
4103 the left margin and then to the specified location.
4105 @findex mk
4106 @findex rt
4107 The request @code{mk} can be used to mark a location on a page, for
4108 movement to later.  This request takes a register name as an
4109 argument in which to store the current page location, with no
4110 argument it will store the location in an internal register.
4111 The results of this can be used later by the @code{rt} or the
4112 @code{sp} request.  The @code{rt} request will return
4113 @strong{upwards} to the location given in the register name given as
4114 an argument, with no argument it will return to the location marked
4115 with the @code{mk} request
4117 @example
4118 ... dual column example ...
4119 @end example
4121 There are escapes which will give you much finer control of movements
4122 about the page.
4124 @findex \v
4125 The @code{\v'@var{e}'} will let you do arbitrary vertical motion from
4126 the current location on the page.  The argument @var{e} specifies the
4127 distance to move, positive is downwards and negative upwards.  The
4128 default unit for this escape is vertical spaces, @code{v}'s.  Beware,
4129 however, that troff will leave text processing to continue wherever
4130 the motion ends, so if you don't want to interfere with text
4131 processing, make sure your motions are balanced.
4133 There are some special case escapes for vertical motion.
4135 @ftable @code
4136 @item \r
4137 move upwards 1v.
4138 @item \u
4139 move upwards .5v.
4140 @item \d
4141 move down .5v.
4142 @end ftable
4144 @findex \h
4145 Horizontal motions can be done via the @code{\h'@var{e}'} escape.
4146 The expression @var{e} indicates how far to move: positive is
4147 rightwards and negative leftwards.
4149 There are a number of special case escapes for horizontal motion:
4151 @ftable @code
4152 @item \@key{SP}
4153 An unbreakable and unpadable (i.e. not expanded during filling) space.
4154 (Note: it is a backslash followed by a space.)
4155 @item \~
4156 This produces an unbreakable space that stretches like a normal
4157 interword space when a line is adjusted.
4158 @item \|
4159 a 1/6th em space.
4160 @item \^
4161 a 1/12th em space.
4162 @item \0
4163 a space the size of a digit.
4164 @item \&
4165 A zero width space.
4166 @item \)
4167 Like @code{\&} except that it behaves like a character declared with
4168 the @code{cflags} request to be transparent for the purposes of end
4169 of sentence recognition.
4170 @end ftable
4172 @example
4173 ... tex logo example ...
4174 @end example
4176 @findex \w
4177 @cindex width escape
4178 @cindex escape, width
4179 Often you will want to do horizontal movement based on the width of
4180 some arbitrary text (e.g. given as an argument to a macro).
4181 For that, there is the escape @code{\w'@var{text}'} which will
4182 interpolate to the width of the given @var{text} in basic units.
4184 @example
4185 ... strlen example ...
4186 @end example
4188 Font changes may occur in @var{text} and not affect current settings.
4190 Also after use, @code{\w} sets several registers:
4192 @table @code
4193 @item st
4194 @vindex st
4195 @itemx sb
4196 @vindex sb
4197 The highest and lowest point, respectively, in @var{text}.
4198 @item rst
4199 @vindex rst
4200 @itemx rsb
4201 @vindex rsb
4202 Like the @code{st} and @code{sb} registers, but takes account of the
4203 heights and depths of characters.
4204 @item ct
4205 @vindex ct
4206 is set according to what kinds of characters occur in @var{text}.
4207 @table @asis
4208 @item 0
4209 all short characters, no decenders or tall characters.
4210 @item 1
4211 decender
4212 @item 2
4213 tall character
4214 @item 3
4215 both a decender and a tall character
4216 @end table
4217 @item ssc
4218 @vindex ssc
4219 The amount of horizontal space (possibly negative) that should be
4220 added to the last character before a subscript.
4221 @item skw
4222 @vindex skw
4223 How far to right of the center of the last character in the @code{\w}
4224 argument, the center of an accent from a roman font should  be
4225 placed over that character.
4226 @end table
4228 @findex \k
4229 @vindex .k
4230 @code{\k}
4231 @code{.k}
4234 @node Drawing Functions, Traps, Page Motions, Programming Tutorial
4235 @section Drawing Functions
4236 @cindex drawing functions
4237 @cindex functions for drawing
4239 Groff provides a number of ways to draw lines, and other figures on
4240 the page.  Used in combination with the page motion commands
4241 (@pxref{Page Motions}, for more info) you can draw a wide variety of
4242 figures.  However, for complex drawings these operations can be quite
4243 cumbersome, and it may be wise to use the pic preprocessor.
4244 @xref{gpic}, for more information.
4246 All drawing is done via escapes.
4248 @findex \l
4249 The @code{\l} will draw a line rightwards from the current location.
4250 The full syntax for this escape is @samp{\l'@var{l}@var{c}'}, where
4251 @var{l} is the length of the line to be drawn, starting at the
4252 current location, positive numbers will draw to the right, and
4253 negative will draw towards the left.  This can also be specified
4254 absolutely (i.e. with a leading |) which will draw back to the
4255 begining of the line.
4257 The optional second parameter @var{c} is a character to draw the line
4258 with.  If this second argument is not specified, troff will use the
4259 underscore character.
4261 If you need to separate the two arguments (to prevent troff from
4262 interpreting a drawing character as a scaling indicator), you can
4263 separate them with @code{\&}.
4265 And now, for a useful example:
4267 @example
4268 .de box
4269 \(br\\$*\(br\l'|0\(rn'\l'|0\(ul'
4271 @end example
4273 Note that this works by outputing a box rule (a vertical line), then
4274 the text given as an argument and then another box rule.
4275 Then the line drawing escapes both draw from the current location to
4276 the beginning of the @emph{input} line.
4278 @findex \L
4279 Vertical lines are drawn using the @code{\L} escape.  It's parameters
4280 are specified the same as the @code{\l} escape.  If the length is
4281 positive, the movement will be downwards, and upwards for negative.
4282 The default character is the box rule character.
4283 As with the vertical motion escapes, text processing will blindly
4284 continue where the line ends.
4286 @example
4287 ...box macro...
4288 @end example
4290 @findex \D
4291 More flexible drawing functions are available via the @code{\D}
4292 escape.  While the previous escapes will work on a character device,
4293 these escapes will not.
4295 @table @code
4296 @item \D'l @var{x} @var{y}'
4297 Draw a line from the current location to the relative point specified
4298 by @var{x}, @var{y}.
4300 @example
4301 ...revised box macro...
4302 @end example
4304 @item \D'c @var{d}'
4305 Draw a circle with a diameter of @var{d} with the leftmost point at
4306 the current position.
4307 @item \D'C @var{d}'
4308 Draw a solid circle with the same parameters as an outlined circle.
4309 @item \D'e @var{dx} @var{dy}'
4310 Draw an ellipse with a horizontal diameter of @var{dx} and a vertical
4311 diameter of @var{dy} with the leftmost point at the current position.
4312 @item \D'E @var{dx} @var{dy}'
4313 Draw a solid elipse with the same parameters as an outlined elipse.
4314 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
4315 Draw an arc clockwise from the current location through the two
4316 specified locations.
4317 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4318 Draw a spline from the current location to
4319 @var{dx1}, @var{dy1} and then to @var{dx2}, @var{dy2}, and so on.
4320 @item \D'f @var{n}'
4321 Set the shade of gray to be used for filling solid objects to @var{n};
4322 @var{n} must be an integer between 0 and 1000, where 0 corresponds
4323 solid white and 1000 to solid black, and values in between correspond
4324 to intermediate shades of gray.  This applies only to solid circles,
4325 solid ellipses and solid polygons.  By default, a level of 1000 will
4326 be used.
4327 @item  \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4328 Draw a polygon from the current location to @var{dx1}, @var{dy1}
4329 and then to @var{dx2}, @var{dy2} and so on.  When the specified data
4330 points are exhausted, a line is drawn back to the starting point.
4332 @example
4333 ... box example (yes, again)...
4334 @end example
4336 @itemx \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4337 Draw a solid polygon with the same parameters as an outlined polygon.
4339 @example
4340 ... shaded box example ...
4341 @end example
4343 @item \D't @var{n}'
4344 Set the current line thickness to @var{n} machine units.
4345 A value of zero selects the smallest available line thickness.
4347 @end table
4349 Current position
4351 @findex \b
4352 @cindex pile, character
4353 @cindex character pile
4354 The @code{\b} escape will @dfn{pile} a sequence of characters
4355 vertically, and center it vertically on the current line.
4356 This can be used to build large brackets and braces.
4358 @example
4359 \b'\(lt\(bv\(lk\(bv\(lb'
4360 @end example
4363 @node Traps, Diversions, Drawing Functions, Programming Tutorial
4364 @section Traps
4365 @cindex traps
4367 Traps are locations, which, when reached, will call a specified macro.
4368 These traps can occur at a given location on the page, at a given
4369 location in the current diversion, after a certain number of input
4370 lines or at the end of input.
4372 @findex ch
4373 Any of these traps can be changed after they have been set with the
4374 @code{ch} request.  The first arguemnt is the name of the trap or
4375 macro, and the second is the new value for that trap.
4377 @menu
4378 * Page Location Traps::         
4379 * Diversion Traps::             
4380 * Input Line Traps::            
4381 * End-of-input Traps::          
4382 @end menu
4384 @node Page Location Traps, Diversion Traps, Traps, Traps
4385 @subsection Page Location Traps
4386 @cindex page location traps
4387 @cindex traps, page location
4389 Page location traps are frequently used for page headers and
4390 footers.  The following is a simple example of this.
4392 @example
4393 .de hd                          \" Page header
4394 'sp .5i
4395 .tl 'Title''date'
4396 'sp .3i
4398 .de fo                          \" Page footer
4399 'sp 1v
4400 .tl ''%''
4403 .wh 0   hd                      \" top of the page
4404 .wh -1i fo                      \" one inch from bottom
4405 @end example
4407 @vindex .t
4408 The number register @code{.t} is the distance to the next trap.
4410 @findex ch
4411 The location of a trap can be changed later on with the @code{ch}
4412 request.
4413 The first argument is the name of the macro to be invoked at the trap
4414 and the second argument is the new location for the trap.
4415 This is useful when you are building up footnotes in a diversion, and
4416 you need to allow more space at the bottom of the page for them.
4418 @example
4419 ... (simplified) footnote example ...
4420 @end example
4422 @findex vpt
4423 @findex wh
4424 @findex dt
4425 @vindex .vpt
4426 The @code{vpt} request will enable vertical position traps if the argment is
4427 non-zero, disable them otherwise.  Vertical position traps are traps
4428 set by the @code{wh} or @code{dt} requests.  Traps set by the
4429 @code{it} request are not vertical position traps.  The parameter that
4430 controls whether vertical position traps are enabled is global.
4431 Initially vertical position traps are enabled.  The current setting of
4432 this is available in the number register @code{.vpt}.
4434 @vindex .trunc
4435 @findex ne
4436 The number register @code{.trunc} contains
4437 the amount of vertical space truncated by the most recently
4438 sprung vertical position trap, or, if the trap was sprung by a
4439 @code{ne} request, minus the amount of vertical motion produced by
4440 the @code{ne} request.  In other words, at the point a trap is
4441 sprung, it represents the difference of what the vertical position
4442 would have been but for the trap, and what the vertical position
4443 actually is.
4445 @vindex .ne
4446 The number register @code{.ne} contains
4447 the amount of space that was needed in the last @code{ne} request that caused
4448 a trap to be sprung.  Useful in conjunction with the @code{.trunc}
4449 register.  @xref{Page Control}, for more information.
4451 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
4452 @subsection Diversion Traps
4453 @cindex diversion traps
4454 @cindex traps, diversion
4456 @findex dt
4457 @vindex .t
4458 Traps can also be set @emph{within} a diversion using the @code{dt}
4459 request.  Like @code{wh} the first argument is the location of the
4460 trap and the second argument is the name of the macro to be invoked.
4461 The number register @code{.t} will still work within diversions.
4462 @xref{Diversions}, for more information.
4464 @node Input Line Traps, End-of-input Traps, Diversion Traps, Traps
4465 @subsection Input Line Traps
4466 @cindex input line traps
4467 @cindex traps, input line
4469 @findex it
4470 The @code{it} request will set an input line trap.  The format for
4471 calling this is @samp{.it @var{n} @var{name}}, where @var{n} is the
4472 number of lines of input which may be read before @dfn{springing} the
4473 trap, @var{name} is the macro to be invoked.  Request lines are not
4474 counted as input lines.
4476 For example, one possible use is to have a macro which will print the
4477 next @var{n} lines in a bold font.
4479 @example
4480 .de B
4481 .it B-end \\$1
4482 .ft B
4484 .de B-end
4485 .ft R
4487 @end example
4489 @node End-of-input Traps,  , Input Line Traps, Traps
4490 @subsection End-of-input Traps
4491 @cindex end-of-input traps
4492 @cindex traps, end-of-input
4494 @findex em
4495 The @code{em} request will set a trap at the end of input.
4496 The macro specified as an arguement will be executed after the last
4497 line of the input file has been processed.
4499 For example, if your document had to have a section at the bottom of
4500 the last page for someone to approve you document, you could set it
4501 up with @code{em}.
4503 @example
4504 .de approval
4505 .ne 5v
4506 .sp |(\\n(.t-6v)
4507 .in +4i
4508 .lc _
4510 Approved:\t\a
4512 Date:\t\t\a
4514 .em approval
4515 @end example
4518 @node Diversions, Environments, Traps, Programming Tutorial
4519 @section Diversions
4520 @cindex diversions
4522 In Troff you can divert text into a named storage area, due to the
4523 similarity to defining macros it is sometimes said to be stored in a
4524 macro.  This is used for saving text for output at a later time,
4525 which is useful for keeping blocks of text on the same page,
4526 footnotes, tables of contents and indexes.
4528 @findex di
4529 @findex da
4530 Diversion is initiated by the @code{di} request, like the @code{de}
4531 request it takes an argument of a macro name to divert subsequent
4532 text to into.  The @code{da} macro will append to an existing diversion.
4534 @example
4535 ... end-note example ...
4536 @end example
4538 @vindex .z
4539 @vindex .d
4540 @vindex nl
4541 @vindex .h
4542 Diversions may be nested.
4543 The number register @code{.z} contains the name of the current diversion.
4544 The number register @code{.d} contains the current vertical place in
4545 the diversion.  If not in a diversion it is the same as the register
4546 @code{nl}.
4547 @code{.h}
4549 @vindex dn
4550 @vindex dl
4551 After compleating a diversion, the builtin number registers @code{dn}
4552 and @code{dl} contain the vertical and horizontal size of the diversion.
4554 @example
4555 .\" Center text both horizontally & vertically
4556 .de (c
4559 .di @@c
4561 .de )c
4564 .nr @@s (((\\n(.tu-\\n(dnu)/2u)-1v)
4565 .sp \\n(@@su
4566 .ce 1000
4570 .ce 0
4571 .sp \\n(@@su
4574 .rr @@s
4576 @end example
4578 @findex \!
4579 Requests, macros and escapes are interpreted when read into a
4580 diversion.
4581 There are two ways to prevent this, either way will take the given
4582 text and @dfn{transparently} embed it into the diversion.
4583 The first method is to prefix the line with @code{\!}.  This will
4584 cause the entire line to be transparently inserted into the diversion.
4585 This is useful for macros you do not want invoked until the diverted
4586 text is actually output.
4588 @c anything  is  read  in  copy  mode. (what about \! ??)
4590 @findex \?
4591 The other way is to surround the text by the @code{\?} escape, i.e.
4592 @samp{\?@var{anything}\?}.
4593 @var{anything} may not  contain
4594 newlines; use @code{\!} if you want to embed newlines in a diversion.  The
4595 escape sequence @code{\?} is also recognised in copy mode and turned into a
4596 single internal code; it is this code that terminates anything.  Thus
4597 the followin example will print 4.
4599 @example
4600 .nr x 1
4602 .di d
4603 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
4605 .nr x 2
4606 .di e
4609 .nr x 3
4610 .di f
4613 .nr x 4
4615 @end example
4617 @findex rn
4618 @code{rn}
4620 @findex rm
4621 @code{rm}
4623 @findex als
4624 @code{als}
4626 @findex chop
4627 @code{chop}
4629 @findex asciify
4630 @code{asciify}
4631 This request only exists in order to make it possible to make certain
4632 gross hacks work with GNU troff.  It @dfn{unformats} the diversion
4633 specified as an argument in
4634 such a way that @sc{ascii} characters that were formatted and diverted
4635 will be treated like ordinary input characters when the diversion is
4636 reread.  For example, the following will set register @code{n} to 1.
4638 @example
4639 .tr  @@.
4640 .di  x
4641 @@nr\  n\  1
4644 .tr  @@@@
4645 .asciify  x
4647 @end example
4650 @c distribute these through the text
4651 @xref{Copy-in Mode}
4654 @node Environments, I/O, Diversions, Programming Tutorial
4655 @section Environments
4656 @cindex environments
4658 Often you will need to print some text in a certain format regardless
4659 of what may be in effect at the time, for example, in a trap invoked
4660 macro to print headers and footers.
4661 To solve this groff has @dfn{environments} in which text is processed.
4662 An environment contains most of the parameters that control
4663 text processing.  You can switch amongst these environments, by
4664 default groff processes text in environment 0.
4665 The following is the information kept in an environment.
4667 @itemize @bullet{}
4668 @item
4669 Type size
4670 @item
4671 Font (family and style)
4672 @item
4673 Page parameters
4674 @item
4675 Fill/adjust mode
4676 @item
4677 Tab stops
4678 @item
4679 Partially collected lines
4680 @end itemize
4682 These environments may be given arbitrary names
4683 (@pxref{Identifiers}, for more info.)
4684 Old versions of troff only had environments named 0, 1 and 2.
4686 @findex ev
4687 @vindex .ev
4688 The @code{ev} request will switch among these environments.
4689 The single argument is the name of the environment to switch to, with
4690 no argument groff will switch back to the previous enviroment.
4691 There is no limit on the number of named environments;
4692 they will be created the first time that they are referenced.
4693 The @code{.ev} number register contains
4694 the name or number of the current environment.  This is a string-valued
4695 register.
4697 @example
4698 ... page break macro, revised ...
4699 @end example
4701 @example
4702 .ev footnote-env
4703 .fam N
4704 .ps 6
4705 .vs 8
4706 .ll -.5i
4709 .ev footnote-env
4710 \(dg Note the large, friendly letters.
4712 @end example
4715 @node I/O, Postprocessor Access, Environments, Programming Tutorial
4716 @section I/O
4717 @cindex i/o
4719 @findex so
4720 The @code{so} request will read in the file given as an argument and
4721 include it in place of the @code{so} request.  This is quite useful
4722 for large documents, i.e. keeping each chapter in a separate file.
4723 @xref{gsoelim}, for more information.
4725 @findex mso
4726 The @code{mso} request is
4727 the same as the @code{so} request except that file is searched for in
4728 the same way that @file{tmac.@var{name}} is searched for when the
4729 @samp{-m@var{name}} option is specified.
4731 @findex cf
4732 @findex trf
4733 The @code{cf} and @code{trf} requests are to include a file.
4734 It will transparently output the contents of file filename.  Each
4735 line is output
4736 as it would be were it preceded by @code{\!}; however, the lines are not
4737 subject to copy-mode interpretation.  If the file does not end with a
4738 newline, then a newline will be added.  For example, you can define a
4739 macro @code{x} containing the contents of file @file{f}, using
4741 @example
4742 .di x
4743 .trf f
4745 @end example
4747 .cf filename
4748 When  used  in  a  diversion, this will embed in the diversion an object
4749 which,  when  reread,  will  cause  the  contents  of  filename  to   be
4750 transparently copied through to the output.  In @sc{Unix} troff, the contents
4751 of filename is immediately copied through to the  output  regardless  of
4752 whether  there  is  a  current diversion; this behaviour is so anomalous
4753 that it must be considered a bug.
4756 With @code{trf}, unlike @code{cf}, the file cannot contain characters
4757 such as NUL that are not legal troff input characters.
4759 @findex nx
4760 The @code{nx} request will force groff to continue processing of the
4761 file specified as an argument.
4763 @findex rd
4764 The @code{rd} request will read from standard input, and include what
4765 is read as though it were part of the input file.  Text is read until
4766 a blank line is encountered.
4768 @cindex form letters
4769 @cindex letters, form
4770 Using these two requests you can set up form letters.
4771 The form letter template is constructed like this:
4773 @example
4775 \*(td
4776 .sp 2
4782 Body of letter.
4784 .nx repeat.let
4785 @end example
4787 @findex ex
4788 When this is run, the following file should be redirected in.
4789 Note that requests included in this file are executed as though they
4790 were part of the form letter.  The last block of input is the
4791 @code{ex} requests which tells groff to stop processing.  If this was
4792 not there, groff would not know when to stop.
4794 @cindex Beagle Brothers
4795 @example
4796 Trent A. Fisher
4797 708 NW 19th Av., #202
4798 Portland, OR  97209
4800 Dear Trent,
4802 Len Adollar
4803 4315 Sierra Vista
4804 San Diego, CA  92103
4806 Dear Mr. Adollar,
4809 @end example
4811 @findex pi
4812 @code{pi}
4814 @findex sy
4815 The @code{sy} request will allow arbitrary system commands to be
4816 executed from within a groff document.  The output is not saved
4817 anyplace, so it is up to you to do so.
4819 For example, the following example will introduce the current time
4820 into your document:
4822 @cindex time
4823 @pindex perl
4824 @example
4825 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
4826              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
4827 .so /tmp/x\n[$$]
4828 .sy rm /tmp/x\n[$$]
4829 \nH:\nM:\nS
4830 @end example
4832 Note that this works by having the perl script (run by @code{sy})
4833 print out the @code{nr} requests which will set the number registers
4834 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in
4835 with the @code{so} request.
4837 @vindex systat
4838 The @code{systat} number register contains
4839 The return value of the @code{system()} function executed by the last
4840 @code{sy} request.
4842 @findex open
4843 The @code{open} request will open
4844 a file (specified as the second argument) for writing and associate
4845 the stream (specified as the first argument) with it.
4847 @findex opena
4848 The @code{opena} is
4849 like open, but if filename exists, append to it instead of truncating
4852 @findex write
4853 @findex ds
4854 @cindex copy-in mode
4855 @cindex mode, copy-in
4856 The @code{write} request will write to the file associated with the
4857 stream specified by the first argument.  The stream must previously
4858 have been the subject of an open request.  The remainder of the line
4859 in interpreted as the @code{ds} request reads its second argument: a
4860 leading @code{"} will be stripped, and it will be read in copy-in mode.
4862 @findex close
4863 The @code{close} request will
4864 close the stream specified by the first argument; stream will no
4865 longer be an acceptable argument to the @code{write} request.
4867 @example
4868 ... example of open write &c...
4869 @end example
4871 @findex \v
4872 The @code{\V} escape will
4873 interpolate the contents of the specified environment variable, as returned
4874 by getenv(3).
4875 The argument to @code{\V} is specified as an identifier, i.e.
4876 @samp{\V@var{x}}, @samp{\V(@var{xx}} or @samp{\V[@var{xxx}]}.
4877 @code{\V} is interpreted in copy-in mode.
4880 @node Postprocessor Access, Miscellany, I/O, Programming Tutorial
4881 @section Postprocessor Access
4882 @cindex postprocessor access
4883 @cindex access of postprocessor
4885 There are two escapes which will allow you to give information
4886 directly to the postprocessor.  This is particularly useful for
4887 embedding PostScript into your final document.
4889 @findex \X
4890 The @code{\X} escape will embed its argument into the gtroff output
4891 preceded with @samp{x X}.
4893 @findex \Y
4894 The @code{\Y} escape is called with an identifier (i.e.
4895 @code{\Y@var{x}},
4896 @code{\Y(@var{xx}} or
4897 @code{\Y[@var{xxx}]}).
4898 This is approximately equivalent to @samp{\X'\*[@var{xxx}]'}.
4899 However the contents
4900 of the string or macro @var{xxx} are not interpreted; also it is
4901 permitted for
4902 @var{xxx} to have been defined as a macro and thus contain newlines
4903 (it is not permitted for the argument to @code{\X} to contain newlines).
4904 The inclusion of
4905 newlines requires an extension to the @sc{Unix} troff output format, and will
4906 confuse drivers that do not know about this extension.
4909 @c distribute these through the text
4910 @xref{Output Devices}
4913 @node Miscellany, Debugging, Postprocessor Access, Programming Tutorial
4914 @section Miscellany
4915 @cindex miscellany
4917 This section contains parts of troff which cannot (yet) be
4918 categorized elsewhere in this manual.
4920 @findex nm
4921 Line numbers can be printed in the left margin
4922 using the @code{nm} request.
4923 The first argument is the line number of the @emph{next} output line,
4924 this defaults to 1.
4925 The second argument indicates on which lines numbers will be printed,
4926 i.e. 5 means put line numbers on every 5 lines, this defaults to 1.
4927 The third argument is the space to be left between the number and
4928 your text, this defaults to 1.
4929 The fourth argument is the indentation of the line numbers.
4930 Without arguments, line numbers are turned off.
4932 @findex nn
4933 The @code{nn} request will temporarily turn off line numbering.
4934 The first argument is the number of lines not to be numbered,
4935 this defaults to 1. (does this disable incrementing or display?)
4937 @example
4938 ... line numbering example ...
4939 @end example
4941 @findex mc
4942 margin characters can be automatically printed to the right of your
4943 text with the @code{mc} request.
4944 The first argument is the character to be printed and the second
4945 argument is the distance away from your text.
4946 With no arguments the margin characters are turned off.
4947 If this occurs before a break, no margin character will be printed.
4949 This is quite useful for indicating text that has changed, and, in
4950 fact, there are programs available for doing this (they are called
4951 @code{nrchbar} and @code{changebar} and can be found in any
4952 @samp{comp.sources.unix} archive.
4954 @example
4955 ... margin char example ...
4956 @end example
4958 @findex lf
4959 @pindex soelim
4960 The @code{lf} primary reason for existence is to make debugging
4961 documents which are split into many files, which are then put
4962 together with @code{soelim} and other preprocessors.
4963 The first argument is the name of the file and the second argument is
4964 the input line number in that file.
4965 This way troff can produce error messages which are intelligible to
4966 the user.
4968 @example
4969 ... example of soelim'ed doc ...
4970 @end example
4973 @node Debugging, Implementation Differences, Miscellany, Programming Tutorial
4974 @section Debugging
4975 @cindex debugging
4977 Troff is not easy to debug, but there are some useful features and
4978 strategies for debugging.
4980 @itemize @bullet{}
4981 @item
4982 @findex tm
4983 The @code{tm} request will send output to stderr, this is very useful for
4984 printing debugging output.
4985 @item
4986 When doing something involved it is useful to leave the debugging
4987 statements in the code and have them turned on by a command line
4988 flag.
4990 @example
4991 .if \n(DB .tm debugging output
4992 @end example
4994 Then you can activate these statements with:
4996 @example
4997 groff -rDB=1 file
4998 @end example
5000 @item
5001 @findex ab
5002 The @code{ab} request is similar to the @code{tm} request,
5003 except that it will cause groff to stop processing.
5004 With no argument it will print @samp{User Abort}.
5005 @item
5006 @findex ex
5007 The @code{ex} request will also cause groff to stop processing.
5008 @item
5009 If you know you are going to get many errors and no useful output,
5010 you can tell groff to suppress formatted output with the @samp{-z}
5011 flag.
5012 @item
5013 @findex pm
5014 The @code{pm} request will dump out the entire symbol table.
5015 @item
5016 @findex pnr
5017 The @code{pnr} request will print the names and contents of all
5018 currently defined number registers on stderr.
5019 @item
5020 @findex ptr
5021 The @code{ptr} request will
5022 print the names and positions of all traps (not including input line
5023 traps and diversion traps) on stderr.  Empty slots in the page trap list
5024 are printed as well, because they can affect the priority of
5025 subsequently planted traps.
5026 @item
5027 @findex fl
5028 The @code{fl} request instructs groff to flush its output immediately.
5029 The intention is that this be used when using troff interactively.
5030 There is little other use for it.
5031 @item
5032 @findex backtrace
5033 The @code{backtrace} request will
5034 print a backtrace of the input stack on stderr.
5035 @item
5036 Groff has command line options for printing out more warnings
5037 (@samp{-w}) and for printing backtraces (@samp{-b}) when a warning or
5038 an error occurs.  The most verbose level of warnings is @samp{-ww}.
5039 @item
5040 @findex warn
5041 @vindex .warn
5042 The @code{warn} request controls the level of warnings checked for.
5043 The one argument is the sum of the numbers associated with each
5044 warning that is to be enabled; all other warnings will be disabled.
5045 The number associated with each warning is listed below.
5046 For example, @code{.warn 0} will disable all warnings, and
5047 @code{.warn 1} will disable
5048 all warnings except that about missing characters.  If an argument
5049 is not given, all warnings will be enabled.
5050 The number register @code{.warn} contains the current warning level.
5051 @end itemize
5053 @subsection Warnings
5054 @cindex warnings
5056 The warnings that can be given by troff are divided into the
5057 following categories.  The name associated with each warning is used
5058 by the @samp{-w} and @samp{-W} options; the number is used by the
5059 @code{warn} request, and by the @code{.warn} register.
5061 @table @samp
5062 @item  char
5063 @itemx 1
5064 Non-existent characters.  This is enabled by default.
5065 @item  number
5066 @itemx 2
5067 Invalid numeric expressions.  This is enabled by default.
5068 @item  break
5069 @itemx 4
5070 In fill mode, lines which could not be broken so that
5071 their length was less than the line length.  This is
5072 enabled by default.
5073 @item  delim
5074 @itemx 8
5075 Missing or mismatched closing delimiters.
5076 @item  el
5077 @itemx 16
5078 Use of the @code{el} request with no matching @code{ie} request.
5079 @xref{if-else}, for more information.
5080 @item  scale
5081 @itemx 32
5082 Meaningless scaling indicators.
5083 @item  range
5084 @itemx 64
5085 Out of range arguments.
5086 @item  syntax
5087 @itemx 128
5088 Dubious syntax in numeric expressions.
5089 @item  di
5090 @itemx 256
5091 @findex di
5092 @findex da
5093 Use of @code{di} or @code{da} without an argument when there is no
5094 current diversion.
5095 @item  mac
5096 @itemx 512
5097 Use of undefined strings, macros and diversions.
5098 When an undefined string, macro or diversion is used,
5099 that string is automatically defined as empty.  So,
5100 in most cases, at most one warning will be given for
5101 each name.
5102 @item  reg
5103 @itemx 1024
5104 Use of undefined number registers.  When an undefined
5105 number register is used, that register is
5106 automatically defined to have a value of 0.  a
5107 definition is automatically made with a value of 0.
5108 So, in most cases, at most one warning will be given
5109 for use of a particular name.
5110 @item  tab
5111 @itemx 2048
5112 Use of a tab character where a number was expected.
5113 @item  right-brace
5114 @itemx 4096
5115 @findex \@}
5116 Use of @code{\@}} where a number was expected.
5117 @item  missing
5118 @itemx 8192
5119 Requests that are missing non-optional arguments.
5120 @item  input
5121 @itemx 16384
5122 Illegal input characters.
5123 @item  escape
5124 @itemx 32768
5125 Unrecognized escape sequences.  When an unrecognized
5126 escape sequence is encountered, the escape character
5127 is ignored.
5128 @item  space
5129 @itemx 65536
5130 Missing space between a request or macro and its
5131 argument.  This warning will be given when  an
5132 undefined name longer than two characters is
5133 encountered, and the first two characters of the name
5134 make a defined name.  The request or macro will not
5135 be invoked. When this warning is given, no macro is
5136 automatically defined.  This is enabled by default.
5137 This warning will never occur in compatibility mode.
5138 @item  font
5139 @itemx 131072
5140 Non-existent fonts. This is enabled by default.
5141 @item all
5142 All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
5143 intended that this covers
5144 all warnings that are useful with traditional macro packages.
5145 @item w
5146 All warnings.
5147 @end table
5150 @node Implementation Differences, Summary, Debugging, Programming Tutorial
5151 @section Implementation Differences
5152 @cindex implementation differences
5153 @cindex differences in implementation
5155 GNU troff has a number of features which cause incompatibilites with
5156 documents written with old versions of troff.
5158 Long names cause some incompatibilities.  @sc{Unix} troff will interpret
5160 @example
5161 .dsabcd
5162 @end example
5164 @findex \*
5165 @findex \n
5166 @findex cp
5167 @vindex .C
5168 as defining a string @samp{ab} with contents @samp{cd}.
5169 Normally, GNU troff will interpret this as a call of a macro named
5170 @code{dsabcd}.  Also @sc{Unix} troff will interpret @code{\*[} or
5171 @code{\n[} as references to a string or number register called
5172 @samp{[}.  In GNU troff, however, this will normally be interpreted as the
5173 start of a long name.  In compatibility mode GNU troff will interpret
5174 these things in the traditional way.  In compatibility mode, however,
5175 long names are not recognised.  Compatibility mode can be turned on with
5176 the @samp{-C} command line option, and turned on or off with the
5177 @code{cp} request.
5178 The number register @code{.C} is 1 if compatibility mode is on, 0 otherwise.
5180 @findex \A
5181 GNU troff does not allow the use of the escape sequences
5182 @samp{\| \^ \& \@} \@{ \@key{SP} \' \` \- \_ \! \% \c} in names of
5183 strings, macros,
5184 diversions, number registers, fonts or environments; @sc{Unix} troff does.
5185 The @code{\A} escape sequence may be helpful in avoiding use of these escape
5186 sequences in names.
5188 @cindex fractional point sizes
5189 @cindex point sizes, fractional
5190 @findex ps
5191 Fractional pointsizes cause one noteworthy incompatibility.  In @sc{Unix}
5192 troff the @code{ps} request ignores scale indicators and so
5194 @example
5195 .ps 10u
5196 @end example
5198 will set the pointsize to 10 points, whereas in GNU troff it will set
5199 the pointsize to 10 scaled points.
5200 @xref{Fractional Type Sizes}, for more information.
5202 @findex bd
5203 @findex cs
5204 @findex tkf
5205 @findex tr
5206 @findex fp
5207 In GNU troff there is a fundamental difference between unformatted,
5208 input characters, and formatted, output characters.  Everything that
5209 affects how an output character will be output is stored with the
5210 character; once an output character has been constructed it  is
5211 unaffected by any subsequent requests that are executed, including
5212 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp}
5213 requests.  Normally output characters are constructed
5214 from input characters at the moment immediately before the character is
5215 added to the current output line.  Macros, diversions and strings are
5216 all, in fact, the same type of object; they contain lists of input
5217 characters and output characters in any combination.  An  output
5218 character does not behave like an input character for the purposes of
5219 macro processing; it does not inherit any of the special properties that
5220 the input character from which it was constructed might have had. For
5221 example,
5223 @example
5224 .di x
5225 \\\\
5229 @end example
5231 @findex \e
5232 @findex \!
5233 @findex \?
5234 will print @samp{\\} in GNU troff; each pair of input backslashes is
5235 turned into one
5236 output backslash and the resulting output backslashes are not
5237 interpreted as escape
5238 characters when they are reread. @sc{Unix} troff would interpret them as
5239 escape characters when they were reread and would end up printing one
5240 @samp{\}.
5241 The correct way to obtain a printable backslash is to use the
5242 @code{\e} escape
5243 sequence: this will always print a single instance of the current escape
5244 character, regardless of whether or not it is used in a diversion; it
5245 will also work in both GNU troff and @sc{Unix} troff. If you wish for some
5246 reason to store in a diversion an escape sequence that will be
5247 interpreted when the diversion is reread, you can either use the
5248 traditional @code{\!} transparent output facility, or, if this is unsuitable,
5249 the new @code{\?} escape sequence.  @xref{Diversions}, for more information.
5252 @node Summary,  , Implementation Differences, Programming Tutorial
5253 @section Summary
5254 @cindex summary
5258 @node Preprocessors, Output Devices, Programming Tutorial, Top
5259 @chapter Preprocessors
5260 @cindex preprocessors
5262 This chapter covers describes all preprocessors that come with
5263 @code{groff} or which are freely available.
5265 @menu
5266 * geqn::                        
5267 * gtbl::                        
5268 * gpic::                        
5269 * ggrn::                        
5270 * grap::                        
5271 * grefer::                      
5272 * gsoelim::                     
5273 @end menu
5276 @node geqn, gtbl, Preprocessors, Preprocessors
5277 @section @code{geqn}
5278 @cindex @code{eqn}
5279 @cindex @code{geqn}
5281 @menu
5282 * Invoking geqn::               
5283 @end menu
5285 @node Invoking geqn,  , geqn, geqn
5286 @subsection Invoking @code{geqn}
5287 @cindex invoking @code{geqn}
5288 @cindex @code{geqn}, invoking
5291 @node gtbl, gpic, geqn, Preprocessors
5292 @section @code{gtbl}
5293 @cindex @code{tbl}
5294 @cindex @code{gtbl}
5296 @menu
5297 * Invoking gtbl::               
5298 @end menu
5300 @node Invoking gtbl,  , gtbl, gtbl
5301 @subsection Invoking @code{gtbl}
5302 @cindex invoking @code{gtbl}
5303 @cindex @code{gtbl}, invoking
5306 @node gpic, ggrn, gtbl, Preprocessors
5307 @section @code{gpic}
5308 @cindex @code{pic}
5309 @cindex @code{gpic}
5311 @menu
5312 * Invoking gpic::               
5313 @end menu
5315 @node Invoking gpic,  , gpic, gpic
5316 @subsection Invoking @code{gpic}
5317 @cindex invoking @code{gpic}
5318 @cindex @code{gpic}, invoking
5321 @node ggrn, grap, gpic, Preprocessors
5322 @section @code{ggrn}
5323 @cindex @code{grn}
5324 @cindex @code{ggrn}
5326 @menu
5327 * Invoking ggrn::               
5328 @end menu
5330 @node Invoking ggrn,  , ggrn, ggrn
5331 @subsection Invoking @code{ggrn}
5332 @cindex invoking @code{ggrn}
5333 @cindex @code{ggrn}, invoking
5336 @node grap, grefer, ggrn, Preprocessors
5337 @section @code{grap}
5338 @cindex @code{grap}
5340 @code{grap} is available as an extra package, written by Ted Faber.
5343 @node grefer, gsoelim, grap, Preprocessors
5344 @section @code{grefer}
5345 @cindex @code{refer}
5346 @cindex @code{grefer}
5348 @menu
5349 * Invoking grefer::             
5350 @end menu
5352 @node Invoking grefer,  , grefer, grefer
5353 @subsection Invoking @code{grefer}
5354 @cindex invoking @code{grefer}
5355 @cindex @code{grefer}, invoking
5358 @node gsoelim,  , grefer, Preprocessors
5359 @section @code{gsoelim}
5360 @cindex @code{soelim}
5361 @cindex @code{gsoelim}
5363 @menu
5364 * Invoking gsoelim::            
5365 @end menu
5367 @node Invoking gsoelim,  , gsoelim, gsoelim
5368 @subsection Invoking @code{gsoelim}
5369 @cindex invoking @code{gsoelim}
5370 @cindex @code{gsoelim}, invoking
5374 @node Output Devices, File formats, Preprocessors, Top
5375 @chapter Output Devices
5376 @cindex output devices
5377 @cindex devices for output
5379 @menu
5380 * Special Characters::          
5381 * grotty::                      
5382 * grops::                       
5383 * grodvi::                      
5384 * grolj4::                      
5385 * grohtml::                     
5386 * gxditview::                   
5387 @end menu
5390 @node Special Characters, grotty, Output Devices, Output Devices
5391 @section Special Characters
5392 @cindex special characters
5393 @cindex characters, special
5395 @c distribute these through the text
5396 @xref{Font Files}
5399 @node grotty, grops, Special Characters, Output Devices
5400 @section @code{grotty}
5401 @cindex @code{grotty}
5403 @menu
5404 * Invoking grotty::             
5405 @end menu
5407 @node Invoking grotty,  , grotty, grotty
5408 @subsection Invoking @code{grotty}
5409 @cindex invoking @code{grotty}
5410 @cindex @code{grotty}, invoking
5413 @node grops, grodvi, grotty, Output Devices
5414 @section @code{grops}
5415 @cindex @code{grops}
5417 @menu
5418 * Invoking grops::              
5419 * Embedding PostScript::        
5420 @end menu
5422 @node Invoking grops, Embedding PostScript, grops, grops
5423 @subsection Invoking @code{grops}
5424 @cindex invoking @code{grops}
5425 @cindex @code{grops}, invoking
5427 @node Embedding PostScript,  , Invoking grops, grops
5428 @subsection Embedding PostScript
5429 @cindex embedding postscript
5430 @cindex postscript, embedding
5433 @node grodvi, grolj4, grops, Output Devices
5434 @section @code{grodvi}
5435 @cindex @code{grodvi}
5437 @menu
5438 * Invoking grodvi::             
5439 @end menu
5441 @node Invoking grodvi,  , grodvi, grodvi
5442 @subsection Invoking @code{grodvi}
5443 @cindex invoking @code{grodvi}
5444 @cindex @code{grodvi}, invoking
5447 @node grolj4, grohtml, grodvi, Output Devices
5448 @section @code{grolj4}
5449 @cindex @code{grolj4}
5451 @menu
5452 * Invoking grolj4::             
5453 @end menu
5455 @node Invoking grolj4,  , grolj4, grolj4
5456 @subsection Invoking @code{grolj4}
5457 @cindex invoking @code{grolj4}
5458 @cindex @code{grolj4}, invoking
5461 @node grohtml, gxditview, grolj4, Output Devices
5462 @section @code{grohtml}
5463 @cindex @code{grohtml}
5465 @menu
5466 * Invoking grohtml::            
5467 @end menu
5469 @node Invoking grohtml,  , grohtml, grohtml
5470 @subsection Invoking @code{grohtml}
5471 @cindex invoking @code{grohtml}
5472 @cindex @code{grohtml}, invoking
5475 @node gxditview,  , grohtml, Output Devices
5476 @section @code{gxditview}
5477 @cindex @code{gxditview}
5479 @menu
5480 * Invoking gxditview::          
5481 @end menu
5483 @node Invoking gxditview,  , gxditview, gxditview
5484 @subsection Invoking @code{gxditview}
5485 @cindex invoking @code{gxditview}
5486 @cindex @code{gxditview}, invoking
5490 @node File formats, Installation, Output Devices, Top
5491 @chapter File formats
5492 @cindex file formats
5493 @cindex formats, file
5495 @menu
5496 * gtroff Output::               
5497 * Font Files::                  
5498 @end menu
5501 @node gtroff Output, Font Files, File formats, File formats
5502 @section @code{gtroff} Output
5503 @cindex @code{gtroff} output
5504 @cindex output, @code{gtroff}
5507 This section describes the format output by GNU troff.  The output
5508 format used by GNU troff is very similar to that used by @sc{Unix}
5509 device-independent troff.
5511 The output format is text based, as opposed to a binary format (like
5512 @TeX{} dvi).
5513 The output format is 8 bit clean, thus single characters can have the
5514 eighth bit set, as can the names of fonts and special characters.
5516 The output format consists of single command characters with attached
5517 parameters which are separated from subsequent text by whitespace, or
5518 a newline.
5520 The names of characters and fonts an be of arbitrary length; drivers
5521 should not assume that they will be only two characters long (as
5522 device-independent troff did).
5524 When a character is to be printed, that character will always be in the
5525 current font.
5526 Unlike device-independent troff, it is not necessary for
5527 drivers to search special fonts to find a character.
5529 @table @code
5530 @item H@var{n}
5531 @item V@var{n}
5532 @item h@var{n}
5533 @item v@var{n}
5534 @item c@var{n}
5535 @item C@var{n}
5536 @item @var{nn}@var{c}
5537 @item t@var{xxx}
5538 @var{xxx} is any sequence of characters terminated by a space or a
5539 newline; the first character should be printed at the current
5540 position, the the current horizontal position should be increased by
5541 the width of the first character, and so on for each character.
5542 The width of the character is that given in the font file,
5543 appropriately scaled for the current point size,
5544 and rounded so that it is a multiple of the horizontal resolution.
5545 Special characters cannot be printed using this command.
5547 This command is only allowed if the @samp{tcommand} line is present
5548 in the @file{DESC} file.
5549 @item u@var{n} @var{xxx}
5550 @pindex DESC
5551 This is same as the @code{t} command except that after printing each
5552 character, the current horizontal position is increased by the sum of
5553 the width of that character and @code{n}.
5555 This command is only allowed if the @samp{tcommand} line is present
5556 in the @file{DESC} file.
5557 @item n@var{a}@var{b}
5558 @item p@var{n}
5559 @item s@var{n}
5560 The argument to the s command is in scaled points (units of points/n,
5561 where n is the argument to the sizescale command  in the DESC file.)
5562 @item f@var{n}
5563 @item x @dots{} \n
5564 Device control.
5565 @item D@var{c} @var{x}@dots{}\n
5566 @end table
5568 @subsection Device Control
5570 The @code{x} command is normally followed by a letter or word
5571 indicating the function to perform, followed by white space separated
5572 arguments.
5574 The first argument can be abreviated to the first letter.
5576 @table @code
5577 @item x init
5578 @item x T
5579 @item x res @var{n} @var{h} @var{v}
5580 @item x H
5581 The argument to the x Height command is also in scaled points.
5582 @end table
5584 The first three output commands are guaranteed to be:
5586 @example
5587 x T device
5588 x res n h v
5589 x init
5590 @end example
5592 For example, the input @samp{crunchy \fH\s+2frog\s0\fP!?} will produce:
5594 @example
5595 ... sample output here ...
5596 @end example
5598 @subsection Drawing Functions
5600 The D drawing command has been extended.  These extensions will only be
5601 used by GNU pic if the -x option is given.
5603 @table @code
5605 @item Df n\n
5606 Set the shade of gray to be used for filling solid objects to n; n must
5607 be an integer between 0 and 1000, where 0 corresponds solid white and
5608 1000 to solid black, and values in between correspond to intermediate
5609 shades of gray.  This applies only to solid circles, solid ellipses and
5610 solid polygons.  By default, a level of 1000 will be used.  Whatever
5611 color a solid object has, it should completely obscure everything
5612 beneath it. A value greater than 1000 or less than 0 can also be used:
5613 this means fill with the shade of gray that is currently being used for
5614 lines and text.  Normally this will be black, but some drivers may
5615 provide a way of changing this.
5616 @item DC d\n
5617 Draw a solid circle with a diameter of d with the leftmost point at the
5618 current position.
5619 @item DE dx dy\n
5620 Draw a solid ellipse with a horizontal diameter of dx and a vertical
5621 diameter of dy with the leftmost point at the current position.
5622 @item Dp $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub
5623 n$\n
5624 Draw a polygon with, for $i = 1 ,..., n+1$, the i-th vertex at the
5625 current position $+ sum from j=1 to i-1 ( dx sub j , dy sub j )$. At
5626 the moment, GNU pic only uses this command to generate triangles and
5627 rectangles.
5628 @item DP $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub
5629 n$\n
5630 Like Dp but draw a solid rather than outlined polygon.
5631 @item Dt n\n
5632 Set the current line thickness to n machine units.  Traditionally @sc{Unix}
5633 troff drivers use a line thickness proportional to the current point
5634 size; drivers should continue to do this if no Dt command has been
5635 given, or if a Dt command has been given with a negative value of n.  A
5636 zero value of n selects the smallest available line thickness.
5637 @end table
5639 A difficulty arises in how the current position should be changed after
5640 the execution of these commands. This is not of great importance since
5641 the code generated by GNU pic does not depend on this. Given a drawing
5642 command of the form
5644 \D'c $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$'
5646 where c is not one of c, e, l, a or ~, @sc{Unix} troff will treat each of the
5647 $x sub i$ as a horizontal quantity, and each of the $y sub i$ as a
5648 vertical quantity and will assume that the width of the drawn object is
5649 $sum from i=1 to n x sub i$, and that the height is $sum from i=1 to n y
5650 sub i$.  (The assumption about the height can be seen by examining the
5651 st and sb registers after using such a D command in a \w escape
5652 sequence.)  This rule also holds for all the original drawing commands
5653 with the exception of De.  For the sake of compatibility GNU troff also
5654 follows this rule, even though it produces an ugly result in the case of
5655 the Df, Dt, and, to a lesser extent, DE commands.  Thus after executing
5656 a D command of the form
5658 Dc $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$\n
5660 the current position should be increased by $( sum from i=1 to n x sub i
5661 , sum from i=1 to n y sub i )$.
5663 @subsection Line Continuation
5665 There is a continuation convention which permits the argument to the x X
5666 command to contain newlines: when outputting the argument to the x X
5667 command,  GNU troff will follow each newline in the argument with a +
5668 character (as usual, it will terminate the entire argument with a
5669 newline); thus if the line after the line containing the x X command
5670 starts with +, then the newline ending the line containing the x X
5671 command should be treated as part of the argument to the x X command,
5672 the + should be ignored, and the part of the line following the + should
5673 be treated like the part of the line following the x X command.
5676 @node Font Files,  , gtroff Output, File formats
5677 @section Font Files
5678 @cindex font files
5679 @cindex files, font
5681 The groff font format is roughly a superset of the ditroff font
5682 format.  Unlike the ditroff font format, there is no associated binary
5683 format.  The font files for device name are stored in a directory
5684 @file{dev@var{name}}.  There are two types of file: a device
5685 description file called @file{DESC} and for each font @samp{F} a font
5686 file called @file{F}.  These are text files; there is no associated
5687 binary format.
5689 @subsection @file{DESC} file format
5690 @pindex DESC
5692 The @file{DESC} file can contain the following types of line:
5694 @table @code
5695 @item res @var{n}
5696 There are @var{n} machine units per inch.
5697 @item hor @var{n}
5698 The horizontal resolution is @var{n} machine units.
5699 @item vert @var{n}
5700 The vertical resolution is @var{n} machine units.
5701 @item sizescale @var{n}
5702 The scale factor for pointsizes.  By default this has a value of 1.  One
5703 scaled point is equal to one point/@var{n}.  The arguments to the
5704 @code{unitwidth} and @code{sizes} commands are given in scaled points.
5705 @xref{Fractional Type Sizes}, for more information.
5706 @item unitwidth @var{n}
5707 Quantities in the font files are given in machine units for fonts  whose
5708 point size is @var{n} scaled points.
5709 @item tcommand
5710 This means that the postprocessor can handle the @code{t} and
5711 @code{u} output commands.
5712 @item sizes @var{s1} @var{s2}@dots{}@var{sn} 0
5713 This means that the device has fonts at @var{s1}, @var{s2},
5714 @dots{}@var{sn} scaled points.  The list of sizes must be terminated
5715 by a 0.  Each @var{si} can also be a range of
5716 sizes @var{m}-@var{n}.  The list can extend over more than one line.
5717 @item styles @var{S1 S2@dots{}Sm}
5718 The first @var{m} font positions will be associated with styles
5719 @var{S1}@dots{}@var{Sm}.
5720 @item fonts @var{n} @var{F1 F2 F3@dots{}Fn}
5721 Fonts @var{F1@dots{}Fn} will be mounted in the font positions
5722 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m}
5723 is the number of styles.  This command may extend over more than one
5724 line. A font name of 0 will cause no font to be mounted on the
5725 corresponding font position.
5726 @item family @var{fam}
5727 The default font family is @var{fam}.
5728 @item charset
5729 This line and everything following in the file are ignored.  It is
5730 allowed for the sake of backwards compatibility.
5731 @end table
5733 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
5734 are compulsory.  Other commands are ignored by troff but may be used
5735 by postprocessors to store arbitrary information about the device in
5736 the @file{DESC} file.
5739 @subsection Font file format
5741 A font file has two sections.  The first section is a sequence of lines
5742 each containing a sequence of blank delimited words; the first word in
5743 the line is a key, and subsequent words give a value for that key.
5745 @table @code
5746 @item name @var{F}
5747 The name of the font is @var{F}.
5748 @item spacewidth @var{n}
5749 The normal width of a space is @var{n}.
5750 @item slant @var{n}
5751 The characters of the font have a slant of @var{n} degrees.
5752 (Positive means forward.)
5753 @item ligatures @var{lig1} @var{lig2}@dots{}@var{lign} [0]
5754 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
5755 possible ligatures are ff, fi, fl and ffl.  For backwards
5756 compatibiliy, the list of ligatures may be terminated with a 0.  The
5757 list of ligatures may not extend over more than one line.
5758 @item special
5759 The font is special; this means that when a character is requested that
5760 is not present in the current font, it will be searched for in any
5761 special fonts that are mounted.
5762 @end table
5764 Other commands are ignored by troff but may be used by postprocessors to
5765 store arbitrary information about the font in the font file.
5767 The first section can contain comments which start with the # character
5768 and extend to the end of a line.
5770 The second section contains one or two subsections.  It must contain a
5771 @code{charset} subsection and it may also contain a @code{kernpairs}
5772 subsection.  These subsections can appear in any order.  Each
5773 subsection starts with a word on a line by itself.
5775 The word @code{charset} starts the @code{charset} subsection. The
5776 @code{charset} line is followed by a sequence of lines. Each line
5777 gives information for one character.  A line comprises a number of
5778 fields separated by blanks or tabs. The format is
5780 @display
5781 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
5782 @end display
5784 @var{name} identifies the character: if @var{name} is a single
5785 character @var{c} then it corresponds to the groff input character
5786 @var{c}; if it is of the form @samp{\@var{c}} where @var{c} is a
5787 single character, then it corresponds to the groff input character
5788 @samp{\@var{c}}; otherwise it corresponds to the groff input character
5789 @samp{\[@var{name}]} (if it is exactly two characters @var{xx} it can
5790 be entered as @samp{\(@var{xx}}.) Groff supports eight bit characters;
5791 however some utilities has difficulties with eight bit characters.
5792 For this reason, there is a convention that the @var{name}
5793 @samp{char@var{n}} is equivalent to the single character whose code is
5794 @var{n}. For example, @samp{char163} would be equivalent to the
5795 character with @var{code} 163 which is the pounds sterling sign in ISO
5796 Latin-1 character set.  The name @samp{---} is special and indicates
5797 that the character is unnamed; such characters can only be used by
5798 means of the @code{\N} escape sequence in troff.
5800 The @var{type} field gives the character type:
5802 @table @code
5803 @item 1
5804 means the character has an descender, for example, p;
5805 @item 2
5806 means the character has an ascender, for example, b;
5807 @item 3
5808 means the character has both an ascender and a descender, for example,
5809 @samp{(}.
5810 @end table
5812 The @var{code} field gives the code which the postprocessor uses to
5813 print the character.  The character can also be input to groff using
5814 this code by means of the @code{\N} escape sequence. The code can be any
5815 integer.  If it starts with a 0 it will be interpreted as octal; if it
5816 starts with 0x or 0X it will be intepreted as hexdecimal.
5818 Anything on the line after the @var{code} field will be ignored.
5820 The @var{metrics} field has the form:
5822 @smallexample
5823 @var{width[,height[,depth[,italic_correction[,left_italic_correction[,subscript_correction]]]]]}
5824 @end smallexample
5826 There must not be any spaces between these subfields.  Missing
5827 subfields are assumed to be 0.  The subfields are all decimal
5828 integers.  Since there is no associated binary format, these values
5829 are not required to fit into a variable of type @samp{char} as they
5830 are in ditroff.  The @var{width} subfields gives the width of the
5831 character.  The @var{height} subfield gives the height of the
5832 character (upwards is positive); if a character does not extend above
5833 the baseline, it should be given a zero height, rather than a negative
5834 height.  The @var{depth} subfield gives the depth of the character,
5835 that is, the distance below the lowest point below the baseline to
5836 which the character extends (downwards is positive); if a character
5837 does not extend below above the baseline, it should be given a zero
5838 depth, rather than a negative depth.  The @var{italic_correction}
5839 subfield gives the amount of space that should be added after the
5840 character when it is immediately to be followed by a character from a
5841 roman font.  The @var{left_italic_correction} subfield gives the
5842 amount of space that should be added before the character when it is
5843 immediately to be preceded by a character from a roman font.  The
5844 @var{subscript_correction} gives the amount of space that should be
5845 added after a character before adding a subscript. This should be less
5846 than the italic correction.
5848 A line in the @code{charset} section can also have the format
5850 @example
5851 @var{name} "
5852 @end example
5854 This indicates that @var{name} is just another name for the character
5855 mentioned in the preceding line.
5857 The word @code{kernpairs} starts the kernpairs section.  This contains a
5858 sequence of lines of the form:
5860 @display
5861 @var{c1 c2 n}
5862 @end display
5864 This means that when character @var{c1} appears next to character
5865 @var{c2} the space between them should be increased by @var{n}.  Most
5866 entries in kernpairs section will have a negative value for @var{n}.
5870 @node Installation, Request Index, File formats, Top
5871 @chapter Installation
5872 @cindex installation
5876 @node Request Index, Register Index, Installation, Top
5877 @chapter Request Index
5879 @printindex fn
5883 @node Register Index, String Index, Request Index, Top
5884 @chapter Register Index
5886 @printindex vr
5889 @node String Index, Macro Index, Register Index, Top
5890 @chapter String Index
5894 @node Macro Index, Program Index, String Index, Top
5895 @chapter Macro Index
5899 @node Program Index, Concept Index, Macro Index, Top
5900 @chapter Program Index
5902 @printindex pg
5906 @node Concept Index,  , Program Index, Top
5907 @chapter Concept Index
5909 @printindex cp
5913 @summarycontents
5914 @contents
5915 @bye