Minimal Working Example
Consider the following code:
\documentclass{article}
% \usepackage{hyperref} % Uncomment causes compile error
\usepackage{cleveref}
\usepackage{enumitem}
\newlist{main}{enumerate}{1}
\setlist[main,1]{label={$\cdot$}, ref={\arabic*}}
\creflabelformat{maini}{#2#1#3}
\crefname{maini}{Main}{Mains}
\newcounter{sub}[maini]
\crefname{sub}{Sub}{Subs}
\renewcommand{\thesub}{\themaini.\arabic{sub}}
\begin{document}
\begin{main}
\item\label{main:a} A
\refstepcounter{sub}\label{main:a:1}
\refstepcounter{sub}\label{main:a:2}
\item\label{main:b} B
\refstepcounter{sub}\label{main:b:1}
\refstepcounter{sub}\label{main:b:2}
\end{main}
\setlength{\parindent}{0pt}
\cref{main:a}\\ % Main 1
\cref{main:a:1}\\ % Sub 1.1
\cref{main:a:2}\\ % Sub 1.2
\cref{main:b}\\ % Main 2
\cref{main:b:1}\\ % Sub 1.1
\cref{main:b:2}\\ % Sub 1.2
\end{document}
Problem
The above code compiles fine without the hyperref
. If it is loaded, however, the document no longer compiles and a cryptic error is produced:
! Missing \endcsname inserted.
<to be read again>
\global
l.20 \refstepcounter{sub}
\label{main:a:1}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
! Missing number, treated as zero.
<to be read again>
\c@
l.20 \refstepcounter{sub}
\label{main:a:1}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)