[texhax] xspace

tom sgouros tomfool at as220.org
Mon Dec 11 05:29:35 CET 2006

Disgusted of Tunbridge Wells <Disgusted at Royal-Tunbridge-Wells.Org> wrote:

> Tom Sgouros wrote:
>  > My questions:
>  >
>  >  o What token does the \xspace macro think is following it in a sentence
>  >    like "The \tableref{mg} lists the elements..."
> Presumably an e-group ("}"); that is what follows it in the definition

Right.  I see that the \egroup follows the \xspace, but I guess I was
under the impression that expanding a macro made the marks used to
define that macro go away.  In other words, once \testref is expanded,
the brackets used to define it wouldn't be there any more and \xpsace
would be sitting there, at the end of the \tableref.  When I define a
macro using \xspace, it looks like this: \newcommand{\hello}{Hello\xspace}
There's an \egroup after the \xspace there and \xspace looks past it
without trouble.

Why is this wrong?

>  >  o How can I persuade it to look at the token that follows the \tableref
>  >    macro instead of whatever it's seeing?
> By removing the superfluous grouping, or by placing it outside
> of the group
>  >

The offending definitions are below.  I guess I don't see a superfluous
grouping, since it seems like the grouping is necessary to feed it to

> I have this macro defined to test a reference and give me some alternate
> text if the label doesn't exist.
> \newcommand{\testref}[3]{%
>   \expandafter\ifx\csname r@#1\endcsname\relax #2\else #3\fi}
> It's used like this:
> \renewcommand{\tableref}[1]{\testref{#1}{User Guide\xspace}{Table~\ref{#1}\xspace}}

Many thanks for the help.  (Again.)


 tomfool at as220 dot org

More information about the texhax mailing list