[tex-eplain] Warnings about redefinition of xref labels

Oleg Katsitadze olegkat at gmail.com
Wed Mar 1 11:21:35 CET 2006

On Tue, Feb 28, 2006 at 03:59:36PM -0600, Karl Berry wrote:
> so all the page number shift by one.  Won't you get 100
> warnings?  That's what my comment was trying to say.

I see what you meant.  But after some experimenting and
reflecting, it turned out there are no warnings in the case
of \xrdef.  The trick is that the labels are only checked at
the time the .aux file is read, when no labels have been
defined yet except those which come earlier in the .aux
file.  And later, \definexref does not (re)define labels
directly, it writes the definitions into the .aux file.  So,
we only catch the redefinitions from _inside_ the .aux file.

However, your comment fully applies to equation numbers,
because equation numbers are defined immediately in addition
to being written out to the .aux file.  So, if you add
another numbered equation before a hundred others, during
the next TeX run you'll get 100 warnings.

I'll update the comment to include this.

I am not sure that making equations work like the other
labels, i.e., not defining the labels directly but only
through the .aux file, is acceptable.  Most importantly, the
trick with \eqdef{} (empty label) will no longer work,
breaking many existing documents (and that trick is really
nice sometimes).  Also, it seems nice to require only a
single pass for texts which don't use references other than
equation refs.

> Maybe it's worth the warnings to get the diagnostics in the more usual
> case.

Yes, I agree that it's worth.  Getting warnings after
shifting equation numbers is reasonable (although not
necessary -- the document comes out right anyway, because
"direct" definitions of equation labels override definitions
in the .aux file).  On the other hand, warnings about
redefined labels can help prevent some really nasty bugs.

> So, a couple notes, maybe you already considered them:

Sure, I'll do this when it goes to xeplain.tex.  I just
didn't want to mutilate Tom's code and then say "I've
received this from Tom" :).

> Also, perhaps the message could just use `\oldvalue' instead of
> repeating its definition.

Yes, makes sense.

> Also, the grammar seems a little odd.  I've forgotten -- what kind of
> words are #2 and #3?  I'd speculate something like this might read better:
>         \message{\linenumber `\csname#3word\endcsname' label `#1's
>                  new value `#2' overwriting previous value `\oldvalue'.}

Yes, this seems more readable.  Also, checking for undefined
class word and omitting it from the message if it's undefined
would be nice, I think.


More information about the tex-eplain mailing list