I have recently started working with the fabulous tcolorbox package and have successfully been able to generate the boxes I need with the label as an argument. However, I want to be able to use that label for referencing. Working from the manuals and this site (notably the answer at How to define labels within a tcolorbox?), I have got partway.
The correct box is generated with this code. However, the referencing is not working. In the MWE, I want the text to read "reference the below box as Test Box 1a" as the label I passed is "1a".
Instead, I am getting an error ! Use of \cref@override@label@type doesn't match its definition.
\documentclass[a4paper, twoside]{book}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}
\newtcolorbox{testbox}[2]{
enhanced,
label type=mytype,
label = #1,
title = Test~#1:~#2
}
\crefname{mytype}{Test Box}{Test Boxes}
\begin{document}
What I want is to be able to reference the below box as \cref{1a} (Should say \textit{Test Box 1a}).
\begin{testbox}{1a}{Title of first box}
The contents of the box
\end{testbox}
\end{document}
With further investigation (and the excellent explanation in the answer at How to cross-reference an unnumbered theorem using hyperref and cleveref), it looks like \label only works with a counter and not an arbitrary text label, so I might need to change my whole approach. But I would appreciate confirmation if this is true.
