![按相同顺序对自定义定理/引理/例子进行编号](https://linux22.com/image/468327/%E6%8C%89%E7%9B%B8%E5%90%8C%E9%A1%BA%E5%BA%8F%E5%AF%B9%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AE%9A%E7%90%86%2F%E5%BC%95%E7%90%86%2F%E4%BE%8B%E5%AD%90%E8%BF%9B%E8%A1%8C%E7%BC%96%E5%8F%B7.png)
我创建了自定义定理/定义/示例格式,以便它们以图像中的颜色显示。但是,编号并不像我希望的那样(见第一张图片)。
与图像中所示不同,我希望有定理 1.5...定义 1.6...示例 1.7...
声明的当前状态如下。我也尝试过在定义和示例中写入“numberwithin=section”,但同样不起作用。如果有人能帮助我,我将不胜感激。谢谢!
% Theorem
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt, headfont=\color{red}\normalfont\bfseries, notefont=\color{black}\mdseries\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
%postheadspace=1em,
headpunct={ }]{mystyle}
\declaretheorem[name={Theorem}, style=mystyle,
numberwithin=section
]{thm}
% Definition
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt, headfont=\color{blue}\normalfont\bfseries, notefont=\color{black}\mdseries\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
%postheadspace=1em,
headpunct={ }]{mystyledef}
\declaretheorem[name={Definition}, style=mystyledef,
numberwithin=thm
]{defn}
% Example
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt, headfont=\color{olive}\normalfont\bfseries, notefont=\color{black}\mdseries\normalfont,
notebraces={(}{)},
bodyfont=\normalfont,
%postheadspace=1em,
headpunct={ }]{mystyleexa}
\declaretheorem[name={Example}, style=mystyleexa,
numberwithin = thm
]{exa}