[tex-k] Error in TeXbook: Trailing tabs don't typeset

Julian Gilbey julian at d-and-j.net
Fri Sep 1 11:02:31 CEST 2017


On Fri, Sep 01, 2017 at 11:39:31AM +0300, Evan Aad wrote:
> The first line, which sets <tab>'s catcode to 12 undoes Plain TeX's
> settings, and the <tab> no longer acts like a blank space.

Oh, sorry, I overlooked that.

The reason is that the Web2C implementation of TeX has actually
changed the semantics from that of the original TeX.  (That may have
been intentional or not, but it might be good if TeX itself could have
its own variant version which conforms to DEK's spec.)

The source is in web2c/lib/texmfmp.c, lines 2407-2409, in the middle
of the function input_line (which is a replacement for tex.web's
input_ln): they read:

  /* Trim trailing whitespace.  */
  while (last > first && ISBLANK (buffer[last - 1]))
    --last;

So instead of just trimming ASCII space characters, it trims all
blanks.  Incidentally, ISBLANK is defined by:

#define ISBLANK(c) (isascii (c) && isblank ((unsigned char)c))

in kpathsea/c-ctype.h

Best wishes,

   Julian

> On Fri, Sep 1, 2017 at 11:17 AM, Julian Gilbey <julian at d-and-j.net> wrote:
> >
> > On Wed, Aug 30, 2017 at 07:55:55PM +0300, Evan Aad wrote:
> > > I think I found an error in the TeXbook. Please vet.
> > >
> > > Consider the following Plain TeX manuscript
> > >
> > > ---
> > > \catcode9=12\relax% ASCII 9 is tab
> > > .\ \ .\par%
> > > .
> > > .%
> > > \bye
> > >
> > > [...]
> > > Observe that there seem to be two spaces between the dots on the first
> > > line, but only one space between the dots on the second line.
> > >
> > > However, based on the TeXbook, I'd expect there two be two spaces
> > > between the dots on the second line too: one for the tab, and one for
> > > the carriage-return at the end of the line.
> >
> > This is not correct: "Plain TeX makes <tab> act like a blank space."
> > says the TeXbook (page 45), so you have a blank space, and TeX enters
> > state S (skipping blanks).  It now reaches the end-of-line, and "if
> > TeX is in state S (skipping blanks), the end-of-line character is
> > simply dropped." (page 46).  So all that you end up with is a single
> > space character, as you observed.
> >
> >    Julian


More information about the tex-k mailing list