为什么 \PackageWarning 在修补标准 Latex 列表环境时出现 LaTeX 错误:缺少 \begin{document}?

为什么 \PackageWarning 在修补标准 Latex 列表环境时出现 LaTeX 错误:缺少 \begin{document}?

我写了这段代码,之后开始做如何在环境内的乳胶标准列表实现中设置 \topsep=0pt?我发现\list{}如果不修补它,我就无法改变标准乳胶环境行为:

\PassOptionsToPackage{brazil,main=english}{babel}
\documentclass[
10pt,
a5paper,
twoside
chapter=TITLE,
section=TITLE
]{abntex2}
\pdfstringdefDisableCommands{\let\uppercase\relax}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{xpatch}

\xpatchcmd{\citacao}
{\list{}}
{\list{}{\topsep=0pt}}
{\PackageWarning{ufscthesisx}{Citation topsep not patched}{The citacao environment must be patched with topsep=0pt but it failed. This is probably dua an update on the main class abnTeX2, the its new update need to be checked and the topsep patch must need to be updated accordingly}}
{}

\begin{document}

    Test
    \begin{citacao}
        Test
    \end{citacao}
    Test

\end{document}

在代码中,我仅将其放在\PackageWarning成功xpatchcmd子句中,以进行测试。当我知道它正常工作时,我会将其放在失败子句中。

无论如何,会出现此错误,其中行20是定义行之后的一行\PackageWarning

Package ufscthesisx Warning: Citation topsep not patched on input line 20.


test3.tex:20: LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help 
Here is how much of TeX's memory you used:
 17782 strings out of 493314
 308100 string characters out of 3134142
 399813 words of memory out of 3000000
 21254 multiletter control sequences out of 15000+200000
 531633 words of font info for 25 fonts, out of 3000000 for 9000
 1141 hyphenation exceptions out of 8191
 38i,1n,26p,10383b,275s stack positions out of 5000i,500n,10000p,200000b,50000s

test3.tex:20:  ==> Fatal error occurred, no output PDF file produced!

我们看到警告似乎有效,但错误毫无意义。我也尝试将其放入我的包中,它给出了相同的错误,但现在它指出了LaTeX Error: Missing \begin{document}.发生在我的包中的事情:

Package ufscthesisx Warning: Citation `\topsep ` not patched on input line 81.


ufscthesisx.sty:81: LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help 
Here is how much of TeX's memory you used:
 25262 strings out of 493314
 445286 string characters out of 3134142
 710952 words of memory out of 3000000
 28611 multiletter control sequences out of 15000+200000
 531633 words of font info for 25 fonts, out of 3000000 for 9000
 1141 hyphenation exceptions out of 8191
 68i,1n,57p,10427b,424s stack positions out of 5000i,500n,10000p,200000b,50000s

ufscthesisx.sty:81:  ==> Fatal error occurred, no output PDF 
file produced!

有关的:

  1. 请指导一下patchcmd和xpatch的使用
  2. 奇怪的 \patchcmd 行为
  3. 有没有办法在 LaTeX 中生成自定义错误/警告?
  4. “缺少 \begin{document}” 如何起作用?

答案1

与 相对\PackageError\PackageWarning只有两个参数,包名和警告文本。“第三个参数”作为 group with text 执行,文本导致缺少 的错误\begin{document}

可能的修复:

  • 删除第三个参数。
  • 将第三个参数包含在第二个参数中。
  • 使用\PackageError代替\PackageWarning

相关内容