1 .\" This module is believed to contain source code proprietary to AT&T.
2 .\" Use and redistribution is subject to the Berkeley Software License
3 .\" Agreement and your Software Agreement with AT&T (Western Electric).
5 .\" @(#)tt11 8.1 (Berkeley) 6/8/93
6 .\" Copyright (C) Caldera International Inc. 2001-2002. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions are
12 .\" Redistributions of source code and documentation must retain the above
13 .\" copyright notice, this list of conditions and the following
16 .\" Redistributions in binary form must reproduce the above copyright
17 .\" notice, this list of conditions and the following disclaimer in the
18 .\" documentation and/or other materials provided with the distribution.
20 .\" All advertising materials mentioning features or use of this software
21 .\" must display the following acknowledgement:
23 .\" This product includes software developed or owned by Caldera
24 .\" International, Inc. Neither the name of Caldera International, Inc.
25 .\" nor the names of other contributors may be used to endorse or promote
26 .\" products derived from this software without specific prior written
29 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
30 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
31 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 .\" DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
34 .\" FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
39 .\" OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
40 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 The next step is to define macros that can change from one
49 according to parameters supplied as arguments.
50 To make this work, we need two things:
51 first, when we define the macro, we have to indicate that some
52 parts of it will be provided as arguments when the macro is called.
53 Then when the macro is
55 we have to provide actual arguments
56 to be plugged into the definition.
58 Let us illustrate by defining a macro
60 that will print its argument two points
61 smaller than the surrounding text.
62 That is, the macro call
77 Within a macro definition,
83 that the macro was called with.
86 is the string to be placed in a smaller point
91 As a slightly more complicated version, the following definition of
93 permits optional second and third arguments
94 that will be printed in the normal size:
97 \e\e$3\es\-2\e\e$1\es+2\e\e$2
100 Arguments not provided when the macro is called are treated
114 It is convenient to reverse
115 the order of arguments because trailing punctuation
116 is much more common than leading.
118 By the way, the number of arguments that a macro was called with
119 is available in number register
124 is the one used to make the
125 `bold roman' we have been using for
127 command names in text.
128 It combines horizontal motions, width computations,
129 and argument rearrangement.
132 \e&\e\e$3\ef1\e\e$1\eh'\-\ew'\e\e$1'u+1u'\e\e$1\efP\e\e$2
139 commands need no extra backslash, as we discussed above.
142 is there in case the argument begins with a period.
145 Two backslashes are needed with the
148 to protect one of them when the macro is
150 Perhaps a second example will make this clearer.
151 Consider a macro called
154 produces section headings rather like those in this paper,
155 with the sections numbered automatically,
156 and the title in bold in a smaller size.
159 ^SH "Section title ..."
161 (If the argument to a macro is to contain blanks,
166 unlike a string, where only one leading quote is permitted.)
168 Here is the definition of the
173 ^nr SH 0 \e" initialize section number
177 ^nr SH \e\en(SH+1 \e" increment number
178 ^ps \e\en(PS\-1 \e" decrease PS
179 \e\en(SH. \e\e$1 \e" number. title
180 ^ps \e\en(PS \e" restore PS
185 The section number is kept in number register SH, which is incremented each
186 time just before it is used.
187 (A number register may have the same name as a macro
188 without conflict but a string may not.)
200 we would get the value of the register at the time the macro was
203 not at the time it was
206 If that's what you want, fine,
211 we get the point size at the time the macro is called.
214 As an example that does not involve numbers,
219 ^tl 'left'center'right'
221 We could make these into parameters by using instead
223 ^tl '\e\e*(LT'\e\e*(CT'\e\e*(RT'
225 so the title comes from three strings called LT, CT and RT.
226 If these are empty, then the title will be a blank line.
227 Normally CT would be set with something like
231 to give just the page number between hyphens (as on the top of this page),
232 but a user could supply private definitions for