コマンドを無視 / 複数のスペースを抑制

コマンドを無視 / 複数のスペースを抑制

この例では、複数のスペースを抑制するにはどうすればよいですか?

\documentclass{article}
\begin{document}
\newcommand*{\foo}[1]{dummy foo output}
Test this \foo{3} command.
% but now I want to ignore it completely
\renewcommand*{\foo}[1]{\relax}
Test this \foo{3} command.
% ...and have no multiple spaces between "this" and "command"
\end{document}

完全に無視したい\foo(ソースコードにはまだ残しておきます)。

よろしくお願いいたします、イヴァン

答え1

LaTeX カーネルにはこのための と\@bsphackがあります\@esphack

\documentclass{article}

\makeatletter
\newcommand{\kokanignore}{\@bsphack\@esphack}
\makeatother

\begin{document}

\newcommand*{\foo}[1]{dummy foo output}
Test this \foo{3} command.

\foo{3} xyz

% but now I want to ignore it completely
\renewcommand*{\foo}[1]{\kokanignore}
Test this \foo{3} command.
% ...and have no multiple spaces between "this" and "command"

\foo{3} xyz

\end{document}

ここに画像の説明を入力してください

関連情報