[texhax] Query : why can \ifnum comparison operators not be \let, yet \def is OK ?

Philip Taylor P.Taylor at Rhul.Ac.Uk
Wed Feb 3 11:39:27 CET 2016



David Carlisle wrote:

> "Why?" is hard to answer. That is just how it is.
> 
> The comparison syntax needs an explicit < of catcode 12 but macros are
> as usual expanded when tex is looking for syntactic forms, so it may
> be produced by expanding \def defined macros.
> The implicit < token defined by \let is a syntax error because it
> isn't a catcode 12 token with character code of < > or =

Thank you David.  Your answer not only explained everything to my
complete satisfaction but also led me to a more elegant solution :

\newcount \maxchapter
\maxchapter = 0
\advance \maxchapter by 1

\catcode `\< = \active
\def <#1>{\csname XML:#1\endcsname}

\def \Chapter #1 #2%
    {
        \vfill \eject
        \mark {{Chapter #1}{#2}}
        \ifnum #1 \string < \maxchapter
        \def \next {\input #1.xml}
        \else
        \let \next = \relax
        \fi
        \next
    }

\Chapter 1 {Introduction}
\end

** Phil.


More information about the texhax mailing list