[l2h] Trouble with control space

Greg Gamble gregg at maths.uwa.edu.au
Fri Feb 10 04:41:18 CET 2006


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

to ensure that (La)TeX (and LaTeX2HTML) does not gobble up the space
looking for the next token. The ~ (tie) method works slightly differently
in (La)TeX, by forcing the following word to appear on the same line, and
the space doesn't stretch.

> LaTeX2html seems to screw this up completely, usually losing some of
> the text after the control space, and (when I do use it as with \foo
> above) using caps and small caps for the whole of the text that
> follows.
> 
> This seems a fairly basic bug -- or is this a a documented `feature'?

I recommend you do a global substitute \foo -> {\foo}. Encapsulating in
curly braces works also (by effectively doing nothing), in those situations
where there is no space intended after the macro \foo:

   {\foo}FOLLOWING TEXT

If you get into this habit, you will find that those times when an expanded
macro butts up to following text don't happen anymore.

  Regards,
  Greg Gamble



More information about the latex2html mailing list