BSD 3 development
[unix-history] / usr / doc / trofftut / tt07
CommitLineData
8340f87c
BJ
1.NH
2Strings
3.PP
4Obviously if a paper contains a large number of occurrences
5of an acute accent over a letter `e',
6typing
7.BD \eo"e\e\'"
8for each \*e
9would be a great nuisance.
10.PP
11Fortunately,
12.UL troff
13provides a way in which you can store an arbitrary
14collection of text in a `string',
15and thereafter use the string name as a shorthand
16for its contents.
17Strings are one of several
18.UL troff
19mechanisms whose judicious use
20lets you type a document
21with less effort and organize
22it
23so that extensive format changes
24can be made with few editing changes.
25.PP
26A reference to a string is replaced by whatever
27text
28the string was defined as.
29Strings are defined with the command
30.BD .ds .
31The line
32.P1
33\&^ds e \eo"e\e'"
34.P2
35defines the string
36.BD e
37to have the value
38.BD \eo"e\e\'"
39.PP
40String names may be either one or two characters long,
41and are referred to by
42.BD \e*x
43for one character names or
44.BD \e*(xy
45for two character names.
46Thus to get
47t\*el\*ephone,
48given the definition of the string
49.BD e
50as above,
51we can say
52t\e*el\e*ephone.
53.PP
54If a string must begin with blanks, define it as
55.P1
56\&.ds xx " text
57.P2
58The double quote signals the beginning of the definition.
59There is no trailing quote;
60the end of the line terminates the string.
61.PP
62A string may actually be several lines long;
63if
64.UL troff
65encounters a
66.BD \e
67at the end of
68.ul
69any
70line, it is thrown away and the next line
71added to the current one.
72So you can make a long string simply by ending each line
73but the last with a backslash:
74.P1
75\&^ds xx this \e
76is a very \e
77long string
78.P2
79.PP
80Strings may be defined in terms of other strings, or even in terms of themselves;
81we will discuss some of these possibilities later.