[texhax] Finding the widest string

José Romildo Malaquias j.romildo at gmail.com
Tue May 4 18:39:01 CEST 2010


On Tue, May 04, 2010 at 04:33:59PM +0100, Joseph Wright wrote:
> On 04/05/2010 16:14, José Romildo Malaquias wrote:
> > What excatly are \dimen@ and \z@ ? Are they a pre-defined dimension and
> > a pre-defined box, respectively? If so, can they be freely used in my
> > code? Using them would affect any other part of the system, for
> > instance, other macros that also use them?
> >
> > In the above example we found the snippet \wid at fmt{#1} of code, where
> > the macro \wid at fmt was defined to be a macro that is passed as argument,
> > so one cannot tell what it is in advance. What about if this macro also
> > makes use of \dimen@ or \z@, using their current value or setting new
> > values to them?
> 
> Both \dimen@ and \z@ are defined by the LaTeX kernel (and I think the 
> plain format). \z@ is equal to 0 pt, and can be used as either "0" or "0 
> pt": it should never be altered. \dimen@ is the name given to \dimen0, 
> and it is used as a scratch dimension: set it and use is straight away, 
> or something else might alter the content.

So the following:

  \setbox\z@\hbox{\wid at fmt{#1}}

is equivalent to

  \setbox0\hbox{\wid at fmt{#1}}

and it records the given box in a special box variable that has the
index 0, right? After doing some more searching I have found that there
are 256 possible indexes, from 0 to 255, that can be used with \setbox.

See if my understanding is right: everyone using \dimen@ and \setbox\z@
should know that they may be used anywhere else, therefore their
contents could be changed anytime, and should not rely on them not being
modified. Furthermore, he/she should not worry about other uses of them in
other macros if he/she want to change them.

Romildo


More information about the texhax mailing list