I know three macros that test two fully expanded character strings for equality:
\ifthenelse{\equal{<op1>}{<op2>}}{<true>}{<false>}(ifthenpackage)\IfStrEq{<op1>}{<op2>}{<true>}{<false>}(xstringpackage)\ifstr{<op1>}{<op2>}{<true>}{<false>}(scrbasepackage)
Interestingly, they share one drawback: They are fragile, which means that
- we have to
\protectthem in moving arguments (e.g. in the argument of\section). - they don’t properly work in the context of PDF string expansion (e.g. for PDF outlines) as implemented by the
hyperrefpackage.
Minimal example:
\documentclass{article}
\usepackage{xstring}
\usepackage{hyperref}
\newcommand*{\juhu}{%
juhu%
}
\newcommand*{\test}[1]{%
\IfStrEq{#1}{juhu}{Juhu!}{Oje!}%
}
\begin{document}
\tableofcontents
\section{\test{\juhu}}
%% \section{\protect\test{\juhu}}
\end{document}
Hence my question: Is it possible to implement an equality test that fully expands its operands, but removes the restrictions listed above?