[comp.text.tex] error in LaTeX's \paragraph command

zzhang@xihu.inria.fr (Zhengyou Zhang) (01/10/91)

When the "\paragraph" is followed by a word beginning with "plus" or "Plus",
eg. 
    \paragraph{title of the paragraph}
    Plusieurs ...
LaTeX will report the error as follows:
! Missing number, treated as zero.
<to be read again>
                   i
l.35 Plusi
          eurs ...


I think it may be a bug in LaTeX.


-- 
Zhengyou Zhang -- Robotvis Project -- 
Email: zzhang@mirsa.inria.fr, Phone: (33) 93.65.78.33
INRIA - Sophia Antipolis, 2004, route des Lucioles
06565 Valbonne Cedex, FRANCE

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (01/11/91)

zzhang@xihu.inria.fr (Zhengyou Zhang) writes:

>When the "\paragraph" is followed by a word beginning with "plus" or "Plus",

Marvelous! I'll cherish this for the rest of my LaTeX-flaming life!

To find out what happened, look up `weird error' in the index
of the TeX book. Knuth warns against just this sort of thing
occurring.

Victor.

ken@csis.dit.csiro.au (Ken Yap) (01/14/91)

>When the "\paragraph" is followed by a word beginning with "plus" or "Plus",
>eg. 
>    \paragraph{title of the paragraph}
>    Plusieurs ...
>LaTeX will report the error as follows:
>! Missing number, treated as zero.
><to be read again>
>                   i
>l.35 Plusi
>          eurs ...
>
>
>I think it may be a bug in LaTeX.

Yes, it's a bug. Typically this happens when the last command in a
macro is one that will take an optional "plus" or "minus" followed by a
dimension.  The fix is for macro package writers to be careful to put
\relax after such commands.

jtkohl@MIT.EDU (John T Kohl) (01/14/91)

In article <1991Jan14.000029.3377@csis.dit.csiro.au> ken@csis.dit.csiro.au (Ken Yap) writes:

> >When the "\paragraph" is followed by a word beginning with "plus" or "Plus",
> >eg. 
> >    \paragraph{title of the paragraph}
> >    Plusieurs ...
> >LaTeX will report the error as follows:
> > ...
> >I think it may be a bug in LaTeX.

> Yes, it's a bug. ... The fix is for macro package writers to be
> careful to put \relax after such commands.

What I don't understand is why putting \relax after the \paragraph{foo}
fails to fix the problem.  This file gets errors on BOTH \paragraphs
rather than just the first:

\documentstyle{article}
\begin{document}

This is some stuff.
\section{Section header}
Plusieurs the section.

\subsection{Subsection header}
Plusieurs the subsection.

\paragraph{Paragraph header 1}
\relax
Plusieurs the paragraph.

\paragraph{Paragraph header 2}
Plusieurs the paragraph.

\end{document}
--
John Kohl <jtkohl@ATHENA.MIT.EDU> or <jtkohl@MIT.EDU>
Digital Equipment Corporation/Project Athena
(The above opinions are MINE.  Don't put my words in somebody else's mouth!)

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (01/15/91)

jtkohl@MIT.EDU (John T Kohl) writes:

>In article <1991Jan14.000029.3377@csis.dit.csiro.au> ken@csis.dit.csiro.au (Ken Yap) writes:

>> >When the "\paragraph" is followed by a word beginning with "plus" or "Plus",
>> >eg. 
>> >    \paragraph{title of the paragraph}
>> >    Plusieurs ...
>> >LaTeX will report the error as follows:
>> > ...
>> >I think it may be a bug in LaTeX.

>> Yes, it's a bug. ... The fix is for macro package writers to be
>> careful to put \relax after such commands.

>What I don't understand is why putting \relax after the \paragraph{foo}
>fails to fix the problem. 

Very well observed. Took me a second to figure this one out:
the crux is that it only goes wrong with \paragraph, not with \section,
because only with the former the heading is embedded in the text.
The \hskip command that accidentally absorbs the 'plus'
in only inserted by the \everypar, and that happens at the moment
the 'P' is encountered.

So in 
\paragraph{ .. }
\relax
Plus...
The \relax is glossed over: the net effect is still
\hskip ... Plus
Remedy: put \leavevmode in front of 'Plus...'.

Victor.

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (01/16/91)

As quoted from <1991Jan14.180927.14720@csrd.uiuc.edu> by eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout):
+---------------
| The \hskip command that accidentally absorbs the 'plus'
| in only inserted by the \everypar, and that happens at the moment
| the 'P' is encountered.
| Remedy: put \leavevmode in front of 'Plus...'.
+---------------

Wouldn't it be better to put \relax at the end of the token list for \everypar
when it's set?  I.e. fix the LaTeX macros, rather than have to use a
workaround every time.

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (01/16/91)

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) writes:

>As quoted from <1991Jan14.180927.14720@csrd.uiuc.edu> by eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout):
>+---------------
>| The \hskip command that accidentally absorbs the 'plus'
>| in only inserted by the \everypar, and that happens at the moment
>| the 'P' is encountered.
>| Remedy: put \leavevmode in front of 'Plus...'.
>+---------------

>Wouldn't it be better to put \relax at the end of the token list for \everypar
>when it's set?  I.e. fix the LaTeX macros, rather than have to use a
>workaround every time.

I agree entirely. I've mailed this problem to one of the people who's
working on the new LaTeX, so the bug will be fixed. Eventually that is.
For the moment of course, anyone can fix it in his/her own style file.
Trouble is if you're not the TeX person on your system.

Victor.

maj@cl.cam.ac.uk (Martyn Johnson) (01/16/91)

In article <1991Jan14.185757.12462@agate.berkeley.edu>,
raymond@math.berkeley.edu (Raymond Chen) writes:

> Easy exercise:  Explain why you *don't* get an error with
> 
>    \paragraph{Minuscule chance of error}
> 
> even though \@svsechd expands to
> 
>    ...\hskip \z@ Minuscule chance of error...

I haven't seen any more on this "easy exercise", so I'll risk sticking
my neck out.

I spent a while trying to work out why it wouldn't fail, and couldn't
think of any reason.  So in desperation, I tried it.  It *did* fail,
complaining at the "c" in "Minuscule".

Am I missing something very very subtle here?

Martyn Johnson  ---  University of Cambridge Computer Lab  ---  Cambridge UK