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?

arz
  • 157

1 Answers1

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}

Ulrike Fischer
  • 327,261