[texhax] A problem about \jobname
geolsoft at mail.ru
geolsoft at mail.ru
Thu Aug 19 13:58:26 CEST 2004
On Thu, Aug 19, 2004 at 07:44:45AM +0100, Robin Fairbairns wrote:
> the code you quote comes from the latex cite package, and is mentioned,
> among many others in the discussion of this issue in
> http://www.tex.ac.uk/cgi-bin/texfaq2html?label=isitanum
>
> good for oleg, i say, but it would be nice if he had quoted his
> sources...
I agree with your reaction. In fact, I myself hate when people don't give fair
credit. But please read below quote from my original message (archived at
http://tug.org/pipermail/tex-eplain/2004-August.txt.gz):
> the following for the checking:
>
> \def\gobbleminus#1{\ifx-#1\else#1\fi}
> \def\IsInteger#1{%
> TT\fi
> \ifcat_\ifnum9<1\gobbleminus#1 _\else A\fi
> }
>
> which must be used as
>
> \if\IsInteger{<subject of test>}%
> <deal with integer>%
> \else
> <deal with non-integer>%
> \fi
>
> (I adopted these macros from The UK TeX FAQ, http://www.tex.ac.uk/faq).
I did not refer to the cite package as the macro I borrowed, according to the
FAQ, is a generalization of the one used in cite package.
By the way, would not it be useful to document in the FAQ situations when
\IsInteger could fail? The ones I can think of are:
1. \IsInteger{ {23}} will say it has an integer (i.e., leading spaces and/or one
level of braces are disregarded, due to the \gobbleminus helper).
2. When `<subject of test>' starts with a number, followed by an `_', followed
by something else, \IsInteger gives truth, and `something else' followed by
an `_' gets out into the output.
It has just come to my mind (might be a blunder, I did not do much testing)---it
seems to me that the first problem can be solved by eliminating the call to
\gobbleminus, like this:
\def\IsInteger#1{%
TT\fi
\ifcat_\ifnum9<1\ifx-#1\else#1\fi _\else A\fi
}
This trades one problem for another---now _trailing_ spaces are disregarded
(i.e., \IsInteger{23 } will give truth), but at least the braces problem is gone
now. Do you see any problems with this?
Best regards,
Oleg Katsitadze
More information about the texhax
mailing list