Sadly Knuth in his wisdom gave only few clues in the TeXBook for cases like this.
In order to understand the error we need to firstly understand the definition of \the
, which is for the case of catcode
\the<codename><8-bit number>
, where <codename>
stands for either \catcode
,
\mathcode
, \lccode
etc...
So clearly in this case catcode
TeX expects a number and hence the error generated in the example provided by the OP.
All solutions provided by the other posts revolve around changing the definition one way or another to produce the required character code number and which I am demonstrating here with some different examples:
The example below will produce the right answer in both cases,
% results category 11
\makeatletter
\def\ABC{`@ }
\the\catcode\ABC
% results category 12
\makeatother
\def\ABC{`@ }
\the\catcode\ABC
While comparing two tokens using \ifcat
things become a bit more complicated, if you want to compare two active characters you have to say \noexpand
- Knuth says so somewhat obscurely in Exercise 20.11!
Consider the following definitions
\catcode`[=13 \catcode`]=13
\def[{*}
The following will result True since we comparing [
with ']' both now being category 13
\ifcat\noexpand[\noexpand] True \else False \fi
Also \ifcat[* True \else False \fi
is True
Since now we have established two facts \the\catcode
needs a number and if you use an active character, implicitly or explicitly we can understand why the following will all work!
\def\abc{`A}
\chardef\abc=65
or Joseph's suggestion for comparisons:
\let\abc=A
\ifcat\noexpand\abc A%
\TRUE
\else
\FALSE
\fi
There is no reason why it should be \catcode`,=\active
in the first case and \catcode`\,=\active
in the second. Both could be either with \,
or ,
. Escaping the character is necessary only for \
, %
(and other less important cases), but escaping is not harming either.
Probably the author of the macros was concerned that an active character might do something strange if not escaped.
The commas disappear because, when a character is active, it is like a macro and it is replaced by the replacement text, in this case \mskip\pFqskip\relax
.
Actually this is not the best way to define that macro for typesetting hypergeometric functions parameters.
A cleaner way, that allows \pFq
to be the argument to another command, is
\usepackage{amsmath} % for \genfrac
\newmuskip\pFqskip
\pFqskip=6mu
\mathchardef\pFcomma=\mathcode`, % keep a copy of the comma
\newcommand*\pFq[5]{%
\begingroup
\begingroup\lccode`~=`,
\lowercase{\endgroup\def~}{\pFcomma\mkern\pFqskip}%
\mathcode`,=\string"8000
{}_{#1}F_{#2}\biggl[\genfrac..{0pt}{}{#3}{#4};#5\biggr]%
\endgroup
}
The comma is made "math active", and its meaning becomes: "print a comma and insert a space" (if you don't want the comma, remove \pFcomma
from the definition). I've reduced the spacing, because commas add some after them.
The lines
\begingroup\lccode`~=`,
\lowercase{\endgroup\def~}{\pFcomma\mkern\pFqskip}%
define locally a meaning for the active comma, then this meaning is triggered by \mathcode`,=\string"8000
(the \string
may be necessary in case babel
is used). The rest is as in the previous version.
Best Answer
This is an incompability between graphicx and turkish:
turkish makes the equal sign active at begin document and this leads to error when later supp-pdf.mkii is read. The problem will be resolve in the next graphicx version. A work-around until then is to load graphicx before babel: