4

I'm trying to reference a item with \cref from a new list type created with enumitem:

\documentclass[12pt, twoside, openright]{book}
% Language options
\usepackage[english]{babel}
\selectlanguage{\english}

% Enable UTF-8 input
\usepackage[utf8]{inputenc}


\usepackage{glossaries}

\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{placeins}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[sf,outermarks]{titlesec}
\usepackage{tocloft}
\usepackage{fancyhdr}
\usepackage[figuresright]{rotating}
\usepackage{eso-pic}
\usepackage{fancyvrb}
\usepackage{helvet}
\usepackage{latexsym}
\usepackage{color}
\usepackage{supertabular}
\usepackage[font=small]{caption}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{listing}

\usepackage{url}
\usepackage{bigstrut}
\usepackage{epstopdf}
\usepackage[inline]{enumitem}
\usepackage[colorlinks=false,linkcolor=blue,urlcolor=orange]{hyperref}

\usepackage{titlesec}
\usepackage{cleveref}


\begin{document}

\newlist{flatlist}{enumerate*}{1}
\setlist[flatlist]{label={\textit{\alph*)}}}   


\crefname{flatlisti}{item}{items}
\creflabelformat{flatlisti}{#2#1#3}


\begin{description}
    \item [Dictionaries]  (i.e. words  \cref{gender_item}), and (i.e. usage count \cref{gender_data_item}).

    \begin{flatlist}
      \item Gender data \label{gender_data_item}
      \item Unigrams\label{gender_item}
    \end{flatlist}
\end{description}
\end{document}

I get ??a) and ??b) references and the next Warning:

LaTeX Warning: cref reference format for label type `flatlisti' undefined on i nput line 22.
4
  • Welcome to TeX.SE. Please provide a compilable document ,not fragments only. (Putting all together and using article as document class, I get the correct references. Did you compile twice?)
    – user31729
    Jun 15, 2017 at 11:37
  • Thanks for the help I put a full compilable document that fails. I provide the full packages in the same order. In case it is a package conflict. I use overleaf an I'm getting the correct bibliography. So i think is compiling two times.
    – Nasgar
    Jun 15, 2017 at 11:57
  • Please put the \newlist and \setlist definitions as well as the \crefformat statements before \begin{document}. Also clean up the preamble. You're loading some packages twice and in the wrong order, but the main issue the wrong position of \newlist etc.
    – user31729
    Jun 15, 2017 at 12:04
  • 1
    Please, avoid those slanted parentheses: label=\textit{\alph*}\textup{)} will yield a much better result.
    – egreg
    Jun 15, 2017 at 12:18

1 Answer 1

5

The \crefname must be given always before \begin{document}, a specification later on will not work, since cleveref freezes its internal 'tables' of known counter names.

Following 'minimal' document has the same issue as from the OP: \crefname{foolist}{foo}{foos} is called too late here, unless shifted to \begin{document}

\documentclass{article}

\usepackage[inline]{enumitem}

\usepackage{cleveref}

\newlist{foolist}{enumerate*}{1}
\setlist[foolist,1]{label={\Roman*)}}

\creflabelformat{foolisti}{#2#1#3}

\crefname{foolisti}{foo}{foos}

\begin{document}

%%% Too late, see just before \begin{document}
%\crefname{foolisti}{foo}{foos}

\begin{description}
\begin{foolist}
\item A foo\label{foolabel}
\end{foolist}
\end{description}

However, see \cref{foolabel}


\end{document}
2
  • Put the ' \crefformat' statements after \begin{document} was the error. Thanks a lot! The other issues comes from quick copy pasting.
    – Nasgar
    Jun 15, 2017 at 12:16
  • What if you didn't create a newlist and instead just used enumerate* directly. What would \crefname look like in that case? What is an appropriate "name" for a enumerate* item?
    – khatchad
    Jul 23, 2021 at 20:21

You must log in to answer this question.

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