I defined the following command:
\NewDocumentCommand \displayls {s m}{%
\IfBooleanTF{#1}{\textls*[250]{#2}}{\textls[250]{#2}}%
}
I would like to refactor the definition to remove the duplication.
I can make a trivial version:
\NewDocumentCommand \displayls {s m}{%
\csname textls\endcsname[250]{#2}%
}
If I then try to process the star argument, I get into trouble. I tried:
\NewDocumentCommand \displayls {s m}{%
\csname textls\IfBooleanTF{#1}{*}{}\endcsname[250]{#2}%
}
But this does not work for the *-form; it produces:
Here is the test document:
\documentclass{article}
\usepackage{microtype,xparse}
\NewDocumentCommand \displayls {s m}{%
% (One of the definitions above)
}
\begin{document}
\displayls{foo}
\displayls*{foo}
\end{document}
I tried adding \expandafter before \csname, but that didn't make any difference.


*macro) – Werner Sep 21 '17 at 00:23