\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

이러한 정리와 유사한 환경에서의 상호 참조는 다르게 작동합니다. 레이블은 다음 세 번째 인수에 있어야 하며 \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}

여기에 이미지 설명을 입력하세요

관련 정보