0

I would like to have a progressive numbering of Theorems, Lemmas, Corollaries, Examples, Remarks, etc. within sections. While for equations I would like a numbering within chapters. Also, I would like the counter to be set to 0 when starting a new chapter. I would say that the main problem is that I use the package tcolorbox for theorems, corollaries, lemmas, etc., and amsthm for examples and remarks. Below you find the MWE I'd need.

\documentclass[x11names,two sides,12pt]{book}

\usepackage{changepage}
\usepackage[titles]{tocloft}

\renewcommand{\cftdot}{}

\renewcommand{\cftchapfont}{\normalsize \bf\scshape}
\renewcommand{\cftsecfont}{\normalsize}
\renewcommand{\cftsubsecfont}{\itshape}


\usepackage{geometry}
 \geometry{
 left=25mm,
 right=25mm,
 top=20mm,
 bottom=20mm,
 headheight=14pt
 }

\usepackage{soul}

\usepackage{pgfkeys}

\usepackage{tikz,tikz-cd}

\usepackage{amsthm,amssymb,amsfonts,mathrsfs}

\usepackage[T1]{fontenc}

\usepackage[utf8]{inputenc}

\usepackage[english]{babel}


\usepackage[colorlinks = true,
            linkcolor = blue,
            filecolor=black,
            urlcolor  = black!40!cyan,
            citecolor = blue,
            anchorcolor = red!60!black,
            pdfencoding=auto,
            psdextra
            ]{hyperref}
            
\usepackage{tcolorbox}
\tcbuselibrary{theorems,breakable}

\usepackage[pagestyles, clearempty,explicit]{titlesec}

\usepackage[titles]{tocloft}
\usepackage[nottoc,numbib]{tocbibind} 

\theoremstyle{definition}
\newtheorem{ex}{Example}[section]

\theoremstyle{definition}
\newtheorem{rmk}{Remark}[section]


\newtcbtheorem[number within=section]{thm}{Theorem}{before skip=10pt, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad},coltitle=black, colback=black!3!white, colframe=black!10!white, fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{theo}

\newtcbtheorem[number within=section]{thm1}{Théorème}{before skip=10pt, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad},coltitle=black, colback=black!3!white, colframe=black!10!white, fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{theo1}

\newtcbtheorem[number within=section]{propn}{Proposition}{before skip=10pt, breakable , coltitle=black, leftrule=2mm, detach title, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{propn} %questo serve per il ref

\newtcbtheorem[number within=section]{lem}{Lemma}{before skip=10pt, breakable, coltitle=black, detach title, leftrule=2mm, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{lem}

\newtcbtheorem[number within=section]{defn}{Definition}{before skip=10pt, coltitle=black, breakable, leftrule=2mm, coltitle=black, detach title, before upper={\tcbtitle\quad}, colback=black!3!white, colframe=black!10!white, fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{defn}

\newtcbtheorem[number within=section]{cor}{Corollary}{before skip=10pt, coltitle=black, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{corol}

\newtcbtheorem[number within=section]{cor1}{Corollaire}{before skip=10pt, coltitle=black, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{corol1}

\titleformat{\section}[display]{\fontsize{12}{0} \bfseries}{}{0pt}{\colorbox{black!15!white}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\thesection \textcolor{black}{\quad#1}}}}[]


\titleformat{\subsection}[display]
{\itshape \normalsize \bfseries}{\thesubsection \textcolor{black}{\quad#1}}{-0.4cm}{}


\titleformat{name=\section,numberless}[display]{\fontsize{11.4}{0} \bfseries}{}{0pt}{\colorbox{black!15!white}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textcolor{black}{\quad#1}}}}[]
\titlespacing*{\section}{-0.8cm}{0.7cm}{0.2cm}[0pt]
{\setcounter{secnumdepth}{0}%
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}\ignorespaces}}
{\setcounter{secnumdepth}{2}%
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}\ignorespaces}}


\titleformat{\chapter}[display]
  {\scshape\bfseries}
  {}{10pt}
  {\centering \LARGE \color{black!80!white} #1}
\titlespacing*{\chapter}{0pt}{0pt}{20pt}{}
  
\titleformat{\paragraph}[display]{\fontsize{11}{0}\selectfont \bfseries }{}{0pt}{#1}
\titlespacing*{\paragraph}{0.3cm}{0.4cm}{0.1cm}[0pt]


\setcounter{secnumdepth}{3}

\begin{document}

\section{Section}
\begin{thm}{}{}
Theorem.
\end{thm}
\begin{cor}{}{}
Corollary.
\end{cor}
\begin{rmk}
\end{rmk}
\begin{equation}
1+1=2
\end{equation}
\begin{rmk}
Remark.
\end{rmk}
\begin{equation}
2+1=3
\end{equation}
\begin{ex}
Another example.
\end{ex}
\begin{lem}{}{}
Lemma.
\end{lem}
\begin{defn}{}{}
Definition.
\end{defn}
\end{document}

So, referring to the above, I would like it to appear like "Theorem 0.1.1", "Corollary 0.1.2", "Remark 0.1.3", "Equation 0.1", "Remark 0.1.4", "Equation 0.2", "Example 0.1.5", "Lemma 0.1.6", "Definition 0.1.7". When changing the chapter, for example, I would like the numbering to start from "1.1.1" in the first section of the first chapter (for theorems etc.), while from 1.1 for equations. I hope I well explained what I'd need!

1 Answer 1

1

In tcolorbox you can use the option use counter (unfortunately I can't make the use counter* option work if used for all the \newtcbtheorem instructions, so I use use counter together with number within on all of them).

For amsmath you can specify the counter it should use by using \newtheorem{<env>}[<counter>]{<title>}.

To alter the equation counter you can use \counterwithin{equation}{chapter}.

Put together:

\documentclass[x11names,twoside,12pt]{book}

\usepackage{amsthm}
\usepackage{tcolorbox}
\tcbuselibrary{theorems,breakable}
\theoremstyle{definition}

\counterwithin{equation}{chapter}

\newcounter{fradnscounter}[section]

\newtheorem{ex}[fradnscounter]{Example}

\theoremstyle{definition}
\newtheorem{rmk}[fradnscounter]{Remark}

\newtcbtheorem[number within=section, use counter=fradnscounter]{thm}{Theorem}{before skip=10pt, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad},coltitle=black, colback=black!3!white, colframe=black!10!white, fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{theo}

\newtcbtheorem[number within=section, use counter=fradnscounter]{thm1}{Théorème}{before skip=10pt, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad},coltitle=black, colback=black!3!white, colframe=black!10!white, fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{theo1}

\newtcbtheorem[number within=section, use counter=fradnscounter]{propn}{Proposition}{before skip=10pt, breakable , coltitle=black, leftrule=2mm, detach title, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{propn} %questo serve per il ref

\newtcbtheorem[number within=section, use counter=fradnscounter]{lem}{Lemma}{before skip=10pt, breakable, coltitle=black, detach title, leftrule=2mm, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{lem}

\newtcbtheorem[number within=section, use counter=fradnscounter]{defn}{Definition}{before skip=10pt, coltitle=black, breakable, leftrule=2mm, coltitle=black, detach title, before upper={\tcbtitle\quad}, colback=black!3!white, colframe=black!10!white, fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{defn}

\newtcbtheorem[number within=section, use counter=fradnscounter]{cor}{Corollary}{before skip=10pt, coltitle=black, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{corol}

\newtcbtheorem[number within=section, use counter=fradnscounter]{cor1}{Corollaire}{before skip=10pt, coltitle=black, breakable, detach title, leftrule=2mm, before upper={\tcbtitle\quad}, colback=black!3!white,colframe=black!10!white,fonttitle=\bfseries, arc=0mm, separator sign none, description delimiters parenthesis, terminator sign colon}{corol1}

\setcounter{secnumdepth}{3}

\begin{document}
\section{Section}
\begin{thm}{}{}
Theorem.
\end{thm}
\begin{cor}{}{}
Corollary.
\end{cor}
\begin{rmk}
\end{rmk}
\begin{equation}
1+1=2
\end{equation}
\begin{rmk}
Remark.
\end{rmk}
\begin{equation}
2+1=3
\end{equation}
\begin{ex}
Another example.
\end{ex}
\begin{lem}{}{}
Lemma.
\end{lem}
\begin{defn}{}{}
Definition.
\end{defn}

\section{Section}
\begin{thm}{}{}
Theorem.
\end{thm}
\begin{cor}{}{}
Corollary.
\end{cor}
\begin{rmk}
\end{rmk}
\begin{equation}
1+1=2
\end{equation}
\begin{rmk}
Remark.
\end{rmk}
\begin{equation}
2+1=3
\end{equation}
\begin{ex}
Another example.
\end{ex}
\begin{lem}{}{}
Lemma.
\end{lem}
\begin{defn}{}{}
Definition.
\end{defn}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .