Consider this MWE, modified from ifthenelse equal string comparison fails:
\documentclass{article}
\edef\test{german\relax}
\edef\curentry{\string german\relax}
\typeout{test: \meaning\test, curentry: \meaning\curentry}
\ifx\curentry\test
\typeout{ equal}
\else
\typeout{ unequal}
\fi
\begin{document}
\end{document}
If you compile this with pdflatex test.tex
, you'll see this output in terminal:
test: macro:->german\relax , curentry: macro:->german\relax
unequal
Now, the linked post explains why this is the case:
what happens is that \string is applied to the first token it sees, in this case a g. Comparing the two results, they are not the same: one has one non-letter then five letters, the second has six letters.
However, let's say I try to inspect some situation, in a package where I don't really know how the macros have been defined. So I decide to \typeout
the \meaning
of the macros - and I get the exact same contents printed, and the conditional still fails. What can I do to debug this kind of situation?
In other words, is there some sort of a function I could use, which (similar to Generating a catcode table in Latex (with \typeout to terminal)?) would output for the above macros, say:
% \typeoutComponents{\test}
g (catcode 11)
e (catcode 11)
r (catcode 11)
m (catcode 11)
a (catcode 11)
n (catcode 11)
\relax (catcode ?)
% \typeoutComponents{\curentry}
g (catcode 12)
e (catcode 11)
r (catcode 11)
m (catcode 11)
a (catcode 11)
n (catcode 11)
\relax (catcode ?)
... so that I'd have a chance of deducing myself why a "string" (macro) equality would fail?
(BTW, a subquestion: can a macro/command/token/control sequence (i.e. the thing starting with \
) have a catcode or not?)