2

I use declaretheoremstyle to define a theorem environment, and print a list of theorems in the end of my document:

\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}

The theorems are numbered from the beginning to the end of the book, and from 1:

enter image description here

However, I would like to number the theorems with chapter number (like Figures or Tables), for instance, 1.1 (the first theorem in Chapter 1), 1.2 (the first theorem in Chapter 2)...

Does anyone know how to do it?

1 Answer 1

4

Simply add

numberwithin=chapter

to the definition:

\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}

An image of the resulting List of Theorems:

enter image description here

You must log in to answer this question.

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