我制作了这个简单的宏:
\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}