例如,
\begin{mybluebox}[label={myreference}]{My title}
This is an example.
\end{mybluebox}
从(tcolorbox Manual, page 99)
我想得到的Bluebox 5.1 My title
不仅仅是给予的Bluebox 5.1
东西\Cref{myreference}
。
答案1
一个解决方案是使用以下选项将标题添加为数字的一部分number freestyle
:
\documentclass{article}
\usepackage{varioref}
\usepackage{cleveref}
\usepackage{tcolorbox}
\newtcolorbox[
auto counter,
number within=section,
number freestyle={\noexpand\thesection.\noexpand\arabic{\tcbcounter}~\noexpand\mytitle},
crefname={bluebox}{blueboxes}]%
{mybluebox}[2][]{
colback=blue!5!white,
colframe=blue!75!black,
fonttitle=\bfseries,
code={\def\mytitle{#2}},
title=Bluebox \thetcbcounter,%
#1}
\begin{document}
\section{Test}
\begin{mybluebox}[label={myreference}]{My title}
This is an example.
\end{mybluebox}
\Cref{myreference}
\end{document}