Commit | Line | Data |
---|---|---|
54b544da BK |
1 | .NH |
2 | Environments | |
3 | .PP | |
4 | As we mentioned, there is a potential problem | |
5 | when going across a page boundary: | |
6 | parameters like size and font | |
7 | for a page title may well be different from those | |
8 | in effect in the text when the page boundary occurs. | |
9 | .UL troff | |
10 | provides a very general way to deal with this and | |
11 | similar situations. | |
12 | There are three `environments', | |
13 | each of which has independently settable versions of | |
14 | many of the parameters associated with processing, | |
15 | including size, font, line and title lengths, | |
16 | fill/nofill mode, tab stops, and even partially collected lines. | |
17 | Thus the titling problem may be readily solved by processing the main text | |
18 | in one environment and titles in a separate one | |
19 | with its own suitable parameters. | |
20 | .PP | |
21 | The command | |
22 | .BD .ev\ n | |
23 | shifts to environment | |
24 | .BD n ; | |
25 | .BD n | |
26 | must be 0, 1 or 2. | |
27 | The command | |
28 | .BD .ev | |
29 | with no argument returns to the | |
30 | previous environment. | |
31 | Environment names are maintained in a stack, so calls | |
32 | for different environments may be nested and unwound consistently. | |
33 | .PP | |
34 | Suppose we say that the main text is processed in environment 0, | |
35 | which is where | |
36 | .UL troff | |
37 | begins by default. | |
38 | Then we can modify the new page macro | |
39 | .BD .NP | |
40 | to 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 | |
51 | It is also possible to initialize the parameters for an environment | |
52 | outside the | |
53 | .BD .NP | |
54 | macro, | |
55 | but the version shown keeps all the processing in one place | |
56 | and is thus easier to understand and change. |