xspace 的间距问题
假设我的宏是 \newcommand{\k}{king\xspace}
。然后是间距 “……\k 说。”会没事的。但是如果我不希望中间有空格该怎么办 \k\k 的中间。?我想要“王”。不是“王王”。
有办法做到这一点吗?
Let's say my macro is \newcommand{\k}{king\xspace}
. Then the spacings in
"... said the \k." will be fine. But what do I do if I want no spacing in the
middle of \k\k.? I want "kingking." not "king king."
Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
\unskip
删除之前插入的所有跳过(其中包括空格),因此在需要删除它的奇怪情况下使用\K\unskip\K
也足够了:\unskip
removes any previous skip inserted (which includes a space), so using\K\unskip\K
for the odd occasions when you want to remove it could also suffice:\xspace
的要点是在单词之间添加空格,而不是在标点符号之前添加空格。因此,如果您不希望宏的两次使用之间有空格,请不要使用\xspace
。但是,当然这需要您在末尾使用{}
:The whole point of
\xspace
is to add a space between words and not add space before punctuation. So, if you don't want spaces between the two uses of the macro don't use\xspace
. But, of course this will require you to you to use a{}
at the end:xspace 文档说,处理此问题的方法是在宏调用后立即使用 {}:
最近版本的 xspace 还允许您指定不应在宏后生成空格的其他宏:
我想将其用于 \xspaceaddexceptions{\ textsuperscript},但它对我不起作用,因为我的商店有 xspace v1.06,而且还不够新。所以我使用了:
除了粗体部分标题之外,它工作得很好,因为我使用的字体中没有粗体小型大写字母。叹...
The xspace documentation says that the way to handle this is with {} immediately after your macro invocation:
Recent versions of xspace also permit you to specify additional macros that should not generate space after your macro:
I wanted to use this for \xspaceaddexceptions{\textsuperscript}, but it didn't work for me since my shop has xspace v1.06 and that's not recent enough. So I used:
Which worked fine except in bold section headings, since there's no bold small caps in the font that I'm using. Sigh...