[texhax] Catching a space.
Paul Isambert
zappathustra at free.fr
Sat May 1 20:15:19 CEST 2010
Dear all,
I'm trying to write a macro, say \ifspace{true}{false}, that checks
whether the next character is a space. However, I would like to do it in
a purely expandable manner, so that the usual \futurelet technique can't
work here (and, of course, I don't want to change catcodes beforehand).
With LuaTeX, I think it can be done quite easily (inspecting incoming
tokens), but I can't find a solution with other engines (with at least
the eTeX extensions). My best guess would be to launch the following:
\let\emptystring\relax
\def\checkspace#1 {% There's a space after #1
\ifcsname\detokenize{#1}emptystring\endcsname
% it was a space...
% etc.
\fi
}
But, of course, the flaws are blatant, and it'll probably run into a lot
trouble (for instance, at the end of a file). So my best guess is pretty
bad.
I tend to think that it can't be done, but since I've seen a good deal
of wizardry here, I thought I'd ask before I give up...
Best,
Paul
More information about the texhax
mailing list