开发者

latex: xspace not suppressing space in combination with textit [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question

I put xspace at the end of most of my macros, e.g.

\newcommand*{\foobar}{foobar\index{foobar}\xspace}

but I just discovered that if the macro is placed inside textit开发者_开发知识库, it does not work as expected, e.g.

Test 1: \foobar. Test 2: \textit{\foobar}.

produces

Test 1: foobar. Test 2: foobar .

with an extra space before the . character. Of course I could make a duplicate non-xspace macro for these case, but can I fix this more properly in some way?


I found the answer "hidden" in /usr/share/texmf/doc/latex/tools/xspace.pdf:

Sometimes \xspace may make the wrong decision, and add a space when it is not required. There may be different reasons for this behavior but it can always be handled by following the macro with {}, as this has the effect of suppressing the space.

So

Test 3: \textit{\foobar{}}.

produces

Test 3: foobar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜