Next: , Previous: Auxiliary files, Up: Programming definitions


7.11 User-defined environments

Plain TeX does not provide “named” block structures, only the anonymous \begingroup and \endgroup pair. The disadvantage of this is that when there are several such groups and one is mismatched, it can be difficult to find the error. Eplain provides a named block structure so that if you forget an \environment or an \endenvironment, you will (probably) get an error message about it.

For example:

     \def\itpar{
       \environment{@italicpar}
       \it\par
     }
     \def\enditpar{
       \par
       \endenvironment{@italicpar}%
     }

which could then be used to set italicized paragraphs:

     \itpar
     If I reprehend anything in this world, it is the use of my oracular
     tongue, and a nice derangement of epitaphs!
     \enditpar

The above sort of environment allows nesting. But environments shouldn't always be allowed to nest. Put the control sequence \checkenv at the beginning of a macro that is going to define an environment that should not be nested.