[l2h] Trouble with control space

Anthony Stone ajs1 at cam.ac.uk
Fri Feb 10 18:52:20 CET 2006


After a great deal of time and trouble, I have got to the bottom of
this problem. It is indeed not a problem with the control space, "\ ",
itself, but arises from the fact that whereas LaTeX accepts
\newcommand definitions like
\newcommand\foo{stuff}
LaTeX2html doesn't understand them. Of course it is true that such
definitions are not strictly allowed in LaTeX either, but the fact is
that they are accepted.

Unfortunately the behaviour of LaTeX2html on encountering such a
construction is very unhelpful. It does produce an error message, but
it is rather obscure and difficult to relate to the source code that
casued the trouble. Moreover it leads to garbage in the resulting html
that is completely unconnected to the original error. I had
inadvertently introduced the line
\newcommand\version{4.6}
and \version was used once. (It was defined merely to avoid having to
hunt through the text in order to change it.) The result was as I
described: using "\ " anywhere in the source led to material being
lost.

OK, so I should have written
\newcommand{\version}{4.6}
but it seems to me that LaTeX2html's behaviour when faced with the
incorrect version is wholly unsatisfactory. It clearly cannot handle
it. It's clear too that a backslash immediately after \newcommand or
\renewcommand must be the start of a bare control sequence, i.e. one
not enclosed in braces. If LaTeX2html can't do something sensible with
it (and it surely wouldn't be too hard to handle it as LaTeX does)
then it should treat it as a fatal error rather than generating
garbage.

Let me make it clear that I fully appreciate the hard work that Ross
and others have put into this program over the years, and nobody's
perfect. However I am feeling a bit grumpy at the moment, having spent
most of the day grappling with this problem.


At 21:25 on 10 February, Greg Gamble wrote:

 > On Thu, Feb 09, 2006 at 12:26:42PM +0000, Anthony Stone wrote:
 > >  > > I'm having trouble with LaTeX2html's treatment of "control space",
 > >  > > i.e. backslash followed by space, which TeX and LaTeX use to force a
 > >  > > space after a control sequence. That is, if I say
 > >  > > \newcommand{\foo}{{\sc Foo}}
 > >  > > to get Foo in caps and small caps, I have to write \foo\ in the LaTeX
 > >  > > source in order to make sure it is followed by a space.
 > >  > 
 > >  > Dear Anthony,
 > >  > 
 > >  > This is a `feature', not of LaTeX2HTML, but of (La)TeX which uses a space
 > >  > to separate tokens. You will find that the space disappears in your .dvi,
 > >  > .ps and .pdf versions as well. You need to do one of:
 > >  > 
 > >  >   ... \foo\ FOLLOWING TEXT
 > >  >   ... \foo~FOLLOWING TEXT
 > >  >   ... {\foo} FOLLOWING TEXT
 > >  >
 > >  > [snip]
 > > 
 > > Thank you. I am already using the first of these constructions (i.e. 
 > > "control space", in the terminology of the TeXbook), as I thought I
 > > made clear. The problem is that not only does it not work, it seems
 > > that some of the following material gets gobbled up and lost.
 > 
 > Hmm! ... it seems I misunderstood what you were asking. It is supposed
 > to work with LaTeX2HTML, and in my experience it always has. 
 > 
 > > I am also aware of the workarounds suggested, and I can use one or
 > > more of them in running text. The problem also arises in math mode,
 > > where "\ " is used to force a space. Most of the workarounds do not
 > > work here, though I can achieve what I want, for example by defining
 > > \spc to mean \mkern6mu and using that instead.
 > > 
 > > The fact is that "\ " doesn't behave in LaTeX2html as it does in
 > > LaTeX. I believe that this is a bug. The fact that there are
 > > workarounds doesn't alter this.
 > 
 > I think you should provide a short example that exhibits the problem.
 > Maybe it's something else that's the problem.
 > 
 > Regards,
 > Greg Gamble
 > 
 > _______________________________________________
 > latex2html mailing list
 > latex2html at tug.org
 > http://tug.org/mailman/listinfo/latex2html

-- 
Anthony Stone                           www-stone.ch.cam.ac.uk
University Chemical Laboratory,         Email:  ajs1 at cam.ac.uk
Lensfield Road,                         Phone: +44 1223 336375
Cambridge CB2 1EW                       Fax:   +44 1223 336362



More information about the latex2html mailing list