\cref
我正在尝试引用使用以下命令创建的新列表类型中的项目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}
我得到了??a) 和 ??b) 引用以及下一个警告:
LaTeX Warning: cref reference format for label type `flatlisti' undefined on i nput line 22.
答案1
必须\crefname
始终在之前给出\begin{document}
,稍后的指定将不起作用,因为它cleveref
会冻结其已知计数器名称的内部“表”。
以下“最小”文档与 OP 存在同样的问题:\crefname{foolist}{foo}{foos}
此处调用得太晚,除非转移到\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}