I have a large \foreach
loop, and need to evaluate macros on the arguments. (These are string comparison macros, but maybe that doesn't matter.) Here's an example:
\documentclass{article}
\usepackage{tikz}
\usepackage{etoolbox}
\newcommand\process[1]{\ifstrequal{#1}{Fridge}{EQUAL}{UNEQUAL}}
\begin{document}
\foreach \a in {Fridge,Badger} {\process{\a} }
\end{document}
This produces the output UNEQUAL UNEQUAL
. My desired output is EQUAL UNEQUAL
.
In my real example I'm doing a simultaneous iteration over multiple variables (\foreach \a/\b in ...
), and my macros take multiple parameters, not just one.
I'm not completely clueless; I know why this is happening, and I've tried hundreds of combinations of \expandafter
, \edef
, and so on, but without any success. I find this aspect of LaTeX extremely hard to understand.
\ifstrequal
does not expand its arguments.\ifstrequal
, I'd be happy to use some other macro that lets me test an argument for string equality.