Interval issues with xspace

Say my macro is \newcommand{\k}{king\xspace} . Then distances to "... said \ k." will be good. But what should I do if I do not want an interval in the middle of \ k \ k.? I want to squint. not the "king of the king."

Is there any way to do this?

+4
source share
3 answers

The whole point of \xspace is to add a space between words and not add a space before punctuation. So, if you do not want the spaces between the two uses of the macro to not use \xspace . But of course, this will require you to use {} 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} 
+3
source

The xspace documentation says that the way to handle this is with {} right after the macro is called:

  \k{}\k 

Recent versions of xspace also allow you to specify additional macros that should not generate space after your macro:

  \xspaceaddexceptions{\k} 

I wanted to use this for \ xspaceaddexceptions {\ textsuperscript}, but this did not work for me, since my store has xspace v1.06 and this is not very recent. Therefore, I used:

  \newcommand{\unix}{\textsc{unix}\xspace} \unix{}\textsuperscript{\textregistered} 

Which works great, except for the bold section headings, as the font I use does not have bright little caps. Sigh...

+3
source

\unskip removes any previous skipped inserted (which includes a space), so using \K\unskip\K for odd occasions when you want to remove it may also be sufficient:

enter image description here

 \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} 
+1
source

Source: https://habr.com/ru/post/1341014/


All Articles