On the question Missing number, treated as zero when renewing enumerate \item and using hyperref I learned I have to define my custom commands from the question How to recognize the enumerate shortlabels in my custom environment? before the package hyperref
to be loaded.
However, my thesis should use the class abntex2
and the abntex2
class got the brilliant and extraordinary idea of including the package hyperref
on their source code, without any practical reason.
Now, I got no idea how I can include the package hyperref
after defining my code. So far I tried using \RequirePackage{enumitem}
and defining my command before loading the abntex2
class. However, LaTeX threw the error
enumitem.sty:1587: LaTeX Error: Environment description undefined.
\PassOptionsToPackage{shortlabels}{enumitem}
\RequirePackage{enumitem}
\let\itemenumerateoptional\item
\newcounter{enumerateoptionalcount}
\def\renewenumerateoptionalitem{%
\let\itemenumerateoptional\item
\renewcommand{\item}[1][]{%
\refstepcounter{enumerateoptionali}% increment the counter
\itemenumerateoptional[\bfseries##1~\theenumerateoptionali]%
}%
}
\newlist{enumerateoptional}{enumerate}{1}
\setlist[enumerateoptional]{
before=\renewenumerateoptionalitem,
label=\arabic*,
nosep,
labelindent=20mm,
leftmargin=*,
after=\let\item\itemenumerateoptional,
}
\documentclass{abntex2}
\begin{document}
\begin{enumerateoptional}[1.]
\item[Some first] item one
\item[Some second] item two
\end{enumerateoptional}
\end{document}
Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
(D:\latex\enumitem.sty
D:\latex\enumitem.sty:1587: LaTeX Error: Environment description undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
D:\latex\enumitem.sty:1587: ==> Fatal error occurred, no output PDF file produced!
Related questions
- Using later-defined commands in an own document class
- How to override command on my preamble, after its redefinition by my class with renewcommand?
- Hyperref is loaded by the class, and I need to load packages that are supposed to be loaded before
- when using hyperref package undefined control sequence \chapter error
- Which packages should be loaded after hyperref instead of before?
- Using later-defined commands in an own document class