0

I wrote this code I started doing after on How to set \topsep=0pt on the latex standard list implementation inside an environment? I find out I could not change the standard latex \list{} environment behavior without patching it:

\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}

On the code, I just put the \PackageWarning on the success xpatchcmd clause, for testing purposes. When I know it is working I put it on the failure clause.

Anyways, gives this error, where line 20 is one line after the line defining the \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!

We see the warning seems to be working, but the error makes no sense. I also tried to put this inside my package, and it gives the same error, but now it points out the LaTeX Error: Missing \begin{document}. is happening inside my package:

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!

Related:

  1. Please tutor the usage of patchcmd and xpatch
  2. Strange \patchcmd behavior
  3. Is there any way to generate custom errors/warnings in LaTeX?
  4. How does "missing \begin{document}" work?
5

In opposite to \PackageError, \PackageWarning has two arguments only, the package name and the warning text. The "third argument" is executed as group with text, and the text causes the error about missing \begin{document}.

Possible fixes:

  • Removal of the third argument.
  • Inclusion of the third argument in the second argument.
  • Use of \PackageError instead of \PackageWarning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.