\newtcbtheorem の参照の問題

\newtcbtheorem の参照の問題

次のコードを考えてみましょう。

\documentclass[a4paper,12pt,openany]{book}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}
\makeatletter
\makeatother
\newtcbtheorem[auto counter, number within = section]{defn}{Définition}{
colback=green!5,
colframe=green!35!black,
fonttitle=\bfseries,}
{defn}
\newtcbtheorem[auto counter, number within = section]{theo}{Théorème}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{theo}
\newtcbtheorem[auto counter, number within = section]{prop}{Proposition}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{prop}
\newtcbtheorem[auto counter, number within = section]{lem}{Lemme}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{lem}
\newtcbtheorem[auto counter, number within = section]{coro}{Corollaire}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{coro}
\begin{document}
\chapter{CH 1}
\begin{theo}{}{}\label{A}
A
\end{theo}
\section{sec 1}
\begin{prop}{}{}\label{B}
B
\end{prop}
\section{sec 2}
\begin{lem}{}{}\label{C}
C
\end{lem}
\section{sec 3}
\begin{coro}{}{}\label{D}
D
\end{coro}
Théorème ({\color{blue}\ref{A}}), proposition ({\color{blue}\ref{B}}), lemme ({\color{blue}\ref{C}}), corollaire ({\color{blue}\ref{D}}).
\end{document}

得られた結果は次のとおりです。

ここに画像の説明を入力してください

私の問題は、最後の文を次のようにしたいということです。

「定理(1.0.1)、命題(1.1.1)、レム(1.2.1)、巻数(1.3.1)」

アイデアをお願いします。

答え1

このような定理のような環境との相互参照は動作が異なります。ラベルは 3 番目の引数の後に記述する必要があり\begin、参照の前には定義の最後の項目を付ける必要もあります。

theo最後の項目で定義しているのでtheo、参照は のようになります\ref{theo:A}

ここでは、すべてに対してより単純なプレフィックスを使用する以外に、これについてできることはあまりないと思いますt

\documentclass[a4paper,12pt,openany]{book}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}

\newtcbtheorem[auto counter, number within = section]{defn}{Définition}{
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries,
}{t}
\newtcbtheorem[auto counter, number within = section]{theo}{Théorème}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{t}
\newtcbtheorem[auto counter, number within = section]{prop}{Proposition}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{t}
\newtcbtheorem[auto counter, number within = section]{lem}{Lemme}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{t}
\newtcbtheorem[auto counter, number within = section]{coro}{Corollaire}{
    colback=green!5,
    colframe=green!35!black,
    fonttitle=\bfseries,
}{t}

\begin{document}
\chapter{CH 1}
\begin{theo}{}{A}
text A
\end{theo}
\section{sec 1}
\begin{prop}{}{B}
text B
\end{prop}
\section{sec 2}
\begin{lem}{}{C}
text C
\end{lem}
\section{sec 3}
\begin{coro}{}{D}
text D
\end{coro}

Théorème (\textcolor{blue}{\ref{t:A}}), 
proposition (\textcolor{blue}{\ref{t:B}}), 
lemme (\textcolor{blue}{\ref{t:C}}), 
corollaire (\textcolor{blue}{\ref{t:D}}).

\end{document}

ここに画像の説明を入力してください

のサポートを追加しcleveref、パッケージの機能に合わせて調整できます。

\documentclass[a4paper,12pt,openany]{book}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}

\newtcbtheorem[auto counter, number within = section]{defn}{Définition}{
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries,
  label type=defn,
}{t}
\newtcbtheorem[auto counter, number within = section]{theo}{Théorème}{
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries,
  label type=theo,
}{t}
\newtcbtheorem[auto counter, number within = section]{prop}{Proposition}{
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries,
  label type=prop,
}{t}
\newtcbtheorem[auto counter, number within = section]{lem}{Lemme}{
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries,
  label type=lem,
}{t}
\newtcbtheorem[auto counter, number within = section]{coro}{Corollaire}{
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries,
  label type=coro,
}{t}

\crefname{defn}{définition}{définitions}
\crefname{theo}{théorème}{théorèmes}
\crefname{prop}{proposition}{propositions}
\crefname{coro}{corollaire}{corollaires}
\crefname{lem}{lemme}{lemmes}
\begin{document}
\chapter{CH 1}
\begin{theo}{}{A}
text A
\end{theo}
\section{sec 1}
\begin{prop}{}{B}
text B
\end{prop}
\section{sec 2}
\begin{lem}{}{C}
text C
\end{lem}
\section{sec 3}
\begin{coro}{}{D}
text D
\end{coro}

\Cref{t:A}, \cref{t:B}, \cref{t:C}, \cref{t:D}.

Théorème (\textcolor{blue}{\ref{t:A}}), 
proposition (\textcolor{blue}{\ref{t:B}}), 
lemme (\textcolor{blue}{\ref{t:C}}), 
corollaire (\textcolor{blue}{\ref{t:D}}).

\end{document}

ここに画像の説明を入力してください

関連情報