1 % \iffalse meta-comment
3 % Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
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
32 %<def>\ProvidesFile{autoerr.sty}
33 %<def> [1995/11/28 v1.2l LaTeX error autoload file]
36 \ProvidesFile{lterror.dtx}
37 [1998/05/28 v1.2n LaTeX Kernel (errors)]
39 \documentclass{ltxdoc}
40 \GetFileInfo{lterror.dtx}
60 % \changes{v1.1a}{1994/05/16}{(ASAJ) Split from ltinit.dtx.}
61 % \changes{v1.1a}{1994/05/16}{(ASAJ) Completely new error interface.}
62 % \changes{v1.1b}{1994/05/17}{(ASAJ) Moved error stuff from
64 % \changes{v1.1c}{1994/05/20}{(ASAJ) Added \cs{@latex@info@no@line}.}
65 % \changes{v1.1c}{1994/05/20}{(ASAJ) Added missing full stops.}
66 % \changes{v1.1c}{1994/05/20}{(ASAJ) Fixed a bug with
68 % \changes{v1.1d}{1994/05/21}{(ASAJ) Made the error commands robust.}
69 % \changes{v1.1e}{1994/05/22}{(ASAJ) Replaced bgroup by begingroup in
70 % error messages, to stop extra mathords creeping into math mode.}
71 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaced \cs{@generic@message} and
72 % \cs{@generic@error} by \cs{GenericError}, \cs{GenericWarning} and
74 % \changes{v1.2a}{1994/05/22}{(ASAJ) Made \cs{GenericError},
75 % \cs{GenericWarning} and \cs{GenericInfo} robust.}
76 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaced \cmd\\ and tilde by
77 % \cs{MessageBreak} and \cs{space}.}
78 % \changes{v1.2a}{1994/05/22}{(ASAJ) Replaces \cs{string} by
79 % \cs{protect} in some messages.}
80 % \changes{v1.2f}{1994/05/24}{(DPC) wrap long lines}
81 % \changes{v1.2h}{1994/11/17}
82 % {\cs{@tempa} to \cs{reserved@a}}
83 % \changes{v1.2i}{1995/09/01}
84 % {Add autoload support}
85 % \changes{v1.2j}{1995/10/09}
86 % {Modify autoload support}
88 % \section{Error handling}
90 % This section defines \LaTeX's error commands.
95 % The `2ekernel' code ensures that a |\usepackage{autoerr}| is
96 % essentially ignored if a `full' format is being used that has
97 % the error messages already in the format.
99 %<2ekernel>\expandafter\let\csname ver@autoerr.sty\endcsname\fmtversion
103 %<*2ekernel|autoload>
106 % \subsection{General commands}
108 % \begin{macro}{\MessageBreak}
109 % This command prints a new-line inside a message, followed by a
110 % continuation line begun with |\@msg@continuation|. Normally it is
111 % defined to be |\relax|, but inside messages, it is let to
114 \let\MessageBreak\relax
118 % \changes{v1.2g}{1994/11/04}{Added \cs{set@display@protect} to
119 % \cs{Generic*} commands. ASAJ.}
121 % \begin{macro}{\GenericInfo}
122 % This takes two arguments: a continuation and a message, and sends
123 % the result to the log file.
125 \DeclareRobustCommand{\GenericInfo}[2]{%
127 \def\MessageBreak{^^J#1}%
129 \immediate\write\m@ne{#2\on@line.}%
135 % \begin{macro}{\GenericWarning}
136 % This takes two arguments: a continuation and a message, and sends
137 % the result to the screen.
139 \DeclareRobustCommand{\GenericWarning}[2]{%
141 \def\MessageBreak{^^J#1}%
143 \immediate\write\@unused{^^J#2\on@line.^^J}%
146 %</2ekernel|autoload>
150 % \begin{macro}{\GenericError}
151 % This macro takes four arguments: a continuation,
152 % an error message, where to go for further information, and the help
153 % information. It displays the error message, and sets the error help
154 % (the result of typing |h| to the prompt), and does a horrible hack
155 % to turn the last context line (which by default is the only context
156 % line) into just three dots. This could be made more efficient.
157 % \changes{v1.2d}{1994/05/22}
158 % {(DPC) New version using long command name.}
159 % \changes{v1.2d}{1994/05/22}
160 % {(DPC) Alternative version added for old TeXs}
162 %<autoload>\def\GenericError{\@autoerr\GenericError}
171 \catcode`\ =11\relax%
176 % Unfortunately \TeX\ versions older than 3.141 have a bug which means
177 % that |^^J| does not force a linebreak in |\message| and |\errmessage|
178 % commands. So for these old \TeX's we use |\typeout| to produce the
179 % message, and then have an empty |\errmessage| command. This causes an
180 % extra line of the form
184 % To appear on the terminal, but if you do not like it, you can always
185 % upgrade your \TeX! In order for your format to use this version, you
186 % must define the macro |\@TeXversion| to be the version number, e.g.,
187 % 3.14 of the underlying \TeX. See the comments in
188 % \texttt{ltdircheck.dtx}.
190 \dimen@\ifx\@TeXversion\@undefined4\else\@TeXversion\fi\p@%
191 \ifdim\dimen@>3.14\p@%
194 % First the `standard case'.
196 \DeclareRobustCommand{\GenericError}[4]{%
198 \immediate\write\@unused{}%
199 \def\MessageBreak{^^J}%
200 \set@display@protect%
202 % %<-------------------do not delete this space!------------------->%
206 % %<-------------------do not delete this space!------------------->%
209 % %<-------------------do not delete this space!------------------->%
212 \def\MessageBreak{^^J#1}%
216 Type H <return> for immediate help%
217 % %<-------------------do not delete this space!------------------->%
228 % Secondly the version for old \TeX's.
230 \DeclareRobustCommand{\GenericError}[4]{%
232 \immediate\write\@unused{}%
233 \def\MessageBreak{^^J}%
234 \set@display@protect%
236 % %<-------------------do not delete this space!------------------->%
240 % %<-------------------do not delete this space!------------------->%
243 % %<-------------------do not delete this space!------------------->%
246 \def\MessageBreak{^^J#1}%
250 Type H <return> for immediate help.}%
251 % %<-------------------do not delete this space!------------------->%
264 % \begin{macro}{\PackageError}
265 % \begin{macro}{\PackageWarning}
266 % \begin{macro}{\PackageWarningNoLine}
267 % \begin{macro}{\PackageInfo}
268 % \begin{macro}{\ClassError}
269 % \begin{macro}{\ClassWarning}
270 % \begin{macro}{\ClassWarningNoLine}
271 % \begin{macro}{\ClassInfo}
272 % These commands are intended for use by package and class writers, to
273 % give information to authors. The syntax is:
275 % |\PackageError{|\meta{package}|}{|^^A
276 % \meta{error}|}{|\meta{help}|}| \\
277 % |\PackageWarning{|\meta{package}|}{|\meta{warning}|}| \\
278 % |\PackageWarningNoLine{|\meta{package}|}{|\meta{warning}|}| \\
279 % |\PackageInfo{|\meta{package}|}{|\meta{info}|}|
281 % and similarly for classes. The |Error| commands print the
282 % \meta{error} message, and present the interactive prompt; if the
283 % author types |h|, then the \meta{help} information is displayed.
284 % The |Warning| commands produce a warning but do not present the
285 % interactive prompt. The |WarningNoLine| commands do the same,
286 % but don't print the input line number. The |Info| commands write
288 % |log| file. Within the messages, the command
289 % |\MessageBreak| can be used to
290 % break a line, |\protect| can be used to protect command names,
291 % and |\space| is a space, for example:
293 % \newcommand{\foo}{FOO}
294 % \PackageWarning{ethel}{%
295 % Your hovercraft is full of eels,\MessageBreak
296 % and \protect\foo\space is \foo}
300 % Package ethel warning: Your hovercraft is full of eels,
301 % (ethel) and \foo is FOO on input line 54.
305 %<autoload>\def\PackageError{\@autoerr\PackageError}
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.%
320 %<*2ekernel|autoload>
321 \def\PackageWarning#1#2{%
323 (#1)\@spaces\@spaces\@spaces\@spaces
325 Package #1 Warning: #2%
328 \def\PackageWarningNoLine#1#2{%
329 \PackageWarning{#1}{#2\@gobble}%
331 \def\PackageInfo#1#2{%
333 (#1) \@spaces\@spaces\@spaces
338 %</2ekernel|autoload>
341 % \changes{v1.2l}{1995/11/28}
342 % {Typo in autoload code /1985}
344 %<autoload>\def\ClassError{\@autoerr\ClassError}
346 \gdef\ClassError#1#2#3{%
348 (#1) \space\@spaces\@spaces\@spaces
352 See the #1 class documentation for explanation.%
359 %<*2ekernel|autoload>
360 \def\ClassWarning#1#2{%
362 (#1) \space\@spaces\@spaces\@spaces
364 Class #1 Warning: #2%
367 \def\ClassWarningNoLine#1#2{%
368 \ClassWarning{#1}{#2\@gobble}%
372 (#1) \space\space\@spaces\@spaces
377 %</2ekernel|autoload>
388 % \begin{macro}{\@latex@error}
389 % \begin{macro}{\@latex@warning}
390 % \begin{macro}{\@latex@warning@no@line}
391 % \begin{macro}{\@latex@info}
392 % \begin{macro}{\@latex@info@no@line}
393 % \changes{v1.2e}{1994/05/24}{Macro added}
394 % Errors and other info, for use in the \LaTeX{} core.
396 %<autoload>\def\@latex@error{\@autoerr\@latex@error}
398 \gdef\@latex@error#1#2{%
400 \space\space\space\@spaces\@spaces\@spaces
404 See the LaTeX manual or LaTeX Companion for explanation.%
411 %<*2ekernel|autoload>
412 \def\@latex@warning#1{%
414 \space\space\space\@spaces\@spaces\@spaces
422 \def\@latex@warning@no@line#1{%
423 \@latex@warning{#1\@gobble}}
429 \@spaces\@spaces\@spaces
437 \def\@latex@info@no@line#1{%
438 \@latex@info{#1\@gobble}}
441 % |\@font@warning| and |\@font@info| are defined later since they
442 % have to be redefined by the \texttt{tracefnt} package.
444 %\def\@font@warning#1{%
446 % {(font)\@spaces\@spaces}%
447 % {Font Warning: #1}%
451 % (font)\space\@spaces
463 % \begin{macro}{\c@errorcontextlines}
464 % \changes{LaTeX2e}{1993/11/22}{Macro added}
465 % |\errorcontextlines| as a \LaTeX\ counter, so that it may be be
466 % manipulated with |\setcounter| (once it is defined :-)
468 \let\c@errorcontextlines\errorcontextlines
469 \c@errorcontextlines=-1
473 % \changes{v1.0d}{1994/03/28}
474 % {Remove test for \cs{inputlineno} undefined.}
475 % \begin{macro}{\on@line}
476 % The message ` on input line~$n$', if possible.
478 \ifnum\inputlineno=\m@ne
481 \def\on@line{ on input line \the\inputlineno}
486 % \begin{macro}{\@warning}
487 % \begin{macro}{\@@warning}
488 % \begin{macro}{\@latexerr}
489 % Older \LaTeX{} messages. For the moment, these
490 % |\let| to the new message commands. They may be changed later,
491 % once only obsolete packages and classes contain them.
492 % \changes{v1.0b}{1993/12/03}{Set \cs{c@errorcontextlines} to -1}
493 % \changes{v1.0e}{1993/04/09}{Mention The Companion}
494 % \changes{v1.0f}{1993/04/11}{Remove setting of errorcontextlines}
495 % \changes{v1.0k}{1994/05/01}{(CAR) Added draft \cs{@latexinfo}.}
496 % \changes{v1.0n}{1994/05/10}{(ASAJ) Added extra blank lines to
498 % \changes{v1.0o}{1994/05/11}
499 % {(ASAJ) Removed one of the extra blank lines to \cs{@latexerr}.}
501 \let\@warning\@latex@warning
502 \let\@@warning\@latex@warning@no@line
503 %</2ekernel|autoload>
504 \global\let\@latexerr\@latex@error
510 % \begin{macro}{\@spaces}
513 %<*2ekernel|autoload>
514 \def\@spaces{\space\space\space\space}
515 %</2ekernel|autoload>
519 % \subsection{Specific errors}
521 % \begin{macro}{\@eha}
522 % \begin{macro}{\@ehb}
523 % \begin{macro}{\@ehc}
524 % \begin{macro}{\@ehd}
525 % The more common error help messages.
529 Your command was ignored.\MessageBreak
530 Type \space I <command> <return> \space to replace it %
531 with another command,\MessageBreak
532 or \space <return> \space to continue without it.}
534 You've lost some text. \space \@ehc}
536 Try typing \space <return> %
537 \space to proceed.\MessageBreak
538 If that doesn't work, type \space X <return> \space to quit.}
540 You're in trouble here. \space\@ehc}
543 % As |\latex@error| triggers the autoload, these definitions
544 % should not be needed in the autoload format, but just to be safe\ldots
547 \let\@eha\@empty\let\@ehb\@empty\let\@ehc\@empty\let\@ehd\@empty
555 % Here are most of the error message-generating commands of \LaTeX.
556 % \begin{macro}{\@autoerr}
557 % Make this autoload command robust, as it may be read in at
558 % unpredicatble times.
560 %<autoload>\def\@autoerr{\protect\@autoload{err}\protect}
564 % \begin{macro}{\@notdefinable}
565 % Error message generated in |\@ifdefinable| from calls
566 % to one of the commands |\newcommand|, |\newlength| or |\newtheorem|
567 % specifying an already-defined command name or one that begins
569 % \changes{v1.2n}{1998/05/28}{Added message re `end...' pr/1555}
571 \gdef\@notdefinable{%
572 %<!autoload> \@latex@error{%
573 %<!autoload> Command \@backslashchar\reserved@a\space
574 %<!autoload> already defined.\MessageBreak
575 %<!autoload> Or name \@backslashchar\@qend... illegal,
576 %<!autoload> see p.192 of the manual}\@eha}
577 %<autoload> \@autoerr\@notdefinable}
581 % \begin{macro}{\@nolnerr}
582 % Generated by |\newline| and |\\| when called in vertical mode.
585 %<!autoload> \@latex@error{There's no line here to end}\@eha}
586 %<autoload> \@autoerr\@nolnerr}
590 % \begin{macro}{\@nocounterr}
591 % \changes{v1.0h}{1994/04/17}{New name for error message,
592 % old error message (without arg) kept}
593 % Generated by |\setcounter|, |\addtocounter| or
594 % |\newcounter| if applied to an undefined counter \meta{cnt}.
596 % \begin{macro}{\@nocnterr}
597 % Obsolete error message generated in \LaTeX2.09 by
598 % |\setcounter|, |\addtocounter| or |\newcounter|
599 % for undefined counter.
600 % DO NOT use for \LaTeXe\ it MIGHT vanish!
601 % Use |\@nocounterr|\marg{cnt} instead.
603 \gdef\@nocounterr#1{%
604 %<!autoload> \@latex@error{No counter '#1' defined}\@eha}
605 %<autoload> \@autoerr\@nocounterr}
606 \gdef\@nocnterr{\@nocounterr?}
611 % \begin{macro}{\@ctrerr}
612 % Called when trying to print the value of a counter
613 % numbered by letters that's greater than 26.
616 %<!autoload> \@latex@error{Counter too large}\@ehb}
617 %<autoload> \@autoerr\@ctrerr}
621 % \begin{macro}{\@nodocument}
622 % Error produced if paragraphs are typeset in the preamble.
623 % \changes{v1.2m}{1996/11/04}{Always define \cs{@nodocument}
624 % in kernel, so that it can be cleared by \cs{document}.}
626 %<!def>\gdef\@nodocument{%
627 %<!def> \@latex@error{Missing \protect\begin{document}}\@ehd}
631 % \begin{macro}{\@badend}
632 % Called by |\end| that doesn't match its |\begin|.
633 % RmS 1992/08/24: added code to |\@badend| to display position of
634 % non-matching |\begin|.
635 % FMi 1993/01/14: missing space added.
638 %<!autoload> \@latex@error{\protect\begin{\@currenvir}\@currenvline
639 %<!autoload> \space ended by \protect\end{#1}}\@eha}
640 %<autoload> \@autoerr\@badend}
644 % \begin{macro}{\@badmath}
645 % Called by |\[|, |\]|, |\(| or |\)| when used in wrong mode.
648 %<!autoload> \@latex@error{Bad math environment delimiter}\@eha}
649 %<autoload> \@autoerr\@badmath}
653 % \begin{macro}{\@toodeep}
654 % Called by a list environment nested more than six levels
655 % deep, or an enumerate or itemize nested more than four levels.
658 %<!autoload> \@latex@error{Too deeply nested}\@ehd}
659 %<autoload> \@autoerr\@toodeep}
663 % \begin{macro}{\@badpoptabs}
664 % Called by |\endtabbing| when not enough |\poptabs| have
665 % occurred, or by |\poptabs| when too many have occurred.
668 %<!autoload> \@latex@error{\protect\pushtabs\space and \protect\poptabs
669 %<!autoload> \space don't match}\@ehd}
670 %<autoload> \@autoerr\@badpoptabs}
674 % \begin{macro}{\@badtab}
675 % Called by |\>|, |\+| , |\-| or |\<| when stepping to an undefined tab.
678 %<!autoload> \@latex@error{Undefined tab position}\@ehd}
679 %<autoload> \@autoerr\@badtab}
683 % \begin{macro}{\@preamerr}
684 % \changes{v1.2k}{1995/10/24}
685 % {Modify autoload support}
686 % This error is special: it appears in places where we normally have
687 % to |\protect| expansions. However, to prevent a protection of
688 % the error message itself (which would result in the message
689 % getting printed not issued on the terminal) we need to locally
690 % reset |\protect| to |\relax|.
696 \@latex@error{\ifcase #1 Illegal character\or
697 Missing @-exp\or Missing p-arg\fi\space
700 %<autoload> \@autoerr\@preamerr{#1}%
705 % \begin{macro}{\@badlinearg}
706 % Occurs in |\line| and |\vector| command when a bad slope
707 % argument is encountered.
710 %<!autoload> \@latex@error{%
711 %<!autoload> Bad \protect\line\space or \protect\vector
712 %<!autoload> \space argument}\@ehb}
713 %<autoload> \@autoerr\@badlinearg}
717 % \begin{macro}{\@parmoderr}
718 % Occurs in a float environment or a |\marginpar| when
719 % encountered in inner vertical mode.
722 %<!autoload> \@latex@error{Not in outer par mode}\@ehb}
723 %<autoload> \@autoerr\@parmoderr}
727 % \begin{macro}{\@fltovf}
728 % Occurs in float environment or |\marginpar| when there
729 % are no more free boxes for storing floats.
732 %<!autoload> \@latex@error{Too many unprocessed floats}\@ehb}
733 %<autoload> \@autoerr\@fltovf}
737 % \begin{macro}{\@latexbug}
738 % Occurs in output routine. This is bad news.
741 %<!autoload> \@latex@error{This may be a LaTeX bug}{Call for help}}
742 %<autoload> \@autoerr\@latexbug}
746 % \begin{macro}{\@badcrerr}
747 % This error was removed and replaced by |\@nolnerr|.
748 % \changes{v1.0m}{1994/05/04}{Error message removed}
750 %\def\@badcrerr {\@latex@error{Bad use of \protect\\}\@ehc}
754 % \begin{macro}{\@noitemerr}
755 % |\addvspace| or |\addpenalty| was called when not in
756 % vmode. Probably caused by a missing |\item|.
759 %<!autoload> \@latex@error{Something's wrong--perhaps a missing %
760 %<!autoload> \protect\item}\@ehc}
761 %<autoload> \@autoerr\@noitemerr}
765 % \begin{macro}{\@notprerr}
766 % A command that can be used only in the preamble
767 % appears after the command |\begin{document}|.
770 %<!autoload> \@latex@error{Can be used only in preamble}\@eha}
771 %<autoload> \@autoerr\@notprerr}
775 % \begin{macro}{\@inmatherr}
776 % \changes{v1.0j}{1994/04/28}{Macro added}
777 % \changes{v1.1c}{1994/04/28}{Replaced \cs{noexpand} with \cs{protect}.}
778 % Issued by commands that don't work correctly within math (like
779 % |\item|). There is no real error recovery happening, e.g., the
780 % user might get additional errors afterwards.
785 %<!autoload> \@latex@error{Command \protect#1 invalid in math mode}\@ehc
786 %<autoload> \@autoerr\@inmatherr#1%
791 % \begin{macro}{\@invalidchar}
792 % \changes{LaTeX2.09}{1993/09/19}
793 % {(RmS) Error message for invalid input characters.}
794 % \changes{v1.0d}{1994/03/28}
795 % {(DPC) Comment out (use catcode15 instead)}
796 % An error for use with invalid characters. This is commented
797 % out, since we decided to use chatcode 15 instead.
799 %\def\@invalidchar{\@latex@error{Invalid character in input}\@ehc}
803 % As well as the above error commands some error messages are directly
804 % coded to save space. The Messages alrerady present in \LaTeX2.09
807 % |Environment --- undefined|\\
808 % Issued by |\begin| for undefined environment.
811 % Occurs in |\= when| maximum number of tabs exceeded.
814 % Occurs in |\<| when it appears in middle of line.
817 % In output routine, caused by a float environment or
818 % |\marginpar| occurring in inner vertical mode.