I'd like to test whether \solflag
is defined or whether \profflag
is defined. I'd like to do so with a macro whose argument could be either "sol" or "prof" (or some other word).
My "minimal (non)working example" attempt at this is
\documentclass{article}
\RequirePackage{ifthen}
\newcommand{\solflag}{}
\newcommand{\mytest}[1]
{\ifthenelse{\isundefined{\#1flag}} {UNDEFINED}{DEFINED}}
\begin{document}
Sol test: \mytest{sol}
Bar test: \mytest{bar}
2nd bar test: \ifthenelse{\isundefined{\barflag}} {UNDEFINED}{DEFINED}
\end{document}
The result, however, is this:
Sol test: DEFINED
Bar test: DEFINED
2nd bar test: UNDEFINED
My guess is that the first "Bar" test is checking whether \bar
is defined, i.e., that the concatenation of \#1
and flag
in the macro just isn't happening or something.
I suspect that the answer I need is somewhere in the LaTeX-Fu of this answer, but I simply cannot make head or tail of that.
Is it possible to do what I'm hoping to do?
\mytest
douesn't use#1
at all so it does not use its argument#1
, but with the improper syntax\#1flag
. To the OP, the proper way to convey\#1flag
is\csname #1flag\endcsname
. The sequence\#1flag
gets expanded as#1flag
where#
is literally the pound sign.#1
would be a reference to an argument\#
is an instruction to typeset a#
(a pound sign is £ :-) it does not expand to a#
(it doesn't expand at all actually, it's a chardef token)