[texhax] xspace
Tom Sgouros
tomfool at as220.org
Fri Dec 8 21:34:14 CET 2006
Hello all:
Can anyone tell me what's going on here?
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}}
It exists so that I can copy chunks of text from one document into
another without having to go back and fix all the cross-references.
The \xspace macro in the arguments to \testref is apparently seeing
a token that makes it think a space is required, and inserting a space
for me, no matter what.
My questions:
o What token does the \xspace macro think is following it in a sentence
like "The \tableref{mg} lists the elements..."
o How can I persuade it to look at the token that follows the \tableref
macro instead of whatever it's seeing?
Incidentally, I do know that I could change \tableref to this, and it would work:
\renewcommand{\tableref}[1]{\testref{#1}{User Guide}{Table~\ref{#1}}\xspace}
But I'm still curious about what's going on in the other case. I can't
explain it, so I'm apparently missing something I wish I understood better.
Many thanks,
-tom
--
------------------------
tomfool at as220 dot org
http://sgouros.com
http://whatcheer.net
More information about the texhax
mailing list