38

This question: \addvspace can't replace \vspace shows a situation in which an error message can be confusing. If \addvspace is used when not in vmode the error message obtained is

! LaTeX Error: Something's wrong--perhaps a missing \item.

which can be seen, for example, compiling the following simple example

\documentclass{article}
\begin{document}
a\addvspace{3em}
\end{document}

in this case, the error message is not really descriptive and could be misleading. The definition of \addvspace (Section 16.5 Vertical spacing in source2e) explains what's going on:

\def\addvspace#1{%
  \ifvmode
    \if@minipage\else
      \ifdim \lastskip =\z@
        \vskip #1\relax
      \else
      \@tempskipb#1\relax
        \@xaddvskip
      \fi
    \fi
  \else
    \@noitemerr
  \fi}

so when \addvspace is used not in vmode, \@noitemerr is called producing the mentioned error message, as can be seeing in lterror.dtx.

\gdef\@noitemerr{%
<!autoload> \@latex@error{Something's wrong--perhaps a missing %
<!autoload> \protect\item}\@ehc}
<autoload> \@autoerr\@noitemerr}  

Which other situations have you encountered in which the error message obtained seems confusing and (apparently) not related to the problem originating the error?

I would suggest to accompany each answer with the textual error message, a minimal example code producing the error, and a brief explanation of why that is the error message.

1
  • 20
    Package authors: make sure your package contains some amusing error messages.
    – Seamus
    Apr 7, 2011 at 20:45

3 Answers 3

35

There are many, I prefer the ones with a bit of humor from TeX itself, my two favorites:

Sorry, Pandora. (You sneaky devil.)

To trigger this message type:

\setbox0=\vbox{\halign{#\hfil\cr a\cr b\cr}}
\unhbox0
\bye

This will trigger an error Incompatible list can't be unboxed. Press 'h' for help and you will see the error.

and

Pretend that you’re Hercule Poirot: Examine all clues

How to trigger this message is left as an exercise for the reader. Clue is in the file TEX.POOL.

4
  • 1
    \setbox0\vbox{}\unhbox0 is sufficient. The error message is wrong on two counts, though. It's not an \hbox that it is trying to unbox and TeX is perfectly happy to unbox an \hbox in vertical mode.
    – TH.
    Apr 8, 2011 at 6:48
  • 1
    This question was revived by samcarter’s bounty; I’d like to add a couple of remarks. 1) “Sorry, Pandora…” is actually not an error message, but rather a help message. 2) About the remarks made by @TH., the help message is not wrong, since it says the TeX refuses “to unbox an \hbox in vertical mode or vice versa”; in this case, it has been asked to unbox a \vbox in horizontal mode (“vice versa”). Indeed, it is not true that TeX happiliy \unhboxes a box (that’s the correct way to state what is happening) in vertical mode: it will switch to horizontal mode and then examine the box.
    – GuM
    May 9, 2017 at 8:39
  • @GustavoMezzetti is absolutely right. The \unhbox causes TeX to move to horizontal mode and a \vbox cannot be unboxed in horizontal mode. Everything about my comment was wrong. Sorry!
    – TH.
    May 11, 2017 at 2:00
  • Is the Pandora one what became of the infamous ‘You can’t do that in horizontal mode’ in (I think) TeX78? Dec 12, 2021 at 1:43
13

Partially taken from the TeX FAQ entry Capacity exceeded [semantic nest …]: The MWE

\documentclass{article}
\begin{document}
\def\silly{\hbox{here's \silly being executed}}
\silly% Be silly
\end{document}

produces the following error:

! TeX capacity exceeded, sorry [grouping levels=255].
<to be read again> 
                   {
l.4 \silly
          
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
3
+50

Does an infinite loop count as confusing error message?

In some early experiments with catcodes I tried the following:

\documentclass{article}

\newcommand{\makeunderscoreactive}{\catcode`_=\active }
\newcommand{\makeunderscoreother}{\catcode`_=12\relax}
\makeunderscoreother
   \def\underscoreother{_}
\makeunderscoreactive
   \def_{\underscoreother}

\begin{document}
   \texttt{hello_world.txt} % this is fine
   $a_0$ % this causes an infinite loop
\end{document}

To be honest I am still not really sure why it's behaving that way.

5
  • So _ is replaced by \underscoreother which is replaced by _ which is replaced by ... May 9, 2017 at 7:44
  • @MartinSchröder: There is something I’m still missing: the active _ is replaced by \underscoreother that, in turn, is replaced by a “\catcode 12”-_; so why is this last character expanded again?
    – GuM
    May 9, 2017 at 9:07
  • 1
    @MartinSchröder: Understood; LaTeX sets \mathcode`\_="8000 (file fontmath.ltx, l. 161), as plain TeX does.
    – GuM
    May 9, 2017 at 11:09
  • @GustavoMezzetti thanks, that explains it (in combination with this answer which explains \mathcode).
    – jakun
    May 9, 2017 at 12:19
  • 2
    @jakun: Exactly. That’s why infinite recursion occurs only in math mode. And of course, the \mathcode of an _ of category 8 is not looked at, as that answer also explains.
    – GuM
    May 9, 2017 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .