带章节编号的数字定理

带章节编号的数字定理

我用来declaretheoremstyle定义一个定理环境,并在我的文档末尾打印一个定理列表:

\documentclass[12pt]{book}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{etoolbox}

\declaretheoremstyle[
  spaceabove=6pt, spacebelow=6pt,
  headfont=\normalfont\bfseries,
  postheadspace=1em,
  notefont=\bfseries,
  notebraces={(}{)},
  bodyfont=\itshape,
  shaded={bgcolor=yellow!20}
]{thmstyle}

\declaretheorem[style=thmstyle,name=Theorem]{theorem}

\begin{document}

\begin{theorem}[Somebody]
...
\end{theorem}

\begin{theorem}
...
\end{theorem}

\renewcommand{\listtheoremname}{List of Theorems}
\addcontentsline{toc}{section}{\listtheoremname}
\listoftheorems[ignoreall,show=theorem]

\end{document}

定理从书的开头到结尾按以下顺序编号1

在此处输入图片描述

但是,我想用章节编号(如图或表格)来编号定理,例如,1.1(第 1 章中的第一个定理),1.2(第 2 章中的第一个定理)...

有人知道怎么做吗?

答案1

只需添加

numberwithin=chapter

定义:

\documentclass[12pt]{book}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{etoolbox}

\declaretheoremstyle[
  spaceabove=6pt, spacebelow=6pt,
  headfont=\normalfont\bfseries,
  postheadspace=1em,
  notefont=\bfseries,
  notebraces={(}{)},
  bodyfont=\itshape,
  shaded={bgcolor=yellow!20}
]{thmstyle}

\declaretheorem[style=thmstyle,name=Theorem,numberwithin=chapter]{theorem}
\renewcommand{\listtheoremname}{List of Theorems}

\begin{document}

\chapter{Test chapter one}
\begin{theorem}[Somebody]
test
\end{theorem}

\chapter{Test chapter two}
\begin{theorem}
test
\end{theorem}

    \addcontentsline{toc}{section}{\listtheoremname}
    \listoftheorems[ignoreall,show=theorem]

\end{document}

所得定理列表的图像:

在此处输入图片描述

相关内容