Next: , Previous: Diversions, Up: gtroff Reference


5.26 Environments

It happens frequently that some text should be printed in a certain format regardless of what may be in effect at the time, for example, in a trap invoked macro to print headers and footers. To solve this gtroff processes text in environments. An environment contains most of the parameters that control text processing. It is possible to switch amongst these environments; by default gtroff processes text in environment 0. The following is the information kept in an environment.

These environments may be given arbitrary names (see Identifiers, for more info). Old versions of troff only had environments named ‘0’, ‘1’, and ‘2’.

— Request: .ev [env]
— Register: \n[.ev]

Switch to another environment. The argument env is the name of the environment to switch to. With no argument, gtroff switches back to the previous environment. There is no limit on the number of named environments; they are created the first time that they are referenced. The .ev read-only register contains the name or number of the current environment. This is a string-valued register.

Note that a call to ev (with argument) pushes the previously active environment onto a stack. If, say, environments ‘foo’, ‘bar’, and ‘zap’ are called (in that order), the first ev request without parameter switches back to environment ‘bar’ (which is popped off the stack), and a second call switches back to environment ‘foo’.

Here is an example:

          
          .ev footnote-env
          .fam N
          .ps 6
          .vs 8
          .ll -.5i
          .ev
          
          ...
          
          .ev footnote-env
          \(dg Note the large, friendly letters.
          .ev
— Request: .evc env

Copy the environment env into the current environment.

The following environment data is not copied:

— Register: \n[.w]
— Register: \n[.cht]
— Register: \n[.cdp]
— Register: \n[.csk]

The \n[.w] register contains the width of the last glyph added to the current environment.

The \n[.cht] register contains the height of the last glyph added to the current environment.

The \n[.cdp] register contains the depth of the last glyph added to the current environment. It is positive for glyphs extending below the baseline.

The \n[.csk] register contains the skew (how far to the right of the glyph's center that gtroff should place an accent) of the last glyph added to the current environment.

— Register: \n[.n]

The \n[.n] register contains the length of the previous output line in the current environment.