매크로가 간격을 따르거나 간격이 부족하도록 만듭니다.

매크로가 간격을 따르거나 간격이 부족하도록 만듭니다.

저는 다음과 같은 간단한 매크로를 만들었습니다.

\documentclass{ltxdoc}
\newcommand\Q{\textbf{Q}}

\begin{document}
I like to type my \Q's in bold quickly, but sometimes I also end my line with \Q. 
This doesn't have it's intended effect.
\end{document}

매크로에 앞에 공백(또는 문자)을 확인하고 \textbf{Q}정상적으로 입력한 것처럼 따르도록 지시할 수 있나요? 앞에 점(.)이 있든 공백( )이 있든 상관없이 정상적으로 동작했으면 좋겠습니다.

답변1

최근에는 생각조차 금기시되고 있지만 xspace패키지는 다음과 같이 합니다.

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

암호:

\documentclass{ltxdoc}
\usepackage{xspace}
\newcommand\Q{\textbf{Q}\xspace}

\begin{document}
I like to type my \Q's in bold quickly, but sometimes I also end my line with \Q. 
This doesn't have it's intended effect.

In a sentence \Q works now.
\end{document}

관련 정보