If I use:
\LetLtxMacro{\MacroToUse}{\FormatText}
then using \MacroToUse
invokes \FormatText
exactly as desired. But, how do use this construct to invoke \FormatText*
?
The MWE below yields:
but the desired output is the two lines being identical.
References:
Code:
\documentclass{article}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{letltxmacro}
\newcommand*{\FormatColor}{}%
\NewDocumentCommand{\FormatText}{s m}{%
\IfBooleanTF{#1}{%
\def\FormatColor{red}%
}{%
\def\FormatColor{blue}%
}%
\textcolor{\FormatColor}{#2}%
}%
\begin{document}
\FormatText{one}
\FormatText*{two}
\newcommand{\MacroToUse}{}%
\LetLtxMacro{\MacroToUse}{\FormatText}%
\MacroToUse{one}
\LetLtxMacro{\MacroToUse}{\FormatText*}%
\MacroToUse{two}
\end{document}
model
for all. very nice\LetLtxMacro
and, in general, all patching commands should not be used with macros defined withxparse
facilities. In this case\def\MacroToUse{\FormatText*}
is more than sufficient. There's no reason for using\LetLtxMacro
here.\MacroToUse*
?\newcommand*{\FormatTextStar}{\FormatText*}
for which\LetLtxMacro{\MacroToUse}{\FormatTextStar}
would work...