lbp font description files
[s-roff.git] / doc / groff.texinfo
blob19c82bcc2765136ef98b0a0f529d021d2fe32f68
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 the
645 use of the Times font family in @code{troff} 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 @pindex troffrc-end
947 Note that @code{gtroff} also accepts a @samp{-R} option, which is not
948 accessible via @code{groff}.  This option prevents the loading of the
949 @file{troffrc} and @file{troffrc-end} files.
950 @item -v
951 Make programs run by @code{groff} print out their version number.
952 @item -V
953 Print the pipeline on stdout instead of executing it.
954 @item -z
955 Suppress output from @code{gtroff}.  Only error messages will be
956 printed.
957 @item -Z
958 Do not postprocess the output of @code{gtroff}.  Normally @code{groff}
959 will automatically run the appropriate postprocessor.
960 @item -P@var{arg}
961 Pass @var{arg} to the postprocessor.  Each argument should be passed
962 with a separate @samp{-P} option.  Note that @code{groff} does not
963 prepend @samp{-} to @var{arg} before passing it to the postprocessor.
964 @item -l
965 Send the output to a printer.  The command used for this is specified by
966 the print command in the device description file.
967 @item -L@var{arg}
968 Pass @var{arg} to the spooler.  Each argument should be passed with a
969 separate @samp{-L} option.  Note that @code{groff} does not prepend a
970 @samp{-} to @var{arg} before passing it to the postprocessor.
971 @item -T@var{dev}
972 Prepare output for device @var{dev}.  The default device is @samp{ps}.
973 The following are the output devices currently available:
974 @table @samp
975 @item ps
976 For PostScript printers and previewers.
977 @item dvi
978 For @TeX{} dvi format.
979 @item X75
980 For a 75dpi X11 previewer.
981 @item X100
982 For a 100dpi X11 previewer.
983 @item @sc{ascii}
984 For typewriter-like devices.
985 @item latin1
986 For typewriter-like devices using the ISO@w{ }Latin@w{-}1 (ISO@w{
987 }8859@w{-}1) character set.
988 @item utf8
989 For typewriter-like devices using the Unicode (ISO@w{ }10646) character
990 set with UTF@w{-}8 encoding.
991 @item lj4
992 For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
993 @item html
994 To produce HTML output.
995 @end table
997 The postprocessor to be used for a device is specified by the
998 @code{postpro} command in the device description file.  (@xref{Font
999 Files}, for more info.)  This can be overridden with the @samp{-X}
1000 option.
1001 @item -X
1002 Preview with @code{gxditview} instead of using the usual postprocessor.
1003 This is unlikely to produce good results except with @samp{-Tps}.
1004 @item -N
1005 Don't allow newlines with @code{eqn} delimiters.  This is the same as
1006 the @samp{-N} option in @code{geqn}.
1007 @item -S
1008 Safer mode.  Pass the @samp{-S} option to @code{gpic} and use the
1009 @samp{-msafer} macros with @code{gtroff} (enabled by default).
1010 @item -U
1011 Unsafe mode.  Reverts to the old unsafe behaviour.
1012 @item -a
1013 Generate an @sc{ascii} approximation of the typeset output.
1014 @item -b
1015 Print a backtrace with each warning or error message.  This backtrace
1016 should help track down the cause of the error.  The line numbers given
1017 in the backtrace may not always be correct: @code{gtroff} can get
1018 confused by @code{as} or @code{am} requests while couting line numbers.
1019 @item -i
1020 Read the standard input after all the named input files have been
1021 processed.
1022 @item -w@var{name}
1023 Enable warning @var{name}.  Available warnings are described in
1024 @ref{Debugging}.  Multiple @samp{-w} options are allowed.
1025 @item -W@var{name}
1026 Inhibit warning @var{name}.  Multiple @samp{-W} options are allowed.
1027 @item -E
1028 Inhibit all error messages.
1029 @item -C
1030 Enable compatibility mode.
1031 @item -d@var{cs}
1032 @itemx -d@var{name}=s
1033 Define @var{c} or @var{name} to be a string @var{s}; @var{c} must be a
1034 one-letter @var{name}.
1035 @item -f@var{fam}
1036 Use @var{fam} as the default font family.
1037 @item -m@var{name}
1038 Read in the file @file{tmac.@var{name}}.  Normally this will be searched
1039 for in the library directory of @code{groff}.
1040 @item -n@var{num}
1041 Number the first page @var{num}.
1042 @item -o@var{list}
1043 Output only pages in @var{list}, which is a comma-separated list of page
1044 ranges; @var{n} means print page @var{n}, @samp{@var{m}-@var{n}} means
1045 print every page between @var{m} and @var{n}, @samp{-@var{n}} means
1046 print every page up to @var{n}, @samp{@var{n}-} means print every page
1047 from @var{n}.  @code{gtroff} will exit after printing the last page in
1048 the list.
1049 @item -r@var{cn}
1050 @itemx -r@var{name}=@var{n}
1051 Set number register @var{c} or @var{name} to @var{n}; @var{c} must be a
1052 one-letter @var{name}; @var{n} can be any troff numeric expression.
1053 @item -F@var{dir}
1054 Search @var{dir} for subdirectories dev@var{name} (@var{name} is the
1055 name of the device) for the @file{DESC} file and font files before the
1056 normal directory.
1057 @item -M@var{dir}
1058 Search directory @var{dir} for macro files before the normal directory.
1059 @item -I@var{dir}
1060 This option is as described in @ref{gsoelim}.  It implies the @samp{-s}
1061 option.
1062 @end table
1065 @node Environment, Invocation Examples, Options, Invoking groff
1066 @section Environment
1067 @cindex environment variables
1068 @cindex variables in environment
1070 There are also several environment variables which can modify the
1071 behavior of @code{groff}.
1073 @table @code
1074 @item GROFF_COMMAND_PREFIX
1075 @tindex GROFF_COMMAND_PREFIX
1076 If this is set to @var{X}, then @code{groff} will run
1077 @var{X}@code{troff} instead of @code{gtroff}.  This also applies to
1078 @code{tbl}, @code{pic}, @code{eqn}, @code{grn}, @code{refer}, and
1079 @code{soelim}.  It does not apply to @code{grops}, @code{grodvi},
1080 @code{grotty}, @code{grohtml}, @code{grolj4}, and @code{gxditview}.
1081 @item GROFF_TMAC_PATH
1082 @tindex GROFF_TMAC_PATH
1083 A colon separated list of directories in which to search for macro
1084 files.
1085 @item GROFF_TYPESETTER
1086 @tindex GROFF_TYPESETTER
1087 The default output device.
1088 @item GROFF_FONT_PATH
1089 @tindex GROFF_FONT_PATH
1090 A colon separated list of directories in which to search for the
1091 @code{dev}@var{name} directory.
1092 @item PATH
1093 @tindex PATH
1094 The search path for commands executed by @code{groff}.
1095 @item GROFF_TMPDIR
1096 @tindex GROFF_TMPDIR
1097 @tindex TMPDIR
1098 The directory in which temporary files will be created.  If this is not
1099 set and @code{TMPDIR} is set, temporary files will be created in that
1100 directory.  Otherwise temporary files will be created in @code{/tmp}.
1101 The @code{grops} and @code{grefer} commands can create temporary files.
1102 @end table
1105 @node Invocation Examples,  , Environment, Invoking groff
1106 @section Invocation Examples
1107 @cindex invocation examples
1108 @cindex examples of invocation
1110 This section will list several common uses of @code{groff} and the
1111 command line which will accomplish it.
1113 @example
1114 groff file
1115 @end example
1117 @noindent
1118 This command processes @var{file} without a macro package or a
1119 preprocessor.  The output device is the default, @var{ps}, and the
1120 output is sent to stdout.
1122 @example
1123 groff -t -mandoc -Tascii file | less
1124 @end example
1126 @noindent
1127 This is basically what a call to @code{man} does.  The manual page
1128 @var{file} is processed with the @code{-mandoc} macros (which in turn
1129 either call the @code{-man} or the @code{-mdoc} macro package), using
1130 the @code{tbl} preprocessor and the @sc{ascii} output device.  Finally,
1131 the result is displayed with the @code{less} pager.
1133 @example
1134 groff -X -me file
1135 @end example
1137 @noindent
1138 Preview @var{file} with @code{gxditview}, using the @code{-me} macro
1139 package.
1141 @example
1142 groff -man -rD1 -z file
1143 @end example
1145 @noindent
1146 Check @var{file} with the @code{-man} macro package, forcing
1147 double-sided printing---don't produce any output.
1149 @subsection @code{grog}
1151 @code{grog} reads files and guesses which of the @code{groff}
1152 preprocessors and/or macro packages are are required for formatting
1153 them, and prints the @code{groff} command including those options on the
1154 standard output.  The options generated are one of @samp{-e},
1155 @samp{-man}, @samp{-me}, @samp{-mm}, @samp{-ms}, @samp{-p}, @samp{-R},
1156 @samp{-g}, @samp{-s}, and @samp{-t}.
1158 A filename of @samp{-} is taken to refer to the standard input.  If no
1159 files are specified the standard input will be read.  Any specified
1160 options will be included in the printed command.  No space is allowed
1161 between options and their arguments.  For example,
1163 @example
1164 grog -Tdvi paper.ms
1165 @end example
1167 @noindent
1168 will guess the appropriate command to print @file{paper.ms} and then
1169 print it to the command line after adding the @samp{-Tdvi} option.  If
1170 you want to directly execute it, enclose the call to @code{grog} in
1171 backquotes on the @sc{Unix} shell prompt:
1173 @example
1174 `grog -Tdvi paper.ms` > paper.dvi
1175 @end example
1177 @noindent
1178 As you can see, it is still necessary to redirect the output to
1179 something meaningful (i.e.@: either a file or a pager program like
1180 @code{less}).
1184 @node Tutorial for Macro Users, Macro Packages, Invoking groff, Top
1185 @chapter Tutorial for Macro Users
1186 @cindex tutorial for macro users
1187 @cindex macro tutorial for users
1188 @cindex user's tutorial for macros
1189 @cindex user's macro tutorial
1191 Most users tend to use a macro package to format their papers.  This
1192 means that the whole breadth of @code{groff} is not neccessary for most
1193 people.  This chapter covers the material needed to efficiently use a
1194 macro package.
1196 @menu
1197 * Basics::                      
1198 * Common Features::             
1199 @end menu
1202 @node Basics, Common Features, Tutorial for Macro Users, Tutorial for Macro Users
1203 @section Basics
1204 @cindex basics
1206 This section covers some of the basic concepts you will need to
1207 understand to use a macro package.@footnote{This section is derived from
1208 @cite{Writing Papers with nroff using -me} by Eric P.@w{ }Allman.}
1209 References are made throughout to more detailed information, if desired.
1211 @code{gtroff} reads an input file prepared by the user and outputs a
1212 formatted paper suitable for publication or framing.  The input consists
1213 of text, or words to be printed, and embedded commands (@dfn{requests}
1214 and @dfn{escapes}), which tell @code{gtroff} how to format the printed
1215 copy.  For more detail on this @pxref{Embedded Commands}.
1217 The word @dfn{argument} is used in this manual to mean a word or number
1218 which appears on the same line as a request which modifies the meaning
1219 of that request.  For example, the request
1221 @example
1223 @end example
1225 @noindent
1226 spaces one line, but
1228 @example
1229 .sp 4
1230 @end example
1232 @noindent
1233 spaces four lines.  The number@w{ }4 is an argument to the @code{sp}
1234 request which says to space four lines instead of one.  Arguments are
1235 separated from the request and from each other by spaces.  More details
1236 on this can be found in @ref{Request Arguments}.
1238 The primary function of @code{gtroff} is to collect words from input
1239 lines, fill output lines with those words, justify the right hand margin
1240 by inserting extra spaces in the line, and output the result.  For
1241 example, the input:
1243 @example
1244 Now is the time
1245 for all good men
1246 to come to the aid
1247 of their party.
1248 Four score and seven
1249 years ago,...
1250 @end example
1252 @noindent
1253 will be read, packed onto output lines, and justified to produce:
1255 @quotation
1256 Now is the time for all good men to come to the aid of their party.
1257 Four score and seven years ago,...
1258 @end quotation
1260 @cindex break
1261 @cindex line break
1262 Sometimes you may want to start a new output line even though the line
1263 you are on is not yet full; for example, at the end of a paragraph.  To
1264 do this you can cause a @dfn{break}, which starts a new output line.
1265 Some requests cause a break automatically, as do blank input lines and
1266 input lines beginning with a space.
1268 Not all input lines are text to be formatted.  Some of the input lines
1269 are requests which describe how to format the text.  Requests always
1270 have a period or an apostrophe (@samp{'}) as the first character of the
1271 input line.
1273 The text formatter also does more complex things, such as automatically
1274 numbering pages, skipping over page boundaries putting footnotes in the
1275 correct place, and so forth.
1277 Here a few hints for preparing text for input to @code{gtroff}.  First,
1278 keep the input lines short.  Short input lines are easier to edit, and
1279 @code{gtroff} will pack words onto longer lines for you anyhow.  In
1280 keeping with this, it is helpful to begin a new line after every period,
1281 comma, or phrase, since common corrections are to add or delete
1282 sentences or phrases.  Secondly, do not hyphenate words at the end of
1283 lines---@code{gtroff} is smart enough to hyphenate words for you as
1284 needed, but is not smart enough to take hyphens out and join a word back
1285 together.  Also, words such as ``mother-in-law'' should not be broken
1286 over a line, since then you will get a space where not wanted, such as
1287 ``@w{mother- in}-law''.
1289 @findex ls
1290 @cindex double spacing
1291 @cindex spacing
1292 @code{gtroff} will double space output text automatically if you use the
1293 request @w{@samp{.ls 2}}.  You can revert to single spaced mode by
1294 typing @w{@samp{.ls 1}}.
1296 A number of requests allow you to change the way the printed copy looks,
1297 sometimes called the @dfn{layout} of the output page.  Most of these
1298 requests adjust the placing of @dfn{white space} (blank lines or
1299 spaces).
1301 @findex bp
1302 @cindex new page
1303 The @samp{.bp} request starts a new page.
1305 @findex sp
1306 @cindex blank lines
1307 @cindex empty lines
1308 @cindex lines, empty
1309 The request @w{@samp{.sp @var{N}}} leaves @var{N}@w{ }lines of blank
1310 space.  @var{N}@w{ }can be omitted (meaning skip a single line) or can
1311 be of the form @var{N}i (for @var{N}@w{ }inches) or @var{N}c (for
1312 @var{N}@w{ }centimeters).  For example, the input:
1314 @example
1315 .sp 1.5i
1316 My thoughts on the subject
1318 @end example
1320 @noindent
1321 leaves one and a half inches of space, followed by the line ``My
1322 thoughts on the subject'', followed by a single blank line.
1324 @findex ce
1325 @cindex centering lines
1326 @cindex lines, centering
1327 Text lines can be centered by using the @samp{.ce} request.  The line
1328 after @samp{.ce} is centered (horizontally) on the page.  To center more
1329 than one line, use @w{@samp{.ce @var{N}}} (where @var{N} is the number
1330 of lines to center), followed by the @var{N}@w{ }lines.  If you want to
1331 center many lines but don't want to count them, type:
1333 @example
1334 .ce 1000
1335 lines to center
1336 .ce 0
1337 @end example
1339 @noindent
1340 The @w{@samp{.ce 0}} request tells @code{groff} to center zero more
1341 lines, in other words, stop centering.
1343 @findex br
1344 @cindex line break
1345 @cindex break
1346 All of these requests cause a break; that is, they always start a new
1347 line.  If you want to start a new line without performing any other
1348 action, use @samp{.br}.
1351 @node Common Features,  , Basics, Tutorial for Macro Users
1352 @section Common Features
1353 @cindex common features
1354 @cindex features, common
1356 @code{gtroff} provides very low level operations for formatting a
1357 document.  There are many common routine operations which are done in
1358 all documents.  These common operations are written into @dfn{macros}
1359 and collected into a @dfn{macro package}.
1361 All macro packages provide certain common capabilities which fall into
1362 the following categories.
1364 @subsection Paragraphs
1365 @cindex paragraphs
1367 One of the most common and most used capability is starting a paragraph.
1368 There are a number of different types of paragraphs, any of which can be
1369 initiated with macros supplied by the macro package.  Normally,
1370 paragraphs start with a blank line and the first line indented, like the
1371 text in this manual.  There are also block style paragraphs, which omit
1372 the indentation:
1374 @example
1375 Some   men  look   at  constitutions   with  sanctimonious
1376 reverence, and deem them like the ark of the covenant, too
1377 sacred to be touched.
1378 @end example
1380 @noindent
1381 And there are also indented paragraphs which begin with a tag or label
1382 at the margin and the remaining text indented.
1384 @example
1385 one   This is  the first paragraph.  Notice  how the first
1386       line of  the resulting  paragraph lines up  with the
1387       other lines in the paragraph.
1388 longlabel
1389       This  paragraph   had  a  long   label.   The  first
1390       character of text on the first line will not line up
1391       with  the  text  on  second  and  subsequent  lines,
1392       although they will line up with each other.
1393 @end example
1395 A variation of this is a bulleted list.
1396 @c XXX description
1398 @subsection Sections and Chapters
1400 Most macro packages supply some form of section headers.  The simplest
1401 kind is simply the heading on a line by itself in bold type.  Others
1402 supply automatically numbered section heading or different heading
1403 styles at different levels.  Some, more sophisticated, macro packages
1404 supply macros for starting chapters and appendicies.
1406 @subsection Headers and Footers
1408 Every macro packages gives you some way to manipulate the headers and
1409 footers (or @dfn{titles}) on each page.  Some packages will allow you to
1410 have different ones on the even and odd pages (for material printed in a
1411 book form).
1413 The titles are called three-part titles, that is, there is a
1414 left-justified part, a centered part, and a right-justified part.  An
1415 automatically generated page number may be put in any of these fields
1416 with the @samp{%} character (@pxref{Page Layout} for more details).
1418 @subsection Page Layout
1420 Most macro packages let you specify top and bottom margins and other
1421 details about the appearance of the printed pages.
1423 @subsection Displays
1424 @cindex displays
1426 Displays are sections of text to be set off from the body of the paper.
1427 Major quotes, tables, and figures are types of displays, as are all the
1428 examples used in this document.
1430 @cindex quotes, major
1431 @cindex major quotes
1432 @dfn{Major quotes} are quotes which are several lines long, and hence
1433 are set in from the rest of the text without quote marks around them.
1435 @cindex list
1436 A @dfn{list} is an indented, single spaced, unfilled display.  Lists
1437 should be used when the material to be printed should not be filled and
1438 justified like normal text, such as columns of figures or the examples
1439 used in this paper.
1441 @cindex keep
1442 A @dfn{keep} is a display of lines which are kept on a single page if
1443 possible.  An example of where you would use a keep might be a diagram.
1444 Keeps differ from lists in that lists may be broken over a page boundary
1445 whereas keeps will not.
1447 @cindex keep, floating
1448 @cindex floating keep
1449 Floating keeps move relative to the text.  Hence, they are good for
1450 things which will be referred to by name, such as ``See figure@w{ }3''.
1451 A floating keep will appear at the bottom of the current page if it will
1452 fit; otherwise, it will appear at the top of the next page.  Meanwhile,
1453 the surrounding text will `flow' around the keep, thus leaving now blank
1454 areas.
1456 @subsection Footnotes and annotations
1457 @cindex footnotes
1458 @cindex annotations
1460 There are a number of requests to save text for later printing.
1461 @dfn{Footnotes} are printed at the bottom of the current page.  Delayed
1462 text is intended to be a variant form of footnote; the text is printed
1463 only when explicitly called for, such as at the end of each chapter.
1465 @cindex delayed text
1466 @dfn{Delayed text} is very similar to a footnote except that it is
1467 printed when called for explicitly.  This allows a list of references to
1468 appear (for example) at the end of each chapter, as is the convention in
1469 some disciplines.
1471 Most macro packages which supply this functionality also supply a means
1472 of automatically numbering either type of annotation.
1474 @subsection Table of Contents
1475 @cindex table of contents
1476 @cindex contents, table of
1478 @dfn{Tables of contents} are a type of delayed text having a tag
1479 (usually the page number) attached to each entry after a row of dots.
1480 The table accumulates throughout the paper until printed, usually after
1481 the paper has ended.  Many macro packages will provide the ability to
1482 have several tables of contents (i.e.@: one standard one, one for
1483 tables, etc).
1485 @subsection Indices
1486 @cindex index
1488 While some macro packages will use the term @dfn{index}, none actually
1489 provide that functionality.  The facilities they call indices are
1490 actually more appropriate for tables of contents.
1492 @subsection Paper formats
1493 @cindex paper formats
1495 Some macro packages provide stock formats for various kinds of
1496 documents.  Many of them provide a common format for the title and
1497 opening pages of a technical paper.  The @code{-mm} macros in particular
1498 provide formats for letters and memoranda.
1500 @subsection Multiple Columns
1502 Some macro packages (except @code{-man}) provide the ability to have two
1503 or more columns on a page.
1505 @subsection Font and Size changes
1507 The built-in font and size functions are not always intuitive, so all
1508 macro packages provide macros to make these operations simpler.
1510 @subsection Predefined Strings
1512 Most macro packages provide various predefined strings for a variety of
1513 uses, examples are sub- and superscripts, printable dates, quotes and
1514 various special characters.
1516 @subsection Preprocessor Support
1518 All macro packages provide support for the various preprocessors.
1520 @subsection Configuration and Customization
1522 Some macro packages provide means of customizing many of details of how
1523 the package behaves.  This ranges from setting the default type size to
1524 changing the appearance of section headers.
1528 @node Macro Packages, Programming Tutorial, Tutorial for Macro Users, Top
1529 @chapter Macro Packages
1530 @cindex macro packages
1531 @cindex packages, macros
1533 This chapter documents the main macro packages that come with
1534 @code{groff}.
1536 @menu
1537 * -man::                        
1538 * -mdoc::                       
1539 * -ms::                         
1540 * -me::                         
1541 * -mm::                         
1542 @end menu
1545 @node -man, -mdoc, Macro Packages, Macro Packages
1546 @section -man
1547 @cindex @code{-man}
1549 @c XXX documentation
1552 @node -mdoc, -ms, -man, Macro Packages
1553 @section -mdoc
1554 @cindex @code{-mdoc}
1556 @c XXX documentation
1559 @node -ms, -me, -mdoc, Macro Packages
1560 @section -ms
1561 @cindex @code{-ms}
1563 @c XXX documentation
1566 @node -me, -mm, -ms, Macro Packages
1567 @section -me
1568 @cindex @code{-me}
1570 @c XXX documentation
1573 @node -mm,  , -me, Macro Packages
1574 @section -mm
1575 @cindex @code{-mm}
1577 @c XXX documentation
1581 @node Programming Tutorial, Preprocessors, Macro Packages, Top
1582 @chapter Programming Tutorial
1583 @cindex programming tutorial
1584 @cindex tutorial for programming
1586 This chapter covers @strong{all} of the facilities of @code{gtroff}.  If
1587 you are intending to use a macro package, you probably do not want to
1588 read this chapter.
1590 @menu
1591 * Text::                        
1592 * Input Conventions::           
1593 * Measurements::                
1594 * Expressions::                 
1595 * Identifiers::                 
1596 * Embedded Commands::           
1597 * Registers::                   
1598 * Manipulating Filling and Adjusting::  
1599 * Manipulating Hyphenation::    
1600 * Manipulating Spacing::        
1601 * Tabs and Fields::             
1602 * Character Translations::      
1603 * Line Layout::                 
1604 * Page Layout::                 
1605 * Page Control::                
1606 * Fonts::                       
1607 * Sizes::                       
1608 * Strings::                     
1609 * Conditionals and Loops::      
1610 * Writing Macros::              
1611 * Page Motions::                
1612 * Drawing Functions::           
1613 * Traps::                       
1614 * Diversions::                  
1615 * Environments::                
1616 * I/O::                         
1617 * Postprocessor Access::        
1618 * Miscellany::                  
1619 * Debugging::                   
1620 * Implementation Differences::  
1621 * Summary::                     
1622 @end menu
1625 @node Text, Input Conventions, Programming Tutorial, Programming Tutorial
1626 @section Text
1627 @cindex text
1629 @code{gtroff} input files contain text with control commands
1630 interspersed throughout.  But, even without control codes, @code{gtroff}
1631 will still do several things with your text: filling and adjusting,
1632 adding additional space after sentences, hyphenating and inserting
1633 implicit line breaks.
1635 @menu
1636 * Filling and Adjusting::       
1637 * Hyphenation::                 
1638 * Sentences::                   
1639 * Tab Stops::                   
1640 * Implicit Line Breaks::        
1641 @end menu
1643 @node Filling and Adjusting, Hyphenation, Text, Text
1644 @subsection Filling and Adjusting
1645 @cindex filling and adjusting
1646 @cindex adjusting and filling
1648 When @code{gtroff} reads in text it collects words from input and fits
1649 as many of them together on one output line as it can.  This is known as
1650 @dfn{filling}.
1652 Once @code{gtroff} has a @dfn{filled} line it will try to @dfn{adjust}
1653 it.  which means it will widen the spacing between words until the text
1654 reaches the right margin (in the default adjustment mode).  Extra spaces
1655 between words are preserved, but spaces at the end of lines are ignored.
1656 Spaces at the front of a line will cause a @dfn{break} (breaks will be
1657 explained in @ref{Implicit Line Breaks})
1659 @xref{Manipulating Filling and Adjusting}.
1661 @node Hyphenation, Sentences, Filling and Adjusting, Text
1662 @subsection Hyphenation
1663 @cindex hyphenation
1665 Since the odds of finding a set of words, for every output line, which
1666 will fit nicely on a line without inserting excessive amounts of space
1667 between words is not great, @code{gtroff} will hyphenate words so that
1668 lines can be justified without there being too much space between words.
1669 It uses an internal hyphenation algorithm, to indicate which words can
1670 be hyphenated and how to do so.  When a word is hyphenated the first
1671 part of the word will be added to the current filled line being output
1672 (with an attached hyphen), and the other portion will be added to the
1673 next line to be filled.
1675 @xref{Manipulating Hyphenation}.
1677 @node Sentences, Tab Stops, Hyphenation, Text
1678 @subsection Sentences
1679 @cindex sentences
1681 Although it is often debated, some typesetting rules say there should be
1682 different amounts of space after various puctuation marks.  For example,
1683 a period at the end of a sentence should have twice as much space
1684 following it as would a comma or a period as part of an abbreviation.
1686 @cindex sentence spaces
1687 @cindex spaces between sentences
1688 @cindex french-spacing
1689 @code{gtroff} does this by flagging certain characters (normally
1690 @samp{!}, @samp{?} and @samp{.}) as @dfn{end of sentence} characters.
1691 When @code{gtroff} encounters one of these characters at the end of a
1692 line it will append two @dfn{sentence spaces} in the formatted output.
1693 (Thus, one of the conventions mentioned in @ref{Input Conventions}).
1695 @c XXX also describe how characters like ) are treated here -jjc
1696 @c gotta do some research on this -trent
1698 @node Tab Stops, Implicit Line Breaks, Sentences, Text
1699 @subsection Tab Stops
1700 @cindex tab stops
1701 @cindex stops, tabulator
1703 @code{gtroff} translates @dfn{tabulator stops}, also called @dfn{tabs},
1704 in the input into movements to the next tab stop.  These tab stops are
1705 initially located every half inch across the page.  Using this you can
1706 make simple tables.  However, this can often be deceptive as the
1707 appearance (and width) of your text on a terminal and the results from
1708 @code{gtroff} can vary greatly.
1710 Also, a possible sticking point is that lines beginning with tab
1711 characters will still be filled, again producing unexpected results.
1712 For example, the following input
1714 @multitable {12345678} {12345678} {12345678} {12345678}
1715 @item
1716 @tab 1 @tab 2 @tab 3
1717 @item
1718 @tab   @tab 4 @tab 5
1719 @end multitable
1721 @noindent
1722 will produce
1724 @multitable {12345678} {12345678} {12345678} {12345678} {12345678} {12345678} {12345678}
1725 @item
1726 @tab 1 @tab 2 @tab 3 @tab   @tab 4 @tab 5
1727 @end multitable
1729 @xref{Tabs and Fields}.
1731 @node Implicit Line Breaks,  , Tab Stops, Text
1732 @subsection Implicit Line Breaks
1733 @cindex implicit line breaks
1734 @cindex implicit breaks of lines
1735 @cindex line, implicit breaks
1736 @cindex break
1737 @cindex break, implicit
1738 @cindex line break
1740 An important concept in @code{gtroff} is the @dfn{break}.  When a break
1741 occurs, @code{gtroff} will output the partially filled line
1742 (unadjusted), and resume collecting and filling text on the next output
1743 line.
1745 @cindex blank line
1746 @cindex empty line
1747 @cindex line, blank
1748 There are several ways to cause a break in @code{gtroff}.  A blank line
1749 will not only cause a break, but it will also cause a one line vertical
1750 space (effectively a blank line) to be output.
1752 A line which begins with a space will cause a break and the space will
1753 be output at the beginning of the next line.  Note that this space isn't
1754 adjusted, even in fill mode.
1756 The end of file will also cause a break (otherwise the last line of your
1757 document may vanish!)
1759 Certain requests also cause breaks, implicitly or explicity.  This will
1760 be discussed later.
1762 @xref{Manipulating Filling and Adjusting}.
1765 @node Input Conventions, Measurements, Text, Programming Tutorial
1766 @section Input Conventions
1767 @cindex input conventions
1768 @cindex conventions for input
1770 Since @code{gtroff} does filling automatically, it is traditional in
1771 @code{groff} not to try and type things in as nicely formatted
1772 paragraphs.  These are some conventions commonly used when typing
1773 @code{gtroff} text:
1775 @itemize @bullet{}
1776 @item
1777 Break lines after punctuation, particularily at the end of sentences,
1778 and in other logical places.  Keep separate phrases on lines by
1779 themselves, as entire phrases are often added or deleted when editing.
1780 @item
1781 Try to keep lines less than 40-60@w{ }characters, to allow space for
1782 inserting more text.
1783 @item
1784 Do not try to do any formatting in a WYSIWYG manner (i.e.@: don't try
1785 and use spaces to get proper indentation).
1786 @end itemize
1789 @node Measurements, Expressions, Input Conventions, Programming Tutorial
1790 @section Measurements
1791 @cindex measurements
1793 @cindex units of measurement
1794 @cindex basic units
1795 @cindex machine units
1796 @cindex measurement units
1797 @code{gtroff} (like any other programs) requires numeric parameters to
1798 specify various measurements.  Most numeric parameters@footnote{those
1799 that specify vertical or horizontal motion or a type size} may have a
1800 @dfn{measurement unit} attached.  These units are specified as a single
1801 character which immediately follows the number or expression.  Each of
1802 these units are understood, by @code{gtroff}, to be a multiple of its
1803 @dfn{basic unit}.  So, whenever a different measurement unit is
1804 specified @code{gtroff} converts this into its @dfn{basic units}.  This
1805 basic unit, represented by a @samp{u}, is a device dependent measurement
1806 which is quite small, ranging from 1/75th to 1/72000th of an inch; all
1807 other units are converted eventually to basic units.  The values may be
1808 given as fractional numbers---nevertheless, fractional basic units are
1809 always rounded to integers.
1811 Some of the measurement units are completely independent of any of the
1812 current settings (e.g.@: type size) of @code{gtroff}.
1814 @table @samp
1815 @item i
1816 @cindex inch
1817 @cindex @code{i} unit
1818 @cindex unit, @code{i}
1819 Inches.  An antiquated measurement unit still in use in certain
1820 backwards countries.  One inch is equal to 2.54@dmn{cm}.
1821 @item c
1822 @cindex centimeter
1823 @cindex @code{c} unit
1824 @cindex unit, @code{c}
1825 Centimeters.  One centimeter is equal to 0.3937@dmn{in}.
1826 @item p
1827 @cindex points
1828 @cindex @code{p} unit
1829 @cindex unit, @code{p}
1830 Points.  This is a typesetter's measurement used for measure type size.
1831 It is 72@w{ }points to an inch.
1832 @item P
1833 @cindex pica
1834 @cindex @code{P} unit
1835 @cindex unit, @code{P}
1836 Pica.  Another typesetting measurement.  6@w{ }Picas to an inch (and
1837 12@w{ }points to a pica).
1838 @item s
1839 @itemx z
1840 @cindex @code{s} unit
1841 @cindex unit, @code{s}
1842 @cindex @code{z} unit
1843 @cindex unit, @code{z}
1844 @xref{Fractional Type Sizes}, for a discussion of these units.
1845 @end table
1847 The other measurements understood by @code{gtroff} are dependent on
1848 settings currently in effect in @code{gtroff}.  These are very useful
1849 for specifying measurements which should look proper with any size of
1850 text.
1852 @table @samp
1853 @item m
1854 @cindex em unit
1855 @cindex @code{m} unit
1856 @cindex unit, @code{m}
1857 Ems.  This unit is equal to the current font size in points.  So called
1858 because it is @emph{approximately} the width of the letter@w{ }@samp{m}
1859 in the current font.
1860 @item n
1861 @cindex en unit
1862 @cindex @code{n} unit
1863 @cindex unit, @code{n}
1864 Ens.  This is half of an em.
1865 @item v
1866 @cindex vertical space
1867 @cindex space, vertical
1868 @cindex @code{v} unit
1869 @cindex unit, @code{v}
1870 Vertical space.  This is equivalent to the current line spacing.
1871 @xref{Sizes}, for more information about this.
1872 @item M
1873 @cindex @code{M} unit
1874 @cindex unit, @code{M}
1875 100ths of an em.
1876 @end table
1878 @xref{Fractional Type Sizes}.
1880 @menu
1881 * Default Units::               
1882 @end menu
1884 @node Default Units,  , Measurements, Measurements
1885 @subsection Default Units
1886 @cindex default units
1887 @cindex units, default
1889 Many requests take a default unit.  While this can be helpful at times,
1890 it can cause strange errors in some expressions.  For example, the line
1891 length request expects em's.  Here are several attempts to get a line
1892 length of 3.5@w{ }inches and the results:
1894 @example
1895 3.5i      @result{}   3.5i
1896 7/2       @result{}   0i
1897 7/2i      @result{}   0i
1898 7i/2      @result{}   .1i
1899 7i/2u     @result{}   3.5i
1900 @end example
1902 @noindent
1903 As you can see, the safest way to specify measurements is to always
1904 attach a scaling indicator.
1907 @node Expressions, Identifiers, Measurements, Programming Tutorial
1908 @section Expressions
1909 @cindex expressions
1911 @code{gtroff} has most of operators common to other languages:
1913 @c XXX more details; examples
1915 @itemize @bullet
1916 @item
1917 @cindex arithmetic operators
1918 @cindex operators, arithmetic
1919 @findex +
1920 @findex -
1921 @findex /
1922 @findex *
1923 @findex %
1924 Arithmetic: @samp{+} (addition), @samp{-} (subtraction), @samp{/}
1925 (division), @samp{*} (multiplication), @samp{%} (modulo).
1926 @item
1927 @cindex comparison operators
1928 @cindex operators, comparison
1929 @findex <
1930 @findex >
1931 @findex >=
1932 @findex <=
1933 @findex =
1934 @findex ==
1935 Comparison: @samp{<} (less than), @samp{>} (greater than), @samp{<=}
1936 (less than or equal), @samp{>=} (greater than or equal), @samp{=}
1937 (equal), @samp{==} (the same as @samp{=}).
1938 @item
1939 @cindex logical operators
1940 @cindex operators, logical
1941 @findex &
1942 @findex :
1943 Logical: @samp{&} (logical and), @samp{:} (logical or).
1944 @item
1945 @cindex unary operators
1946 @cindex operators, unary
1947 @findex -
1948 @findex +
1949 @findex !
1950 Unary operators: @samp{-} (negating, i.e.@: changing the sign), @samp{+}
1951 (just for completeness; does nothing in expressions), @samp{!} (logical
1952 not).  See below for the use of unary operators in motion requests.
1953 @c XXX (if/while only??)
1954 @item
1955 @cindex extremum operators
1956 @cindex operators, extremum
1957 @findex >?
1958 @findex <?
1959 Extremum: @samp{>?} (maximum), @samp{<?} (minimum).  For example,
1960 @samp{5>?3} yields@w{ }@samp{5}.
1961 @c XXX add example
1962 @item
1963 @cindex scaling operator
1964 @cindex operator, scaling
1965 Scaling: @code{(@var{c};@var{e})}.  Evaluate @var{e} using @var{c} as
1966 the default scaling indicator.  If @var{c} is missing, ignore scaling
1967 indicators in the evaluation of @var{e}.
1968 @end itemize
1970 @cindex parentheses
1971 @findex (
1972 @findex )
1973 Parentheses may be used as in any other language.  However, in
1974 @code{gtroff} they are necessary to ensure order of evaluation.
1975 @code{gtroff} has no operator precedence; expressions are evaluated left
1976 to right.  This means that @samp{3+5*4} is evaluated as if it were
1977 parenthesized like @samp{(3+5)*4}, not as @samp{3+(5*4)}, like you may
1978 expect.
1980 @findex +
1981 @findex -
1982 @findex |
1983 @cindex motion operators
1984 @cindex operators, motion
1985 For many requests which cause a motion on the page, the unary operators
1986 work differently.  The @samp{+} and @samp{-} operators indicate a motion
1987 relative to the current position (down or up, respectively).  The
1988 @samp{|} operator indicates an absolute position on the page or input
1989 line.
1990 @c XXX (????)
1991 @samp{+} and @samp{-} are also treated differently by the @code{nr}
1992 request.
1993 @c XXX (?), add xref
1995 @cindex space characters in expressions
1996 @cindex expressions and space characters
1997 Due to the way arguments are parsed, spaces are not allowed in
1998 expressions, unless the entire expression is surrounded by parentheses.
2000 @xref{Request Arguments}, and @ref{Conditionals and Loops}.
2003 @node Identifiers, Embedded Commands, Expressions, Programming Tutorial
2004 @section Identifiers
2005 @cindex identifiers
2007 @findex \
2008 @findex [
2009 @findex ]
2010 @findex ?
2011 Like any other language, @code{gtroff} has rules for properly formed
2012 @dfn{identifiers}.  In @code{gtroff} an identifier can be made up of
2013 almost any printable character.  The only exception are characters which
2014 are interpreted by @code{gtroff} (backslash, square brackets, and
2015 @samp{?}).  So, for example, any of the following is valid.
2017 @example
2021 end-list
2023 @end example
2025 @findex \A
2026 You can test whether an identifier is valid in @code{gtroff} with the
2027 @code{\A} escape.  It expands to@w{ }1 or@w{ }0 according to whether its
2028 argument (given in quotes) is or is not acceptable as the name of a
2029 string, macro, diversion, number register, environment, or font.  It
2030 will return@w{ }0 if no argument is given.  This is useful if you want
2031 to look up user input in some sort of associative table.
2033 @c XXX add xrefs above
2035 Identifiers in @code{gtroff} can be any length, but, in some contexts,
2036 @code{gtroff} needs to be told where identifiers end and text begins
2037 (and in different ways depending on their length).
2039 @findex (
2040 @findex [
2041 @findex ]
2042 @itemize @bullet{}
2043 @item
2044 Single character.
2045 @item
2046 Two characters.  Must be prefixed with @samp{(} in some situations.
2047 @item
2048 Arbitrary length (@code{gtroff} only).  Must be bracketed with @samp{[}
2049 and@w{ }@samp{]} in some situations.  Any length identifier can be put
2050 in brackets.
2051 @end itemize
2053 Unlike many other programming languages, undefined identifiers are
2054 silently ignored or expanded to nothing.
2056 @c XXX add info about -ww command line option.
2058 @xref{Interpolating Registers}, and @ref{Strings}.
2061 @node Embedded Commands, Registers, Identifiers, Programming Tutorial
2062 @section Embedded Commands
2063 @cindex embedded commands
2064 @cindex commands, embedded
2066 With most documents you need more funtionality beyond filling, adjusting
2067 and implicit line breaking.  In order to gain further functionality,
2068 @code{gtroff} allows commands to be embedded into your text, in two
2069 ways.
2071 The first is a @dfn{request} which takes up an entire line, and does
2072 some large scale operation (e.g.@: break lines, start new pages).
2074 The other is an @dfn{escape} which can be embedded anywhere in your
2075 text, or even as an argument to a request.
2076 @c XXX (Not always?)
2077 Escapes generally do more minor operations like sub- and superscripts,
2078 print a symbol, etc.
2080 @menu
2081 * Requests::                    
2082 * Macros::                      
2083 * Escapes::                     
2084 @end menu
2086 @node Requests, Macros, Embedded Commands, Embedded Commands
2087 @subsection Requests
2088 @cindex requests
2090 @cindex control character
2091 @cindex character, control
2092 @findex '
2093 @findex .
2094 A request line begins with a control character, which is either a single
2095 quote (@samp{'}) or a period (@samp{.}).  These can be changed;
2096 @xref{Character Translations}, for details.  After this there may be
2097 optional tabs or spaces followed by an identifier which is the name of
2098 the request.  This may be followed by any number of space separated
2099 arguments.
2101 @findex \&
2102 If you want to begin a line with a control character without it being
2103 interpreted, precede it with @code{\&}.  This represents a zero width
2104 space, which means it will not affect your output.
2106 In most cases you will use the period as a control character.  Several
2107 requests will cause a break; using the single quote control character
2108 will prevent this.
2110 @menu
2111 * Request Arguments::           
2112 @end menu
2114 @node Request Arguments,  , Requests, Requests
2115 @subsubsection Request Arguments
2116 @cindex request arguments
2117 @cindex arguments to requests
2119 Arguments to requests (and macros) are processed much like the shell:
2120 The line is split into arguments according to spaces.  An argument which
2121 is intended to contain spaces can either be enclosed in quotes (single
2122 or double), or have the spaces @dfn{escaped} with 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 @noindent
2133 The first line is the @code{uh} macro being called with 3 arguments,
2134 @samp{The}, @samp{Mouse}, and @samp{Problem}.  The latter two have the
2135 same effect or calling the @code{uh} macro with one argument @samp{The
2136 Mouse Problem}.
2138 Note, however, that the @code{ds} request works differently.
2140 @xref{Strings}.
2142 @node Macros, Escapes, Requests, Embedded Commands
2143 @subsection Macros
2144 @cindex macros
2146 @code{gtroff} has a @dfn{macro} facility for defining a series of lines
2147 which can be invoked by name.  They are called in the same manner as
2148 requests---arguments also may be passed in the same manner.
2150 @xref{Writing Macros}, and @ref{Request Arguments}.
2152 @node Escapes,  , Macros, Embedded Commands
2153 @subsection Escapes
2154 @cindex escapes
2156 @findex \e
2157 @findex \\
2158 Escapes may occur anywhere in the input to @code{gtroff}.  They begin
2159 with a backslash and are followed by a single character which indicates
2160 the function to be performed.  If you want to have a backslash appear in
2161 your document, you should use the escape sequence @code{\e}.  Merely
2162 escaping the backslash with another backslash will work in @emph{some}
2163 curcumstances.
2165 Many escapes have no parameters; those that do, do so in one of two
2166 ways.  For escapes which require an identifier there must be a way for
2167 @code{gtroff} to tell where the identifier ends and the text begins.  It
2168 assumes that the next single character is the identifier, but if that
2169 character is an opening parenthesis, it takes the next two characters as
2170 the identifier; and if the next character is an opening bracket, all
2171 characters until a closing bracket are taken as the identifier.  Note
2172 that in the second case there is no closing parenthesis.  For example:
2174 @example
2176 \n(XX
2177 \*[TeX]
2178 @end example
2180 @findex '
2181 Other escapes may require several arguments and/or some special format.
2182 In these cases the @dfn{argument} is enclosed in single quotes
2183 @c XXX (not required??)
2184 and the enclosing text is decoded according to what that escape expects.
2186 @example
2187 \l'1.5i\(bu'
2188 @end example
2190 @findex \\
2191 @findex \e
2192 @findex \E
2193 If you want to have a backslash appear in your output, you can use
2194 several escapes: @code{\\}, @code{\e} or @code{\E}.  These are very
2195 similar, and only differ with respect to being used in macros or
2196 diversions.  @xref{Copy-in Mode}, and @ref{Diversions}, for more
2197 information.
2199 @xref{Identifiers}.
2201 @menu
2202 * Comments::                    
2203 @end menu
2205 @node Comments,  , Escapes, Escapes
2206 @subsubsection Comments
2207 @cindex comments
2209 @findex \"
2210 Probably one of the most@footnote{Unfortunately, this is a lie.  But
2211 hopefully future @code{gtroff} hackers will believe it :-)} common forms
2212 of escapes is the comment.  They begin with the @code{\"} escape and end
2213 at the end of the input line.
2215 This may sound simple, but it can be tricky to keep the comments from
2216 interfering with the apperarance of your final outupt.
2218 @findex ds
2219 If the escape is to the right of some text or a request, that portion of
2220 the line will be ignored, but the space leading up to it will be noticed
2221 by @code{gtroff}.  This only affects the @code{.ds} request.
2222 @c XXX (any others?)
2224 One possibly irritating idiosyncracy is that you must not use tabs to
2225 line up your comments.  Tabs are not treated as white space between the
2226 request and macro arguments.
2228 @cindex undefined request
2229 @cindex request, undefined
2230 If you have a comment on a line by itself, it will be treated as a blank
2231 line, because after eliminating the comment, that is all that remains.
2232 So, it is common to start the line with @code{.\"} which will cause the
2233 line to be treated as an undefined request.
2235 Another commenting scheme seen sometimes is three consecutive single
2236 quotes (@code{'''}) at the begining of a line.  This works, but
2237 @code{gtroff} will give a warning about an undefined macro, which is
2238 harmless, but irritating.
2240 @findex \#
2241 Now to avoid all this @code{gtroff} has a new comment mechanism using
2242 the @code{\#} escape.  This escape works the same as @code{\"} except
2243 that the newline is also ignored.
2245 @findex ig
2246 For large blocks of text, the @code{ig} request may be useful.
2247 @xref{Strings}.
2250 @node Registers, Manipulating Filling and Adjusting, Embedded Commands, Programming Tutorial
2251 @section Registers
2252 @cindex registers
2254 Numeric variables in @code{gtroff} are called @dfn{registers}.  There
2255 are a number of built-in registers, supplying anything from the date to
2256 details of formatting parameters.
2258 @xref{Identifiers}.
2260 @menu
2261 * Setting Registers::           
2262 * Interpolating Registers::     
2263 * Auto-increment::              
2264 * Assigning Formats::           
2265 * Built-in Registers::           
2266 @end menu
2268 @node Setting Registers, Interpolating Registers, Registers, Registers
2269 @subsection Setting Registers
2270 @cindex setting registers
2271 @cindex registers, setting
2273 @findex nr
2274 @findex \R
2275 Registers are defined resp.@: set via the @code{nr} request or the
2276 @code{\R} escape.  For example, the following two lines are equivalent:
2278 @example
2279 .nr a 1
2280 \R'a 1'
2281 @end example
2283 @findex rr
2284 The @code{rr} request will remove the register specified by the
2285 argument.
2287 @findex rnn
2288 The @code{rnn} request will rename a number register.  The format is
2289 @w{@samp{.rnn @var{x} @var{y}}}, which will rename number register
2290 @var{x} to @var{y}.
2292 @findex aln
2293 Aliases can be created for a number register.  The format is
2294 @w{@samp{.aln @var{xx} @var{yy}}}, which will create an alias @var{xx}
2295 for number register object named @var{yy}.  The new name and the old
2296 name will be exactly equivalent.  If @var{yy} is undefined, a warning of
2297 type @samp{reg} will be generated, and the request will be ignored.
2298 @xref{Debugging}, for information about warnings.
2300 @node Interpolating Registers, Auto-increment, Setting Registers, Registers
2301 @subsection Interpolating Registers
2302 @cindex interpolating registers
2303 @cindex registers, interpolating
2305 @findex \n
2306 Numeric registers are @dfn{interpolated} via the @code{\n} escape.
2308 @c XXX the following is wrong.  Should I say any more than the above??
2309 @c This means that the value of the number register is expanded in-place
2310 @c on the input line before any other actions, i.e. before requests and
2311 @c escapes are interpreted.
2313 @example
2314 .nr as \na+\na
2315 \n(as
2316 @end example
2318 @node Auto-increment, Assigning Formats, Interpolating Registers, Registers
2319 @subsection Auto-increment
2320 @cindex auto-increment
2321 @cindex increment, automatic
2323 @findex nr
2324 Number registers can also be auto-incremented and auto-decremented.  You
2325 can specify the increment resp.@: decrement factor with a third argument
2326 to the @code{nr} request.  The default value is@w{ }0.  For example,
2328 @example
2329 .nr a 0 1
2330 .nr xx 0 5
2331 \n+a, \n+a, \n+a, \n+a, \n+a
2333 \n+(xx, \n+(xx, \n+(xx, \n+(xx, \n+(xx
2334 @end example
2336 @noindent
2337 produces
2339 @example
2340 1, 2, 3, 4, 5
2341 5, 10, 15, 20, 25
2342 @end example
2344 If you want to change the increment factor without changing the value of
2345 a register, the following can be used.
2347 @example
2348 .nr a \na 10
2349 @end example
2351 @node Assigning Formats, Built-in Registers, Auto-increment, Registers
2352 @subsection Assigning Formats
2353 @cindex assigning formats
2354 @cindex formats, assigning
2356 @findex af
2357 When a register is used in the text of an input file (as opposed to part
2358 of an expression) it is textually replaced (or interpolated) with a
2359 representation of that number.  This output format can be changed to a
2360 variety of formats (numbers, roman numerals, etc).  This is done using
2361 the @code{af} request.  The first argument to @code{af} is the name of
2362 the number register to be changed, and the second argument is the output
2363 format.  The following output formats are available:
2365 @table @samp
2366 @item 1
2367 This is the default format, decimal numbers: 1, 2, 3,@w{ }@dots{}
2368 @item 001
2369 Decimal numbers with as many leading zeros as specified.  So, @samp{001}
2370 would result in 001, 002, 003,@w{ }@dots{}
2371 @item I
2372 @cindex roman numerals
2373 @cindex numerals, roman
2374 Upper-case roman numerals: 0, I, II, III, IV,@w{ }@dots{}
2375 @item i
2376 Lower-case roman numerals: 0, i, ii, iii, iv,@w{ }@dots{}
2377 @item A
2378 Upper-case letters: A, B, C, @dots{},@w{ }Z, AA, AB,@w{ }@dots{}
2379 @item a
2380 Lower-case letters: a, b, c, @dots{},@w{ }z, aa, ab,@w{ }@dots{}
2381 @end table
2383 The following example will produce @samp{10, X, j, 010}:
2385 @example
2386 .nr a 10
2387 .af a 1           \" the default format
2388 \na,
2389 .af a I
2390 \na,
2391 .af a a
2392 \na,
2393 .af a 001
2395 @end example
2397 @findex \g
2398 The @code{\g} escape returns the current format of the specified
2399 register.  For example, @samp{\ga} after the previous example would
2400 produce @samp{001}.
2402 @node Built-in Registers,  , Assigning Formats, Registers
2403 @subsection Built-in Registers
2404 @cindex built-in registers
2405 @cindex registers, built-in
2407 The following lists some built-in registers which are not described
2408 elsewhere in this manual.  Any register which begin with a @samp{.} is
2409 read-only.  A complete listing of all built-in registers can be found in
2410 @ref{Register Index}.
2412 @table @code
2413 @item .H
2414 @vindex .H
2415 Horizontal resolution in basic units.
2416 @item .V
2417 @vindex .V
2418 Vertical resolution in basic units.
2419 @item dw
2420 @vindex dw
2421 Day of the week (1-7).
2422 @item dy
2423 @vindex dy
2424 Day of the year (1-31).
2425 @item mo
2426 @vindex mo
2427 Current month (1-12).
2428 @item year
2429 @vindex year
2430 The year.
2431 @item yr
2432 @vindex yr
2433 The year minus@w{ }1900.  Unfortunately, the @sc{Unix} Version@w{ }7
2434 troff documentation had a year@w{ }2000 bug: It incorrectly claimed that
2435 @samp{\n(yr} was the last two digits of the year.  That claim has never
2436 been true of either traditional @code{troff} or GNU @code{troff}.  If
2437 you see old @code{troff} input that looks like this:
2439 @example
2440 '\" The following line stopped working after 1999
2441 This document was formatted in 19\n(yr.
2442 @end example
2444 @noindent
2445 you can correct it as follows:
2447 @example
2448 This document was formatted in \n[year].
2449 @end example
2451 @noindent
2452 or, if you want to be portable to older @code{troff} versions, as
2453 follows:
2455 @example
2456 .nr y4 1900+\n(yr
2457 This document was formatted in \n(y4.
2458 @end example
2460 @item .c
2461 @vindex .c
2462 @itemx c.
2463 @vindex c.
2464 The current @emph{input} line number.
2465 @item ln
2466 @vindex ln
2467 The current @emph{output} line number.
2468 @item .x
2469 @vindex .x
2470 The major version number.  For example, if the version number is@w{
2471 }1.03 then @code{.x} will contain@w{ }@samp{1}.
2472 @item .y
2473 @vindex .y
2474 The minor version number.  For example, if the version number is@w{
2475 }1.03 then @code{.y} will contain@w{ }@samp{03}.
2476 @item .Y
2477 @vindex .Y
2478 The revision number of @code{groff}.
2479 @item .g
2480 @vindex .g
2481 Always@w{ }1.  Macros should use this to determine whether they are
2482 running under GNU @code{troff}.
2483 @item .A
2484 @vindex .A
2485 If the current output device is @sc{ascii}, this is set to@w{ }1, zero
2486 otherwise.
2487 @item .P
2488 @vindex .P
2489 This register indicates whether the current page is actually being
2490 printed, i.e., whether the @samp{-o} option is being used to only print
2491 selected pages.  @xref{Options}, for more information.
2492 @end table
2495 @node Manipulating Filling and Adjusting, Manipulating Hyphenation, Registers, Programming Tutorial
2496 @section Manipulating Filling and Adjusting
2497 @cindex manipulating filling and adjusting
2498 @cindex filling and adjusting, manipulating
2499 @cindex adjusting and filling, manipulating
2500 @cindex justifying text
2501 @cindex text, justifying
2503 @findex br
2504 @cindex break
2505 @cindex line break
2506 Various ways of causing @dfn{breaks} were given in @ref{Implicit Line
2507 Breaks}.  The @code{br} request will likewise cause a break.  Several
2508 other requests will also cause breaks, but implicitly.  They are
2509 @code{bp}, @code{ce}, @code{fi}, @code{fl}, @code{in}, @code{nf},
2510 @code{sp}, and @code{ti}.
2512 @findex nf
2513 @findex fi
2514 @vindex .u
2515 Initially, @code{gtroff} will fill and ajust text to both margins.
2516 Filling can be disabled via the @code{nf} request and re-enabled with
2517 the @code{fi} request.  These implicitly disable and re-enable
2518 adjusting.  Both of these will cause a break in the text currently being
2519 filled.  The number register @code{.u} is equal to@w{ }1 in fill mode
2520 and@w{ }0 in no-fill mode.
2522 @findex ad
2523 @findex na
2524 Adjusting can be disabled with the @code{ad} request and re-enabled with
2525 the @code{na} request.  The @code{ad} request takes a single argument to
2526 indicate how to adjust text.
2528 @table @samp
2529 @item l
2530 @cindex ragged-right
2531 Adjust text to the left margin.  This produces what is traditionally
2532 called ragged-right text.
2533 @item r
2534 @cindex ragged-left
2535 Adjust text to the right margin, producing ragged-left text.
2536 @item c
2537 @cindex centered text
2538 Center filled text.
2539 @c XXX difference to .ce?
2540 @item b
2541 @itemx n
2542 Justify to both margins.  This is default of @code{gtroff}.
2543 @end table
2545 With no argument to @code{ad}, @code{gtroff} will adjust lines the same
2546 way it was the last time it was filling.  For example:
2548 @example
2549 text
2550 .ad r
2551 text
2552 .ad c
2553 text
2555 text
2556 .ad  \" back to centering
2557 text
2558 @end example
2560 @vindex .j
2561 The current adjustment mode is available in the number register
2562 @code{.j}.
2564 @findex \p
2565 The escape @code{\p} will cause a break and the remaining text to be
2566 adjusted.
2568 @cindex word space size
2569 @cindex size of word space
2570 @cindex space between words
2571 @cindex sentence space size
2572 @cindex size of sentence space
2573 @cindex space between sentences
2574 @findex ss
2575 The @code{ss} request allows you to change the minimum size of a space
2576 between filled words.  This request takes its units as one twelfth of
2577 the space width parameter for the current font.  Initially both the word
2578 space size and the sentence space size are@w{ }12.
2580 If two arguments are given to the @code{ss} request, the second argument
2581 gives the sentence space size.  If the second argument is not given, the
2582 sentence space size will be the same as the word space size.  The
2583 sentence space size is used in two circumstances: If the end of a
2584 sentence occurs at the end of a line in fill mode, then both an
2585 inter-word space and a sentence space will be added; if two spaces
2586 follow the end of a sentence in the middle of a line, then the second
2587 space will be a sentence space. Note that the behaviour of @sc{Unix}
2588 @code{troff} will be exactly that exhibited by GNU @code{troff} if a
2589 second argument is never given to the @code{ss} request.  In GNU
2590 @code{troff}, as in @sc{Unix} @code{troff}, you should always follow a
2591 sentence with either a newline or two spaces.
2593 @vindex .ss
2594 @vindex .sss
2595 The number registers @code{.ss} and @code{.sss} are the values of the
2596 parameters set by the first and second arguments of the @code{ss}
2597 request.
2599 @findex ce
2600 @cindex centering lines
2601 @cindex lines, centering
2602 The @code{ce} request will center text.  While the @w{@samp{ad c}}
2603 request will also center text, it has the side effect of filling the
2604 text.  The @code{.ce} request will not fill the text it affects.  This
2605 request causes a break.
2607 With no arguments, @code{ce} will fill the next line of text.  The
2608 single argument @code{ce} takes is a number indicating the number of
2609 lines to be centered.  If the argument is zero, centering is disabled.
2611 A common idiom is to turn on centering for a large number of lines, and
2612 then turn off centering when you are done with the centered text.  This
2613 is useful for any request which takes a number of lines as an argument.
2615 @example
2616 .ce 1000
2617 replace this
2618 with
2619 something
2620 more interesting
2621 @dots{}
2622 .ce 0
2623 @end example
2625 @vindex .ce
2626 The @code{.ce} number register contains the number of lines remaining to
2627 be centered, as set by the @code{ce} request.
2629 @cindex justifying text
2630 @cindex text, justifying
2631 @cindex right-justifying
2632 @findex rj
2633 @vindex .rj
2634 A similar request is @code{rj} request which will justify unfilled text
2635 to the right margin.  Its arguments are identical to the @code{ce}
2636 request.  The @code{.rj} number register is the number of lines to be
2637 right-justified as set by the @code{rj} request.
2640 @node Manipulating Hyphenation, Manipulating Spacing, Manipulating Filling and Adjusting, Programming Tutorial
2641 @section Manipulating Hyphenation
2642 @cindex manipulating hyphenation
2643 @cindex hyphenation, manipulating
2645 As discussed in @ref{Hyphenation}, @code{gtroff} will hyphenate words.
2646 There are a number of ways to influence how hyphenation is done.
2648 @findex nh
2649 @findex hy
2650 @vindex .hy
2651 Hyphenation can be turned off with the @code{nh} request, and turned
2652 back on with the @code{hy} request.  However, the hyphenation facilities
2653 of @code{gtroff} are far more flexible than this.  The @code{hy} request
2654 can be used to tell @code{gtroff} to restrict hypenation to certain
2655 cases.  The request takes a single numeric argument.  The current
2656 hyphenation restrictions can be found in the number register @code{.hy}.
2658 @table @samp
2659 @item 1
2660 The default argument, which indicates to hyphenate without restrictions.
2661 @item 2
2662 Do not hyphenate the last word on a page or column.
2663 @item 4
2664 Do not hyphenate the last two characters of a word.
2665 @item 8
2666 Do not hyphenate the first two characters of a word.
2667 @end table
2669 The values in the previous table are additive.  For example, the
2670 value@w{ }12 causes @code{gtroff} to neither hyphenate the last two nor
2671 the first two characters of a word.
2673 @findex hlm
2674 @vindex .hlc
2675 @vindex .hlm
2676 @findex \%
2677 @cindex explicit hyphens
2678 @cindex hyphen, explicit
2679 The @code{hlm} request will set the maximum number of consecutive
2680 hyphenated lines to the value given as the first argument.  If this
2681 number is negative, there is no maximum.  The default value is@w{ }-1.
2682 This value is associated with the current environment.  Only lines
2683 output from an environment count towards the maximum associated with
2684 that environment.  Hyphens resulting from @code{\%} are counted;
2685 explicit hyphens are not.  The current setting of this is available in
2686 the @code{.hlm} register.  Also the number of immediately preceding
2687 consecutive hyphenated lines are available in the number register
2688 @code{.hlc}.
2690 @findex hw
2691 The @code{hw} request allows you to specify how a specific word is to be
2692 hyphenated.  It takes only one argument which is the word with hyphens
2693 at the hyphenation points.  For example: 
2695 @example
2696 .hw in-sa-lub-rious
2697 @end example
2699 @noindent
2700 This request can be used more than once.
2702 @c XXX
2703 @c In old versions of troff there was a
2704 @c limited amount of space to store such information, fortunately,
2705 @c with groff, this is no longer a restriction.
2707 @findex \%
2708 @cindex hyphenation character
2709 @cindex character, hyphenation
2710 @cindex disabling hyphenation
2711 @cindex hyphenation, disabling
2712 You can also tell @code{gtroff} how to hyphenate words on the fly with
2713 the use of the @code{\%} escape, also known as the @dfn{hyphenation
2714 character}.  Preceding a word with this character will prevent it from
2715 being hyphenated, putting it in a word will indicate to @code{gtroff}
2716 that the word may be hyphenated at that point.  Note that this mechanism
2717 will only affect one word; if you want to change the hyphenation of a
2718 word for the entire document, use the @code{hw} request.
2720 @findex hc
2721 The @code{hc} request allows you to change the hyphenation character.
2722 The character specified as an argument will then work the same as the
2723 @code{\%} escape, and, thus, no longer appear in the output.  Without
2724 an argument it will return the hyphenation character to @code{\%}.
2726 @cindex hyphenation patterns
2727 @cindex pattern for hyphenation
2728 @findex hpf
2729 To further customize hyphenation the @code{hpf} request will read in a
2730 file of hyphenation patterns.  This file will be searched for in the
2731 same way that @file{tmac.@var{name}} is searched for when the
2732 @samp{-m@var{name}} option is specified.
2734 It should have the same format as the argument to the @code{\patterns}
2735 primitive in @TeX{}; the letters appearing in this file are interpreted
2736 as hyphenation codes.  A @samp{%} character in the patterns file
2737 introduces a comment that continues to the end of the line.
2739 @findex hla
2740 @findex hpf
2741 @pindex troffrc
2742 @pindex troffrc-end
2743 The set of hyphenation patterns is associated with the current language
2744 set by the @code{hla} request.  The @code{hpf} request is usually
2745 invoked by the @file{troffrc} or @file{troffrc-end} file.
2747 @findex hcode
2748 The @code{hcode} request has the following syntax:
2750 @example
2751 .hcode @var{c1 code1 c2 code2...}
2752 @end example
2754 It sets the hyphenation code of character @var{c1} to @var{code1} and
2755 that of @var{c2} to @var{code2}.  A hyphenation code must be a single
2756 input character (not a special character) other than a digit or a space.
2757 Initially each lower-case letter has a hyphenation code, which is
2758 itself, and each upper-case letter has a hyphenation code which is the
2759 lower-case version of itself.
2761 @cindex hyphenation margin
2762 @cindex margin for hyphenation
2763 @findex hym
2764 @vindex .hym
2765 The @code{hym} request will set the hyphenation margin to the value
2766 given as its argument: when the current adjustment mode is not@w{
2767 }@samp{b}, the line will not be hyphenated if the line is no more than
2768 that amount short.  The default hyphenation margin is@w{ }0.  The
2769 default scaling indicator for this request is@w{ }m.  The hyphenation
2770 margin is associated with the current environment.  The current
2771 hyphenation margin is available in the @code{.hym} register.
2773 @cindex hyphenation space
2774 @findex hys
2775 @vindex .hys
2776 The @code{hys} request sets the hyphenation space to the value given as
2777 the first argument: when the current adjustment mode is@w{ }@samp{b},
2778 don't hyphenate the line if the line can be justified by adding no more
2779 than that amount of extra space to each word space.  The default
2780 hyphenation space is@w{ }0.  The default scaling indicator for this
2781 request is@w{ }m.  The hyphenation space is associated with the current
2782 environment.  The current hyphenation space is available in the
2783 @code{.hys} register.
2785 @cindex soft hyphen character
2786 @cindex character, soft hyphen
2787 @findex shc
2788 The @code{shc} request will set the soft hyphen character to the
2789 character given as an argument.  If the argument is omitted, the soft
2790 hyphen character will be set to the default character @code{\(hy}. The
2791 soft hyphen character is the character which will be inserted when a
2792 word is hyphenated at a line break.  If the soft hyphen character does
2793 not exist in the font of the character immediately preceding a potential
2794 break point, then the line will not be broken at that point.  Neither
2795 definitions (specified with the @code{char} request) nor translations
2796 (specified with the @code{tr} request) are considered when finding the
2797 soft hyphen character.
2799 @findex hla
2800 @findex hpf
2801 @findex hw
2802 @vindex .hla
2803 @pindex troffrc
2804 @pindex troffrc-end
2805 The @code{hla} request will set the current hyphenation language to that
2806 given by the first argument.  Hyphenation exceptions specified with the
2807 @code{hw} request and hyphenation patterns specified with the @code{hpf}
2808 request are both associated with the current hyphenation language.  The
2809 @code{hla} request is usually invoked by the @file{troffrc} or the
2810 @file{troffrc-end} files.  The current hyphenation language is available
2811 in the number register @code{.hla}.
2814 @node Manipulating Spacing, Tabs and Fields, Manipulating Hyphenation, Programming Tutorial
2815 @section Manipulating Spacing
2816 @cindex manipulating spacing
2817 @cindex spacing, manipulating
2819 @findex sp
2820 The @code{sp} request will cause troff to space downwards the
2821 distance specified as the first argument.  With no argument it will
2822 advance 1 line.
2823 A negative argument will cause troff to move up the page the
2824 specified distance.
2825 If the argument is preceded by a @samp{|} troff will move that
2826 distance from the top of the page.
2828 @findex ls
2829 @vindex .L
2830 Often you may want your output to be double or triple spaced.
2831 The @code{ls} request will cause troff to output @var{n}-1 blank
2832 lines after each line of text, where @var{n} is the argument given to
2833 the @code{ls} request.  With no argument troff will go back to single
2834 spacing.  The number register @code{.L} contains the current line
2835 spacing setting.
2837 @findex \x
2838 @vindex .a
2839 Sometimes, extra vertical spacing is only needed occasionaly,
2840 i.e. to allow space for a tall construct (like an equation).
2841 The @code{\x} escape will do this.
2842 The escape is given a numerical argument (like @samp{\x'3p'}).
2843 If this number is positive extra vertical space will be inserted
2844 below the current line.  A negative number will add space above.
2845 If this escape is used multiple times on the same line, the maximum
2846 values are used.
2847 The @code{.a} number register contains the most recent
2848 extra vertical @strong{emph} line space.
2850 @example
2851 ... example of inline equation ...
2852 @end example
2854 @findex ns
2855 @findex rs
2856 @cindex no-space mode
2857 @cindex mode, no-space
2858 Spacing (via either @code{sp} or via blank lines) can be disabled
2859 with the @code{ns} request.  This will enable @dfn{no-space mode}.
2860 This mode will end when actual text is output or the @code{rs}
2861 request is encountered.  No-space mode will also prevent requests to
2862 advance to the next page unless they are accompanied by a page number
2863 (@pxref{Page Control}, for more information.)
2866 @node Tabs and Fields, Character Translations, Manipulating Spacing, Programming Tutorial
2867 @section Tabs and Fields
2868 @cindex tabs and fields
2869 @cindex fields and tabs
2871 @findex \t
2872 Tab stops are much like those on a typewriter: a tab character (or the
2873 @code{\t} escape) on input will cause horizontal motion to the next
2874 tab stop.
2876 @findex ta
2877 Tab stops can be changed with the @code{ta} request.
2878 This request takes a series of numbers as arguments which indicate
2879 where each tab stop is to be (overriding any previous settings).
2880 These can be specified absolutely,
2881 i.e. as the distance from the left margin.
2882 For example, the following wil set tab stops every one inch.
2884 @example
2885 .ta 1i 2i 3i 4i 5i 6i
2886 @end example
2888 Tab stops can also be specified relatively (using a leading @samp{+})
2889 which means that the specified tab stop will be set that distance
2890 from the previous tab stop.  For example the following is equivalent
2891 to the previous example.
2893 @example
2894 .ta 1i +1i +1i +1i +1i +1i
2895 @end example
2897 After the specified tab stops repeat values may be set for tabs beyond
2898 the last one specified.  This is most commonly used to specify tabs
2899 set at equal intervals.  The compleat syntax for setting tabs is
2900 @code{ta @var{n1} @var{n2} @dots{} @var{nn} T @var{r1} @var{r2}
2901 @dots{} @var{rn}} This will set tabs at positions @var{n1}, @var{n2},
2902 @dots{}, @var{nn} and then set tabs at @var{nn}+@var{r1},
2903 @var{nn}+@var{r2}, @dots{}, @var{nn}+@var{rn} and then at
2904 @var{nn}+@var{rn}+@var{r1}, @var{nn}+@var{rn}+@var{r2}, @dots{},
2905 @var{nn}+@var{rn}+@var{rn}, and so on.  For example the following is,
2906 yet again, the same as the previous examples.
2908 @example
2909 .ta T 1i
2910 @end example
2912 The material in each tab column may be justified to the right or left
2913 or centered in the column.  This is specified by appending an
2914 @samp{R}, @samp{L} or @samp{C} to the number specifying that tab stop.
2915 The default justification is @samp{L}.
2917 @example
2918 .ta 1i 2iC 2iR
2919 @end example
2921 @vindex .tabs
2922 The number register @code{.tabs} contains
2923 a string representation of the current tab settings suitable for use as
2924 an argument to the @code{ta} request.
2926 @findex tc
2927 Normally troff will fill the space to the next tab stop with spaces.
2928 In some cases you may wish to change this.  The @code{tc} request
2929 will do this.  With no argument troff will revert to using spaces.
2931 @subsection Leaders
2932 @cindex leaders
2934 @findex lc
2935 Sometimes you may wish to use the @code{tc} request to fill a tab
2936 stop with a given character, but also, you want to use normal tab
2937 stops on the rest of the line.  For this groff provides an alternate
2938 tab mechanism, called @dfn{leaders} which will do just that.
2939 They are used exclusively to produce a repeated run of characters to
2940 the next tab stop.
2942 You can declare what character will be repeated with the @code{lc}
2943 request.  If you do not give it an argument, the leaders will act the
2944 same as tabs.
2946 @findex \a
2947 The difference is that a leader is invoked by using the @code{\a}
2948 escape.
2950 @cindex table of contents
2951 @cindex contents, table of
2952 So for a table of contents you may want to have tab stops defined so
2953 that the section number is one tab stop, the title is the second with
2954 the remaining space being filled with a line of dots and then the
2955 page number slightly separated from the dots.
2957 @example
2958 .lc .
2959 .ta .5iR 5i +.25i
2960 1.1\tFoo\a\t12
2961 @end example
2963 @subsection Fields
2964 @cindex fields
2966 @findex fc
2967 Fields are a more general way of laying out tabular data.
2968 @code{fc}
2970 @node Character Translations, Line Layout, Tabs and Fields, Programming Tutorial
2971 @section Character Translations
2972 @cindex character translations
2973 @cindex translations of characters
2975 @findex cc
2976 @findex c2
2977 The control character (@samp{.}) and the no-break control character
2978 (@samp{'}) can be changed with the @code{cc} and @code{c2} requests,
2979 respectively.
2980 The single argument is the new character to be used, with no argument
2981 the normal control character is restored.
2983 @findex ec
2984 @findex eo
2985 The @code{eo} request will compleatly disable the escape mechanism.
2986 The @code{ec} request can be used to change the escape character from
2987 the default @samp{\} to what is specified as an argument.
2989 @findex tr
2990 The @code{tr} request will translate characters.
2992 @findex trnt
2993 @findex \!
2994 @code{trnt}
2995 This is the same as the @code{tr} request except that the
2996 translations do not
2997 apply to text that is transparently throughput into a diversion with
2998 @code{\!}.  @xref{Diversions}, for more information.
2999 For example,
3001 @example
3002 .tr ab
3003 .di x
3004 \!.tm a
3007 @end example
3009 will print @samp{b}; if @code{trnt} is used instead of @code{tr} it
3010 will print @samp{a}.
3013 @node Line Layout, Page Layout, Character Translations, Programming Tutorial
3014 @section Line Layout
3015 @cindex line layout
3016 @cindex layout, line
3018 @cindex dimensions, line
3019 @cindex line dimensions
3020 The following drawing shows the dimensions which troff uses for
3021 placing a line of output onto the page.  They are labeled with the
3022 request which manipulates that dimension.
3024 @example
3025 @group
3026               | -->| in |<--                   |
3027            -->| po |<-----------ll------------>|
3028               +----+----+----------------------+----+
3029               |    :    :                      :    |
3030               +----+----+----------------------+----+
3031 @end group
3032 @end example
3034 These dimensions are:
3036 @ftable @code
3037 @item po
3038 @vindex .o
3039 @dfn{Page offset}--This is the leftmost postition of text on the final
3040 output.  This can be adjusted with the @code{po} request, and the
3041 current setting can be found in the built-in number register @code{.o}
3042 Note, that this request does not cause a break, so changing the page
3043 offset in the middle of text being filled may not do what you expect.
3044 @item in
3045 @vindex .i
3046 @dfn{Indentation}--This is the distance from the left margin where text
3047 will be printed.  This can be adjusted with the @code{in} request, and
3048 the current setting can be found in the built-in number register.
3049 @code{.i}
3050 This request causes a break.
3052 @findex ti
3053 @findex .in
3054 There is also the request @code{ti} which will cause one output line
3055 to be indented, after which the indentation returns to 0.
3056 This request causes a break.
3057 The number register @code{.in} is the indent that applies to the
3058 current output line.
3059 @item ll
3060 @findex .l
3061 @findex .ll
3062 @dfn{Line length}--This is the distance from the left margin to right
3063 margin.  This can be adjusted with the @code{.ll} request, and the
3064 current setting can be found in the built-in number register @code{.l}
3065 Note, as the figure implies, line length is not affected by the current
3066 indentation.
3067 The number register @code{.ll} is
3068 the line length that applies to the current output line.
3069 @end ftable
3071 @example
3072 .in +.5i
3073 .ll -.5i
3074 A bunch of really boring text which should
3075 be indented from both margins.
3076 replace me with a better (and more) example!
3077 .in -.5i
3078 .ll +.5i
3079 @end example
3082 @node Page Layout, Page Control, Line Layout, Programming Tutorial
3083 @section Page Layout
3084 @cindex page layout
3085 @cindex layout, page
3087 Troff provides some very primitive operations for controlling page
3088 layout.
3090 @findex pl
3091 @vindex .p
3092 Troff lets you specify the @dfn{page length} via the @code{pl} request.
3093 This is the length of the physical output page.
3094 The current setting can
3095 be found in the built-in number register @code{.p}.  Note that this only
3096 specifies the size of the page, not the not the top and bottom margins.
3097 Those are not done by groff directly, @xref{Traps}, for further
3098 information on how to do this.
3100 @cindex headers
3101 @cindex footers
3102 @cindex titles
3103 Troff provides several operations which help in setting up top and
3104 bottom titles (or headers and footers)
3106 @findex tl
3107 The @code{tl} request will print a @dfn{title line}, which consists
3108 of three parts: a left justified portion, a centered portion and a
3109 right justified portion.  The argument to @code{tl} is specified as
3110 @code{'@var{left}'@var{center}'@var{right}'}
3111 The @samp{%} character is replaced with the current page number.
3113 @findex lt
3114 @vindex .lt
3115 The title line is printed using its own line length, which is
3116 specified with the @code{lt} request.  The current setting of this is
3117 available in the @code{.lt} number register.
3119 @findex pn
3120 The @code{pn} request will change the page number of the @emph{next}
3121 page.  The only argument is the page number.
3123 @vindex %
3124 @vindex .pn
3125 The current page number is stored in the number register @code{%}.
3126 The number register @code{.pn} contains the
3127 number of the next page:
3128 either the value set by a @code{pn} request, or
3129 the number of the current page plus 1.
3131 @findex pc
3132 The @code{pc} request will change the page number character (used by
3133 the @code{tl} request) to a different character.  With no argument,
3134 this mechanism is disabled.
3137 @c distribute these through the text
3138 @xref{Traps}
3141 @node Page Control, Fonts, Page Layout, Programming Tutorial
3142 @section Page Control
3143 @cindex page control
3144 @cindex control, page
3146 @findex bp
3147 To stop processing the current page, and move to the next page, you
3148 can invoke the @code{bp} request.  This request will also cause a
3149 break.  This request can also take an argument of what the next page
3150 should be numbered.
3151 The only difference
3152 between @code{bp} and @code{pn} is that @code{pn} does not cause a
3153 break or actually eject a page.
3155 @example
3156 .de newpage
3158 'sp .5i
3159 .tl 'left top'center top'right top'
3160 'sp .3i
3162 @end example
3164 @cindex orphan
3165 @findex ne
3166 Often you may want to make sure that you have a certain amount of
3167 space before a new page occurs.  This is most useful to make sure
3168 that there is not a single @dfn{orphan} line left at the bottom of a
3169 page.  The @code{ne} request will ensure that there is a certain
3170 distance, specified by the first argument, before the next page is
3171 triggered (@pxref{Traps}, for further information).
3172 The default unit for @code{ne} is v's and the default argument
3173 is 1v.
3175 For example, to make sure that no fewer than 2 lines get orphaned,
3176 you can do the following before each paragraph.
3178 @example
3179 .ne 2
3180 .ti +5n
3181 text
3182 @end example
3184 @findex sv
3185 @findex os
3186 The @code{sv} is similar to the @code{ne} request, it reserves the
3187 specified amount of vertical space.  If the desired amount of space
3188 exists before the next trap (bottom page boundary), the space will be
3189 output immediately.  If there is not enough space, it is stored for
3190 later output via the @code{os} request.
3191 The default argument is 1v and the default units are v's.
3194 @node Fonts, Sizes, Page Control, Programming Tutorial
3195 @section Fonts
3196 @cindex fonts
3198 @findex ft
3199 @findex \f
3200 Groff gives you the ability to switch fonts at any point in your
3201 text.  There are two ways to do this, via the @code{ft} request and
3202 the @code{\f} escape.
3204 Fonts are generaly specified as upper-case strings, which are usually
3205 1 to 4 characters representing an abreviation of acronym of the font
3206 name.
3208 The basic set of fonts are R, I, B, and BI.  These are Times Roman,
3209 Italic, Bold, and Bold Italic.  There is also at least one symbol
3210 font which contains various special symbols (greek, mathematics).
3211 These latter fonts cannot be used directly, but should be used via an
3212 escape.
3214 @menu
3215 * Changing Fonts::              
3216 * Font Families::               
3217 * Font Positions::              
3218 * Using Symbols::               
3219 * Artificial Fonts::            
3220 * Ligatures and Kerning::       
3221 @end menu
3223 @node Changing Fonts, Font Families, Fonts, Fonts
3224 @subsection Changing Fonts
3225 @cindex changing fonts
3226 @cindex fonts, changing
3228 @findex ft
3229 You can change fonts with both the @code{ft} request.
3230 With no arguments it
3231 will switch to the previous font (also known as P).
3233 @example
3234 eggs, bacon,
3235 .ft B
3236 spam
3238 and sausage.
3239 @end example
3241 @findex \f
3242 The @code{\f} escape is useful for changing fonts in the middle of words
3244 @example
3245 eggs, bacon, \fBspam\fP and sausage.
3246 @end example
3248 Both of the above examples will produce the same output.
3250 Sometimes when putting letters of different fonts, you need more or
3251 less space at such boundaries.  There are two escapes to help with
3252 this.
3254 @findex \/
3255 The @code{\/} escape
3256 increases the width of the preceding character so that the spacing
3257 between that character and the following character will be correct if
3258 the following character is a roman character.  For example, if an italic
3259 f is immediately followed by a roman right parenthesis,  then in many
3260 fonts the top right portion of the f will overlap the top left of the
3261 right parenthesis.
3262 It is a good idea to use this escape sequence
3263 whenever an italic character is immediately followed by a roman
3264 character without any intervening space.
3266 @c producing @i{f}), which is ugly.  Inserting \/ produces f) and avoids this problem.
3268 @findex \,
3269 The @code{\,} escape
3270 modifies the spacing of the following character so that the spacing
3271 between that character and the preceding character will correct if the
3272 preceding character is a roman character.
3273 It is a good idea
3274 to use this escape sequence whenever a roman character is immediately
3275 followed by an italic character without any intervening space.
3277 @c For example, inserting \, between the parenthesis and the f changes (f to (f.
3279 @findex ftr
3280 The @code{ftr} request will translate fonts, it is called as
3281 @samp{.ftr @var{F G}}, which
3282 Translate font @var{F} to @var{G}.
3283 Whenever a font named @var{F} is referred to in @code{\f}
3284 escape sequence,
3285 or in the @code{ft}, @var{ul}, @var{bd}, @var{cs}, @var{tkf},
3286 @var{special}, @var{fspecial}, @var{fp},
3287 or @var{sty} requests, font @var{G} will be used.  If @var{G} is
3288 missing, or equal to @var{F} then font @var{F} will not be translated.
3291 @node Font Families, Font Positions, Changing Fonts, Fonts
3292 @subsection Font Families
3293 @cindex font families
3294 @cindex families, font
3296 Due to the variety of fonts available, groff has added the concept of
3297 font families.  Each of these families has four styles (R, I, B and BI),
3299 The fonts are specified as the concatenation of the font family and
3300 style.  Specifying a font without the family part will cause groff to
3301 use that style of the current family.
3302 By default, groff uses the Times family.
3304 This way, you can just use the basic four fonts and select a
3305 different font family on the command line.
3307 @findex fam
3308 @vindex .fam
3309 You can also switch font families with the @code{fam} request
3310 The current font family is available in the number register
3311 @code{.fam}.
3312 This is a string-valued register.
3314 @example
3315 spam,
3316 .fam H
3317 spam,
3318 .ft B
3319 spam,
3320 .fam T
3321 spam,
3322 .ft AR
3323 baked beans,
3324 .ft R
3325 and spam.
3326 @end example
3328 @node Font Positions, Using Symbols, Font Families, Fonts
3329 @subsection Font Positions
3330 @cindex font positions
3331 @cindex positions, font
3333 For the sake of old phototypesetters and compatability with old
3334 versions of troff, groff has the concept of font
3335 @dfn{positions}, on which various fonts are mounted.
3336 The last one or two are reserved for the symbol font(s).
3338 @findex fp
3339 New fonts can be mounted with the @code{fp} request.
3340 These numeric positions can then be referred to with font changing commands.
3341 When groff starts it is using font number one.
3343 @example
3344 .fp 1 H
3345 .fp 2 HI
3346 .fp 3 HB
3347 wink, wink,
3348 .ft 2
3349 nudge, nudge,
3351 .ft 3
3352 say no more!
3354 @end example
3356 (note that after these font changes have taken place the original
3357 font is restored.)
3359 @vindex .f
3360 The current font in use, as a font position.
3361 This can be useful to remember the current font, for later recall.
3363 @example
3364 .nr save-font \n(.f
3365 ... lots 'o text ...
3366 .ft \n[save-font]
3367 @end example
3369 @vindex .fp
3370 The number of the next free font position is available in the number
3371 register @code{.fp}.  This is useful when mounting a new font, like so:
3373 @example
3374 .fp \n[.fp] NEATOFONT
3375 @end example
3377 @pindex DESC
3378 Fonts not listed in the @file{DESC} file are automatically mounted on
3379 the next available font position when they are referenced.
3380 If a font is to be
3381 mountfed explicitly with the @code{fp} request on an unused font position, it
3382 should be mounted on the first unused font position, which can be found
3383 in the @code{.fp} register; although troff does not enforce this strictly,
3384 it will not allow a font to be mounted at a position whose number is
3385 much greater than that of any currently used position.
3387 The @code{fp} request has an optional third argument.
3388 This argument gives the
3389 external name of the font, which is used for finding the font
3390 description file.  The second argument gives the internal name of the
3391 font which is used to refer to the font in troff after it has been
3392 mounted.  If there is no third argument then the internal name will be
3393 used as the external name.  This feature allows you to use fonts with
3394 long names in compatibility mode.
3396 @node Using Symbols, Artificial Fonts, Font Positions, Fonts
3397 @subsection Using Symbols
3398 @cindex using symbols
3399 @cindex symbols, using
3401 @findex \(
3402 @findex \[
3403 Symbols can be inserted by using a special escape sequence.
3404 This escape is simply the escape character (a backslash) followed by
3405 an identifier.  The symbol identifiers have to be two or more
3406 characters, since single characters conflict with all the other
3407 escapes.  The identifier can be either preceded by a parenthesis if
3408 it is two character, or surrounded by square brackets.
3409 So, the symbol for pi can be produced either by @code{\(*p} or
3410 @code{\[*p]}.
3412 @example
3413 area = \(*p\fIr\fP\u2\d
3414 @end example
3416 @findex \C
3417 The escape @code{\C'@var{xxx}'} will typeset character named
3418 @var{xxx}.  Normally it is more convenient to use @code{\[@var{xxx}]}.
3419 But @code{\C} has the advantage that it is compatible with recent
3420 versions of ditroff and is available in compatibility mode.
3422 @findex \N
3423 The escape @code{\N'@var{n}'} will typeset the character with code
3424 @var{n} in the current font.  @var{n} can be any integer.  Most devices only
3425 have characters with codes between 0 and 255.  If the current font
3426 does not contain a character with that code, special fonts will not be
3427 searched.  The @code{\N} escape sequence can be conveniently used on
3428 conjunction with the @code{char} request:
3430 @example
3431 .char \[phone] \f(ZD\N'37'
3432 @end example
3434 The code of each character is given in the fourth column in the font
3435 description file after the charset command.  It is possible to include
3436 unnamed characters in the font description file by using a name of
3437 @samp{---}; the @code{\N} escape sequence is the only way to use these.
3439 @findex cflags
3440 Each character has certain properties associated with it.
3441 These properties can be modified with the @code{cflags} request.
3442 The first argument is the the sum of the desired flags and the
3443 remaining arguments are the characters to have those properties.
3444 @table @code
3445 @item 1
3446 the character ends sentences (initially characters @samp{.?!} have this
3447 property);
3448 @item 2
3449 lines can be broken before the character (initially no characters have
3450 this property);
3451 @item 4
3452 lines can be broken after the character (initially characters
3453 @samp{-\(hy\(em} have this property);
3454 @item 8
3455 the character overlaps horizontally (initially characters
3456 @samp{\(ul\(rn\(ru} have this property);
3457 @item 16
3458 the character overlaps vertically (initially character @samp{\(br} has
3459 this property);
3460 @item 32
3461 an end of sentence character followed by any number of characters with
3462 this property will be treated as the end of a sentence if followed by a
3463 newline or two spaces; in other words the character is transparent for
3464 the purposes of end of sentence recognition; this is the same as having
3465 a zero space factor in @TeX{} (initially characters
3466 @samp{"')]*\(dg\(rq} have this property).
3467 @end table
3469 @findex char
3470 You can create new characters with the @code{char} request.  It is
3471 called as @samp{.char @var{c} @var{string}} Define character @var{c}
3472 to be @var{string}. Every time character @var{c} needs to be printed,
3473 @var{string} will be processed in a temporary environment and the
3474 result will be wrapped up into a single object.  Compatibility mode
3475 will be turned off and the escape character will be set to \ while
3476 @var{string} is being processed.  Any emboldening, constant spacing or
3477 track kerning will be applied to this object rather than to individual
3478 characters in @var{string}.  A character defined by this request can
3479 be used just like a normal character provided by the output device.
3480 In particular other characters can be translated to it with the
3481 @code{tr} request; it can be made the leader character by the
3482 @code{lc} request; repeated patterns can be drawn with the character
3483 using the @code{\l} and @code{\L} escape sequences;  words containing
3484 the character can be hyphenated correctly, if the @code{hcode} request
3485 is used to give the character a hyphenation code. There is a special
3486 anti-recursion feature: use of character within the character's
3487 definition will be handled like normal characters not defined with
3488 @code{char}.
3490 @findex rchar
3491 A character definition can be removed with the @code{rchar} request.  Its
3492 arguments are the characters to be removed.  This undoes the effect of
3493 a @code{char} request.
3495 @c distribute these through the text
3496 @xref{Special Characters}
3498 @node Artificial Fonts, Ligatures and Kerning, Using Symbols, Fonts
3499 @subsection Artificial Fonts
3500 @cindex artificial fonts
3501 @cindex fonts, artificial
3503 There are a number of requests for artificially creating fonts.
3504 These are largely vestigal remains from the days when output devices
3505 did not have a wide variety of fonts, and when nroff and troff were
3506 separate programs.
3507 These are no longer necessary in GNU Troff.
3509 @findex ul
3510 The @code{ul} request will print subsequent lines in italics on a device
3511 capable of it, or underline the text on an character output device.  The
3512 single argument is the number of lines to be ``underlined,'' with no
3513 argument, the next line will be underlined.
3515 @findex cu
3516 The @code{cu} request is similar to @code{ul} ...
3518 @findex uf
3519 The @code{uf} request will set the underline font used by @code{ul}
3520 and @code{cu}.
3522 @findex bd
3523 The @code{bd} request artificially creates a bold font by printing
3524 each character twice, slightly offset.
3525 The first argument specifies the font to embolden, and the second is
3526 the number of basic units, minus one, by which the two characters
3527 will be offset.  If the second argument is missing, emboldening will
3528 be turned off.
3530 @node Ligatures and Kerning,  , Artificial Fonts, Fonts
3531 @subsection Ligatures and Kerning
3532 @cindex ligatures and kerning
3533 @cindex kerning and ligatures
3535 @findex lg
3536 @vindex .lg
3537 @code{lg}
3538 @code{.lg}
3539 The current ligature mode.
3541 What is kerning??
3543 If the font description file contains pairwise kerning information,
3544 characters from that font will be kerned.  Kerning between two
3545 characters can be inhibited by placing a @code{\&} between them.
3547 @findex kern
3548 @vindex .kern
3549 @code{kern}
3550 If n is non-zero or missing, enable pairwise kerning, otherwise disable
3552 @code{.kern}
3553 1 if pairwise kerning is enabled, 0 otherwise.
3555 @findex tkf
3556 .tkf f s1 n1 s2 n2
3557 Enable track kerning for font f.  When the current font is f the width
3558 of every character will be increased by an amount between n1 and n2;
3559 when the current point size is less than or equal to s1 the width will
3560 be increased by n1; when it is greater than or equal to s2 the width
3561 will be increased by n2; when the point size is greater than or equal to
3562 s1 and less than or equal to s2 the increase in width is a linear
3563 function of the point size.
3566 @node Sizes, Strings, Fonts, Programming Tutorial
3567 @section Sizes
3568 @cindex sizes
3570 @cindex baseline
3571 Groff uses two dimensions with each line of text, type size and
3572 vertical spacing.  The type size is the height from the text
3573 @dfn{baseline} to the top of the tallest character (decenders may drop
3574 below this baseline).  Vertical spacing is the amount of space groff
3575 allows for a line of text, normally, this is about 20% larger than the
3576 current type size.  Ratios smaller than this can result in
3577 hard-to-read text, larger that this, it will spread your text out more
3578 vertically (useful for term papers).  By default, troff uses 10 point
3579 type on 12 point spacing.
3581 @cindex leading
3582 The difference between type size and vertical spacing is known, by
3583 typesetters, as @dfn{leading}.
3585 @menu
3586 * Changing Type Sizes::         
3587 * Fractional Type Sizes::       
3588 @end menu
3590 @node Changing Type Sizes, Fractional Type Sizes, Sizes, Sizes
3591 @subsection Changing Type Sizes
3592 @cindex changing type sizes
3593 @cindex type sizes, changing
3595 @findex ps
3596 @findex vs
3597 @findex \s
3598 @vindex .s
3599 @vindex .v
3600 Using the @code{ps} request and the @code{\s} escape you can change
3601 the type size.  The @code{vs} request will change the vertical
3602 spacing. The default unit for the @code{ps} and @code{vs} requests are
3603 points.
3604 The number registers @code{.s} and @code{.v} contain the current
3605 type size and vertical spacing.
3607 These requests take parameters in units of points.  You can specify
3608 sizes as an absolute size, or as a relative change from the current
3609 size.  The size 0 means go back to the previous size.  With no
3610 argument it will revert to the previous size.
3612 @example
3613 snap, snap,
3614 .ps +2
3615 grin, grin,
3616 .ps +2
3617 wink, wink, \s+2nudge, nudge,\s+8 say no more!
3618 .ps 10
3619 @end example
3621 The @code{\s} escape may be called in a variety of ways.
3622 Much like other escapes there must be a way to determine where the
3623 argument ends and the text begins.
3624 Any of the following forms are valid:
3625 @code{\s@var{n}},
3626 @code{\s+@var{n}},
3627 @code{\s-@var{n}},
3628 @code{\s(@var{nn}},
3629 @code{\s+(@var{nn}},
3630 @code{\s-(@var{nn}},
3631 @code{\s[+@var{nnn}]},
3632 @code{\s[-@var{nnn}]},
3633 @code{\s+[@var{nnn}]},
3634 @code{\s-[@var{nnn}]}.
3636 Some devices may only have certain permissible sizes, in which case
3637 groff will round to the nearest permissible size.
3639 @example
3640 ... .sz macro example?? ...
3641 @end example
3643 @node Fractional Type Sizes,  , Changing Type Sizes, Sizes
3644 @subsection Fractional Type Sizes
3645 @cindex fractional type sizes
3646 @cindex type sizes, fractional
3648 @cindex @code{s} unit
3649 @cindex unit, @code{s}
3650 @cindex @code{z} unit
3651 @cindex unit, @code{z}
3652 A @dfn{scaled point} is equal to 1/@var{sizescale} points, where
3653 @var{sizescale} is specified in the @file{DESC} file (1 by default.)
3654 There is a new scale indicator @samp{z} which has the effect of
3655 multiplying by @var{sizescale}.  Requests and escape sequences in
3656 troff interpret arguments that represent a pointsize as being in units
3657 of scaled points, but they evaluate each such argument using a default
3658 scale indicator of @samp{z}.  Arguments treated in this way are the
3659 argument to the @code{ps} request, the third argument to the @code{cs}
3660 request, the second and fourth arguments to the @code{tkf} request,
3661 the argument to the @code{\H} escape sequence, and those variants of
3662 the @code{\s} escape sequence that take a numeric expression as their
3663 argument.
3665 For example, suppose @var{sizescale} is 1000; then a scaled point will be
3666 equivalent to a millipoint; the request @samp{.ps 10.25} is equivalent to
3667 @samp{.ps 10.25z} and so sets the pointsize to 10250 scaled points, which is
3668 equal to 10.25 points.
3670 The number register @code{\n(.s} returns the pointsize in points as
3671 decimal fraction.  There is also a new number register @code{\n[.ps]}
3672 that returns the pointsize in scaled points.
3674 It would make no sense to use the @samp{z} scale indicator in a
3675 numeric expression whose default scale indicator was neither @samp{u}
3676 nor @samp{z}, and so troff disallows this.  Similarily it would make
3677 no sense to use a scaling indicator other than @samp{z} or @samp{u} in a
3678 numeric expression whose default scale indicator was @samp{z}, and so
3679 troff disallows this as well.
3681 There is also new scale indicator @samp{s} which multiplies by the
3682 number of units in a scaled point.  So, for example, @samp{\n[.ps]s}
3683 is equal to 1m.  Be sure not to confuse the @samp{s} and @samp{z}
3684 scale indicators.
3686 @code{\s'+@var{n}'}
3687 @code{\s'-@var{n}'}
3688 @code{\s+'@var{n}'}
3689 @code{\s-'@var{n}'}
3690 Set the point size to @var{n} scaled points; @var{n} is a numeric
3691 expression with a default scale indicator of @samp{z}.
3693 @code{\n[.ps]}
3694 The current pointsize in scaled points.
3696 @code{\n[.psr]}
3697 The last-requested pointsize in scaled points.
3699 @code{\n[.sr]}
3700 The last requested pointsize in points as a decimal fraction.  This is a
3701 string-valued register.
3704 @c distribute these through the text
3705 @xref{Font Files}
3708 @node Strings, Conditionals and Loops, Sizes, Programming Tutorial
3709 @section Strings
3710 @cindex strings
3712 @findex ds
3713 Groff has string variables, which are entirely for user convenience
3714 (i.e. there are no built-in strings).  They are defined via the
3715 @code{ds} request.
3717 @example
3718 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d
3719 @end example
3721 @findex \*
3722 They are interpolated, or expanded in-place, via the @code{\*} escape:
3724 @example
3725 The \*(UX Operating System
3726 @end example
3728 Will produce:
3730 @example
3731 The UNIXtm Operating System
3732 @end example
3734 If the string named by the @code{\*} does not exist, the escape will
3735 be replaced by nothing.
3737 @cindex comments, with @code{ds}
3738 NOTE:  Unlike other requests the third argument takes up the entire
3739 line including trailing spaces.  This means that comments on a line
3740 with such a request can introduce unwanted space into a string.
3742 @example
3743 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d \" trademark of you-know-who
3744 @end example
3746 Instead you should either put the comment on another line or
3747 have the comment escape adjacent with the end of the string.
3749 @example
3750 .ds UX \s-1UNIX\s0\u\s-3tm\s0\d\"  trademark of you-know-who
3751 @end example
3753 If you need leading space you can start the string with a double
3754 quote.  No trailing quote is needed, in fact any trailing quote is
3755 included in your string.
3757 @cindex canibalism
3758 @example
3759 .ds sign "           Yours in a white wine sauce,
3760 @end example
3762 @findex as
3763 @cindex appending to strings
3764 @cindex strings, appending
3765 You can also append onto a string with the @code{as} request.
3766 It works the same as the @code{ds} request except that it appends the
3767 second argument onto the string named by the first argument.
3769 @example
3770 .as sign " with shallots, onions and garlic,
3771 @end example
3773 @findex \@key{ret}
3774 Strings are not limited to a sigle line of text.  A string can span
3775 several lines by escaping the newlines with a backslash.  The
3776 resulting string will be stored @emph{without} the newlines.
3778 @example
3779 .ds foo lots and lots \
3780 of text are on these \
3781 next several lines
3782 @end example
3784 @findex substring
3785 @cindex substrings
3786 @code{.substring xx n1 [n2]}
3787 Replace the string in register@w{ }xx with the substring defined by the
3788 indices n1 and@w{ }n2.  The first character in the string has index one.
3789 If n2 is omitted, it is taken to be equal to the string's length.  If
3790 the index value n1 or n2 is negative or zero, it will be counted from
3791 the end of the string, going backwards: The last character has index@w{
3792 }0, the character before the last character has index@w{ }-1, etc.
3794 @findex length
3795 @cindex length of a string
3796 @cindex string, length of
3797 @code{.length xx string}
3798 Compute the length of string and return it in the number register@w{ }xx
3799 (which is not necessarily defined before).
3801 @findex rn
3802 @code{rn}
3804 @findex rm
3805 @code{rm}
3807 @findex als
3808 @code{als}
3810 @findex chop
3811 @code{chop}
3813 @c distribute these through the text
3814 @xref{Identifiers}
3815 @c distribute these through the text
3816 @xref{Comments}
3819 @node Conditionals and Loops, Writing Macros, Strings, Programming Tutorial
3820 @section Conditionals and Loops
3821 @cindex conditionals and loops
3822 @cindex loops and conditionals
3824 @findex if
3825 @findex while
3826 In @code{if} and @code{while} requests, there are several more operators
3827 available:
3829 @table @code
3830 @item e
3831 @itemx o
3832 True if the current page is even or odd numbered (respectively)
3833 @item n
3834 @itemx t
3835 True if the document is being processed by
3836 nroff (or a character device) or troff.
3837 @item '@var{xxx}'@var{yyy}'
3838 True if the string @var{xxx} is equal to the string @var{yyy}.
3839 Other characters can be used in place of the single quotes.
3840 (Which?)
3841 The strings are `formatted' before being compared. (?)
3842 @item r@var{xxx}
3843 True if there is a number register named @var{xxx}.
3844 @item d@var{xxx}
3845 True if there is a string, macro, diversion, or request named @var{xxx}.
3846 @item c@var{ch}
3847 True if there is a character @var{ch} available;  @var{ch} is
3848 either an @sc{ascii} character or a special character @code{\(@var{ch}} or
3849 @code{\[@var{ch}]}; the condition will also be true if @var{ch} has been
3850 defined by the @code{char} request.
3851 @end table
3853 @menu
3854 * if-else::                     
3855 * while::                       
3856 @end menu
3858 @node if-else, while, Conditionals and Loops, Conditionals and Loops
3859 @subsection if-else
3860 @cindex if-else
3862 Troff has if-then-else constructs like other languages, although
3863 the formatting can be painful.
3865 @findex if
3866 The @code{if} request is troff's if statement, it is called as
3867 @samp{.if @var{expr} @var{anything}}, where @var{expr} is the
3868 expression to be evaluated,
3869 and @var{anything} (the remainder of the line)
3870 which will be executed if
3871 the @var{expr} evaluates to non-zero (true).
3872 @var{anything} will be interpreted as though it was on a line by
3873 itself.
3874 @xref{Expressions}, for more info.
3876 Here are some examples:
3878 @example
3879 .if t .ls 2                             \" double spacing in troff
3880 .if 0 .ab how'd this happen??
3881 @end example
3883 @findex ie
3884 @findex el
3885 An if-then-else is written using two requests @code{ie} and @code{el}
3886 the first request is the if part and the latter is the else part.
3888 @example
3891 @end example
3893 @findex \@{
3894 @findex \@}
3895 In many cases you will want more than one request to be executed as a
3896 result of any of these requests, this can be done using the \@{ and
3897 \@} escapes.
3898 The following example shows the possible ways to use these escapes.
3900 @example
3901 .ie t \@{\
3902 .    ds lq ``
3903 .    ds rq ''
3904 .\@}
3905 .el \
3906 .\@{\
3907 .    ds lq "
3908 .    ds rq "\@}
3909 .ds qq "
3910 @end example
3913 @c distribute these through the text
3914 @xref{Expressions}
3916 @node while,  , if-else, Conditionals and Loops
3917 @subsection while
3918 @cindex while
3920 @findex while
3921 Groff provides a looping construct using the @code{while} request,
3922 which is used much like the @code{if} (and related) requests.
3923 The first argument is an expression which will be evaluated.
3924 The @code{while} request will interpret the remainder of the line
3925 until the expression evaluates to 0 or false.
3927 @example
3928 .nr a 0 1
3929 .while (\na<9) \&\n+a,
3930 \&\n+a
3931 @end example
3933 The preceding example produces:
3935 @example
3936 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
3937 @end example
3939 @findex break
3940 @findex continue
3941 The @code{break} request will
3942 @dfn{break} out of a while loop.
3943 Be sure not to confuse this with the @code{.br} request.
3944 The @code{continue} request will
3945 finish the current iteration of a while loop.
3947 @c distribute these through the text
3948 @xref{Expressions}
3951 @node Writing Macros, Page Motions, Conditionals and Loops, Programming Tutorial
3952 @section Writing Macros
3953 @cindex writing macros
3954 @cindex macros, writing
3956 @findex de
3957 A macro is a collection of text and embedded commands which can be
3958 invoked multiple times.  Macros are used for defining common operations.
3959 Macros are defined using the @code{de} request.  This request takes
3960 a name for the macro as the first argument.  Subsequent lines are
3961 copied into an internal buffer until the line @code{..} is
3962 encountered.  The optional second argument to @code{de} can change
3963 this ending token.
3965 For example, suppose at the beginning of each paragraph, you want
3966 cause a break, move down a partial line and indent the first line.
3967 Such a macro could be defined as follows:
3969 @example
3970 .de P
3972 .sp .8v
3974 @end example
3976 @findex am
3977 The @code{am} request works similarily to @code{de} except it appends
3978 onto the macro named by the first argument.  So, if we decide we want
3979 our previously @code{P} macro to actually do indented instead of
3980 block paragraphs we can add the necessary code to our existing macro.
3982 @example
3983 .am P
3984 .ti +5n
3986 @end example
3988 @findex als
3989 @cindex aliases, macro
3990 @cindex macro aliases
3991 Macros can be aliased with the @code{als} request.
3993 @findex rn
3994 @code{rn}
3996 @findex rm
3997 @code{rm}
3999 @findex chop
4000 @code{chop}
4002 @menu
4003 * Copy-in Mode::                
4004 * Parameters::                  
4005 @end menu
4007 @node Copy-in Mode, Parameters, Writing Macros, Writing Macros
4008 @subsection Copy-in Mode
4009 @cindex copy-in mode
4010 @cindex mode, copy-in
4012 @findex \n
4013 @findex \$
4014 @findex \*
4015 @findex \\
4016 @findex \@key{RET}
4017 When troff reads in the test for a macro or diversion it copies the
4018 text (including request lines) into an internal buffer, except for
4019 escapes.  Escapes will be converted into an internal form, except for
4020 @code{\n}, @code{\$}, @code{\*}, @code{\\} and @code{\@key{RET}} which
4021 are evaluated and inserted into the text where the escape was located.
4022 This is known as @dfn{copy-in} mode.
4024 What this means is that you can specify when these escapes are to be
4025 evaluated (copy-in time or time of use) by insulating the escapes
4026 with an extra backslash.
4028 For example, the following will result in the numbers 20 and 10 being
4029 printed.
4031 @example
4032 .nr x 20
4033 .de y
4034 .nr x 10
4035 \&\nx
4036 \&\\nx
4039 @end example
4041 @node Parameters,  , Copy-in Mode, Writing Macros
4042 @subsection Parameters
4043 @cindex parameters
4045 @findex \$
4046 @vindex .$
4047 The arguments to a macro can be examined using a variety of escapes.
4048 The number of arguments is available in the @code{.$} number register.
4049 Any individual argument can be retrieved with one of the following
4050 escapes:
4052 The escapes @code{\$@var{n}}, @code{\$(@var{nn}}
4053 and @code{\$[@var{nnn}]}
4054 will result in the @var{n}th, @var{nn}th or @var{nnn}th
4055 argument.  Macros can have a unlimited number of arguments.
4056 Note that due to copy-in mode, you will want to have two backslashes
4057 on these in actual use, since you do not want them interpolated until
4058 the macro is actually invoked.
4060 @findex shift
4061 The request @code{shift} will shift the arguments 1 position, or as
4062 many positions as specified by the first argument.
4063 After executing this request, argument
4064 @var{i} will become argument @var{i}-@var{n}; arguments 1 to @var{n}
4065 will no longer be available.
4066 Shifting by negative amounts is currently undefined.
4068 @findex \$*
4069 @findex \$@@
4070 In some cases you will want to just use all of the arguments at once.
4071 For example if you pass the arguments along to another macro.
4072 The @code{\$*} escape is
4073 the concatenation of all the arguments separated by spaces.
4074 A similar escape is @code{\$@@},
4075 which is
4076 the concatenation of all the arguments with each surrounded
4077 by double quotes, and separated by spaces.
4079 @findex \$0
4080 @findex als
4081 The @code{\$0} escape is 
4082 the name by which the current macro was invoked.  The @code{als}
4083 request can make a macro have more than one name.
4085 @example
4086 .de vl
4087 .ie \\n(.$=1 .ds Vl Pre-Release Version
4088 .el          .ds Vl Version \\$3, \\$4.
4090 @end example
4092 This would be called as
4094 @example
4095 .vl $Id$
4096 @end example
4099 @c distribute these through the text
4100 @xref{Request Arguments}
4103 @node Page Motions, Drawing Functions, Writing Macros, Programming Tutorial
4104 @section Page Motions
4105 @cindex page motions
4106 @cindex motions, page
4108 @findex sp
4109 Motions up and down the page can be done with the @code{sp} request.
4110 However, this causes a break so that the actual effect is to move to
4111 the left margin and then to the specified location.
4113 @findex mk
4114 @findex rt
4115 The request @code{mk} can be used to mark a location on a page, for
4116 movement to later.  This request takes a register name as an
4117 argument in which to store the current page location, with no
4118 argument it will store the location in an internal register.
4119 The results of this can be used later by the @code{rt} or the
4120 @code{sp} request.  The @code{rt} request will return
4121 @strong{upwards} to the location given in the register name given as
4122 an argument, with no argument it will return to the location marked
4123 with the @code{mk} request
4125 @example
4126 ... dual column example ...
4127 @end example
4129 There are escapes which will give you much finer control of movements
4130 about the page.
4132 @findex \v
4133 The @code{\v'@var{e}'} will let you do arbitrary vertical motion from
4134 the current location on the page.  The argument @var{e} specifies the
4135 distance to move, positive is downwards and negative upwards.  The
4136 default unit for this escape is vertical spaces, @code{v}'s.  Beware,
4137 however, that troff will leave text processing to continue wherever
4138 the motion ends, so if you don't want to interfere with text
4139 processing, make sure your motions are balanced.
4141 There are some special case escapes for vertical motion.
4143 @ftable @code
4144 @item \r
4145 move upwards 1v.
4146 @item \u
4147 move upwards .5v.
4148 @item \d
4149 move down .5v.
4150 @end ftable
4152 @findex \h
4153 Horizontal motions can be done via the @code{\h'@var{e}'} escape.
4154 The expression @var{e} indicates how far to move: positive is
4155 rightwards and negative leftwards.
4157 There are a number of special case escapes for horizontal motion:
4159 @ftable @code
4160 @item \@key{SP}
4161 An unbreakable and unpadable (i.e. not expanded during filling) space.
4162 (Note: it is a backslash followed by a space.)
4163 @item \~
4164 This produces an unbreakable space that stretches like a normal
4165 interword space when a line is adjusted.
4166 @item \|
4167 a 1/6th em space.
4168 @item \^
4169 a 1/12th em space.
4170 @item \0
4171 a space the size of a digit.
4172 @item \&
4173 A zero width space.
4174 @item \)
4175 Like @code{\&} except that it behaves like a character declared with
4176 the @code{cflags} request to be transparent for the purposes of end
4177 of sentence recognition.
4178 @end ftable
4180 @example
4181 ... tex logo example ...
4182 @end example
4184 @findex \w
4185 @cindex width escape
4186 @cindex escape, width
4187 Often you will want to do horizontal movement based on the width of
4188 some arbitrary text (e.g. given as an argument to a macro).
4189 For that, there is the escape @code{\w'@var{text}'} which will
4190 interpolate to the width of the given @var{text} in basic units.
4192 @example
4193 ... strlen example ...
4194 @end example
4196 Font changes may occur in @var{text} and not affect current settings.
4198 Also after use, @code{\w} sets several registers:
4200 @table @code
4201 @item st
4202 @vindex st
4203 @itemx sb
4204 @vindex sb
4205 The highest and lowest point, respectively, in @var{text}.
4206 @item rst
4207 @vindex rst
4208 @itemx rsb
4209 @vindex rsb
4210 Like the @code{st} and @code{sb} registers, but takes account of the
4211 heights and depths of characters.
4212 @item ct
4213 @vindex ct
4214 is set according to what kinds of characters occur in @var{text}.
4215 @table @asis
4216 @item 0
4217 all short characters, no decenders or tall characters.
4218 @item 1
4219 decender
4220 @item 2
4221 tall character
4222 @item 3
4223 both a decender and a tall character
4224 @end table
4225 @item ssc
4226 @vindex ssc
4227 The amount of horizontal space (possibly negative) that should be
4228 added to the last character before a subscript.
4229 @item skw
4230 @vindex skw
4231 How far to right of the center of the last character in the @code{\w}
4232 argument, the center of an accent from a roman font should  be
4233 placed over that character.
4234 @end table
4236 @findex \k
4237 @vindex .k
4238 @code{\k}
4239 @code{.k}
4242 @node Drawing Functions, Traps, Page Motions, Programming Tutorial
4243 @section Drawing Functions
4244 @cindex drawing functions
4245 @cindex functions for drawing
4247 Groff provides a number of ways to draw lines, and other figures on
4248 the page.  Used in combination with the page motion commands
4249 (@pxref{Page Motions}, for more info) you can draw a wide variety of
4250 figures.  However, for complex drawings these operations can be quite
4251 cumbersome, and it may be wise to use the pic preprocessor.
4252 @xref{gpic}, for more information.
4254 All drawing is done via escapes.
4256 @findex \l
4257 The @code{\l} will draw a line rightwards from the current location.
4258 The full syntax for this escape is @samp{\l'@var{l}@var{c}'}, where
4259 @var{l} is the length of the line to be drawn, starting at the
4260 current location, positive numbers will draw to the right, and
4261 negative will draw towards the left.  This can also be specified
4262 absolutely (i.e. with a leading |) which will draw back to the
4263 begining of the line.
4265 The optional second parameter @var{c} is a character to draw the line
4266 with.  If this second argument is not specified, troff will use the
4267 underscore character.
4269 If you need to separate the two arguments (to prevent troff from
4270 interpreting a drawing character as a scaling indicator), you can
4271 separate them with @code{\&}.
4273 And now, for a useful example:
4275 @example
4276 .de box
4277 \(br\\$*\(br\l'|0\(rn'\l'|0\(ul'
4279 @end example
4281 Note that this works by outputing a box rule (a vertical line), then
4282 the text given as an argument and then another box rule.
4283 Then the line drawing escapes both draw from the current location to
4284 the beginning of the @emph{input} line.
4286 @findex \L
4287 Vertical lines are drawn using the @code{\L} escape.  It's parameters
4288 are specified the same as the @code{\l} escape.  If the length is
4289 positive, the movement will be downwards, and upwards for negative.
4290 The default character is the box rule character.
4291 As with the vertical motion escapes, text processing will blindly
4292 continue where the line ends.
4294 @example
4295 ...box macro...
4296 @end example
4298 @findex \D
4299 More flexible drawing functions are available via the @code{\D}
4300 escape.  While the previous escapes will work on a character device,
4301 these escapes will not.
4303 @table @code
4304 @item \D'l @var{x} @var{y}'
4305 Draw a line from the current location to the relative point specified
4306 by @var{x}, @var{y}.
4308 @example
4309 ...revised box macro...
4310 @end example
4312 @item \D'c @var{d}'
4313 Draw a circle with a diameter of @var{d} with the leftmost point at
4314 the current position.
4315 @item \D'C @var{d}'
4316 Draw a solid circle with the same parameters as an outlined circle.
4317 @item \D'e @var{dx} @var{dy}'
4318 Draw an ellipse with a horizontal diameter of @var{dx} and a vertical
4319 diameter of @var{dy} with the leftmost point at the current position.
4320 @item \D'E @var{dx} @var{dy}'
4321 Draw a solid elipse with the same parameters as an outlined elipse.
4322 @item \D'a @var{dx1} @var{dy1} @var{dx2} @var{dy2}'
4323 Draw an arc clockwise from the current location through the two
4324 specified locations.
4325 @item \D'~ @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4326 Draw a spline from the current location to
4327 @var{dx1}, @var{dy1} and then to @var{dx2}, @var{dy2}, and so on.
4328 @item \D'f @var{n}'
4329 Set the shade of gray to be used for filling solid objects to @var{n};
4330 @var{n} must be an integer between 0 and 1000, where 0 corresponds
4331 solid white and 1000 to solid black, and values in between correspond
4332 to intermediate shades of gray.  This applies only to solid circles,
4333 solid ellipses and solid polygons.  By default, a level of 1000 will
4334 be used.
4335 @item  \D'p @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4336 Draw a polygon from the current location to @var{dx1}, @var{dy1}
4337 and then to @var{dx2}, @var{dy2} and so on.  When the specified data
4338 points are exhausted, a line is drawn back to the starting point.
4340 @example
4341 ... box example (yes, again)...
4342 @end example
4344 @itemx \D'P @var{dx1} @var{dy1} @var{dx2} @var{dy2} ...'
4345 Draw a solid polygon with the same parameters as an outlined polygon.
4347 @example
4348 ... shaded box example ...
4349 @end example
4351 @item \D't @var{n}'
4352 Set the current line thickness to @var{n} machine units.
4353 A value of zero selects the smallest available line thickness.
4355 @end table
4357 Current position
4359 @findex \b
4360 @cindex pile, character
4361 @cindex character pile
4362 The @code{\b} escape will @dfn{pile} a sequence of characters
4363 vertically, and center it vertically on the current line.
4364 This can be used to build large brackets and braces.
4366 @example
4367 \b'\(lt\(bv\(lk\(bv\(lb'
4368 @end example
4371 @node Traps, Diversions, Drawing Functions, Programming Tutorial
4372 @section Traps
4373 @cindex traps
4375 Traps are locations, which, when reached, will call a specified macro.
4376 These traps can occur at a given location on the page, at a given
4377 location in the current diversion, after a certain number of input
4378 lines or at the end of input.
4380 @findex ch
4381 Any of these traps can be changed after they have been set with the
4382 @code{ch} request.  The first arguemnt is the name of the trap or
4383 macro, and the second is the new value for that trap.
4385 @menu
4386 * Page Location Traps::         
4387 * Diversion Traps::             
4388 * Input Line Traps::            
4389 * End-of-input Traps::          
4390 @end menu
4392 @node Page Location Traps, Diversion Traps, Traps, Traps
4393 @subsection Page Location Traps
4394 @cindex page location traps
4395 @cindex traps, page location
4397 Page location traps are frequently used for page headers and
4398 footers.  The following is a simple example of this.
4400 @example
4401 .de hd                          \" Page header
4402 'sp .5i
4403 .tl 'Title''date'
4404 'sp .3i
4406 .de fo                          \" Page footer
4407 'sp 1v
4408 .tl ''%''
4411 .wh 0   hd                      \" top of the page
4412 .wh -1i fo                      \" one inch from bottom
4413 @end example
4415 @vindex .t
4416 The number register @code{.t} is the distance to the next trap.
4418 @findex ch
4419 The location of a trap can be changed later on with the @code{ch}
4420 request.
4421 The first argument is the name of the macro to be invoked at the trap
4422 and the second argument is the new location for the trap.
4423 This is useful when you are building up footnotes in a diversion, and
4424 you need to allow more space at the bottom of the page for them.
4426 @example
4427 ... (simplified) footnote example ...
4428 @end example
4430 @findex vpt
4431 @findex wh
4432 @findex dt
4433 @vindex .vpt
4434 The @code{vpt} request will enable vertical position traps if the argment is
4435 non-zero, disable them otherwise.  Vertical position traps are traps
4436 set by the @code{wh} or @code{dt} requests.  Traps set by the
4437 @code{it} request are not vertical position traps.  The parameter that
4438 controls whether vertical position traps are enabled is global.
4439 Initially vertical position traps are enabled.  The current setting of
4440 this is available in the number register @code{.vpt}.
4442 @vindex .trunc
4443 @findex ne
4444 The number register @code{.trunc} contains
4445 the amount of vertical space truncated by the most recently
4446 sprung vertical position trap, or, if the trap was sprung by a
4447 @code{ne} request, minus the amount of vertical motion produced by
4448 the @code{ne} request.  In other words, at the point a trap is
4449 sprung, it represents the difference of what the vertical position
4450 would have been but for the trap, and what the vertical position
4451 actually is.
4453 @vindex .ne
4454 The number register @code{.ne} contains
4455 the amount of space that was needed in the last @code{ne} request that caused
4456 a trap to be sprung.  Useful in conjunction with the @code{.trunc}
4457 register.  @xref{Page Control}, for more information.
4459 @node Diversion Traps, Input Line Traps, Page Location Traps, Traps
4460 @subsection Diversion Traps
4461 @cindex diversion traps
4462 @cindex traps, diversion
4464 @findex dt
4465 @vindex .t
4466 Traps can also be set @emph{within} a diversion using the @code{dt}
4467 request.  Like @code{wh} the first argument is the location of the
4468 trap and the second argument is the name of the macro to be invoked.
4469 The number register @code{.t} will still work within diversions.
4470 @xref{Diversions}, for more information.
4472 @node Input Line Traps, End-of-input Traps, Diversion Traps, Traps
4473 @subsection Input Line Traps
4474 @cindex input line traps
4475 @cindex traps, input line
4477 @findex it
4478 The @code{it} request will set an input line trap.  The format for
4479 calling this is @samp{.it @var{n} @var{name}}, where @var{n} is the
4480 number of lines of input which may be read before @dfn{springing} the
4481 trap, @var{name} is the macro to be invoked.  Request lines are not
4482 counted as input lines.
4484 For example, one possible use is to have a macro which will print the
4485 next @var{n} lines in a bold font.
4487 @example
4488 .de B
4489 .it B-end \\$1
4490 .ft B
4492 .de B-end
4493 .ft R
4495 @end example
4497 @node End-of-input Traps,  , Input Line Traps, Traps
4498 @subsection End-of-input Traps
4499 @cindex end-of-input traps
4500 @cindex traps, end-of-input
4502 @findex em
4503 The @code{em} request will set a trap at the end of input.
4504 The macro specified as an arguement will be executed after the last
4505 line of the input file has been processed.
4507 For example, if your document had to have a section at the bottom of
4508 the last page for someone to approve you document, you could set it
4509 up with @code{em}.
4511 @example
4512 .de approval
4513 .ne 5v
4514 .sp |(\\n(.t-6v)
4515 .in +4i
4516 .lc _
4518 Approved:\t\a
4520 Date:\t\t\a
4522 .em approval
4523 @end example
4526 @node Diversions, Environments, Traps, Programming Tutorial
4527 @section Diversions
4528 @cindex diversions
4530 In Troff you can divert text into a named storage area, due to the
4531 similarity to defining macros it is sometimes said to be stored in a
4532 macro.  This is used for saving text for output at a later time,
4533 which is useful for keeping blocks of text on the same page,
4534 footnotes, tables of contents and indexes.
4536 @findex di
4537 @findex da
4538 Diversion is initiated by the @code{di} request, like the @code{de}
4539 request it takes an argument of a macro name to divert subsequent
4540 text to into.  The @code{da} macro will append to an existing diversion.
4542 @example
4543 ... end-note example ...
4544 @end example
4546 @vindex .z
4547 @vindex .d
4548 @vindex nl
4549 @vindex .h
4550 Diversions may be nested.
4551 The number register @code{.z} contains the name of the current diversion.
4552 The number register @code{.d} contains the current vertical place in
4553 the diversion.  If not in a diversion it is the same as the register
4554 @code{nl}.
4555 @code{.h}
4557 @vindex dn
4558 @vindex dl
4559 After compleating a diversion, the built-in number registers @code{dn}
4560 and @code{dl} contain the vertical and horizontal size of the diversion.
4562 @example
4563 .\" Center text both horizontally & vertically
4564 .de (c
4567 .di @@c
4569 .de )c
4572 .nr @@s (((\\n(.tu-\\n(dnu)/2u)-1v)
4573 .sp \\n(@@su
4574 .ce 1000
4578 .ce 0
4579 .sp \\n(@@su
4582 .rr @@s
4584 @end example
4586 @findex \!
4587 Requests, macros and escapes are interpreted when read into a
4588 diversion.
4589 There are two ways to prevent this, either way will take the given
4590 text and @dfn{transparently} embed it into the diversion.
4591 The first method is to prefix the line with @code{\!}.  This will
4592 cause the entire line to be transparently inserted into the diversion.
4593 This is useful for macros you do not want invoked until the diverted
4594 text is actually output.
4596 @c anything  is  read  in  copy  mode. (what about \! ??)
4598 @findex \?
4599 The other way is to surround the text by the @code{\?} escape, i.e.
4600 @samp{\?@var{anything}\?}.
4601 @var{anything} may not  contain
4602 newlines; use @code{\!} if you want to embed newlines in a diversion.  The
4603 escape sequence @code{\?} is also recognised in copy mode and turned into a
4604 single internal code; it is this code that terminates anything.  Thus
4605 the followin example will print 4.
4607 @example
4608 .nr x 1
4610 .di d
4611 \?\\?\\\\?\\\\\\\\nx\\\\?\\?\?
4613 .nr x 2
4614 .di e
4617 .nr x 3
4618 .di f
4621 .nr x 4
4623 @end example
4625 @findex rn
4626 @code{rn}
4628 @findex rm
4629 @code{rm}
4631 @findex als
4632 @code{als}
4634 @findex chop
4635 @code{chop}
4637 @findex asciify
4638 @code{asciify}
4639 This request only exists in order to make it possible to make certain
4640 gross hacks work with GNU troff.  It @dfn{unformats} the diversion
4641 specified as an argument in
4642 such a way that @sc{ascii} characters that were formatted and diverted
4643 will be treated like ordinary input characters when the diversion is
4644 reread.  For example, the following will set register @code{n} to 1.
4646 @example
4647 .tr  @@.
4648 .di  x
4649 @@nr\  n\  1
4652 .tr  @@@@
4653 .asciify  x
4655 @end example
4658 @c distribute these through the text
4659 @xref{Copy-in Mode}
4662 @node Environments, I/O, Diversions, Programming Tutorial
4663 @section Environments
4664 @cindex environments
4666 Often you will need to print some text in a certain format regardless
4667 of what may be in effect at the time, for example, in a trap invoked
4668 macro to print headers and footers.
4669 To solve this groff has @dfn{environments} in which text is processed.
4670 An environment contains most of the parameters that control
4671 text processing.  You can switch amongst these environments, by
4672 default groff processes text in environment 0.
4673 The following is the information kept in an environment.
4675 @itemize @bullet{}
4676 @item
4677 Type size
4678 @item
4679 Font (family and style)
4680 @item
4681 Page parameters
4682 @item
4683 Fill/adjust mode
4684 @item
4685 Tab stops
4686 @item
4687 Partially collected lines
4688 @end itemize
4690 These environments may be given arbitrary names
4691 (@pxref{Identifiers}, for more info.)
4692 Old versions of troff only had environments named 0, 1 and 2.
4694 @findex ev
4695 @vindex .ev
4696 The @code{ev} request will switch among these environments.
4697 The single argument is the name of the environment to switch to, with
4698 no argument groff will switch back to the previous enviroment.
4699 There is no limit on the number of named environments;
4700 they will be created the first time that they are referenced.
4701 The @code{.ev} number register contains
4702 the name or number of the current environment.  This is a string-valued
4703 register.
4705 @example
4706 ... page break macro, revised ...
4707 @end example
4709 @example
4710 .ev footnote-env
4711 .fam N
4712 .ps 6
4713 .vs 8
4714 .ll -.5i
4717 .ev footnote-env
4718 \(dg Note the large, friendly letters.
4720 @end example
4723 @node I/O, Postprocessor Access, Environments, Programming Tutorial
4724 @section I/O
4725 @cindex i/o
4727 @findex so
4728 The @code{so} request will read in the file given as an argument and
4729 include it in place of the @code{so} request.  This is quite useful
4730 for large documents, i.e. keeping each chapter in a separate file.
4731 @xref{gsoelim}, for more information.
4733 @findex mso
4734 The @code{mso} request is
4735 the same as the @code{so} request except that file is searched for in
4736 the same way that @file{tmac.@var{name}} is searched for when the
4737 @samp{-m@var{name}} option is specified.
4739 @findex cf
4740 @findex trf
4741 The @code{cf} and @code{trf} requests are to include a file.
4742 It will transparently output the contents of file filename.  Each
4743 line is output
4744 as it would be were it preceded by @code{\!}; however, the lines are not
4745 subject to copy-mode interpretation.  If the file does not end with a
4746 newline, then a newline will be added.  For example, you can define a
4747 macro @code{x} containing the contents of file @file{f}, using
4749 @example
4750 .di x
4751 .trf f
4753 @end example
4755 .cf filename
4756 When  used  in  a  diversion, this will embed in the diversion an object
4757 which,  when  reread,  will  cause  the  contents  of  filename  to   be
4758 transparently copied through to the output.  In @sc{Unix} troff, the contents
4759 of filename is immediately copied through to the  output  regardless  of
4760 whether  there  is  a  current diversion; this behaviour is so anomalous
4761 that it must be considered a bug.
4764 With @code{trf}, unlike @code{cf}, the file cannot contain characters
4765 such as NUL that are not legal troff input characters.
4767 @findex nx
4768 The @code{nx} request will force groff to continue processing of the
4769 file specified as an argument.
4771 @findex rd
4772 The @code{rd} request will read from standard input, and include what
4773 is read as though it were part of the input file.  Text is read until
4774 a blank line is encountered.
4776 @cindex form letters
4777 @cindex letters, form
4778 Using these two requests you can set up form letters.
4779 The form letter template is constructed like this:
4781 @example
4783 \*(td
4784 .sp 2
4790 Body of letter.
4792 .nx repeat.let
4793 @end example
4795 @findex ex
4796 When this is run, the following file should be redirected in.
4797 Note that requests included in this file are executed as though they
4798 were part of the form letter.  The last block of input is the
4799 @code{ex} requests which tells groff to stop processing.  If this was
4800 not there, groff would not know when to stop.
4802 @cindex Beagle Brothers
4803 @example
4804 Trent A. Fisher
4805 708 NW 19th Av., #202
4806 Portland, OR  97209
4808 Dear Trent,
4810 Len Adollar
4811 4315 Sierra Vista
4812 San Diego, CA  92103
4814 Dear Mr. Adollar,
4817 @end example
4819 @findex pi
4820 @code{pi}
4822 @findex sy
4823 The @code{sy} request will allow arbitrary system commands to be
4824 executed from within a groff document.  The output is not saved
4825 anyplace, so it is up to you to do so.
4827 For example, the following example will introduce the current time
4828 into your document:
4830 @cindex time
4831 @pindex perl
4832 @example
4833 .sy perl -e 'printf ".nr H %d\\n.nr M %d\\n.nr S %d\\n",\
4834              (localtime(time))[2,1,0]' > /tmp/x\n[$$]
4835 .so /tmp/x\n[$$]
4836 .sy rm /tmp/x\n[$$]
4837 \nH:\nM:\nS
4838 @end example
4840 Note that this works by having the perl script (run by @code{sy})
4841 print out the @code{nr} requests which will set the number registers
4842 @samp{H}, @samp{M} and @samp{S}, and then reads those commands in
4843 with the @code{so} request.
4845 @vindex systat
4846 The @code{systat} number register contains
4847 The return value of the @code{system()} function executed by the last
4848 @code{sy} request.
4850 @findex open
4851 The @code{open} request will open
4852 a file (specified as the second argument) for writing and associate
4853 the stream (specified as the first argument) with it.
4855 @findex opena
4856 The @code{opena} is
4857 like open, but if filename exists, append to it instead of truncating
4860 @findex write
4861 @findex ds
4862 @cindex copy-in mode
4863 @cindex mode, copy-in
4864 The @code{write} request will write to the file associated with the
4865 stream specified by the first argument.  The stream must previously
4866 have been the subject of an open request.  The remainder of the line
4867 in interpreted as the @code{ds} request reads its second argument: a
4868 leading @code{"} will be stripped, and it will be read in copy-in mode.
4870 @findex close
4871 The @code{close} request will
4872 close the stream specified by the first argument; stream will no
4873 longer be an acceptable argument to the @code{write} request.
4875 @example
4876 ... example of open write &c...
4877 @end example
4879 @findex \v
4880 The @code{\V} escape will
4881 interpolate the contents of the specified environment variable, as returned
4882 by getenv(3).
4883 The argument to @code{\V} is specified as an identifier, i.e.
4884 @samp{\V@var{x}}, @samp{\V(@var{xx}} or @samp{\V[@var{xxx}]}.
4885 @code{\V} is interpreted in copy-in mode.
4888 @node Postprocessor Access, Miscellany, I/O, Programming Tutorial
4889 @section Postprocessor Access
4890 @cindex postprocessor access
4891 @cindex access of postprocessor
4893 There are two escapes which will allow you to give information
4894 directly to the postprocessor.  This is particularly useful for
4895 embedding PostScript into your final document.
4897 @findex \X
4898 The @code{\X} escape will embed its argument into the gtroff output
4899 preceded with @samp{x X}.
4901 @findex \Y
4902 The @code{\Y} escape is called with an identifier (i.e.
4903 @code{\Y@var{x}},
4904 @code{\Y(@var{xx}} or
4905 @code{\Y[@var{xxx}]}).
4906 This is approximately equivalent to @samp{\X'\*[@var{xxx}]'}.
4907 However the contents
4908 of the string or macro @var{xxx} are not interpreted; also it is
4909 permitted for
4910 @var{xxx} to have been defined as a macro and thus contain newlines
4911 (it is not permitted for the argument to @code{\X} to contain newlines).
4912 The inclusion of
4913 newlines requires an extension to the @sc{Unix} troff output format, and will
4914 confuse drivers that do not know about this extension.
4917 @c distribute these through the text
4918 @xref{Output Devices}
4921 @node Miscellany, Debugging, Postprocessor Access, Programming Tutorial
4922 @section Miscellany
4923 @cindex miscellany
4925 This section contains parts of troff which cannot (yet) be
4926 categorized elsewhere in this manual.
4928 @findex nm
4929 Line numbers can be printed in the left margin
4930 using the @code{nm} request.
4931 The first argument is the line number of the @emph{next} output line,
4932 this defaults to 1.
4933 The second argument indicates on which lines numbers will be printed,
4934 i.e. 5 means put line numbers on every 5 lines, this defaults to 1.
4935 The third argument is the space to be left between the number and
4936 your text, this defaults to 1.
4937 The fourth argument is the indentation of the line numbers.
4938 Without arguments, line numbers are turned off.
4940 @findex nn
4941 The @code{nn} request will temporarily turn off line numbering.
4942 The first argument is the number of lines not to be numbered,
4943 this defaults to 1. (does this disable incrementing or display?)
4945 @example
4946 ... line numbering example ...
4947 @end example
4949 @findex mc
4950 margin characters can be automatically printed to the right of your
4951 text with the @code{mc} request.
4952 The first argument is the character to be printed and the second
4953 argument is the distance away from your text.
4954 With no arguments the margin characters are turned off.
4955 If this occurs before a break, no margin character will be printed.
4957 This is quite useful for indicating text that has changed, and, in
4958 fact, there are programs available for doing this (they are called
4959 @code{nrchbar} and @code{changebar} and can be found in any
4960 @samp{comp.sources.unix} archive.
4962 @example
4963 ... margin char example ...
4964 @end example
4966 @findex lf
4967 @pindex soelim
4968 The @code{lf} primary reason for existence is to make debugging
4969 documents which are split into many files, which are then put
4970 together with @code{soelim} and other preprocessors.
4971 The first argument is the name of the file and the second argument is
4972 the input line number in that file.
4973 This way troff can produce error messages which are intelligible to
4974 the user.
4976 @example
4977 ... example of soelim'ed doc ...
4978 @end example
4981 @node Debugging, Implementation Differences, Miscellany, Programming Tutorial
4982 @section Debugging
4983 @cindex debugging
4985 Troff is not easy to debug, but there are some useful features and
4986 strategies for debugging.
4988 @itemize @bullet{}
4989 @item
4990 @findex tm
4991 The @code{tm} request will send output to stderr, this is very useful for
4992 printing debugging output.
4993 @item
4994 When doing something involved it is useful to leave the debugging
4995 statements in the code and have them turned on by a command line
4996 flag.
4998 @example
4999 .if \n(DB .tm debugging output
5000 @end example
5002 Then you can activate these statements with:
5004 @example
5005 groff -rDB=1 file
5006 @end example
5008 @item
5009 @findex ab
5010 The @code{ab} request is similar to the @code{tm} request,
5011 except that it will cause groff to stop processing.
5012 With no argument it will print @samp{User Abort}.
5013 @item
5014 @findex ex
5015 The @code{ex} request will also cause groff to stop processing.
5016 @item
5017 If you know you are going to get many errors and no useful output,
5018 you can tell groff to suppress formatted output with the @samp{-z}
5019 flag.
5020 @item
5021 @findex pm
5022 The @code{pm} request will dump out the entire symbol table.
5023 @item
5024 @findex pnr
5025 The @code{pnr} request will print the names and contents of all
5026 currently defined number registers on stderr.
5027 @item
5028 @findex ptr
5029 The @code{ptr} request will
5030 print the names and positions of all traps (not including input line
5031 traps and diversion traps) on stderr.  Empty slots in the page trap list
5032 are printed as well, because they can affect the priority of
5033 subsequently planted traps.
5034 @item
5035 @findex fl
5036 The @code{fl} request instructs groff to flush its output immediately.
5037 The intention is that this be used when using troff interactively.
5038 There is little other use for it.
5039 @item
5040 @findex backtrace
5041 The @code{backtrace} request will
5042 print a backtrace of the input stack on stderr.
5043 @item
5044 Groff has command line options for printing out more warnings
5045 (@samp{-w}) and for printing backtraces (@samp{-b}) when a warning or
5046 an error occurs.  The most verbose level of warnings is @samp{-ww}.
5047 @item
5048 @findex warn
5049 @vindex .warn
5050 The @code{warn} request controls the level of warnings checked for.
5051 The one argument is the sum of the numbers associated with each
5052 warning that is to be enabled; all other warnings will be disabled.
5053 The number associated with each warning is listed below.
5054 For example, @code{.warn 0} will disable all warnings, and
5055 @code{.warn 1} will disable
5056 all warnings except that about missing characters.  If an argument
5057 is not given, all warnings will be enabled.
5058 The number register @code{.warn} contains the current warning level.
5059 @end itemize
5061 @subsection Warnings
5062 @cindex warnings
5064 The warnings that can be given by troff are divided into the
5065 following categories.  The name associated with each warning is used
5066 by the @samp{-w} and @samp{-W} options; the number is used by the
5067 @code{warn} request, and by the @code{.warn} register.
5069 @table @samp
5070 @item  char
5071 @itemx 1
5072 Non-existent characters.  This is enabled by default.
5073 @item  number
5074 @itemx 2
5075 Invalid numeric expressions.  This is enabled by default.
5076 @item  break
5077 @itemx 4
5078 In fill mode, lines which could not be broken so that
5079 their length was less than the line length.  This is
5080 enabled by default.
5081 @item  delim
5082 @itemx 8
5083 Missing or mismatched closing delimiters.
5084 @item  el
5085 @itemx 16
5086 Use of the @code{el} request with no matching @code{ie} request.
5087 @xref{if-else}, for more information.
5088 @item  scale
5089 @itemx 32
5090 Meaningless scaling indicators.
5091 @item  range
5092 @itemx 64
5093 Out of range arguments.
5094 @item  syntax
5095 @itemx 128
5096 Dubious syntax in numeric expressions.
5097 @item  di
5098 @itemx 256
5099 @findex di
5100 @findex da
5101 Use of @code{di} or @code{da} without an argument when there is no
5102 current diversion.
5103 @item  mac
5104 @itemx 512
5105 Use of undefined strings, macros and diversions.
5106 When an undefined string, macro or diversion is used,
5107 that string is automatically defined as empty.  So,
5108 in most cases, at most one warning will be given for
5109 each name.
5110 @item  reg
5111 @itemx 1024
5112 Use of undefined number registers.  When an undefined
5113 number register is used, that register is
5114 automatically defined to have a value of 0.  a
5115 definition is automatically made with a value of 0.
5116 So, in most cases, at most one warning will be given
5117 for use of a particular name.
5118 @item  tab
5119 @itemx 2048
5120 Use of a tab character where a number was expected.
5121 @item  right-brace
5122 @itemx 4096
5123 @findex \@}
5124 Use of @code{\@}} where a number was expected.
5125 @item  missing
5126 @itemx 8192
5127 Requests that are missing non-optional arguments.
5128 @item  input
5129 @itemx 16384
5130 Illegal input characters.
5131 @item  escape
5132 @itemx 32768
5133 Unrecognized escape sequences.  When an unrecognized
5134 escape sequence is encountered, the escape character
5135 is ignored.
5136 @item  space
5137 @itemx 65536
5138 Missing space between a request or macro and its
5139 argument.  This warning will be given when  an
5140 undefined name longer than two characters is
5141 encountered, and the first two characters of the name
5142 make a defined name.  The request or macro will not
5143 be invoked. When this warning is given, no macro is
5144 automatically defined.  This is enabled by default.
5145 This warning will never occur in compatibility mode.
5146 @item  font
5147 @itemx 131072
5148 Non-existent fonts. This is enabled by default.
5149 @item all
5150 All warnings except @samp{di}, @samp{mac} and @samp{reg}. It is
5151 intended that this covers
5152 all warnings that are useful with traditional macro packages.
5153 @item w
5154 All warnings.
5155 @end table
5158 @node Implementation Differences, Summary, Debugging, Programming Tutorial
5159 @section Implementation Differences
5160 @cindex implementation differences
5161 @cindex differences in implementation
5163 GNU troff has a number of features which cause incompatibilites with
5164 documents written with old versions of troff.
5166 Long names cause some incompatibilities.  @sc{Unix} troff will interpret
5168 @example
5169 .dsabcd
5170 @end example
5172 @findex \*
5173 @findex \n
5174 @findex cp
5175 @vindex .C
5176 as defining a string @samp{ab} with contents @samp{cd}.
5177 Normally, GNU troff will interpret this as a call of a macro named
5178 @code{dsabcd}.  Also @sc{Unix} troff will interpret @code{\*[} or
5179 @code{\n[} as references to a string or number register called
5180 @samp{[}.  In GNU troff, however, this will normally be interpreted as the
5181 start of a long name.  In compatibility mode GNU troff will interpret
5182 these things in the traditional way.  In compatibility mode, however,
5183 long names are not recognised.  Compatibility mode can be turned on with
5184 the @samp{-C} command line option, and turned on or off with the
5185 @code{cp} request.
5186 The number register @code{.C} is 1 if compatibility mode is on, 0 otherwise.
5188 @findex \A
5189 GNU troff does not allow the use of the escape sequences
5190 @samp{\| \^ \& \@} \@{ \@key{SP} \' \` \- \_ \! \% \c} in names of
5191 strings, macros,
5192 diversions, number registers, fonts or environments; @sc{Unix} troff does.
5193 The @code{\A} escape sequence may be helpful in avoiding use of these escape
5194 sequences in names.
5196 @cindex fractional point sizes
5197 @cindex point sizes, fractional
5198 @findex ps
5199 Fractional pointsizes cause one noteworthy incompatibility.  In @sc{Unix}
5200 troff the @code{ps} request ignores scale indicators and so
5202 @example
5203 .ps 10u
5204 @end example
5206 will set the pointsize to 10 points, whereas in GNU troff it will set
5207 the pointsize to 10 scaled points.
5208 @xref{Fractional Type Sizes}, for more information.
5210 @findex bd
5211 @findex cs
5212 @findex tkf
5213 @findex tr
5214 @findex fp
5215 In GNU troff there is a fundamental difference between unformatted,
5216 input characters, and formatted, output characters.  Everything that
5217 affects how an output character will be output is stored with the
5218 character; once an output character has been constructed it  is
5219 unaffected by any subsequent requests that are executed, including
5220 @code{bd}, @code{cs}, @code{tkf}, @code{tr}, or @code{fp}
5221 requests.  Normally output characters are constructed
5222 from input characters at the moment immediately before the character is
5223 added to the current output line.  Macros, diversions and strings are
5224 all, in fact, the same type of object; they contain lists of input
5225 characters and output characters in any combination.  An  output
5226 character does not behave like an input character for the purposes of
5227 macro processing; it does not inherit any of the special properties that
5228 the input character from which it was constructed might have had. For
5229 example,
5231 @example
5232 .di x
5233 \\\\
5237 @end example
5239 @findex \e
5240 @findex \!
5241 @findex \?
5242 will print @samp{\\} in GNU troff; each pair of input backslashes is
5243 turned into one
5244 output backslash and the resulting output backslashes are not
5245 interpreted as escape
5246 characters when they are reread. @sc{Unix} troff would interpret them as
5247 escape characters when they were reread and would end up printing one
5248 @samp{\}.
5249 The correct way to obtain a printable backslash is to use the
5250 @code{\e} escape
5251 sequence: this will always print a single instance of the current escape
5252 character, regardless of whether or not it is used in a diversion; it
5253 will also work in both GNU troff and @sc{Unix} troff. If you wish for some
5254 reason to store in a diversion an escape sequence that will be
5255 interpreted when the diversion is reread, you can either use the
5256 traditional @code{\!} transparent output facility, or, if this is unsuitable,
5257 the new @code{\?} escape sequence.  @xref{Diversions}, for more information.
5260 @node Summary,  , Implementation Differences, Programming Tutorial
5261 @section Summary
5262 @cindex summary
5266 @node Preprocessors, Output Devices, Programming Tutorial, Top
5267 @chapter Preprocessors
5268 @cindex preprocessors
5270 This chapter covers describes all preprocessors that come with
5271 @code{groff} or which are freely available.
5273 @menu
5274 * geqn::                        
5275 * gtbl::                        
5276 * gpic::                        
5277 * ggrn::                        
5278 * grap::                        
5279 * grefer::                      
5280 * gsoelim::                     
5281 @end menu
5284 @node geqn, gtbl, Preprocessors, Preprocessors
5285 @section @code{geqn}
5286 @cindex @code{eqn}
5287 @cindex @code{geqn}
5289 @menu
5290 * Invoking geqn::               
5291 @end menu
5293 @node Invoking geqn,  , geqn, geqn
5294 @subsection Invoking @code{geqn}
5295 @cindex invoking @code{geqn}
5296 @cindex @code{geqn}, invoking
5299 @node gtbl, gpic, geqn, Preprocessors
5300 @section @code{gtbl}
5301 @cindex @code{tbl}
5302 @cindex @code{gtbl}
5304 @menu
5305 * Invoking gtbl::               
5306 @end menu
5308 @node Invoking gtbl,  , gtbl, gtbl
5309 @subsection Invoking @code{gtbl}
5310 @cindex invoking @code{gtbl}
5311 @cindex @code{gtbl}, invoking
5314 @node gpic, ggrn, gtbl, Preprocessors
5315 @section @code{gpic}
5316 @cindex @code{pic}
5317 @cindex @code{gpic}
5319 @menu
5320 * Invoking gpic::               
5321 @end menu
5323 @node Invoking gpic,  , gpic, gpic
5324 @subsection Invoking @code{gpic}
5325 @cindex invoking @code{gpic}
5326 @cindex @code{gpic}, invoking
5329 @node ggrn, grap, gpic, Preprocessors
5330 @section @code{ggrn}
5331 @cindex @code{grn}
5332 @cindex @code{ggrn}
5334 @menu
5335 * Invoking ggrn::               
5336 @end menu
5338 @node Invoking ggrn,  , ggrn, ggrn
5339 @subsection Invoking @code{ggrn}
5340 @cindex invoking @code{ggrn}
5341 @cindex @code{ggrn}, invoking
5344 @node grap, grefer, ggrn, Preprocessors
5345 @section @code{grap}
5346 @cindex @code{grap}
5348 @code{grap} is available as an extra package, written by Ted Faber.
5351 @node grefer, gsoelim, grap, Preprocessors
5352 @section @code{grefer}
5353 @cindex @code{refer}
5354 @cindex @code{grefer}
5356 @menu
5357 * Invoking grefer::             
5358 @end menu
5360 @node Invoking grefer,  , grefer, grefer
5361 @subsection Invoking @code{grefer}
5362 @cindex invoking @code{grefer}
5363 @cindex @code{grefer}, invoking
5366 @node gsoelim,  , grefer, Preprocessors
5367 @section @code{gsoelim}
5368 @cindex @code{soelim}
5369 @cindex @code{gsoelim}
5371 @menu
5372 * Invoking gsoelim::            
5373 @end menu
5375 @node Invoking gsoelim,  , gsoelim, gsoelim
5376 @subsection Invoking @code{gsoelim}
5377 @cindex invoking @code{gsoelim}
5378 @cindex @code{gsoelim}, invoking
5382 @node Output Devices, File formats, Preprocessors, Top
5383 @chapter Output Devices
5384 @cindex output devices
5385 @cindex devices for output
5387 @menu
5388 * Special Characters::          
5389 * grotty::                      
5390 * grops::                       
5391 * grodvi::                      
5392 * grolj4::                      
5393 * grohtml::                     
5394 * gxditview::                   
5395 @end menu
5398 @node Special Characters, grotty, Output Devices, Output Devices
5399 @section Special Characters
5400 @cindex special characters
5401 @cindex characters, special
5403 @c distribute these through the text
5404 @xref{Font Files}
5407 @node grotty, grops, Special Characters, Output Devices
5408 @section @code{grotty}
5409 @cindex @code{grotty}
5411 @menu
5412 * Invoking grotty::             
5413 @end menu
5415 @node Invoking grotty,  , grotty, grotty
5416 @subsection Invoking @code{grotty}
5417 @cindex invoking @code{grotty}
5418 @cindex @code{grotty}, invoking
5421 @node grops, grodvi, grotty, Output Devices
5422 @section @code{grops}
5423 @cindex @code{grops}
5425 @menu
5426 * Invoking grops::              
5427 * Embedding PostScript::        
5428 @end menu
5430 @node Invoking grops, Embedding PostScript, grops, grops
5431 @subsection Invoking @code{grops}
5432 @cindex invoking @code{grops}
5433 @cindex @code{grops}, invoking
5435 @node Embedding PostScript,  , Invoking grops, grops
5436 @subsection Embedding PostScript
5437 @cindex embedding postscript
5438 @cindex postscript, embedding
5441 @node grodvi, grolj4, grops, Output Devices
5442 @section @code{grodvi}
5443 @cindex @code{grodvi}
5445 @menu
5446 * Invoking grodvi::             
5447 @end menu
5449 @node Invoking grodvi,  , grodvi, grodvi
5450 @subsection Invoking @code{grodvi}
5451 @cindex invoking @code{grodvi}
5452 @cindex @code{grodvi}, invoking
5455 @node grolj4, grohtml, grodvi, Output Devices
5456 @section @code{grolj4}
5457 @cindex @code{grolj4}
5459 @menu
5460 * Invoking grolj4::             
5461 @end menu
5463 @node Invoking grolj4,  , grolj4, grolj4
5464 @subsection Invoking @code{grolj4}
5465 @cindex invoking @code{grolj4}
5466 @cindex @code{grolj4}, invoking
5469 @node grohtml, gxditview, grolj4, Output Devices
5470 @section @code{grohtml}
5471 @cindex @code{grohtml}
5473 @menu
5474 * Invoking grohtml::            
5475 @end menu
5477 @node Invoking grohtml,  , grohtml, grohtml
5478 @subsection Invoking @code{grohtml}
5479 @cindex invoking @code{grohtml}
5480 @cindex @code{grohtml}, invoking
5483 @node gxditview,  , grohtml, Output Devices
5484 @section @code{gxditview}
5485 @cindex @code{gxditview}
5487 @menu
5488 * Invoking gxditview::          
5489 @end menu
5491 @node Invoking gxditview,  , gxditview, gxditview
5492 @subsection Invoking @code{gxditview}
5493 @cindex invoking @code{gxditview}
5494 @cindex @code{gxditview}, invoking
5498 @node File formats, Installation, Output Devices, Top
5499 @chapter File formats
5500 @cindex file formats
5501 @cindex formats, file
5503 @menu
5504 * gtroff Output::               
5505 * Font Files::                  
5506 @end menu
5509 @node gtroff Output, Font Files, File formats, File formats
5510 @section @code{gtroff} Output
5511 @cindex @code{gtroff} output
5512 @cindex output, @code{gtroff}
5515 This section describes the format output by GNU troff.  The output
5516 format used by GNU troff is very similar to that used by @sc{Unix}
5517 device-independent troff.
5519 The output format is text based, as opposed to a binary format (like
5520 @TeX{} dvi).
5521 The output format is 8 bit clean, thus single characters can have the
5522 eighth bit set, as can the names of fonts and special characters.
5524 The output format consists of single command characters with attached
5525 parameters which are separated from subsequent text by whitespace, or
5526 a newline.
5528 The names of characters and fonts an be of arbitrary length; drivers
5529 should not assume that they will be only two characters long (as
5530 device-independent troff did).
5532 When a character is to be printed, that character will always be in the
5533 current font.
5534 Unlike device-independent troff, it is not necessary for
5535 drivers to search special fonts to find a character.
5537 @table @code
5538 @item H@var{n}
5539 @item V@var{n}
5540 @item h@var{n}
5541 @item v@var{n}
5542 @item c@var{n}
5543 @item C@var{n}
5544 @item @var{nn}@var{c}
5545 @item t@var{xxx}
5546 @var{xxx} is any sequence of characters terminated by a space or a
5547 newline; the first character should be printed at the current
5548 position, the the current horizontal position should be increased by
5549 the width of the first character, and so on for each character.
5550 The width of the character is that given in the font file,
5551 appropriately scaled for the current point size,
5552 and rounded so that it is a multiple of the horizontal resolution.
5553 Special characters cannot be printed using this command.
5555 This command is only allowed if the @samp{tcommand} line is present
5556 in the @file{DESC} file.
5557 @item u@var{n} @var{xxx}
5558 @pindex DESC
5559 This is same as the @code{t} command except that after printing each
5560 character, the current horizontal position is increased by the sum of
5561 the width of that character and @code{n}.
5563 This command is only allowed if the @samp{tcommand} line is present
5564 in the @file{DESC} file.
5565 @item n@var{a}@var{b}
5566 @item p@var{n}
5567 @item s@var{n}
5568 The argument to the s command is in scaled points (units of points/n,
5569 where n is the argument to the sizescale command  in the DESC file.)
5570 @item f@var{n}
5571 @item x @dots{} \n
5572 Device control.
5573 @item D@var{c} @var{x}@dots{}\n
5574 @end table
5576 @subsection Device Control
5578 The @code{x} command is normally followed by a letter or word
5579 indicating the function to perform, followed by white space separated
5580 arguments.
5582 The first argument can be abreviated to the first letter.
5584 @table @code
5585 @item x init
5586 @item x T
5587 @item x res @var{n} @var{h} @var{v}
5588 @item x H
5589 The argument to the x Height command is also in scaled points.
5590 @end table
5592 The first three output commands are guaranteed to be:
5594 @example
5595 x T device
5596 x res n h v
5597 x init
5598 @end example
5600 For example, the input @samp{crunchy \fH\s+2frog\s0\fP!?} will produce:
5602 @example
5603 ... sample output here ...
5604 @end example
5606 @subsection Drawing Functions
5608 The D drawing command has been extended.  These extensions will only be
5609 used by GNU pic if the -x option is given.
5611 @table @code
5613 @item Df n\n
5614 Set the shade of gray to be used for filling solid objects to n; n must
5615 be an integer between 0 and 1000, where 0 corresponds solid white and
5616 1000 to solid black, and values in between correspond to intermediate
5617 shades of gray.  This applies only to solid circles, solid ellipses and
5618 solid polygons.  By default, a level of 1000 will be used.  Whatever
5619 color a solid object has, it should completely obscure everything
5620 beneath it. A value greater than 1000 or less than 0 can also be used:
5621 this means fill with the shade of gray that is currently being used for
5622 lines and text.  Normally this will be black, but some drivers may
5623 provide a way of changing this.
5624 @item DC d\n
5625 Draw a solid circle with a diameter of d with the leftmost point at the
5626 current position.
5627 @item DE dx dy\n
5628 Draw a solid ellipse with a horizontal diameter of dx and a vertical
5629 diameter of dy with the leftmost point at the current position.
5630 @item Dp $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub
5631 n$\n
5632 Draw a polygon with, for $i = 1 ,..., n+1$, the i-th vertex at the
5633 current position $+ sum from j=1 to i-1 ( dx sub j , dy sub j )$. At
5634 the moment, GNU pic only uses this command to generate triangles and
5635 rectangles.
5636 @item DP $dx sub 1$ $dy sub 1$ $dx sub 2$ $dy sub 2$ $...$ $dx sub n$ $dy sub
5637 n$\n
5638 Like Dp but draw a solid rather than outlined polygon.
5639 @item Dt n\n
5640 Set the current line thickness to n machine units.  Traditionally @sc{Unix}
5641 troff drivers use a line thickness proportional to the current point
5642 size; drivers should continue to do this if no Dt command has been
5643 given, or if a Dt command has been given with a negative value of n.  A
5644 zero value of n selects the smallest available line thickness.
5645 @end table
5647 A difficulty arises in how the current position should be changed after
5648 the execution of these commands. This is not of great importance since
5649 the code generated by GNU pic does not depend on this. Given a drawing
5650 command of the form
5652 \D'c $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$'
5654 where c is not one of c, e, l, a or ~, @sc{Unix} troff will treat each of the
5655 $x sub i$ as a horizontal quantity, and each of the $y sub i$ as a
5656 vertical quantity and will assume that the width of the drawn object is
5657 $sum from i=1 to n x sub i$, and that the height is $sum from i=1 to n y
5658 sub i$.  (The assumption about the height can be seen by examining the
5659 st and sb registers after using such a D command in a \w escape
5660 sequence.)  This rule also holds for all the original drawing commands
5661 with the exception of De.  For the sake of compatibility GNU troff also
5662 follows this rule, even though it produces an ugly result in the case of
5663 the Df, Dt, and, to a lesser extent, DE commands.  Thus after executing
5664 a D command of the form
5666 Dc $x sub 1$ $y sub 1$ $x sub 2$ $y sub 2$ $...$ $x sub n$ $y sub n$\n
5668 the current position should be increased by $( sum from i=1 to n x sub i
5669 , sum from i=1 to n y sub i )$.
5671 @subsection Line Continuation
5673 There is a continuation convention which permits the argument to the x X
5674 command to contain newlines: when outputting the argument to the x X
5675 command,  GNU troff will follow each newline in the argument with a +
5676 character (as usual, it will terminate the entire argument with a
5677 newline); thus if the line after the line containing the x X command
5678 starts with +, then the newline ending the line containing the x X
5679 command should be treated as part of the argument to the x X command,
5680 the + should be ignored, and the part of the line following the + should
5681 be treated like the part of the line following the x X command.
5684 @node Font Files,  , gtroff Output, File formats
5685 @section Font Files
5686 @cindex font files
5687 @cindex files, font
5689 The groff font format is roughly a superset of the ditroff font
5690 format.  Unlike the ditroff font format, there is no associated binary
5691 format.  The font files for device name are stored in a directory
5692 @file{dev@var{name}}.  There are two types of file: a device
5693 description file called @file{DESC} and for each font @samp{F} a font
5694 file called @file{F}.  These are text files; there is no associated
5695 binary format.
5697 @subsection @file{DESC} file format
5698 @pindex DESC
5700 The @file{DESC} file can contain the following types of line:
5702 @table @code
5703 @item res @var{n}
5704 There are @var{n} machine units per inch.
5705 @item hor @var{n}
5706 The horizontal resolution is @var{n} machine units.
5707 @item vert @var{n}
5708 The vertical resolution is @var{n} machine units.
5709 @item sizescale @var{n}
5710 The scale factor for pointsizes.  By default this has a value of 1.  One
5711 scaled point is equal to one point/@var{n}.  The arguments to the
5712 @code{unitwidth} and @code{sizes} commands are given in scaled points.
5713 @xref{Fractional Type Sizes}, for more information.
5714 @item unitwidth @var{n}
5715 Quantities in the font files are given in machine units for fonts  whose
5716 point size is @var{n} scaled points.
5717 @item tcommand
5718 This means that the postprocessor can handle the @code{t} and
5719 @code{u} output commands.
5720 @item sizes @var{s1} @var{s2}@dots{}@var{sn} 0
5721 This means that the device has fonts at @var{s1}, @var{s2},
5722 @dots{}@var{sn} scaled points.  The list of sizes must be terminated
5723 by a 0.  Each @var{si} can also be a range of
5724 sizes @var{m}-@var{n}.  The list can extend over more than one line.
5725 @item styles @var{S1 S2@dots{}Sm}
5726 The first @var{m} font positions will be associated with styles
5727 @var{S1}@dots{}@var{Sm}.
5728 @item fonts @var{n} @var{F1 F2 F3@dots{}Fn}
5729 Fonts @var{F1@dots{}Fn} will be mounted in the font positions
5730 @var{m}+1, @dots{}, @var{m}+@var{n} where @var{m}
5731 is the number of styles.  This command may extend over more than one
5732 line. A font name of 0 will cause no font to be mounted on the
5733 corresponding font position.
5734 @item family @var{fam}
5735 The default font family is @var{fam}.
5736 @item charset
5737 This line and everything following in the file are ignored.  It is
5738 allowed for the sake of backwards compatibility.
5739 @end table
5741 The @code{res}, @code{unitwidth}, @code{fonts} and @code{sizes} lines
5742 are compulsory.  Other commands are ignored by troff but may be used
5743 by postprocessors to store arbitrary information about the device in
5744 the @file{DESC} file.
5747 @subsection Font file format
5749 A font file has two sections.  The first section is a sequence of lines
5750 each containing a sequence of blank delimited words; the first word in
5751 the line is a key, and subsequent words give a value for that key.
5753 @table @code
5754 @item name @var{F}
5755 The name of the font is @var{F}.
5756 @item spacewidth @var{n}
5757 The normal width of a space is @var{n}.
5758 @item slant @var{n}
5759 The characters of the font have a slant of @var{n} degrees.
5760 (Positive means forward.)
5761 @item ligatures @var{lig1} @var{lig2}@dots{}@var{lign} [0]
5762 Characters @var{lig1}, @var{lig2}, @dots{}, @var{lign} are ligatures;
5763 possible ligatures are ff, fi, fl and ffl.  For backwards
5764 compatibiliy, the list of ligatures may be terminated with a 0.  The
5765 list of ligatures may not extend over more than one line.
5766 @item special
5767 The font is special; this means that when a character is requested that
5768 is not present in the current font, it will be searched for in any
5769 special fonts that are mounted.
5770 @end table
5772 Other commands are ignored by troff but may be used by postprocessors to
5773 store arbitrary information about the font in the font file.
5775 The first section can contain comments which start with the # character
5776 and extend to the end of a line.
5778 The second section contains one or two subsections.  It must contain a
5779 @code{charset} subsection and it may also contain a @code{kernpairs}
5780 subsection.  These subsections can appear in any order.  Each
5781 subsection starts with a word on a line by itself.
5783 The word @code{charset} starts the @code{charset} subsection. The
5784 @code{charset} line is followed by a sequence of lines. Each line
5785 gives information for one character.  A line comprises a number of
5786 fields separated by blanks or tabs. The format is
5788 @display
5789 @var{name} @var{metrics} @var{type} @var{code} @var{comment}
5790 @end display
5792 @var{name} identifies the character: if @var{name} is a single
5793 character @var{c} then it corresponds to the groff input character
5794 @var{c}; if it is of the form @samp{\@var{c}} where @var{c} is a
5795 single character, then it corresponds to the groff input character
5796 @samp{\@var{c}}; otherwise it corresponds to the groff input character
5797 @samp{\[@var{name}]} (if it is exactly two characters @var{xx} it can
5798 be entered as @samp{\(@var{xx}}.) Groff supports eight bit characters;
5799 however some utilities has difficulties with eight bit characters.
5800 For this reason, there is a convention that the @var{name}
5801 @samp{char@var{n}} is equivalent to the single character whose code is
5802 @var{n}. For example, @samp{char163} would be equivalent to the
5803 character with @var{code} 163 which is the pounds sterling sign in ISO
5804 Latin-1 character set.  The name @samp{---} is special and indicates
5805 that the character is unnamed; such characters can only be used by
5806 means of the @code{\N} escape sequence in troff.
5808 The @var{type} field gives the character type:
5810 @table @code
5811 @item 1
5812 means the character has an descender, for example, p;
5813 @item 2
5814 means the character has an ascender, for example, b;
5815 @item 3
5816 means the character has both an ascender and a descender, for example,
5817 @samp{(}.
5818 @end table
5820 The @var{code} field gives the code which the postprocessor uses to
5821 print the character.  The character can also be input to groff using
5822 this code by means of the @code{\N} escape sequence. The code can be any
5823 integer.  If it starts with a 0 it will be interpreted as octal; if it
5824 starts with 0x or 0X it will be intepreted as hexdecimal.
5826 Anything on the line after the @var{code} field will be ignored.
5828 The @var{metrics} field has the form:
5830 @smallexample
5831 @var{width[,height[,depth[,italic_correction[,left_italic_correction[,subscript_correction]]]]]}
5832 @end smallexample
5834 There must not be any spaces between these subfields.  Missing
5835 subfields are assumed to be 0.  The subfields are all decimal
5836 integers.  Since there is no associated binary format, these values
5837 are not required to fit into a variable of type @samp{char} as they
5838 are in ditroff.  The @var{width} subfields gives the width of the
5839 character.  The @var{height} subfield gives the height of the
5840 character (upwards is positive); if a character does not extend above
5841 the baseline, it should be given a zero height, rather than a negative
5842 height.  The @var{depth} subfield gives the depth of the character,
5843 that is, the distance below the lowest point below the baseline to
5844 which the character extends (downwards is positive); if a character
5845 does not extend below above the baseline, it should be given a zero
5846 depth, rather than a negative depth.  The @var{italic_correction}
5847 subfield gives the amount of space that should be added after the
5848 character when it is immediately to be followed by a character from a
5849 roman font.  The @var{left_italic_correction} subfield gives the
5850 amount of space that should be added before the character when it is
5851 immediately to be preceded by a character from a roman font.  The
5852 @var{subscript_correction} gives the amount of space that should be
5853 added after a character before adding a subscript. This should be less
5854 than the italic correction.
5856 A line in the @code{charset} section can also have the format
5858 @example
5859 @var{name} "
5860 @end example
5862 This indicates that @var{name} is just another name for the character
5863 mentioned in the preceding line.
5865 The word @code{kernpairs} starts the kernpairs section.  This contains a
5866 sequence of lines of the form:
5868 @display
5869 @var{c1 c2 n}
5870 @end display
5872 This means that when character @var{c1} appears next to character
5873 @var{c2} the space between them should be increased by @var{n}.  Most
5874 entries in kernpairs section will have a negative value for @var{n}.
5878 @node Installation, Request Index, File formats, Top
5879 @chapter Installation
5880 @cindex installation
5884 @node Request Index, Register Index, Installation, Top
5885 @chapter Request Index
5887 @printindex fn
5891 @node Register Index, String Index, Request Index, Top
5892 @chapter Register Index
5894 @printindex vr
5897 @node String Index, Macro Index, Register Index, Top
5898 @chapter String Index
5902 @node Macro Index, Program Index, String Index, Top
5903 @chapter Macro Index
5907 @node Program Index, Concept Index, Macro Index, Top
5908 @chapter Program Index
5910 @printindex pg
5914 @node Concept Index,  , Program Index, Top
5915 @chapter Concept Index
5917 @printindex cp
5921 @summarycontents
5922 @contents
5923 @bye