[Tex/LaTex] How to enumerate a problem set in a book accordingly with the chapter number

bookschaptersnumbering

I am writing a book and in the end of each chapter I have a section with labeled problems that looks like this:

\chapter{Chapter 1}

Bla bla bla...

\section*{Problems:}
\begin{enumerate}
\item \label{ch1_pr1} Prove...
\item \label{ch1_pr2} Calculate...
\item \label{ch1_pr3} Fill the details in...
\end{enumerate}

The issue with this approach is that every problems' section is numbered exactly the same way in every chapter (1, 2, 3, 4, etc…) so if, say, in chapter four I want to cite the first problem in the first chapter I will get in my book just '1' (the number one), which will make it confusing, since it is not making any reference to the chapter the problem I am citing belongs to.

So my question is: How can I enumerate my problems so they take into account the chapter they belong to?

I was thinking something like 1.1, 1.2, 1.3, … for the problems in chapter one, 2.1, 2.2, 2.3, … for the problems in chapter two, etc. But I don't know how to do that.

Since I am not very skilled with Latex, I would ask for the solution to my problem to be as simple as possible.


Update: Here is some sample code so you can compile it and better understand what I need:

\documentclass[12pt,letterpaper]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\begin{document}

\chapter{First}

Bla bla bla...

\section*{Problems:}

\begin{enumerate}
\item \label{ch1_pr1} Prove...
\item \label{ch1_pr2} Calculate...
\item \label{ch1_pr3} Fill the details in...
\end{enumerate}

\chapter{Second}

Bla bla bla....

\section*{Problems:}

\begin{enumerate}
\item \label{ch2_pr1} Prove...
\item \label{ch2_pr2} Calculate...
\item \label{ch2_pr3} Fill the details in...
\end{enumerate}

\chapter{Third}

First problem in Chapter 1:~\ref{ch1_pr1}

First problem in Chapter 2:~\ref{ch2_pr1} \\

The issue: Different problems appear to be the same when cited!

\end{document}

Best Answer

Here's a similar solution using the enumitem package which makes it much easier to define new and customised lists. I also used problems for the environment name. Here, the label within the original problem set is just 1 or whatever, but the reference appears as 1.1 etc.

It is best not to use explicit numbers in your \label{}s in case you insert or remove items later. While LaTeX won't care two hoots, it tends to confuse human beings greatly if chap3_prf5 refers to the problem numbered 9 in chapter 2.

\documentclass{book}
\usepackage{enumitem}
\newlist{problems}{enumerate}{1}
\setlist[problems]{label={\arabic*.}, ref={\thechapter.\arabic*}}
\begin{document}
\chapter{Chapter 1}

Bla bla bla \dots

\section*{Problems:}
\begin{problems}
  \item \label{pr:intro_prove} Prove \dots
  \item \label{pr:intro_calc} Calculate \dots
  \item \label{pr:intro_details} Fill the details in \dots
\end{problems}

\chapter{Pethau Pellach}
Fel dywedwyd ym mhroblem \ref{pr:intro_calc} \dots
\end{document}

fel dywedwyd...

If you would prefer the chapter number to appear in the original label as well, change

\setlist[problems]{label={\arabic*.}, ref={\thechapter.\arabic*}}

to

\setlist[problems]{label={\thechapter.\arabic*}}

original labels, too

Related Question