[texhax] Constructing a very thin space

Paul Isambert zappathustra at free.fr
Fri Jul 26 14:44:24 CEST 2013


Philip Taylor <P.Taylor at Rhul.Ac.Uk> a écrit:
> 
> Paul Isambert wrote:
> > Units can be followed by an optional space, so they’re not
> > “self-terminating”;
> 
> Yes, they take an /optional/ space, which is not quite
> the same as a <space> being /expected/.
> 
>  if \thinspace did not include a space in its
> > definition, expansion would continue until a space is found, see:
> >
> >     \def\aspace{ }
> >     a\kern0pt\aspace b
> >
> > with no space between the two letters. Similarly, “a\kern0ptb” and
> > “a\kern0pt b” are the same thing. So the space at the end of
> > \thinspace is quite important.
> 
> It may indeed be :  I think I am beginning to see why.  But you
> last example seems to be more of a counter-example :  if
> “a\kern0ptb” and > “a\kern0pt b” are the same thing, then
> the space is /not/ important, I would suggest.

The space is important in the definition so a subsequent space, if any
is not gobbled. In other words, the space in the definition makes sure
the macro will have no effect on the tokens to come.

> However, returning both to Karl's original thesis and your
> own variant thereof, it would seem that if one wants to avoid
> a following token (or tokens, if the first expands to empty)
> being expanded solely by virtue of TeX searching for "one
> optional space", then including that space in the definition
> (or by including \relax in its place) can indeed be required.


Exactly.

As for the space being “expected”, I suppose Karl’s point was simply
that, since numbers or dimensions are so peculiar with respect to
space, it is good practise to always include a space token so
surprises are avoided.

In an old TUGboat paper, Donald Arseneau, Raymond Chen and Victor
Eijkhout introduced a “TeX Hierearchy”, describing levels of knowledge
characterizing novices, programmers, wizards, etc., in TeX. They did
not include space tokens as shibboleths, but they could have done so:
- the novice’s document is riddled with unwanted spaces;
- the user puts “%” everywhere, avoiding spurious spaces but sometimes
  running into trouble;
- the wizard knows when s/he should ask her/himself whether to leave a
  space or not, and how to answer that question;
- the guru always knows when to put a space character or not, even
  when spaces have funny catcodes.

Best,
Paul



More information about the texhax mailing list