假设我的宏是\newcommand{\k}{king\xspace}
. 然后“...表示\k”中的间距。会没事的。但是如果我不想在 \k\k. 中间没有间距怎么办?我要“王者”。不是“国王国王”。
有没有办法做到这一点?
\unskip
删除任何先前插入的跳过(包括一个空格),因此\K\unskip\K
在您想要删除它的奇怪场合使用它也足够了:
\documentclass{article}
\usepackage{xspace}% http://ctan.org/pkg/xspace
\newcommand{\K}{king\xspace}
\begin{document}
Here is the \K. Here is the \K\K. Here is the \K\unskip\K.
\end{document}
的重点\xspace
是在单词之间添加空格,而不是在标点符号前添加空格。因此,如果您不想在宏的两个用途之间使用空格,请不要使用\xspace
. 但是,当然这将要求您{}
在最后使用 a :
\documentclass{article}
\newcommand{\K}{king}%
\begin{document}
At end of sentence \K.\par
In between \K\K{} you want one long word.
\end{document}
xspace 文档说处理这个问题的方法是在宏调用后立即使用 {}:
\k{}\k
最近版本的 xspace 还允许您指定不应在宏之后生成空间的其他宏:
\xspaceaddexceptions{\k}
我想将它用于 \xspaceaddexceptions{\textsuperscript},但它对我不起作用,因为我的商店有 xspace v1.06,而且还不够新。所以我用:
\newcommand{\unix}{\textsc{unix}\xspace}
\unix{}\textsuperscript{\textregistered}
除了粗体部分标题外,它工作得很好,因为我正在使用的字体中没有粗体小写字母。叹...