1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
31 %%% From File: lterror.dtx
34 \ProvidesFile{lterror.dtx}
35 [2015/02/21 v1.2o LaTeX Kernel (errors)]
37 \documentclass{ltxdoc}
38 \GetFileInfo{lterror.dtx}
50 \MaintainedByLaTeXTeam{latex}
59 % \changes{v1.1a}{1994/05/16}{(ASAJ) Split from ltinit.dtx.}
60 % \changes{v1.1a}{1994/05/16}{(ASAJ) Completely new error interface.}
61 % \changes{v1.1b}{1994/05/17}{(ASAJ) Moved error stuff from
63 % \changes{v1.1c}{1994/05/20}{(ASAJ) Added \cs{@latex@info@no@line}.}
64 % \changes{v1.1c}{1994/05/20}{(ASAJ) Added missing full stops.}
65 % \changes{v1.1c}{1994/05/20}{(ASAJ) Fixed a bug with
67 % \changes{v1.1d}{1994/05/21}{(ASAJ) Made the error commands robust.}
68 % \changes{v1.1e}{1994/05/22}{(ASAJ) Replaced bgroup by begingroup in
69 % error messages, to stop extra mathords creeping into math mode.}
70 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaced \cs{@generic@message} and
71 % \cs{@generic@error} by \cs{GenericError}, \cs{GenericWarning} and
73 % \changes{v1.2a}{1994/05/22}{(ASAJ) Made \cs{GenericError},
74 % \cs{GenericWarning} and \cs{GenericInfo} robust.}
75 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaced \cmd\\ and tilde by
76 % \cs{MessageBreak} and \cs{space}.}
77 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaces \cs{string} by
78 % \cs{protect} in some messages.}
79 % \changes{v1.2f}{1994/05/24}{(DPC) wrap long lines}
80 % \changes{v1.2h}{1994/11/17}
81 % {\cs{@tempa} to \cs{reserved@a}}
82 % \changes{v1.2i}{1995/09/01}
83 % {Add autoload support}
84 % \changes{v1.2j}{1995/10/09}
85 % {Modify autoload support}
86 % \changes{v1.2o}{2015/02/21}
87 % {Removed autoload support}
89 % \section{Error handling}
91 % This section defines \LaTeX's error commands.
100 % The `2ekernel' code ensures that a |\usepackage{autoerr}| is
101 % essentially ignored if a `full' format is being used that has
102 % the error messages already in the format.
104 % These days we don't support autoloading approach any longer, but
105 % this part bit is kept in case it is used in old documents.
107 \expandafter\let\csname ver@autoerr.sty\endcsname\fmtversion
111 % \subsection{General commands}
113 % \begin{macro}{\MessageBreak}
114 % This command prints a new-line inside a message, followed by a
115 % continuation line begun with |\@msg@continuation|. Normally it is
116 % defined to be |\relax|, but inside messages, it is let to
119 \let\MessageBreak\relax
123 % \changes{v1.2g}{1994/11/04}{Added \cs{set@display@protect} to
124 % \cs{Generic*} commands. ASAJ.}
126 % \begin{macro}{\GenericInfo}
127 % This takes two arguments: a continuation and a message, and sends
128 % the result to the log file.
130 \DeclareRobustCommand{\GenericInfo}[2]{%
132 \def\MessageBreak{^^J#1}%
134 \immediate\write\m@ne{#2\on@line.}%
140 % \begin{macro}{\GenericWarning}
141 % This takes two arguments: a continuation and a message, and sends
142 % the result to the screen.
144 \DeclareRobustCommand{\GenericWarning}[2]{%
146 \def\MessageBreak{^^J#1}%
148 \immediate\write\@unused{^^J#2\on@line.^^J}%
154 % \begin{macro}{\GenericError}
155 % This macro takes four arguments: a continuation,
156 % an error message, where to go for further information, and the help
157 % information. It displays the error message, and sets the error help
158 % (the result of typing |h| to the prompt), and does a horrible hack
159 % to turn the last context line (which by default is the only context
160 % line) into just three dots. This could be made more efficient.
161 % \changes{v1.2d}{1994/05/22}
162 % {(DPC) New version using long command name.}
163 % \changes{v1.2d}{1994/05/22}
164 % {(DPC) Alternative version added for old TeXs}
173 \catcode`\ =11\relax%
178 % Unfortunately \TeX\ versions older than 3.141 have a bug which means
179 % that |^^J| does not force a linebreak in |\message| and |\errmessage|
180 % commands. So for these old \TeX's we use |\typeout| to produce the
181 % message, and then have an empty |\errmessage| command. This causes an
182 % extra line of the form
186 % To appear on the terminal, but if you do not like it, you can always
187 % upgrade your \TeX! In order for your format to use this version, you
188 % must define the macro |\@TeXversion| to be the version number, e.g.,
189 % 3.14 of the underlying \TeX. See the comments in
190 % \texttt{ltdircheck.dtx}.
192 \dimen@\ifx\@TeXversion\@undefined4\else\@TeXversion\fi\p@%
193 \ifdim\dimen@>3.14\p@%
196 % First the `standard case'.
198 \DeclareRobustCommand{\GenericError}[4]{%
200 \immediate\write\@unused{}%
201 \def\MessageBreak{^^J}%
202 \set@display@protect%
204 % %<-------------------do not delete this space!------------------->%
208 % %<-------------------do not delete this space!------------------->%
211 % %<-------------------do not delete this space!------------------->%
214 \def\MessageBreak{^^J#1}%
218 Type H <return> for immediate help%
219 % %<-------------------do not delete this space!------------------->%
230 % Secondly the version for old \TeX's.
232 \DeclareRobustCommand{\GenericError}[4]{%
234 \immediate\write\@unused{}%
235 \def\MessageBreak{^^J}%
236 \set@display@protect%
238 % %<-------------------do not delete this space!------------------->%
242 % %<-------------------do not delete this space!------------------->%
245 % %<-------------------do not delete this space!------------------->%
248 \def\MessageBreak{^^J#1}%
252 Type H <return> for immediate help.}%
253 % %<-------------------do not delete this space!------------------->%
265 % \begin{macro}{\PackageError}
266 % \begin{macro}{\PackageWarning}
267 % \begin{macro}{\PackageWarningNoLine}
268 % \begin{macro}{\PackageInfo}
269 % \begin{macro}{\ClassError}
270 % \begin{macro}{\ClassWarning}
271 % \begin{macro}{\ClassWarningNoLine}
272 % \begin{macro}{\ClassInfo}
273 % These commands are intended for use by package and class writers, to
274 % give information to authors. The syntax is:
276 % |\PackageError{|\meta{package}|}{|^^A
277 % \meta{error}|}{|\meta{help}|}| \\
278 % |\PackageWarning{|\meta{package}|}{|\meta{warning}|}| \\
279 % |\PackageWarningNoLine{|\meta{package}|}{|\meta{warning}|}| \\
280 % |\PackageInfo{|\meta{package}|}{|\meta{info}|}|
282 % and similarly for classes. The |Error| commands print the
283 % \meta{error} message, and present the interactive prompt; if the
284 % author types |h|, then the \meta{help} information is displayed.
285 % The |Warning| commands produce a warning but do not present the
286 % interactive prompt. The |WarningNoLine| commands do the same,
287 % but don't print the input line number. The |Info| commands write
289 % |log| file. Within the messages, the command
290 % |\MessageBreak| can be used to
291 % break a line, |\protect| can be used to protect command names,
292 % and |\space| is a space, for example:
294 % \newcommand{\foo}{FOO}
295 % \PackageWarning{ethel}{%
296 % Your hovercraft is full of eels,\MessageBreak
297 % and \protect\foo\space is \foo}
301 % Package ethel warning: Your hovercraft is full of eels,
302 % (ethel) and \foo is FOO on input line 54.
306 \gdef\PackageError#1#2#3{%
308 (#1)\@spaces\@spaces\@spaces\@spaces
310 Package #1 Error: #2%
312 See the #1 package documentation for explanation.%
318 \def\PackageWarning#1#2{%
320 (#1)\@spaces\@spaces\@spaces\@spaces
322 Package #1 Warning: #2%
325 \def\PackageWarningNoLine#1#2{%
326 \PackageWarning{#1}{#2\@gobble}%
328 \def\PackageInfo#1#2{%
330 (#1) \@spaces\@spaces\@spaces
338 \gdef\ClassError#1#2#3{%
340 (#1) \space\@spaces\@spaces\@spaces
344 See the #1 class documentation for explanation.%
350 \def\ClassWarning#1#2{%
352 (#1) \space\@spaces\@spaces\@spaces
354 Class #1 Warning: #2%
357 \def\ClassWarningNoLine#1#2{%
358 \ClassWarning{#1}{#2\@gobble}%
362 (#1) \space\space\@spaces\@spaces
377 % \begin{macro}{\@latex@error}
378 % \begin{macro}{\@latex@warning}
379 % \begin{macro}{\@latex@warning@no@line}
380 % \begin{macro}{\@latex@info}
381 % \begin{macro}{\@latex@info@no@line}
382 % \changes{v1.2e}{1994/05/24}{Macro added}
383 % Errors and other info, for use in the \LaTeX{} core.
385 \gdef\@latex@error#1#2{%
387 \space\space\space\@spaces\@spaces\@spaces
391 See the LaTeX manual or LaTeX Companion for explanation.%
397 \def\@latex@warning#1{%
399 \space\space\space\@spaces\@spaces\@spaces
407 \def\@latex@warning@no@line#1{%
408 \@latex@warning{#1\@gobble}}
414 \@spaces\@spaces\@spaces
422 \def\@latex@info@no@line#1{%
423 \@latex@info{#1\@gobble}}
426 % |\@font@warning| and |\@font@info| are defined later since they
427 % have to be redefined by the \texttt{tracefnt} package.
429 %\def\@font@warning#1{%
431 % {(font)\@spaces\@spaces}%
432 % {Font Warning: #1}%
436 % (font)\space\@spaces
448 % \begin{macro}{\c@errorcontextlines}
449 % \changes{LaTeX2e}{1993/11/22}{Macro added}
450 % |\errorcontextlines| as a \LaTeX\ counter, so that it may be be
451 % manipulated with |\setcounter| (once it is defined :-)
453 \let\c@errorcontextlines\errorcontextlines
454 \c@errorcontextlines=-1
458 % \changes{v1.0d}{1994/03/28}
459 % {Remove test for \cs{inputlineno} undefined.}
460 % \begin{macro}{\on@line}
461 % The message ` on input line~$n$', if possible.
463 \ifnum\inputlineno=\m@ne
466 \def\on@line{ on input line \the\inputlineno}
471 % \begin{macro}{\@warning}
472 % \begin{macro}{\@@warning}
473 % \begin{macro}{\@latexerr}
474 % Older \LaTeX{} messages. For the moment, these
475 % |\let| to the new message commands. They may be changed later,
476 % once only obsolete packages and classes contain them.
477 % \changes{v1.0b}{1993/12/03}{Set \cs{c@errorcontextlines} to -1}
478 % \changes{v1.0e}{1993/04/09}{Mention The Companion}
479 % \changes{v1.0f}{1993/04/11}{Remove setting of errorcontextlines}
480 % \changes{v1.0k}{1994/05/01}{(CAR) Added draft \cs{@latexinfo}.}
481 % \changes{v1.0n}{1994/05/10}{(ASAJ) Added extra blank lines to
483 % \changes{v1.0o}{1994/05/11}
484 % {(ASAJ) Removed one of the extra blank lines to \cs{@latexerr}.}
486 \let\@warning\@latex@warning
487 \let\@@warning\@latex@warning@no@line
488 \global\let\@latexerr\@latex@error
494 % \begin{macro}{\@spaces}
497 \def\@spaces{\space\space\space\space}
501 % \subsection{Specific errors}
503 % \begin{macro}{\@eha}
504 % \begin{macro}{\@ehb}
505 % \begin{macro}{\@ehc}
506 % \begin{macro}{\@ehd}
507 % The more common error help messages.
510 Your command was ignored.\MessageBreak
511 Type \space I <command> <return> \space to replace it %
512 with another command,\MessageBreak
513 or \space <return> \space to continue without it.}
515 You've lost some text. \space \@ehc}
517 Try typing \space <return> %
518 \space to proceed.\MessageBreak
519 If that doesn't work, type \space X <return> \space to quit.}
521 You're in trouble here. \space\@ehc}
529 % \begin{macro}{\@notdefinable}
530 % Error message generated in |\@ifdefinable| from calls
531 % to one of the commands |\newcommand|, |\newlength| or |\newtheorem|
532 % specifying an already-defined command name or one that begins
534 % \changes{v1.2n}{1998/05/28}{Added message re `end...' pr/1555}
536 \gdef\@notdefinable{%
538 Command \@backslashchar\reserved@a\space
539 already defined.\MessageBreak
540 Or name \@backslashchar\@qend... illegal,
541 see p.192 of the manual}\@eha}
545 % \begin{macro}{\@nolnerr}
546 % Generated by |\newline| and |\\| when called in vertical mode.
549 \@latex@error{There's no line here to end}\@eha}
553 % \begin{macro}{\@nocounterr}
554 % \changes{v1.0h}{1994/04/17}{New name for error message,
555 % old error message (without arg) kept}
556 % Generated by |\setcounter|, |\addtocounter| or
557 % |\newcounter| if applied to an undefined counter \meta{cnt}.
559 % \begin{macro}{\@nocnterr}
560 % Obsolete error message generated in \LaTeX2.09 by
561 % |\setcounter|, |\addtocounter| or |\newcounter|
562 % for undefined counter.
563 % DO NOT use for \LaTeXe\ it MIGHT vanish!
564 % Use |\@nocounterr|\marg{cnt} instead.
566 \gdef\@nocounterr#1{%
567 \@latex@error{No counter '#1' defined}\@eha}
568 \gdef\@nocnterr{\@nocounterr?}
573 % \begin{macro}{\@ctrerr}
574 % Called when trying to print the value of a counter
575 % numbered by letters that's greater than 26.
578 \@latex@error{Counter too large}\@ehb}
582 % \begin{macro}{\@nodocument}
583 % Error produced if paragraphs are typeset in the preamble.
584 % \changes{v1.2m}{1996/11/04}{Always define \cs{@nodocument}
585 % in kernel, so that it can be cleared by \cs{document}.}
588 \@latex@error{Missing \protect\begin{document}}\@ehd}
592 % \begin{macro}{\@badend}
593 % Called by |\end| that doesn't match its |\begin|.
594 % RmS 1992/08/24: added code to |\@badend| to display position of
595 % non-matching |\begin|.
596 % FMi 1993/01/14: missing space added.
599 \@latex@error{\protect\begin{\@currenvir}\@currenvline
600 \space ended by \protect\end{#1}}\@eha}
604 % \begin{macro}{\@badmath}
605 % Called by |\[|, |\]|, |\(| or |\)| when used in wrong mode.
608 \@latex@error{Bad math environment delimiter}\@eha}
612 % \begin{macro}{\@toodeep}
613 % Called by a list environment nested more than six levels
614 % deep, or an enumerate or itemize nested more than four levels.
617 \@latex@error{Too deeply nested}\@ehd}
621 % \begin{macro}{\@badpoptabs}
622 % Called by |\endtabbing| when not enough |\poptabs| have
623 % occurred, or by |\poptabs| when too many have occurred.
626 \@latex@error{\protect\pushtabs\space and \protect\poptabs
627 \space don't match}\@ehd}
631 % \begin{macro}{\@badtab}
632 % Called by |\>|, |\+| , |\-| or |\<| when stepping to an undefined tab.
635 \@latex@error{Undefined tab position}\@ehd}
639 % \begin{macro}{\@preamerr}
640 % This error is special: it appears in places where we normally have
641 % to |\protect| expansions. However, to prevent a protection of
642 % the error message itself (which would result in the message
643 % getting printed not issued on the terminal) we need to locally
644 % reset |\protect| to |\relax|.
649 \@latex@error{\ifcase #1 Illegal character\or
650 Missing @-exp\or Missing p-arg\fi\space
656 % \begin{macro}{\@badlinearg}
657 % Occurs in |\line| and |\vector| command when a bad slope
658 % argument is encountered.
662 Bad \protect\line\space or \protect\vector
663 \space argument}\@ehb}
667 % \begin{macro}{\@parmoderr}
668 % Occurs in a float environment or a |\marginpar| when
669 % encountered in inner vertical mode.
672 \@latex@error{Not in outer par mode}\@ehb}
676 % \begin{macro}{\@fltovf}
677 % Occurs in float environment or |\marginpar| when there
678 % are no more free boxes for storing floats.
681 \@latex@error{Too many unprocessed floats}\@ehb}
685 % \begin{macro}{\@latexbug}
686 % Occurs in output routine. This is bad news.
689 \@latex@error{This may be a LaTeX bug}{Call for help}}
693 % \begin{macro}{\@badcrerr}
694 % This error was removed and replaced by |\@nolnerr|.
695 % \changes{v1.0m}{1994/05/04}{Error message removed}
697 %\def\@badcrerr {\@latex@error{Bad use of \protect\\}\@ehc}
701 % \begin{macro}{\@noitemerr}
702 % |\addvspace| or |\addpenalty| was called when not in
703 % vmode. Probably caused by a missing |\item|.
706 \@latex@error{Something's wrong--perhaps a missing %
711 % \begin{macro}{\@notprerr}
712 % A command that can be used only in the preamble
713 % appears after the command |\begin{document}|.
716 \@latex@error{Can be used only in preamble}\@eha}
720 % \begin{macro}{\@inmatherr}
721 % \changes{v1.0j}{1994/04/28}{Macro added}
722 % \changes{v1.1c}{1994/04/28}{Replaced \cs{noexpand} with \cs{protect}.}
723 % Issued by commands that don't work correctly within math (like
724 % |\item|). There is no real error recovery happening, e.g., the
725 % user might get additional errors afterwards.
730 \@latex@error{Command \protect#1 invalid in math mode}\@ehc
735 % \begin{macro}{\@invalidchar}
736 % \changes{LaTeX2.09}{1993/09/19}
737 % {(RmS) Error message for invalid input characters.}
738 % \changes{v1.0d}{1994/03/28}
739 % {(DPC) Comment out (use catcode15 instead)}
740 % An error for use with invalid characters. This is commented
741 % out, since we decided to use catcode 15 instead.
743 %\def\@invalidchar{\@latex@error{Invalid character in input}\@ehc}
748 % As well as the above error commands some error messages are directly
749 % coded to save space. The Messages already present in \LaTeX2.09
752 % |Environment --- undefined|\\
753 % Issued by |\begin| for undefined environment.
756 % Occurs in |\= when| maximum number of tabs exceeded.
759 % Occurs in |\<| when it appears in middle of line.
762 % In output routine, caused by a float environment or
763 % |\marginpar| occurring in inner vertical mode.