In the following MWE (it's minimal, so not the original problem). As you can check there is one space on both sides of \mycommand
. While I'm making the macro "dummy" for a specific use: can I remove one of the spaces if there would be two left?
\documentclass{article}
\DeclareRobustCommand\mycommand[1]{%
\textbf{#1}%
}
\makeatletter
\newcommand\nobf[1]{%
{\def\mycommand##1{}#1}}
\makeatother
\begin{document}
\def\abc{X \mycommand{Y} Z \mycommand{!}}
\abc
\nobf{\abc}
X Z
\abc
\end{document}
There is a doubled space between the first X
Z
pair: