3

Forgive me if this has already been asked, but I couldn't find this question, exactly. I'm using the xsim package (documentclass book) and I'd like my "top"-level enumeration to be labeled with letters in my exercises, but with Arabic numerals outside of those. So, for instance, if I type

\begin{enumerate}
  \item Hello
\end{enumerate}

outside of the exercises, I want it to read

  1. Hello

but if I type it within an exercise environment I want it to read

a. Hello

Obviously I could hack this by changing my enumeration labeling style each time I enumerate within an exercise, but there has to be a better way. Right? Keep in mind I'm using the default exercise environment supplied by xsim.

1
  • please post MWE of the same
    – MadyYuvi
    Jun 16, 2017 at 5:39

1 Answer 1

5

You can either add the re-definition with the pre-hook or begin-hook options to the exercise environments

\documentclass{article}
\usepackage{xsim}

\xsimsetup{
  exercise/begin-hook = \renewcommand\theenumi{\alph{enumi}} ,
  solution/begin-hook = \renewcommand\theenumi{\alph{enumi}}
}

\begin{document}

\begin{exercise}
  \begin{enumerate}
    \item bla bla
  \end{enumerate}
\end{exercise}

Outside:
\begin{enumerate}
  \item bla bla
\end{enumerate}

\end{document}

or just add the redefinition inside the code of a custom environment template:

\documentclass{article}
\usepackage{xsim}

\DeclareExerciseEnvironmentTemplate{custom}
  {%
    \UseExerciseTemplate{begin}{default}%
    \renewcommand\theenumi{\alph{enumi}}%
  }
  {\UseExerciseTemplate{end}{default}}

\xsimsetup{
  exercise/template=custom ,
  solution/template=custom
}

\begin{document}

\begin{exercise}
  \begin{enumerate}
    \item bla bla
  \end{enumerate}
\end{exercise}

Outside:
\begin{enumerate}
  \item bla bla
\end{enumerate}

\end{document}

enter image description here

1
  • That was exactly what I was looking for, thank you!
    – J. S.
    Jun 17, 2017 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .