4

So I have made this file where I list my exercises as 1.A, 1.B,... for the exercises in Chapter 1, and 2.A,2.B,... for the exercises in Chapter 2.

\documentclass{book}

\usepackage{enumerate}

\begin{document}

\chapter{Chapter 1}

Text 

\section{Exercises}

\begin{enumerate}[\arabic{chapter}.A]
   \item Bla. \label{thislabel}
   \item bla. Hint: use Exercise \ref{thislabel}.
\end{enumerate}

\end{document}

Now the reference prints only the letter A, I would like it to print 1.A instead. When using hyperref, this does not matter unless the material is printed of course.

  • Welcome to TeX.SX. See this question: tex.stackexchange.com/q/464119/28557 , might be related. – nidhin Dec 13 '18 at 14:07
  • In general it's probably better to use \thechapter rather than \arabic{chapter}. – Werner Dec 13 '18 at 16:16
7

Use the enumitem package:

\documentclass{book}

\usepackage{enumitem}

\begin{document}

\chapter{Chapter 1}

Text

\section{Exercises}

\begin{enumerate}[label=\arabic{chapter}.\Alph*]
   \item Bla. \label{thislabel}
   \item bla. Hint: use Exercise \ref{thislabel}.
\end{enumerate}

\end{document}

enter image description here

  • Thank you for this solution. I've removed the enumerate package and used enumitem, as they are known not to work together. At first glance, I am not missing out on features of enumerate right now. – JSchoone Dec 13 '18 at 16:27
  • @JSchoone if you load enumitem with the shortlabels option, then it covers all of the syntax features from the enumerate package. – daleif Dec 13 '18 at 17:18
4

A no package solution

\documentclass{book}

\renewcommand{\theenumi}{\arabic{chapter}.\Alph{enumi}}
\renewcommand{\labelenumi}{\theenumi}

\usepackage{hyperref}
\begin{document}

\chapter{Chapter 1}

Text 

\section{Exercises}

\begin{enumerate}
   \item Bla. \label{thislabel}
   \item bla. Hint: use Exercise \ref{thislabel}.
\end{enumerate}

\end{document}

enter image description here

  • I've decided not to use your solution, but in the future I might, when my co-authors need enumerate instead of enumitem. But your solution seems to be global, am I wrong in that? I need enumerate environments elsewhere and don't want the numbering to be the same as the exercises. But thank you for your solution, which most surely will help others. (: – JSchoone Dec 13 '18 at 16:29
  • The approach is global but you can make it local of course for example by wrapping the two lines in a \zut macro (add a % at end of first line) and the use \begin{enumerate}\zut ... or better define some other environment wrapping enumerate and insert there the two lines. – user4686 Dec 13 '18 at 16:47
  • But enumitem is a useful package and I trust (although I never really looked) you can get with it most if not all of enumerate functionality. (hence I of course +1ed Ulrike's answer and find it the better one) – user4686 Dec 13 '18 at 16:50

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.