2

Following topic1 and topic2, I've implemented Mico's answers. Now, I want to reference equations under this enumeration too. For instance,

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{enumitem,cleveref}

\newlist{myenum}{enumerate}{3}
\setlist[myenum,1]{label=\textbf{\arabic*.},
                   ref  =\arabic*}
\setlist[myenum,2]{label=\textbf{(\alph*)},
                   ref  =\themyenumi.(\alph*)}
\setlist[myenum,3]{label=\bfseries(\roman*),
                   ref  =\themyenumii.(\roman*)}

\numberwithin{equation}{myenumi}

\begin{document}

\begin{myenum}
\item 
   \begin{equation}\label{eq:euler}
      e^{i\pi}+1 = 0
   \end{equation}
\end{myenum}

As shown in \cref{eq:euler}.

\end{document}

However, these lines got me this error: "Missing \endcsname inserted. \begin{equation}". Any ideas about why is this happening and/or how to solve this? Thanks.

Edit: I've discovered that this occurs when including the \usepackage{hyperref} line.

  • The code you posted doesn't actually produce the error you say you're getting. Please revise your posting as needed. – Mico Jan 23 '18 at 3:14
  • 1
    Off-topic: For the first-level myenum enumeration, I think the cross-referencing option should be "ref =\arabic*", not "ref =\arabic*.". – Mico Jan 23 '18 at 3:16
  • Thanks! You were right at both times. I've edited the post accordingly. – mflopezabu Jan 23 '18 at 4:05
2

I suspect you've encountered an incompatibility between the enumitem and hyperref packages. I'm afraid I'm not in a position to offer a full fix. All I can suggest is that you not use the enumitem package and, instead, modify the low-level macros \theenumi, \labelenumi, \theenumii, \labelenumii, \p@enumii, etc.

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}

\renewcommand{\theenumi}{\arabic{enumi}}
\renewcommand{\theenumii}{(\alph{enumii})}
\renewcommand{\theenumiii}{(\roman{enumiii})}
\renewcommand{\labelenumi}{\textbf{\theenumi.}}
\renewcommand{\labelenumii}{\textbf{\theenumii}}
\renewcommand{\labelenumiii}{\textbf{\theenumiii}}
\makeatletter
\renewcommand\p@enumii{\theenumi} % "prefixes" for use in cross-references
\renewcommand\p@enumiii{\theenumi\theenumii}
\makeatother

\numberwithin{equation}{enumi}

\begin{document}

\begin{enumerate}
\item 
   \begin{equation}\label{eq:euler}
      e^{i\pi}+1 = 0
   \end{equation}
\end{enumerate}

As shown in \cref{eq:euler}, \dots
\end{document}
  • This was exactly what I needed but didn't know how to add the prefixes. Thank you so much! – mflopezabu Jan 24 '18 at 1:18

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.