I have defined a new float and would like to reference it using cleveref
.
Here is my MWE:
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{newfloat}
\usepackage{hyperref}
%
\usepackage[nameinlink,capitalize]{cleveref}
\Crefname{vocab}{Vocabulary}{Vocabularies}
\crefname{vocab}{vocabulary}{vocabularies}
%
\DeclareFloatingEnvironment[%
fileext=low,% list of words
listname={List of Words},
name=Vocabulary,
placement=hbt]
{vocabulary}
%
\newcommand{\myvocab}[2]{% #1: heading; #2: content
\begin{tcolorbox}[title={\scshape Vocabulary:} #1]%
#2
\end{tcolorbox}}%
%
\begin{document}
Can we refer to the new floating \texttt{vocabulary} environment using the \texttt{cleveref} package?
\begin{vocabulary}
\myvocab{Trial}{We are trying to test the new float called \texttt{vocabulary} and see if it can be correctly referenced by \texttt{cleveref}.}
\caption[Trial]{Trial}\label{vocab:trial}
The first test of the new floating environment is shown in \Cref{vocab:trial}.
\end{vocabulary}
\end{document}
I have compiled the file with three passes through lualatex
but cannot seem to get rid of the "??" instead of the name Vocabulary. Please see result below.