I am afraid you are out of luck here... If I understand you correctly you want to compare the text that is typeset in the end. For this one would need to expand the argument first before comparing strings.
In TeX what one can compare (basically) are tokens. One can compare if two tokens are equal in character code or equal in category code or both, and one can compare if the definitions of two control sequences have the same meaning. The last thing is what is usually done when one talks of “string” comparison in TeX. (This is by no means complete but should suffice here).
In the following example I'm using etoolbox but similar things are true for ifthen:
Code: Select all
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\def\test{test}
\ifstrequal{\test}{test}{TRUE}{FALSE}% FALSE
\expandafter\ifstrequal\expandafter{\test}{test}{TRUE}{FALSE}% TRUE
\end{document}
The above won't work with your example, though, as
\expandafter
only expands once which will only replace
\textbf
with
\protect\textbf
. One would need to expand the argument until only unexpandable material is left before comparing. However, [CTAN]\textbf[/CTAN] is not expandable. One could try something different, though:
Code: Select all
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\long\def\long@firstofone#1{#1}
\newcommand\compare[4]{%
\begingroup
\let\textbf\long@firstofone
\long\edef\tmpa{#1}% expand everything and store in \tmpa
\long\edef\tmpb{#2}% expand everything and store in \tmpb
\ifdefequal\tmpa\tmpb{#3}{#4}%
\endgroup
}
\makeatother
\begin{document}
\def\test{\textbf{test}}
\compare{\test}{test}{TRUE}{FALSE}% TRUE
\end{document}
This temporarily disables
\textbf
(similar things would be needed for
\textit
, ... ). As for
\someothercommand
: as long as we don't know how it is defined you might still be out of luck here.
Regards