# Number theorems with chapter number

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,
notefont=\bfseries,
notebraces={(}{)},
bodyfont=\itshape,
]{thmstyle}

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

\begin{document}

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

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

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

\end{document}


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

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?

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,
notefont=\bfseries,
notebraces={(}{)},
bodyfont=\itshape,
]{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}