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?
\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:
\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}
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:
\documentclass{article}
\newcommand{\K}{king}%
\begin{document}
At end of sentence \K.\par
In between \K\K{} you want one long word.
\end{document}
The xspace documentation says that the way to handle this is with {} immediately after your macro invocation:
\k{}\k
Recent versions of xspace also permit you to specify additional macros that should not generate space after your macro:
\xspaceaddexceptions{\k}
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:
\newcommand{\unix}{\textsc{unix}\xspace}
\unix{}\textsuperscript{\textregistered}
Which worked fine except in bold section headings, since there's no bold small caps in the font that I'm using. Sigh...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With