lbl.1 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. .\" (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2. .\"
  3. .Dd $Mdocdate$
  4. .Dt LBL 1
  5. .Os
  6. .Sh NAME
  7. .Nm lbl
  8. .Nd preprocess symbolic labels for troff(1) text
  9. .Sh SYNOPSIS
  10. .Nm lbl
  11. .Op Fl d Ar delim
  12. .Op Fl m Ar macro
  13. .Op Fl l
  14. .Op Fl s
  15. .Op Ar
  16. .Sh DESCRIPTION
  17. .Nm
  18. is a preprocessor for
  19. .Xr troff 1
  20. which constructs serial numbers automatically for tables, equations,
  21. sections, etc., and allows them to be referred to by symbolic names.
  22. It avoids the need for a user to keep track of such numberings, and
  23. to alter all cross-references whenever a labelled
  24. object is introduced or deleted.
  25. .Pp
  26. As many independent sequences of labels as required can be maintained;
  27. each sequence is given a symbolic name, known as the
  28. .Em label-type .
  29. Within each label-type, objects are referred to by symbolic names known
  30. as
  31. .Em labels ;
  32. the same label may be used in several different label-types without problems.
  33. Names for labels and label-types may be arbitrary sequences of alphanumeric
  34. characters.
  35. In addition, the special label-name ``*'' may be used as an anonymous label,
  36. used to increment a level counter without generating a label (e.g. to keep
  37. table numbers in step with the corresponding section numbers).
  38. .Pp
  39. .Nm
  40. reads as input the concatenation of all specified
  41. .Ar file
  42. arguments (interpreting ``-'' to mean the standard input);
  43. if no
  44. .Ar file
  45. argument is given,
  46. .Nm
  47. reads the standard input.
  48. The input consists of arbitrary text (normally input for
  49. .Xr troff 1 ,
  50. .Xr eqn 1 ,
  51. and the rest of that family) interspersed with
  52. .Em label-definitions
  53. and
  54. .Em label-references ,
  55. together with a few other sorts of definition described below.
  56. .Pp
  57. .Ss Label Definitions
  58. A label-definition
  59. defines the value of a symbolic label.
  60. All such definitions are introduced by a line beginning with
  61. a special
  62. .Em troff
  63. macro; the default macro is
  64. .Ic .L=
  65. but this can be overridden in the command line.
  66. The label-definition macro is followed by a label-type, a numeric level,
  67. and a label-name;
  68. a value is given to the label by incrementing the current count for
  69. the label-type at the given level (similar to the generation of
  70. numbered headings by such macros as
  71. .Ic .NH
  72. in the
  73. .Xr groff_ms 7
  74. package,
  75. .Ic .H
  76. in
  77. .Xr groff_mm 7
  78. and
  79. .Ic .sh
  80. in
  81. .Xr groff_me 7 ).
  82. Unless otherwise specified, the first count generated at a given level will
  83. be 1; when a count is incremented, all deeper counts are reset to 0.
  84. .Pp
  85. There are several other uses of the definition-macro:
  86. .Bl -tag -width Ds
  87. .It .L= delimiter off
  88. inhibits all subsequent translation of label-references;
  89. .It .L= delimiter \fIchar\fR
  90. resets the delimiter introducing label-references to
  91. .Em char
  92. (see below);
  93. .It .L= format \fIlabel-type pattern\fR
  94. resets the printing format for a label reference (see below);
  95. .It .L= last \fIlabel-type count ...\fR
  96. resets the counts for
  97. .Em label-type
  98. as though the last label generated
  99. had had the specified counts for its successive levels (missing counts
  100. all being taken as 0).
  101. All counts must be arabic numerals, regardless of the print format being
  102. used for the label-type.
  103. .El
  104. .Pp
  105. All label-definition, etc., lines are copied unchanged to the output.
  106. .Ss Label References
  107. A label-reference is introduced and terminated by a
  108. .Em delimiter
  109. character (default ``@'');
  110. the opening delimiter is followed by a label-type and a label-name;
  111. the entire reference is replaced by the value of the specified label,
  112. printed according to the format specified for the label-type (see below).
  113. .Ss Print Formats
  114. A print format consists of a literal string containing escape-sequences
  115. for which successive values of the level counts of a label are substituted.
  116. The format is copied only as far as the escape sequence for the last level
  117. of the label being printed, and it is an error for there to be too few
  118. escape sequences.
  119. The sequences are
  120. .Bl -tag -width Ds
  121. .It %1
  122. print in arabic numerals, no non-significant leading zeros;
  123. .It %0
  124. print as for ``%1'', but subtracting 1 so that counts start from 0 rather than
  125. 1.
  126. .It %i
  127. print in lower-case roman numerals;
  128. .It \&%I
  129. print in upper-case roman;
  130. .It %a
  131. print as a lower-case letter (starting at ``a'');
  132. .It \&%A
  133. print as an upper-case letter.
  134. ``%'' followed by any other character prints as that character.
  135. .El
  136. .Pp
  137. The default format is to print all levels in arabic, separated by periods
  138. (i.e. "%1.%1.%1.%1\ ...").
  139. .Ss Command Line Options
  140. .Bl -tag -width Ds
  141. .It -d\fIdelim\fR
  142. .Em delim
  143. is a single character to be used in place of ``@''
  144. as the label-reference delimiter.
  145. .It -m\fImacro\fR
  146. .Em macro
  147. is a 2-character macro-name to be used in place of ``.L='' as the
  148. label-definition macro.
  149. .It -l
  150. causes a listing of all label-definitions to be written to the standard
  151. error stream.
  152. .It -s
  153. suppresses all output except error messages and the listing generated by
  154. the \fI-l\fR option, which is automatically turned on.
  155. .El
  156. .Sh EXAMPLE
  157. Input
  158. .Bd -literal -offset indent -compact
  159. \&.L= sec 1 intro
  160. \&.L= format sec %A.%1.%1.%1.%1
  161. \&.L= last table 3 1
  162. This is Section @sec intro@; it is followed by Section
  163. @sec next@ which contains Section @sec subsection@.
  164. \&.L= table 2 only.
  165. The only table used is Table @table only@.
  166. \&.L= sec 1 next
  167. \&.L= sec 2 subsection
  168. .Ed
  169. Output
  170. .Bd -literal -offset indent -compact
  171. \&.L= sec 1 intro
  172. \&.L= format sec %A.%1.%1.%1.%1
  173. \&.L= last table 3 1
  174. This is Section A; it is followed by Section
  175. B which contains Section B.1.
  176. \&.L= table 2 only.
  177. The only table used is Table 3.2.
  178. \&.L= sec 1 next
  179. \&.L= sec 2 subsection
  180. .Ed
  181. .Sh BUGS
  182. With the
  183. .Fl s
  184. option, errors such as reference to an undefined label, which can only
  185. be detected on a second scan of the input, are not reported.
  186. .Sh FILES
  187. .Pa /tmp/lbl*
  188. - temporary storage
  189. .Sh SEE ALSO
  190. .Xr troff 1 ,
  191. .Xr nroff 1 ,
  192. .Xr eqn 1 ,
  193. .Xr refer 1 ,
  194. .Xr tbl 1