명령 무시 / 여러 공백 억제

명령 무시 / 여러 공백 억제

이 예에서 여러 공백을 억제하려면 어떻게 해야 합니까?

\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}

여기에 이미지 설명을 입력하세요

관련 정보