Theses, Books, Title pagesHow to create a list of exercises and their solutions at the end of each section of a book class?

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Post Reply
CMP
Posts: 13
Joined: Thu Aug 22, 2019 8:33 pm

How to create a list of exercises and their solutions at the end of each section of a book class?

Post by CMP »

In the LaTeX book class, I am trying to create a list of exercises at the end of each section and then their solutions later at the end of the entire chapter. For example, what I want is the following:

1.1 This is the first section of this chapter.

Exercises
1.1 First problem.
1.2
1.3
1.4

1.2 This is the second section of this chapter

Exercises
1.5
1.6
1.7

Solutions to selected exercises
1.3
1.7

I also want the hyper-reference of the problems and their solutions, too.

And, I do not want to supply the command every time, like:

\begin{exercise}
How old are you?
\end{exercise}

The following is the MWE.

Code: Select all

\documentclass[12pt, openany]{book}
\usepackage[T1]{fontenc}
\usepackage{color}  

\setlength{\parindent}{0in}
\setlength{\parskip}{10pt}

\begin{document}

\chapter{First}

\section{First}

This is the first section of this chapter.

{\bf\em Exercises} \\
1.1 Solve the problem. \\
1.2 What is the sum of 3 and 8? \\
{\textcolor{red}{1.4}} What is your name? 

\section{Second}

This is the second section of this chapter.

{\bf\em Exercises} \\
1.5 Solve the problem. \\
1.6 What is the sum of 3 and 8? \\
{\textcolor{red}{1.7}} What is your name? 

\section{Third}

\section{Four}

{\bf\em Solutions to selected Exercises} \\
1.3 I solved it! \\
1.6 I don't know. 

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Post Reply