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

Martin Heller mr_heller at yahoo.dk
Tue Oct 30 23:35:15 CET 2007


martin f krafft skrev:
> Hi list,
> 
> This is a weird problem. I use the following for my thesis to force
> me to include a date with each link I refer to, or make it explicit
> that I don't need a date, e.g. \link{http://debian.org}{}:
> 
>   % not making #2 optional on purpose
>   \renewcommand{\link}[2] {%
>   \burl{#1}%
>   \if\@empty#2\relax\else{ }\begin{smaller}{[#2]}\end{smaller}\fi%
>   }
> 
> The problem is that this works fine for dates like 1 Oct 2007 or 15
> Sep 2007, but as soon as the date is 11 or 22, something goes fishy:
> 
> While \link{http://debian.org/Bugs/server-control}{10 Oct 2007}}
> yields:
> 
>   http://debian.org/Bugs/server-control [10 Oct 2007]
> 
> \link{http://debian.org/Bugs/server-control}{11 Oct 2007}} gets me
> 
>   http://debian.org/Bugs/server-control Oct 2007
> 
> Either TeX is on drugs, or I am, or I simply don't understand what's
> going on. Could you help me figure this out, please?
> 
> 

Your test for empty arguments is broken.

\documentclass{article}
\usepackage{relsize,ifmtarg}
\usepackage{hyperref,breakurl}
   % not making #2 optional on purpose
   \providecommand\link{}
   \makeatletter
   \renewcommand{\link}[2] {%
   \burl{#1}%
   \@ifnotmtarg{#2}{\begin{smaller}{[#2]}\end{smaller}}%
   }
\makeatother

\begin{document}

\link{http://debian.org/Bugs/server-control}{10 Oct 2007}

\link{http://debian.org/Bugs/server-control}{11 Oct 2007}

\link{http://debian.org/Bugs/server-control}{}

\end{document}



More information about the texhax mailing list