# [texhax] Clash between \emph and \xspace [corrected, improved]

Uwe Lueck uwe.lueck at web.de
Thu Nov 16 21:33:53 CET 2006

Uwe Lueck <uwe.lueck at web.de> wrote 15.11.2006 14:47:46:
> What clash? (Try additional tests attached below.)

Sorry, I am unable to reproduce my former (\emph{\lin}) miracle.
Probably it resulted from code of which I was not aware of,
different from the code code I posted.

To make up for this, I add to Phil Ratcliff's explanation and solution
(to do without {} at each occurrence):

> \documentclass{article}
> \usepackage{xspace}
> \newcommand{\lin}{Lindel\"of\xspace}
> \begin{document}
>
> (property we call \emph{amply \lin})
>
> (property we call {\it amply \lin})
>
> (property we call {\it\lin\/})
>
> \end{document}

The last case is OK since \/ is in the exeptions list.

At 23:27 04.11.06, Philip G. Ratcliffe wrote:
> Well this seems ok:
>
> (property we call \emph{amply \lin{}})
>
> The problem with \xspace is that it looks at the following character, which
> is a problem if it appears at the end of an argument to some macro.  Sorry,
> I've nothing more to offer.

Indeed, the LaTeX font commands like \emph{...} and \textit{...}
put the token \check at icr and some other things behind their argument,
so \xspace cannot see the closing bracket.

\makeatletter
\makeatother

so the final \xpace won't add a \space at the end of the text font
argument.

I wondered why current xspace package doesn't give \check at icr

At 00:06 05.11.06, Michael Barr wrote:
> The thing is that \emph also looks ahead
> and this is what I meant by saying it seems to be a clash of uses of
> \futurelet.

This is not the case. The spurious space before the bracket
comes from the \xspace at the end of the argument, due to \check at icr.