On the {TeX} Q&A site, there was a question recently about splitting the first token off a list, with the requirement that spaces are not skipped. In my answer, I’ve used \let to remove one space. The question is how to do this. Normally, if you want to use \let
you do
\let\TokenA\TokenB
In this case, TeX will skip spaces after \let
and \TokenA
, so we can’t use it to \let
to a space. However, what we can do is notice that TeX allows us to have an optional =
followed by one space in the syntax for \let
. We also need to make sure that TeX does not discard two spaces in the early stage of parsing, so can use \@firstonone
:
\@firstofone{\let\TokenA= }
This will \let
\TokenA
to the next token in the input, even if it is a space. I’ve used this to remove the next token from some input in combination with \afterassignment
:
\long\def\firstofone#1{#1}
\def\GobbleExactlyOne{%
\afterassignment\NextThing
\firstofone{\let\TokenA= }%
}
Not something you need every day, but worth knowing about I think.