列出 LaTeX 测试\item
之前的内容\end{list}
。我想知道导致此错误的一系列事件。从我的分析来看,我得出了以下结论,但在 处迷失了\@noitemerr
。
来源
texdoc 源码
kpsewhich lterror.dtx
列表
前提
这里产生的错误是因为\end{itemize}
仍然处于数学模式或垂直模式(无论如何,不是水平模式)吗?对吗?
\documentclass[a4paper]{article}
\begin{document}
Test.
\begin{itemize}
\end{itemize}
\end{document}
如果你害怕 LaTeX 内核,请停止阅读
我不确定触发器在哪里。我发现似乎导致错误的东西在里面\endtrivlist
。
事件链:\list -> \@trivlist -> \trivlist > \endlist -> \endtrivlist
\结束trivlist
此代码片段检查数学模式,这是\item
不支持的。
\ifhmode\unskip \par
\else
\@inmatherr{\end{\@currenvir}}% Good grief???
\fi
我的理解是,如果在 内调用,\end{itemized}
则会传递给。对吗?\@inmatherr
\begin{itemize}\end{itemize}
错误链
\@inmatherr
\gdef\@inmatherr#1{% #1=\macro, handover to \@latex@error
\relax
\ifmmode
\@latex@error{Command \protect#1 invalid in math mode}\@ehc
\fi}
\@latex@error
\gdef\@latex@error#1#2{% #1=Command \macro invalid in math mode #2=\@ehc
\GenericError{%
\space\space\space\@spaces\@spaces\@spaces
}{%
LaTeX Error: #1%
}{%
See the LaTeX manual or LaTeX Companion for explanation.%
}{#2}%
}
\@noitemerr
我们怎么会走到这一步?我错过了什么?
\gdef\@noitemerr{% how do we get here?
\@latex@error{Something's wrong--perhaps a missing %
\protect\item}\@ehc}
\@ehc
\gdef\@ehc{%
Try typing \space <return> %
\space to proceed.\MessageBreak
If that doesn't work, type \space X <return> \space to quit.}
\通用错误
打印到控制台和日志的东西?
% This macro takes four arguments: a continuation,
% an error message, where to go for further information, and the help
% information. It displays the error message, and sets the error help
% (the result of typing |h| to the prompt), and does a horrible hack
% to turn the last context line (which by default is the only context
% line) into just three dots. This could be made more efficient.
\bgroup
\lccode`\@=`\ %
\lccode`\~=`\ %
\lccode`\}=`\ %
\lccode`\{=`\ %
\lccode`\T=`\T%
\lccode`\H=`\H%
\catcode`\ =11\relax%
\lowercase{%
\egroup%
\DeclareRobustCommand{\GenericError}[4]{%
\begingroup%
\immediate\write\@unused{}%
\def\MessageBreak{^^J}%
\set@display@protect%
\edef%
% %<-------------------do not delete this space!------------------->%
\@err@ %
{{#4}}%
\errhelp
% %<-------------------do not delete this space!------------------->%
\@err@ %
\let
% %<-------------------do not delete this space!------------------->%
\@err@ %
\@empty
\def\MessageBreak{^^J#1}%
\def~{\errmessage{%
#2.^^J^^J%
#3^^J%
Type H <return> for immediate help%
% %<-------------------do not delete this space!------------------->%
\@err@ %
}}%
~%
\endgroup}%
答案1
Latex 正在明确测试该输入并引发错误。
\endtrivlist
做
\if@newlist
\@noitemerr
因此其内容如下:
如果到列表末尾仍然是‘新列表’,则生成没有的错误
\item
。
当您收到可能缺少项目错误时,1000 次中有 999 次,这并不是由于缺少项目而导致的\item
,但只有这种情况下错误确实给出了正确的原因。