我希望在章节内对定理、引理、推论、示例、注释等进行渐进编号。而对于方程式,我希望在章节内进行编号。此外,我希望在开始新章节时将计数器设置为 0。我想说,主要问题是我使用 tcolorbox 包来处理定理、推论、引理等,使用 amsthm 包来处理示例和注释。下面您可以找到我需要的 MWE。
\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}
因此,参考上述内容,我希望它显示为“定理 0.1.1”、“推论 0.1.2”、“注释 0.1.3”、“方程 0.1”、“注释 0.1.4”、“方程 0.2”、“示例 0.1.5”、“引理 0.1.6”、“定义 0.1.7”。例如,在更改章节时,我希望编号从第一章第一节的“1.1.1”开始(对于定理等),而从 1.1 开始(对于方程)。我希望我已经很好地解释了我需要什么!
答案1
您tcolorbox
可以使用该选项(不幸的是,如果用于所有指令,use counter
我无法使该选项起作用,因此我在所有指令上一起使用)。use counter*
\newtcbtheorem
use counter
number within
因为amsmath
您可以使用 来指定它应该使用的计数器\newtheorem{<env>}[<counter>]{<title>}
。
要改变equation
计数器,您可以使用\counterwithin{equation}{chapter}
。
放在一起:
\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}