7

The code

\documentclass[11pt]{article}
\usepackage{hyperref}
\usepackage{enumitem}
\newlist{ilist}{enumerate}{3}
\setlist*[ilist]{leftmargin=*}
\setlist*[ilist,1]{label=\arabic*.}
\setlist*[ilist,2]{label=\arabic{ilisti}.,before=\refstepcounter{ilisti}}
\setlist*[ilist,3]{label=\arabic{ilisti}.,before=\refstepcounter{ilisti}}

\begin{document}

\begin{ilist}
\item A
\begin{ilist}
\item B
\begin{ilist}
\item C
\end{ilist}
\end{ilist}
\end{ilist}

\end{document}

is somehow producing the error

The error resolves if I comment out \usepackage{hyperref}.

Any ideas as to why?

6
  • 4
    With very few exceptions, hyperref should be loaded after all the other packages. Commented Feb 13 at 23:54
  • 2
    @samcarter_is_at_topanswers.xyz in this case you need to load it after all the enumitem definitions not just after the package, which looks a bit strange, but.... Commented Feb 14 at 0:02
  • @DavidCarlisle Ah, right! Commented Feb 14 at 0:05
  • 2
    @samcarter_is_at_topanswers.xyz that was true years ago, but now we want to remove these restrictions and if things do not work with a different loading order we try to correct that. Commented Feb 14 at 9:43
  • 1
    @DenisBitouzé see tex.stackexchange.com/a/709547/2388 Commented Feb 21 at 12:13

1 Answer 1

9

It is an error in hyperref. hyperref tries to provide a \theH<counter> definition for every new counter and uses for this \arabic{#1}. But this means that commands in the #1 are not directly expanded and this falls over here as enumitem uses \@definecounter{\enit@c\romannumeral\count@} to define the new list counters and so e.g. \theHilisti looks like this:

> \theHilisti=macro:
->\arabic {\enit@c \romannumeral \count@ }.

I will change the hyperref definition. A work-around for now is this

\documentclass[11pt]{article}
\usepackage{hyperref}
\makeatletter
\def\@definecounter#1{%
     \H@definecounter{#1}%
     \expandafter
     \gdef\csname theH#1\expandafter\endcsname\expandafter
          {\expandafter\@arabic\csname c@#1\endcsname}}%
\makeatother   
\usepackage{enumitem}
\newlist{ilist}{enumerate}{3}
\setlist*[ilist]{leftmargin=*}
\setlist*[ilist,1]{label=\arabic*.}
\setlist*[ilist,2]{label=\arabic{ilisti}.,before=\refstepcounter{ilisti}}
\setlist*[ilist,3]{label=\arabic{ilisti}.,before=\refstepcounter{ilisti}}
\begin{document}

\begin{ilist}
\item A
\begin{ilist}
\item B
\begin{ilist}
\item C
\end{ilist}
\end{ilist}
\end{ilist}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .