35

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.

  • 19
    Package authors: make sure your package contains some amusing error messages. – Seamus Apr 7 '11 at 20:45
31

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.

  • 1
    how is the Pandora error triggered? – Ian Thompson Apr 7 '11 at 23:23
  • @Ian Thomson please see edit – Yiannis Lazarides Apr 8 '11 at 5:01
  • 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 '11 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 '17 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 '17 at 2:00
10

Partially taken from the UK 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.

  • So _ is replaced by \underscoreother which is replaced by _ which is replaced by ... – Martin Schröder May 9 '17 at 7:44
  • 1
    @MartinSchröder: Understood; LaTeX sets \mathcode`\_="8000 (file fontmath.ltx, l. 161), as plain TeX does. – GuM May 9 '17 at 11:09
  • 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 '17 at 20:31
  • 1
    @jakun: Yet, I cannot put up with upvoting your answer and spoiling your beatiful reputation count of 1729; I’ll wait until someone else has made it change! ;-) – GuM May 9 '17 at 20:36
  • 1
    @GustavoMezzetti thanks, you don't need to worry about that :) I would not gain reputation for upvotes on this answer, anyway, because it is a community wiki. – jakun May 10 '17 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.