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 [2016/10/15 v1.2p LaTeX Kernel (errors)]
37 \documentclass{ltxdoc}
38 \GetFileInfo{lterror.dtx}
50 \MaintainedByLaTeXTeam{latex}
58 % \changes{v1.1a}{1994/05/16}{(ASAJ) Split from ltinit.dtx.}
59 % \changes{v1.1a}{1994/05/16}{(ASAJ) Completely new error interface.}
60 % \changes{v1.1b}{1994/05/17}{(ASAJ) Moved error stuff from
62 % \changes{v1.1c}{1994/05/20}{(ASAJ) Added \cs{@latex@info@no@line}.}
63 % \changes{v1.1c}{1994/05/20}{(ASAJ) Added missing full stops.}
64 % \changes{v1.1c}{1994/05/20}{(ASAJ) Fixed a bug with
66 % \changes{v1.1d}{1994/05/21}{(ASAJ) Made the error commands robust.}
67 % \changes{v1.1e}{1994/05/22}{(ASAJ) Replaced bgroup by begingroup in
68 % error messages, to stop extra mathords creeping into math mode.}
69 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaced \cs{@generic@message} and
70 % \cs{@generic@error} by \cs{GenericError}, \cs{GenericWarning} and
72 % \changes{v1.2a}{1994/05/22}{(ASAJ) Made \cs{GenericError},
73 % \cs{GenericWarning} and \cs{GenericInfo} robust.}
74 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaced \cmd\\ and tilde by
75 % \cs{MessageBreak} and \cs{space}.}
76 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaces \cs{string} by
77 % \cs{protect} in some messages.}
78 % \changes{v1.2f}{1994/05/24}{(DPC) wrap long lines}
79 % \changes{v1.2h}{1994/11/17}
80 % {\cs{@tempa} to \cs{reserved@a}}
81 % \changes{v1.2i}{1995/09/01}
82 % {Add autoload support}
83 % \changes{v1.2j}{1995/10/09}
84 % {Modify autoload support}
85 % \changes{v1.2o}{2015/02/21}
86 % {Removed autoload support}
87 % \changes{v1.2p}{2016/10/15}
90 % \section{Error handling}
92 % This section defines \LaTeX's error commands.
101 % The `2ekernel' code ensures that a |\usepackage{autoerr}| is
102 % essentially ignored if a `full' format is being used that has
103 % the error messages already in the format.
105 % These days we don't support autoloading approach any longer, but
106 % this part bit is kept in case it is used in old documents.
108 \expandafter\let\csname ver@autoerr.sty\endcsname\fmtversion
112 % \subsection{General commands}
114 % \begin{macro}{\MessageBreak}
115 % This command prints a new-line inside a message, followed by a
116 % continuation line begun with |\@msg@continuation|. Normally it is
117 % defined to be |\relax|, but inside messages, it is let to
120 \let\MessageBreak\relax
124 % \changes{v1.2g}{1994/11/04}{Added \cs{set@display@protect} to
125 % \cs{Generic*} commands. ASAJ.}
127 % \begin{macro}{\GenericInfo}
128 % This takes two arguments: a continuation and a message, and sends
129 % the result to the log file.
131 \DeclareRobustCommand{\GenericInfo}[2]{%
133 \def\MessageBreak{^^J#1}%
135 \immediate\write\m@ne{#2\on@line.}%
141 % \begin{macro}{\GenericWarning}
142 % This takes two arguments: a continuation and a message, and sends
143 % the result to the screen.
145 \DeclareRobustCommand{\GenericWarning}[2]{%
147 \def\MessageBreak{^^J#1}%
149 \immediate\write\@unused{^^J#2\on@line.^^J}%
155 % \begin{macro}{\GenericError}
156 % This macro takes four arguments: a continuation,
157 % an error message, where to go for further information, and the help
158 % information. It displays the error message, and sets the error help
159 % (the result of typing |h| to the prompt), and does a horrible hack
160 % to turn the last context line (which by default is the only context
161 % line) into just three dots. This could be made more efficient.
162 % \changes{v1.2d}{1994/05/22}
163 % {(DPC) New version using long command name.}
164 % \changes{v1.2d}{1994/05/22}
165 % {(DPC) Alternative version added for old TeXs}
174 \catcode`\ =11\relax%
179 % Unfortunately \TeX\ versions older than 3.141 have a bug which means
180 % that |^^J| does not force a linebreak in |\message| and |\errmessage|
181 % commands. So for these old \TeX's we use |\typeout| to produce the
182 % message, and then have an empty |\errmessage| command. This causes an
183 % extra line of the form
187 % To appear on the terminal, but if you do not like it, you can always
188 % upgrade your \TeX! In order for your format to use this version, you
189 % must define the macro |\@TeXversion| to be the version number, e.g.,
190 % 3.14 of the underlying \TeX. See the comments in
191 % \texttt{ltdircheck.dtx}.
193 \dimen@\ifx\@TeXversion\@undefined4\else\@TeXversion\fi\p@%
194 \ifdim\dimen@>3.14\p@%
197 % First the `standard case'.
199 \DeclareRobustCommand{\GenericError}[4]{%
201 \immediate\write\@unused{}%
202 \def\MessageBreak{^^J}%
203 \set@display@protect%
205 % %<-------------------do not delete this space!------------------->%
209 % %<-------------------do not delete this space!------------------->%
212 % %<-------------------do not delete this space!------------------->%
215 \def\MessageBreak{^^J#1}%
219 Type H <return> for immediate help%
220 % %<-------------------do not delete this space!------------------->%
231 % Secondly the version for old \TeX's.
233 \DeclareRobustCommand{\GenericError}[4]{%
235 \immediate\write\@unused{}%
236 \def\MessageBreak{^^J}%
237 \set@display@protect%
239 % %<-------------------do not delete this space!------------------->%
243 % %<-------------------do not delete this space!------------------->%
246 % %<-------------------do not delete this space!------------------->%
249 \def\MessageBreak{^^J#1}%
253 Type H <return> for immediate help.}%
254 % %<-------------------do not delete this space!------------------->%
266 % \begin{macro}{\PackageError}
267 % \begin{macro}{\PackageWarning}
268 % \begin{macro}{\PackageWarningNoLine}
269 % \begin{macro}{\PackageInfo}
270 % \begin{macro}{\ClassError}
271 % \begin{macro}{\ClassWarning}
272 % \begin{macro}{\ClassWarningNoLine}
273 % \begin{macro}{\ClassInfo}
274 % These commands are intended for use by package and class writers, to
275 % give information to authors. The syntax is:
277 % |\PackageError{|\meta{package}|}{|^^A
278 % \meta{error}|}{|\meta{help}|}| \\
279 % |\PackageWarning{|\meta{package}|}{|\meta{warning}|}| \\
280 % |\PackageWarningNoLine{|\meta{package}|}{|\meta{warning}|}| \\
281 % |\PackageInfo{|\meta{package}|}{|\meta{info}|}|
283 % and similarly for classes. The |Error| commands print the
284 % \meta{error} message, and present the interactive prompt; if the
285 % author types |h|, then the \meta{help} information is displayed.
286 % The |Warning| commands produce a warning but do not present the
287 % interactive prompt. The |WarningNoLine| commands do the same,
288 % but don't print the input line number. The |Info| commands write
290 % |log| file. Within the messages, the command
291 % |\MessageBreak| can be used to
292 % break a line, |\protect| can be used to protect command names,
293 % and |\space| is a space, for example:
295 % \newcommand{\foo}{FOO}
296 % \PackageWarning{ethel}{%
297 % Your hovercraft is full of eels,\MessageBreak
298 % and \protect\foo\space is \foo}
302 % Package ethel warning: Your hovercraft is full of eels,
303 % (ethel) and \foo is FOO on input line 54.
307 \gdef\PackageError#1#2#3{%
309 (#1)\@spaces\@spaces\@spaces\@spaces
311 Package #1 Error: #2%
313 See the #1 package documentation for explanation.%
319 \def\PackageWarning#1#2{%
321 (#1)\@spaces\@spaces\@spaces\@spaces
323 Package #1 Warning: #2%
326 \def\PackageWarningNoLine#1#2{%
327 \PackageWarning{#1}{#2\@gobble}%
329 \def\PackageInfo#1#2{%
331 (#1) \@spaces\@spaces\@spaces
339 \gdef\ClassError#1#2#3{%
341 (#1) \space\@spaces\@spaces\@spaces
345 See the #1 class documentation for explanation.%
351 \def\ClassWarning#1#2{%
353 (#1) \space\@spaces\@spaces\@spaces
355 Class #1 Warning: #2%
358 \def\ClassWarningNoLine#1#2{%
359 \ClassWarning{#1}{#2\@gobble}%
363 (#1) \space\space\@spaces\@spaces
378 % \begin{macro}{\@latex@error}
379 % \begin{macro}{\@latex@warning}
380 % \begin{macro}{\@latex@warning@no@line}
381 % \begin{macro}{\@latex@info}
382 % \begin{macro}{\@latex@info@no@line}
383 % \changes{v1.2e}{1994/05/24}{Macro added}
384 % Errors and other info, for use in the \LaTeX{} core.
386 \gdef\@latex@error#1#2{%
388 \space\space\space\@spaces\@spaces\@spaces
392 See the LaTeX manual or LaTeX Companion for explanation.%
398 \def\@latex@warning#1{%
400 \space\space\space\@spaces\@spaces\@spaces
408 \def\@latex@warning@no@line#1{%
409 \@latex@warning{#1\@gobble}}
415 \@spaces\@spaces\@spaces
423 \def\@latex@info@no@line#1{%
424 \@latex@info{#1\@gobble}}
427 % |\@font@warning| and |\@font@info| are defined later since they
428 % have to be redefined by the \texttt{tracefnt} package.
430 %\def\@font@warning#1{%
432 % {(font)\@spaces\@spaces}%
433 % {Font Warning: #1}%
437 % (font)\space\@spaces
449 % \begin{macro}{\c@errorcontextlines}
450 % \changes{LaTeX2e}{1993/11/22}{Macro added}
451 % |\errorcontextlines| as a \LaTeX\ counter, so that it may be be
452 % manipulated with |\setcounter| (once it is defined :-)
454 \let\c@errorcontextlines\errorcontextlines
455 \c@errorcontextlines=-1
459 % \changes{v1.0d}{1994/03/28}
460 % {Remove test for \cs{inputlineno} undefined.}
461 % \begin{macro}{\on@line}
462 % The message ` on input line~$n$'.
464 \def\on@line{ on input line \the\inputlineno}
468 % \begin{macro}{\@warning}
469 % \begin{macro}{\@@warning}
470 % \begin{macro}{\@latexerr}
471 % Older \LaTeX{} messages. For the moment, these
472 % |\let| to the new message commands. They may be changed later,
473 % once only obsolete packages and classes contain them.
474 % \changes{v1.0b}{1993/12/03}{Set \cs{c@errorcontextlines} to -1}
475 % \changes{v1.0e}{1993/04/09}{Mention The Companion}
476 % \changes{v1.0f}{1993/04/11}{Remove setting of errorcontextlines}
477 % \changes{v1.0k}{1994/05/01}{(CAR) Added draft \cs{@latexinfo}.}
478 % \changes{v1.0n}{1994/05/10}{(ASAJ) Added extra blank lines to
480 % \changes{v1.0o}{1994/05/11}
481 % {(ASAJ) Removed one of the extra blank lines to \cs{@latexerr}.}
483 \let\@warning\@latex@warning
484 \let\@@warning\@latex@warning@no@line
485 \global\let\@latexerr\@latex@error
491 % \begin{macro}{\@spaces}
494 \def\@spaces{\space\space\space\space}
498 % \subsection{Specific errors}
500 % \begin{macro}{\@eha}
501 % \begin{macro}{\@ehb}
502 % \begin{macro}{\@ehc}
503 % \begin{macro}{\@ehd}
504 % The more common error help messages.
507 Your command was ignored.\MessageBreak
508 Type \space I <command> <return> \space to replace it %
509 with another command,\MessageBreak
510 or \space <return> \space to continue without it.}
512 You've lost some text. \space \@ehc}
514 Try typing \space <return> %
515 \space to proceed.\MessageBreak
516 If that doesn't work, type \space X <return> \space to quit.}
518 You're in trouble here. \space\@ehc}
526 % \begin{macro}{\@notdefinable}
527 % Error message generated in |\@ifdefinable| from calls
528 % to one of the commands |\newcommand|, |\newlength| or |\newtheorem|
529 % specifying an already-defined command name or one that begins
531 % \changes{v1.2n}{1998/05/28}{Added message re `end...' pr/1555}
533 \gdef\@notdefinable{%
535 Command \@backslashchar\reserved@a\space
536 already defined.\MessageBreak
537 Or name \@backslashchar\@qend... illegal,
538 see p.192 of the manual}\@eha}
542 % \begin{macro}{\@nolnerr}
543 % Generated by |\newline| and |\\| when called in vertical mode.
546 \@latex@error{There's no line here to end}\@eha}
550 % \begin{macro}{\@nocounterr}
551 % \changes{v1.0h}{1994/04/17}{New name for error message,
552 % old error message (without arg) kept}
553 % Generated by |\setcounter|, |\addtocounter| or
554 % |\newcounter| if applied to an undefined counter \meta{cnt}.
556 % \begin{macro}{\@nocnterr}
557 % Obsolete error message generated in \LaTeX2.09 by
558 % |\setcounter|, |\addtocounter| or |\newcounter|
559 % for undefined counter.
560 % DO NOT use for \LaTeXe\ it MIGHT vanish!
561 % Use |\@nocounterr|\marg{cnt} instead.
563 \gdef\@nocounterr#1{%
564 \@latex@error{No counter '#1' defined}\@eha}
565 \gdef\@nocnterr{\@nocounterr?}
570 % \begin{macro}{\@ctrerr}
571 % Called when trying to print the value of a counter
572 % numbered by letters that's greater than 26.
575 \@latex@error{Counter too large}\@ehb}
579 % \begin{macro}{\@nodocument}
580 % Error produced if paragraphs are typeset in the preamble.
581 % \changes{v1.2m}{1996/11/04}{Always define \cs{@nodocument}
582 % in kernel, so that it can be cleared by \cs{document}.}
585 \@latex@error{Missing \protect\begin{document}}\@ehd}
589 % \begin{macro}{\@badend}
590 % Called by |\end| that doesn't match its |\begin|.
591 % RmS 1992/08/24: added code to |\@badend| to display position of
592 % non-matching |\begin|.
593 % FMi 1993/01/14: missing space added.
596 \@latex@error{\protect\begin{\@currenvir}\@currenvline
597 \space ended by \protect\end{#1}}\@eha}
601 % \begin{macro}{\@badmath}
602 % Called by |\[|, |\]|, |\(| or |\)| when used in wrong mode.
605 \@latex@error{Bad math environment delimiter}\@eha}
609 % \begin{macro}{\@toodeep}
610 % Called by a list environment nested more than six levels
611 % deep, or an enumerate or itemize nested more than four levels.
614 \@latex@error{Too deeply nested}\@ehd}
618 % \begin{macro}{\@badpoptabs}
619 % Called by |\endtabbing| when not enough |\poptabs| have
620 % occurred, or by |\poptabs| when too many have occurred.
623 \@latex@error{\protect\pushtabs\space and \protect\poptabs
624 \space don't match}\@ehd}
628 % \begin{macro}{\@badtab}
629 % Called by |\>|, |\+| , |\-| or |\<| when stepping to an undefined tab.
632 \@latex@error{Undefined tab position}\@ehd}
636 % \begin{macro}{\@preamerr}
637 % This error is special: it appears in places where we normally have
638 % to |\protect| expansions. However, to prevent a protection of
639 % the error message itself (which would result in the message
640 % getting printed not issued on the terminal) we need to locally
641 % reset |\protect| to |\relax|.
646 \@latex@error{\ifcase #1 Illegal character\or
647 Missing @-exp\or Missing p-arg\fi\space
653 % \begin{macro}{\@badlinearg}
654 % Occurs in |\line| and |\vector| command when a bad slope
655 % argument is encountered.
659 Bad \protect\line\space or \protect\vector
660 \space argument}\@ehb}
664 % \begin{macro}{\@parmoderr}
665 % Occurs in a float environment or a |\marginpar| when
666 % encountered in inner vertical mode.
669 \@latex@error{Not in outer par mode}\@ehb}
673 % \begin{macro}{\@fltovf}
674 % Occurs in float environment or |\marginpar| when there
675 % are no more free boxes for storing floats.
678 \@latex@error{Too many unprocessed floats}\@ehb}
682 % \begin{macro}{\@latexbug}
683 % Occurs in output routine. This is bad news.
686 \@latex@error{This may be a LaTeX bug}{Call for help}}
690 % \begin{macro}{\@badcrerr}
691 % This error was removed and replaced by |\@nolnerr|.
692 % \changes{v1.0m}{1994/05/04}{Error message removed}
694 %\def\@badcrerr {\@latex@error{Bad use of \protect\\}\@ehc}
698 % \begin{macro}{\@noitemerr}
699 % |\addvspace| or |\addpenalty| was called when not in
700 % vmode. Probably caused by a missing |\item|.
703 \@latex@error{Something's wrong--perhaps a missing %
708 % \begin{macro}{\@notprerr}
709 % A command that can be used only in the preamble
710 % appears after the command |\begin{document}|.
713 \@latex@error{Can be used only in preamble}\@eha}
717 % \begin{macro}{\@inmatherr}
718 % \changes{v1.0j}{1994/04/28}{Macro added}
719 % \changes{v1.1c}{1994/04/28}{Replaced \cs{noexpand} with \cs{protect}.}
720 % Issued by commands that don't work correctly within math (like
721 % |\item|). There is no real error recovery happening, e.g., the
722 % user might get additional errors afterwards.
727 \@latex@error{Command \protect#1 invalid in math mode}\@ehc
732 % \begin{macro}{\@invalidchar}
733 % \changes{LaTeX2.09}{1993/09/19}
734 % {(RmS) Error message for invalid input characters.}
735 % \changes{v1.0d}{1994/03/28}
736 % {(DPC) Comment out (use catcode15 instead)}
737 % An error for use with invalid characters. This is commented
738 % out, since we decided to use catcode 15 instead.
740 %\def\@invalidchar{\@latex@error{Invalid character in input}\@ehc}
745 % As well as the above error commands some error messages are directly
746 % coded to save space. The Messages already present in \LaTeX2.09
749 % |Environment --- undefined|\\
750 % Issued by |\begin| for undefined environment.
753 % Occurs in |\= when| maximum number of tabs exceeded.
756 % Occurs in |\<| when it appears in middle of line.
759 % In output routine, caused by a float environment or
760 % |\marginpar| occurring in inner vertical mode.