Моя ссылка на `tcolorbox` не работает

Моя ссылка на `tcolorbox` не работает

Я просто пытаюсь сослаться на один из моих примеров в тексте, но он всегда помечен верхним предыдущим счетчиком (здесь номер раздела).

Мой пример окружения определяется как exmpто, что само по себе является tcolorboxокружением. Я знаю, что проблема, вероятно, исходит из моего newtcolorboxопределения, но я не могу найти откуда. Если у вас есть какие-либо идеи, пожалуйста, сообщите мне.

Я работаю с pdfLaTexкомпилятором и вот мой минимальный код:

\documentclass[justified,notoc,numbers]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{color}
\usepackage[most]{tcolorbox}

%-----------FOR DEMO-----------
\usepackage{lipsum}

%=======================================================
%                      FONT STYLE
%=======================================================
\renewcommand{\rmdefault}{ptm}

%=======================================================
%                       COUNTERS
%=======================================================
\newcounter{theexample}[section]
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
%=======================================================
%                       COLORS
%=======================================================
\definecolor{grey}{rgb}{0.9,0.9,0.9}
\definecolor{myColor}{rgb}{0.0, 0.5, 1.0}

\newtcolorbox{exmp}[1][]{
  breakable,
  enhanced,
  borderline west={2pt}{0pt}{myColor},
  sharp corners,
  boxrule=0pt,
  fonttitle={\large\bfseries},
  coltitle={black},
  title= {\textcolor{myColor}{Exemple  \stepcounter{theexample}\thesection.\arabic{theexample}:} #1\\},
  attach title to upper,
  right=0pt,
  top=0pt,
  bottom=0pt,
  frame hidden,
  colback=white!80!gray,
}



\title{test - tex.stackexchange.com}
\author[Author Name \& Firstname]{Author Name \& Firstname}


%=======================================================
%                       GEOMETRY
%=======================================================
\geometry{
  left=15mm,                    % left margin
  textwidth=140mm,              % main text block
  headsep=10mm,
  headheight = 0mm,
  marginparsep=7mm,             % gutter between main text block and margin notes
  marginparwidth=50mm,          % width of margin notes
  bottom = 1.5cm, 
  top = 1.7cm
}

%=======================================================
%                       DOCUMENT
%=======================================================
\begin{document}
\section{Chapter 1:}
\subsection{Section 1.}
[![\subsection{Section 2.}][1]][1]
\begin{exmp}[My example's title]
\label{EX1}
\lipsum[1]
\end{exmp}

Try to reference to my example counter using \texttt{ref\{EX1\}}: \ref{EX1}

\end{document}

Итак, вот результат

Что это дает

когда то, чего я хочу, это

Что я хочу

Большое спасибо.

решение1

РЕШЕНО:

Проблема действительно была в объявлении параметров, мне нужно 2, а не 1 параметр. #1 — мой вариант, а #2 будет моим заголовком. Вот код решения:

\documentclass[justified,notoc,numbers]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{color}
\usepackage[most]{tcolorbox}

%-----------FOR DEMO-----------
\usepackage{lipsum}

%=======================================================
%                      FONT STYLE
%=======================================================
\renewcommand{\rmdefault}{ptm}

%=======================================================
%                       COUNTERS
%=======================================================
\newcounter{theexample}[section]
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
%=======================================================
%                       COLORS
%=======================================================
\definecolor{grey}{rgb}{0.9,0.9,0.9}
\definecolor{myColor}{rgb}{0.0, 0.5, 1.0}

\newtcolorbox{exmp}[2][]{
  breakable,
  enhanced,
  borderline west={2pt}{0pt}{myColor},
  sharp corners,
  boxrule=0pt,
  fonttitle={\large\bfseries},
  coltitle={black},
  title= {\textcolor{myColor}{Exemple  \stepcounter{theexample}\thesection.\arabic{theexample}:} #2\\},
  attach title to upper,
  right=0pt,
  top=0pt,
  bottom=0pt,
  frame hidden,
  colback=white!80!gray,
  #1,
}



\title{test - tex.stackexchange.com}
\author[Author Name \& Firstname]{Author Name \& Firstname}


%=======================================================
%                       GEOMETRY
%=======================================================
\geometry{
  left=15mm,                    % left margin
  textwidth=140mm,              % main text block
  headsep=10mm,
  headheight = 0mm,
  marginparsep=7mm,             % gutter between main text block and margin notes
  marginparwidth=50mm,          % width of margin notes
  bottom = 1.5cm, 
  top = 1.7cm
}

%=======================================================
%                       DOCUMENT
%=======================================================
\begin{document}
\section{Chapter 1:}
\subsection{Section 1.}
\subsection{Section 2.}
\begin{exmp}[label = EX1]{My example's title}
\lipsum[1]
\end{exmp}

Try to reference to my example counter using \texttt{ref\{EX1\}}: 1.1

\end{document}

Связанный контент