[texhax] TeX command works for "1 Foo" but not for "11 Foo"

martin f krafft madduck at madduck.net
Wed Oct 31 09:52:20 CET 2007

also sprach Martin Heller <mr_heller at yahoo.dk> [2007.10.30.2335 +0100]:
> Your test for empty arguments is broken.

Hello, thanks for your reply! Your proposed solution does in fact
work. Thank you very much.

Now I would like to understand what's going on. And I have two

1. Why do you postpone the command creation until \makeatletter? It
works just fine if I define it in the preamble with \newcommand.

2. I still don't understand the problem I had. It seems that my test
somehow ate arguments.

Let's look at the three kinds of invocation:

\link{http://debian.org/}{} would print
which is correct.

\link{http://debian.org/}{10 Oct 2007} would print
  http://debian.org/ [10 Oct 2007]
with the date in brackets at a smaller font size. Also correct.

\link{http://debian.org/}{11 Oct 2007} would print
  http://debian.org/ Oct 2007
with the date at the same size as the link. This is wrong.

My function did

  \if\@empty#2\relax\else{ }\begin{smaller}{[#2]}\end{smaller}\fi%

but nothing about the test for empty arguments I use explains that
behaviour, and especially not that it works as soon as I use two
extra braces:

  \if\@empty#2\relax\else{ }\begin{smaller}{[{#2}]}\end{smaller}\fi%

It seems as if the function gets "11 Oct 2007" as #2 and then ends
up comparing the first two members (1 & 1). If they are equal, then
it would push back the rest of #2 and exit, such that the remainder,
"Oct 2007" would be printed outside the function (and outside
\begin{smaller}). This just blows my mind. Do you have an idea what
exactly is happening?

martin | http://madduck.net/ | http://two.sentenc.es/
"it is the mark of an educated mind
 to be able to entertain a thought
 without accepting it."
                                                        -- aristoteles
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
Url : http://tug.org/pipermail/texhax/attachments/20071031/e0e72ca8/attachment.bin 

More information about the texhax mailing list