[texhax] A problem about \jobname

Rodolfo Medina romeomedina at libero.it
Sun Aug 15 11:03:51 CEST 2004

Hartmut Henkel wrote:

>maybe this hack keeps you going...
>\input eplain
>See \ifx\tempa\tempb this file\else \ref{label}\fi.

The problem seems to be solved now.

An analogous problem arises when you try to `treat \refn as a number',
i. e. to compare the result of \refn{label} with a number.
Example: if you say:


and, some lines below, you try to compare the result of \refn{label},
which is the number 1,
with a number, say 2, using \ifnum, you have troubles: if I say, e.g.,

 \ifnum2=\refn{label2}yes\else no\fi

you get the error message

 ! Missing number, treated as zero.

The reason why you get that `Missing number, treated as zero' message
is that on the very first run of TeX on your input file,
when no .aux file is present yet,
\refn cannot know what the definition of your label is,
therefore it defines your label to a string (`label', in typewriter face).
So when you try to compare this definition with a number,
TeX gets a back-quote where it expects a number, hence the error message.
Note that when you run TeX next time,
after definition for the label has been written out to the .aux file,
the label will get correct definition and will expand to a number,
and you won't get the error message.

The solution to this problem was suggested by Oleg Katsitadze,
in the tex-eplain eplain mailing list.
It boils down to checking whether \refn{label} expands to a number,
and doing the comparison only when the label does expand to a number.
Here is the hack:

    \ifcat_\ifnum9<1\gobbleminus#1 _\else A\fi
  }                %this definition looks deeply misterious to me!
                   %what on earth will ever mean that `TT\fi'??
                   %and `\ifnum9<1'?

, which must be used as

  \if\IsInteger{<subject of test>}%
    <deal with integer>%
    <deal with non-integer>%

. \IsInteger macro has a flaw, as \IsInteger{ {<integer>}} will hold true,
disregarding the braces and/or leading spaces,
but for our purpose this is good enough.

Now comparing the result of \refn{label} with a number would look like the


    \ifnum2=\refn{label}yes\else no\fi
    <no .aux file present yet>%

Once again, this will not work
if it's possible for the label to get defined as {<integer>}.
In that case you'll need to write a better \IsInteger macro.

Thanks to all,

More information about the texhax mailing list