1

I am using the book document class to prepare an eBook for college algebra students. I have familiarized myself with the Exsol package to write exercises at the end of each section and then print the solutions at the end of the eBook. This is working great, except that I would like the counter on the exerciseseries environment to match the existing eBook section number. By default, the Exsol package labels the first exerciseseries environment of the section as 1, the second exerciseseries environment of the section as 2...and then resets the counter at when a new section is started. For example, I would like the exerciseseries environment that is in Section 1.1 to be labeled as 1.1 (not 1, as the default). Is this possible?

Thank you.

Here's a MWE.


\documentclass{book}
\usepackage[margin=.5in]{geometry}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage[local,nolabels,exerciseaslist,usesolutionserieslabels]{exsol}
\usepackage{blindtext}

\renewcommand{\seriesname}{Section Exercises} %%%%%% names the environmenet - originally called series 1, series 2, etc....

\begin{document}


\chapter{The first Chapter}

\section{Section 1}


\blindtext

\begin{exerciseseries}[columns=2,subrule=\hrule]{}
\begin{exercise}
Calculate $y = 5 + 7$
\end{exercise}
\begin{solution}
$y = 12$
\end{solution}
\begin{exercise}
Calculate $y = 7 - 12$
\end{exercise}
\begin{solution}
$y = -5$
\end{solution}
\end{exerciseseries}




\section{Section 2}

\blindtext

\begin{exerciseseries}[columns=2,subrule=\hrule]{}
\begin{exercise}
Calculate $y = 5 + 7$
\end{exercise}
\begin{solution}
$y = 12$
\end{solution}
\begin{exercise}
Calculate $y = 7 - 12$
\end{exercise}
\begin{solution}
$y = -5$
\end{solution}
\end{exerciseseries}

\end{document}


  • Welcome! Just add \renewcommand{\theexerciseseries}{\arabic{section}.\arabic{exerciseseries}} to the preamble of the document just before \begin{document}. – Schrödinger's cat Oct 3 at 4:34
  • Excellent! Thank you so much for the speedy reply. This worked perfectly. – twothirtyeight Oct 3 at 12:57
0

The counter you mean is already “synchronized” with the section counter in the sense that it is reset with every section. You want to change how it is printed.

For this every counter foo has an associated command \thefoo which holds the represenation of the counter, that which is printed. For section this is \thesection, for example. In your case there are two counters: exerciseseries and exercise. So you want

\renewcommand*\theexerciseseries{\thesection.\arabic{exerciseseries}}

This however also includes the chapter number, 1.1.1, 1.1.2, … So maybe you rather want

\renewcommand*\theexerciseseries{\arabic{section}.\arabic{exerciseseries}}

And then you maybe also want to adjust the exercises:

\renewcommand*\theexercise{\theexerciseseries.\arabic{exercise}}

enter image description here

The complete example:

\documentclass{book}
\usepackage[margin=.5in]{geometry}
\usepackage{amsmath}
\usepackage[english]{babel}
\usepackage[local,nolabels,exerciseaslist,usesolutionserieslabels]{exsol}
\usepackage{blindtext}

% names the environment - originally called series 1, series 2, etc...
\renewcommand{\seriesname}{Section Exercises}

\renewcommand*\theexerciseseries{\arabic{section}.\arabic{exerciseseries}}
\renewcommand*\theexercise{\theexerciseseries.\arabic{exercise}}

\begin{document}

\chapter{The first Chapter}

\section{Section 1}


\blindtext

\begin{exerciseseries}[columns=2,subrule=\hrule]{}
\begin{exercise}
Calculate $y = 5 + 7$
\end{exercise}
\begin{solution}
$y = 12$
\end{solution}
\begin{exercise}
Calculate $y = 7 - 12$
\end{exercise}
\begin{solution}
$y = -5$
\end{solution}
\end{exerciseseries}

\section{Section 2}

\blindtext

\begin{exerciseseries}[columns=2,subrule=\hrule]{}
\begin{exercise}
Calculate $y = 5 + 7$
\end{exercise}
\begin{solution}
$y = 12$
\end{solution}
\begin{exercise}
Calculate $y = 7 - 12$
\end{exercise}
\begin{solution}
$y = -5$
\end{solution}
\end{exerciseseries}

\end{document}
  • Thank you very much, Clemens. Your solution is exactly what I needed. You even anticipated the additional question of exercise numbering. Cheers. – twothirtyeight Oct 3 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.