BSD 3 development
[unix-history] / usr / doc / troff / m4
CommitLineData
8340f87c
BJ
1.tr |
2.mh
3Hyphenation.
4.pg
5The automatic hyphenation may be switched off and on.
6When switched on with \fBhy\fR,
7several variants may be set.
8A \fIhyphenation indicator\fR character may be imbedded in a word to
9specify desired hyphenation points,
10or may be prepended to suppress hyphenation.
11In addition,
12the user may specify a small exception word list.
13.pg
14Only words that consist of a central alphabetic string
15surrounded by (usually null) non-alphabetic strings
16are considered candidates for automatic hyphenation.
17Words that were input containing hyphens
18(minus),
19em-dashes (\fB\e(em\fR),
20or hyphenation indicator characters\
21\(emsuch as mother-in-law\(em\
22are \fIalways\fR subject to splitting after those characters,
23whether or not automatic hyphenation is on or off.
24.h1
25.bt
26\fB&nh\fR hyphenate - E \
27Automatic hyphenation is turned off.
28.bt
29\fB&hy\fIN\fR on,\fIN=\fR1 on,\fIN=\fR1 E \
30Automatic hyphenation is turned on
31for \fIN\fR\|\(>=1, or off for \fIN=\fR\|0.
32If \fIN=\fR\|2, \fIlast\fR lines (ones that will cause a trap)
33are not hyphenated.
34For \fIN=\fR\|4 and 8, the last and first two characters
35respectively of a word are not split off.
36These values are additive;
37i.|e. \fIN=\fR\|14 will invoke all three restrictions.
38.bt
39\fB&hc\fI|c\fR \fB\e% \e%\fR E Hyphenation indicator character is set
40to \fIc\fR or to the default \fB\e%\fR.
41The indicator does not appear in the output.
42.bt
43\fB&hw\fI|word1|...\fR ignored - Specify hyphenation points in words
44with imbedded minus signs.
45Versions of a word with terminal \fIs\fR are implied;
46i.|e. \fIdig\-it\fR implies \fIdig\-its\fR.
47This list is examined initially \fIand\fR after
48each suffix stripping.
49The space available is small\(emabout 128 characters.
50.mh
51Three Part Titles.
52.pg
53The titling function \fBtl\fR provides for automatic placement
54of three fields at the left, center, and right of a line
55with a title-length
56specifiable with \fBlt\fR.
57\fBtl\fR may be used anywhere, and is independent of the
58normal text collecting process.
59A common use is in header and footer macros.
60.h1
61.bt
62\fB&tl\fI|\'left\|\'center\|\'right\|\'\fR - - \
63The strings \fIleft\fR, \fIcenter\fR, and \fIright\fR are
64respectively left-adjusted, centered, and right-adjusted
65in the current title-length.
66Any of the strings may be empty,
67and overlapping is permitted.
68If the page-number character (initially \fB%\fR) is found within any of the fields it is replaced
69by the current page number having the format assigned to register \fB%\fR.
70Any character may be used as the string delimiter.
71.bt
72\fB&pc\fI|c\fR \fB%\fR off - The page number character is set to \fIc\fR,
73or removed.
74The page-number register remains \fB%\fR.
75.bt
76\fB&lt\fI|\(+-N\fR 6.5\|in previous E,\fBm\fR Length of title set to \fI\(+-N\fR.
77The line-length and the title-length are \fIindependent\fR.
78Indents do not apply to titles; page-offsets do.
79.mh
80Output Line Numbering.
81.pg
82.ll -\w'0000'u
83.nm 1 3
84Automatic sequence numbering of output lines may be
85requested with \fBnm\fR.
86When in effect,
87a three-digit, arabic number plus a digit-space
88is prepended to output text lines.
89The text lines are thus offset by four digit-spaces,
90and otherwise retain their line length;
91a reduction in line length may be desired to keep the right margin
92aligned with an earlier margin.
93Blank lines, other vertical spaces, and lines generated by \fBtl\fR
94are \fInot\fR numbered.
95Numbering can be temporarily suspended with \fBnn\fR,
96or with an \fB.nm\fR followed by a later \fB.nm|+0\fR.
97In addition,
98a line number indent \fII\fR, and the number-text separation \fIS\fR
99may be specified in digit-spaces.
100Further, it can be specified that only those line numbers that are
101multiples of some number \fIM\fR are to be printed (the others will appear
102as blank number fields).
103.br
104.nm
105.ll
106.h1
107.bt
108\fB&nm\fI|\(+-N|M|S|I\fR off E \
109Line number mode.
110If \fI\(+-N\fR is given,
111line numbering is turned on,
112and the next output line numbered is numbered \fI\(+-N\fR.
113Default values are \fIM=\fR\|1, \fIS=\fR\|1, and \fII=\fR\|0.
114Parameters corresponding to missing arguments are unaffected;
115a non-numeric argument is considered missing.
116In the absence of all arguments, numbering is turned off;
117the next line number is preserved for possible further use
118in number register \fBln\fR.
119.bt
120\fB&nn\fI|N\fR - \fIN=\fR1 E The next \fIN\fR text output lines are not
121numbered.
122.pg
123.ll -\w'0000'u
124.nm +0
125As an example, the paragraph portions of this section
126are numbered with \fIM=\fR\|3:
127\&\fB.nm|1|3\fR was placed at the beginning;
128\&\fB.nm\fR was placed at the end of the first paragraph;
129and \fB.nm|+0\fR was placed in front of this paragraph;
130and \fB.nm\fR finally placed at the end.
131Line lengths were also changed (by \fB\ew\'0000\'u\fR) to keep the right side aligned.
132Another example is
133\&\fB.nm|+5|5|x|3\fR which turns on numbering with the line number of the next
134line to be 5 greater than the last numbered line,
135with \fIM=\fR\|5, with spacing \fIS\fR untouched, and with the indent \fII\fR set to 3.
136.br
137.ll
138.nm
139.mh
140Conditional Acceptance of Input
141.pg
142In the following,
143\fIc\fR is a one-character, built-in \fIcondition\fR name,
144\fB!\fR signifies \fInot\fR,
145\fIN\fR is a numerical expression,
146\fIstring1\fR and \fIstring2\fR are strings delimited by any non-blank, non-numeric character \fInot\fR in the strings,
147and
148\fIanything\fR represents what is conditionally accepted.
149.h1
150.bt
151\fB&if\fI|c|anything\fR - - If condition \fIc\fR true, accept \fIanything\fR as input;
152in multi-line case use \fI\e{anything\|\e}\fR.
153.bt
154\fB&if|!\fIc|anything\fR - - If condition \fIc\fR false, accept \fIanything\fR.
155.bt
156\fB&if\fI|N|anything\fR - \fBu\fR If expression \fIN\fR > 0, accept \fIanything\fR.
157.bt
158\fB&if|!\fIN|anything\fR - \fBu\fR If expression \fIN\fR \(<= 0, accept \fIanything\fR.
159.bt
160\fB&if\fI|\|\'string1\|\'string2\|\'|anything\fR - If \fIstring1\fR identical to \fIstring2\fR,
161accept \fIanything\fR.
162.bt
163\fB&if|!\fI\|\'string1\|\'string2\|\'|anything\fR - If \fIstring1\fR not identical to \fIstring2\fR,
164accept \fIanything\fR.
165.bt
166\fB&ie\fI|c|anything\fR - \fBu\fR If portion of if-else; all above forms (like \fBif\fR).
167.bt
168\fB&el\fI|anything\fR - - Else portion of if-else.
169.pg
170The built-in condition names are:
171.TS
172center box;
173c2|c2
174c2|c2
175c2|l2.
176Condition
177Name True If
178_
179\fBo\fR Current page number is odd
180\fBe\fR Current page number is even
181\fBt\fR Formatter is \*(TR
182\fBn\fR Formatter is \*(NR
183.TE
184If the condition \fIc\fR is \fItrue\fR, or if the number \fIN\fR is greater than zero,
185or if the strings compare identically (including motions and character size and font),
186\fIanything\fR is accepted as input.
187If a \fB!\fR precedes the condition, number, or string comparison,
188the sense of the acceptance is reversed.
189.pg
190Any spaces between the condition and the beginning of \fIanything\fR are skipped over.
191The \fIanything\fR can be either a single input line (text, macro, or whatever)
192or a number of input lines.
193In the multi-line case,
194the first line must begin with a left delimiter \fB\e{\fR and
195the last line must end with a right delimiter \fB\e}\fR.
196.pg
197The request \fBie\fR (if-else) is identical to \fBif\fR
198except that the acceptance state is remembered.
199A subsequent and matching \fBel\fR (else) request then uses the reverse sense of that state.
200\fBie\fR|-|\fBel\fR pairs may be nested.
201.pg
202Some examples are:
203.x1
204.ftB
205.ne 1
206&if e .tl \'\|Even Page %\'\'\'
207.ftR
208.x2
209which outputs a title if the page number is even; and
210.x1
211.ftB
212.ne 3.1
213&ie \en%>1 \e{\e
214\&\'sp 0.5i
215&tl \'\|Page %\'\'\'
216\&\'sp ~\|1.2i|\e}
217&el .sp ~\|2.5i
218.ftR
219.x2
220which treats page 1 differently from other pages.
221.mh
222Environment Switching.
223.pg
224A number of the parameters that
225control the text processing are gathered together into an
226\fIenvironment\fR, which can be switched by the user.
227The environment parameters are those associated
228with requests noting E in their \fINotes\fR column;
229in addition, partially collected lines and words are in the environment.
230Everything else is global; examples are page-oriented parameters,
231diversion-oriented parameters, number registers, and macro and string definitions.
232All environments are initialized with default parameter values.
233.h1
234.bt
235\fB&ev\fI|N\fR \fIN\(eq\fR0 previous - Environment switched to
236environment 0\(<=\fIN\fR\(<=2.
237Switching is done in push-down fashion so that
238restoring a previous environment \fImust\fR be done with \fB.ev\fR
239rather than specific reference.
240.mh
241Insertions from the Standard Input
242.pg
243The input can be temporarily switched to the system \fIstandard input\fR
244with \fBrd\fR,
245which will switch back when \fItwo\fR newlines
246in a row are found (the \fIextra\fR blank line is not used).
247This mechanism is intended for insertions in form-letter-like documentation.
248On \s-1UNIX\s+1, the \fIstandard input\fR can be the user's keyboard,
249a \fIpipe\fR, or a \fIfile\fR.
250.h1
251.bt
252\fB&rd\fI|prompt\fR - \fIprompt=\fR\s-1BEL\s+1 - \
253Read insertion from the standard input until two newlines in a row are found.
254If the standard input is the user's keyboard, \fIprompt\fR (or a \s-1BEL\s+1)
255is written onto the user's terminal.
256\fBrd\fR behaves like a macro,
257and arguments may be placed after \fIprompt\fR.
258.bt
259\fB&ex\fR - - - Exit from \*(NR\(sl\*(TR.
260Text processing is terminated exactly as if all input had ended.
261.pg
262If insertions are to be
263taken from the terminal keyboard \fIwhile\fR output is being printed
264on the terminal, the command line option \fB\-q\fR will turn off the echoing
265of keyboard input and prompt only with \s-1BEL\s+1.
266The regular input and insertion input \fIcannot\fR
267simultaneously come from the standard input.
268.pg
269As an example,
270multiple copies of a form letter may be prepared by entering the insertions
271for all the copies in one file to be used as the standard input,
272and causing the file containing the letter to reinvoke itself using \fBnx\fR (\(sc19);
273the process would ultimately be ended by an \fBex\fR in the insertion file.
274.mh
275Input\(slOutput File Switching
276.h1
277.bt
278\fB&so\fI|filename\fR - - Switch source file.
279The top input (file reading) level is switched to \fIfilename\fR.
280The effect of an \fBso\fR encountered in a macro
281is not felt until the input level returns to the file level.
282When the new file ends,
283input is again taken from the original file.
284\fBso\fR's may be nested.
285.bt
286\fB&nx\fI|filename\fR end-of-file - Next file is \fIfilename\fR.
287The current file is considered ended, and the input is immediately switched
288to \fIfilename\fR.
289.bt
290\fB&pi\fI|program\fR - - Pipe output to \fIprogram\fR (\*(NR only).
291This request must occur \fIbefore\fR any printing occurs.
292No arguments are transmitted to \fIprogram\fR.
293.mh
294Miscellaneous
295.pg
296.h1
297.bt
298.mc \s12\(br\s0
299\fB&mc\fI|c|N\fR - off E,\fBm\fR \
300Specifies that a \fImargin\fR character \fIc\fR appear a distance
301\fIN\fR to the right of the right margin
302after each non-empty text line (except those produced by \fBtl\fR).
303If the output line is too-long (as can happen in nofill mode)
304the character will be appended to the line.
305If \fIN\fR is not given, the previous \fIN\fR is used; the initial \fIN\fR is
3060.2|inches in \*(NR and 1\|em in \*(TR.
307The margin character used with this paragraph was a 12-point box-rule.
308.br
309.mc
310.bt
311\fB&tm\fI|string\fR - newline - \
312After skipping initial blanks, \fIstring\fR (rest of the line) is read in \fIcopy mode\fR
313and written on the user's terminal.
314.bt
315\fB&ig\fI|yy\fR - \fI.yy=\fB..\fR - Ignore \
316input lines.
317\fBig\fR behaves exactly like \fBde\fR (\(sc7) except that the
318input is discarded.
319The input is read in \fIcopy mode\fR, and any auto-incremented
320registers will be affected.
321.bt
322\fB&pm\fI|t\fR - all - \
323Print macros.
324The names and sizes of all of the defined macros and strings are printed
325on the user's terminal;
326if \fIt\fR is given, only the total of the sizes is printed.
327The sizes is given in \fIblocks\fR
328of 128 characters.
329.bt
330.lg0
331\fB&fl\fR - - B \c
332.lg
333Flush output buffer.
334Used in interactive debugging to force output.
335.mh
336Output and Error Messages.
337.pg
338The output from \fBtm\fR, \fBpm\fR, and the prompt from \fBrd\fR,
339as well as various \fIerror\fR messages are written onto
340\s-1UNIX\s+1's \fIstandard message\fR output.
341The latter is different from the \fIstandard output\fR,
342where \*(NR formatted output goes.
343By default, both are written onto the user's terminal,
344but they can be independently redirected.
345.pg
346Various \fIerror\fR conditions may occur during
347the operation of \*(NR and \*(TR.
348Certain less serious errors having only local impact do not
349cause processing to terminate.
350Two examples are \fIword overflow\fR, caused by a word that is too large
351to fit into the word buffer (in fill mode), and
352\fIline overflow\fR, caused by an output line that grew too large
353to fit in the line buffer;
354in both cases, a message is printed, the offending excess
355is discarded,
356and the affected word or line is marked at the point of truncation
357with a \(** in \*(NR and a \(lh in \*(TR.
358The philosophy is to continue processing, if possible,
359on the grounds that output useful for debugging may be produced.
360If a serious error occurs, processing terminates,
361and an appropriate message is printed.
362Examples are the inability to create, read, or write files,
363and the exceeding of certain internal limits that
364make future output unlikely to be useful.
365.pg
366.bp