kirkaas@oahu.cs.ucla.edu (paul kirkaas) (02/05/91)
I want to define macros that end a group, doing a few cleanup chores in
the process --- for example, a \beginvcenter \endvcenter pair to center
text vertically in a page.
I would like to find a way to either:
1) Include a closing brace `}' as part of the macro substitution
or
2) Figure out how to properly use \begingroup & \endgroup to achieve the
same end.
I have defined a macro \vcenter{ *TEXT* } that will vertically
center the argument text within the brackets as follows:
\long\def\page{\vbox to\vsize \relax}
\long\def\vcenter#1{\page{\vfil #1 \vfil}}
What I want to do is define two macros \beginvcenter & \endvcenter
which allow me to say:
\beginvcenter
*TEXT*
\endvcenter
and I don't know how.
--
Paul Kirkaas
kirkaas@cs.ucla.eduogawa@orion.arc.nasa.gov (Arthur Ogawa) (02/05/91)
You want to define as follows:
\long\def\beginvcenter{\vbox to\vsize\bgroup\vfil}%
\def\endvcenter{\vfil\egroup}%
THen you can write:
\beginvcenter
*TEXT*
\endvcenter
Be careful: the resulting box will always require a page of its own!
Cheers,
Art Ogawaeijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (02/06/91)
kirkaas@oahu.cs.ucla.edu (paul kirkaas) writes: >I want to define macros that end a group, doing a few cleanup chores in >the process --- for example, a \beginvcenter \endvcenter pair to center >text vertically in a page. >I would like to find a way to either: >1) Include a closing brace `}' as part of the macro substitution > or >2) Figure out how to properly use \begingroup & \endgroup to achieve the >same end. Boxes can be opened/closed by braces or by `implicit braces': tokens that are \let to a brace. Because of the definitions \let\bgroup{ \let\egroup} (l)plain.tex, you can write \hbox\bgroup ... \egroup, and you can do that with macros: \def\beginbox{\hbox\bgroup} \def\endbox{\egroup} The \begingroup/\endgroup commands cannot be interchanged with {} or \bgroup/\egroup. But they do define a group in which changes are local. You can use them therefore as some sort of runtime error checking: they will not be matched accidentally with braces or \bgroup/\egroup tokens appearing. Victor.