I have a command \mycom{}
which takes 1 argument. The command should perform a test on the argument and do something accordingly. For simple arguments, I can use \ifthenelse
, but I need to consider more general arguments, e.g. containing commands or environments.
The following MWE follows a solution for a more robust string test, which was given in this post:
\documentclass{article}
\makeatletter
\newcommand{\strtest}[2]{%
\ifnum\pdfstrcmp{#1}{#2}=\z@
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\makeatother
\newcommand{\mycom}[1]{%
\strtest{#1}{}%
{content : empty}%
{content : #1}%
}
\begin{document}
\mycom{}
\mycom{coucou}
\end{document}
This works. But if i try to call \mycom{\textbf{coucou}}
, then the compilation fails.