[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:

\def\checkspace#1 {% There's a space after #1
% it was a space...
% etc.

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 
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...


More information about the texhax mailing list