0

Very often, I will have a macro that is one expansion away from a string that I would like to compare against a constant string. Now yes, obviously, I could simply define a macro that expands to the string I want to test against and use \ifx but that is very annoying to have define needless macros. I am also aware that one could use stringstrings or xstring to do this, but it seems unfortunate to have to import packages for something so conceptually simple. Here's an MWE illustrating what I'm referring to

\documentclass{article}

\def\teststring{xyz}

\begin{document}
\expandafter\ifx\expandafter{xyz}\textstring%
  TRUE%
\else%
  FALSE%
\fi%
\end{document}

This non-working solution is based off the first answer to this question but it does not appear to work in the way the author claims.

junius
  • 2,058

0 Answers0