I would suggest you use the enumitem
package, which enables you to easily change the default style of your enumerate
environments.
Combining this approach with the $\LaTeX$ hook system (texdoc hooks
), we can modify the default labelling style within each exercise
environment:
\documentclass{article}
\usepackage{enumitem}
\newtheorem{exercise}{Exercise}[section]
\AddToHook{ env/exercise/begin } { \setlist [enumerate] { label=\alph*. } }
\begin{document}
Start a list:
\begin{enumerate}
\item foo
\end{enumerate}
List inside environment:
\begin{exercise}
\begin{enumerate}
\item Question 1
\item Question 2
\end{enumerate}
\end{exercise}
List after environment:
\begin{enumerate}
\item foo
\end{enumerate}
\end{document}
Note also that the change of the label is contained inside the exercise
environment, since \begin{...}
also starts grouping, and we used the begin
hook, which inserts our code after entering the exercise
environment, but before processing its contents.
Thus, we do not need to restore the behavior manually after the end of the exercise
, as you observe in the example document.
\documentclass{article}
etc into your code example, such that it will be compiled by LaTeX. This simplifies the answering