# Incompatibility between enumitem and answers packages?

I am facing a strange problem while using the enumitem and answers packages. The following code compiles with no errors.

\documentclass{article}
\usepackage{enumitem}
\Newassociation{sol}{Solution}{ans}

\newlist{question}{enumerate}{1}
\setlist[question,1]{label=\arabic*}

\begin{document}

\Opensolutionfile{ans}
\section{Problems}

\begin{question}
\item Question 1 \begin{sol}Solution 1\end{sol}
\end{question}

\Closesolutionfile{ans}

\section{Solutions}
\input{ans}

\end{document}


However, whenever I try to style the label in the list, answers throws a TeX capacity exceeded, sorry error.

\documentclass{article}
\usepackage{enumitem}
\Newassociation{sol}{Solution}{ans}

\newlist{question}{enumerate}{1}
\setlist[question,1]{label=\textbf{\arabic*}}

\begin{document}

\Opensolutionfile{ans}
\section{Problems}

\begin{question}
\item Question 1 \begin{sol}Solution 1\end{sol}
\end{question}

\Closesolutionfile{ans}

\section{Solutions}
\input{ans}

\end{document}


Surely there must be a way to use these packages together?

• Please edit your MWE so they can be compiled without having to add anything. Thee is no document class in these examples. Jul 1, 2015 at 13:20
• I can confirm this
– user31729
Jul 1, 2015 at 14:52
• Apologies, I have fixed this. Jul 2, 2015 at 7:57

The answers package does an automatic definition of the solution environment numbering/heading, defining \Solutionlabel, basically to be \emph{Solution #1}, #1 being fed with \textbf --- which is wrong for another reason (due to the label=\arabic* way of enumitem, this can't work this way. Use label={\bfseries \arabic*} rather.

The trick is to redefine the \Solutionlabel to use the same labeling style, but this actually tedious, since it requires to define the list labelling and the solution label.

I recommend an question environment being theoremlike instead of an enumeration list.

\documentclass{article}

\usepackage{enumitem}

\Newassociation{sol}{Solution}{ans}

\newlist{question}{enumerate}{1}
\setlist[question,1]{label={\bfseries \arabic*}} % defines questioni counter

\renewcommand{\Solutionlabel}[1]{\bfseries Solution \arabic{questioni}}

\begin{document}

\Opensolutionfile{ans}
\section{Problems}

\begin{question}
\item Question 1 \begin{sol}Solution 1 -- finally\end{sol}
\end{question}

\Closesolutionfile{ans}

\section{Solutions}
\input{ans}

\end{document}