[texhax] Finding the widest string

Stephen Hicks sdh33 at cornell.edu
Tue May 4 23:57:09 CEST 2010

2010/5/4 José Romildo Malaquias <j.romildo at gmail.com>:
> 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.

You're correct in noting that these registers may be changed out from
under you.  Indeed, as far as your macro is concerned, the only place
this might possibly happen is in \wid at fmt, which allows calling
outside code.  Very often there is no need at all to call macros you
don't necessarily trust.  However, even in the case of \wid at fmt,
you're still mostly safe: because \wid at fmt is executed within the
extra grouping of the \hbox, it has its own local scope.  As long as
it doesn't ever use \global\dimen@=..., there's no problem.  And even
if \box\z@ were set \global-ly, it gets overwritten immediately
afterwards by your macro.

I don't know how widely-followed this is, but it seems to me very bad
practice to \global-ly set \count@, \dimen@, \skip@, \box\z@, and so
on.  As far as I know, LaTeX is good about this - it shouldn't be
difficult to do an audit of CTAN to get an idea of who follows this or


More information about the texhax mailing list