BSD 3 development
[unix-history] / usr / doc / trofftut / tt13
CommitLineData
8340f87c
BJ
1.NH
2Environments
3.PP
4As we mentioned, there is a potential problem
5when going across a page boundary:
6parameters like size and font
7for a page title may well be different from those
8in effect in the text when the page boundary occurs.
9.UL troff
10provides a very general way to deal with this and
11similar situations.
12There are three `environments',
13each of which has independently settable versions of
14many of the parameters associated with processing,
15including size, font, line and title lengths,
16fill/nofill mode, tab stops, and even partially collected lines.
17Thus the titling problem may be readily solved by processing the main text
18in one environment and titles in a separate one
19with its own suitable parameters.
20.PP
21The command
22.BD .ev\ n
23shifts to environment
24.BD n ;
25.BD n
26must be 0, 1 or 2.
27The command
28.BD .ev
29with no argument returns to the
30previous environment.
31Environment names are maintained in a stack, so calls
32for different environments may be nested and unwound consistently.
33.PP
34Suppose we say that the main text is processed in environment 0,
35which is where
36.UL troff
37begins by default.
38Then we can modify the new page macro
39.BD .NP
40to process titles in environment 1 like this:
41.P1 2
42^de NP
43^ev 1 \e" shift to new environment
44^lt 6i \e" set parameters here
45^ft R
46^ps 10
47\&... any other processing ...
48^ev \e" return to previous environment
49^^
50.P2
51It is also possible to initialize the parameters for an environment
52outside the
53.BD .NP
54macro,
55but the version shown keeps all the processing in one place
56and is thus easier to understand and change.