# xsim: question/solution throws 'environment already defined'

In xsim I would like to combine a question environment with a solution environment. I am getting an error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! LaTeX error: "xparse/environment-already-defined" ! ! Environment 'solution' already defined! ! ! See the LaTeX3 documentation for further information. ! ! For immediate help type H .

I used to name my environments question/answer, but I'd like to use the name solution instead of answer --- everything else unchanged. Is it possible?

This is what works:

\documentclass{article}
\usepackage{xsim}
\DeclareExerciseType{question}{
exercise-env = question,
exercise-name = Question,
exercise-template = default,
solution-template = default
}
\begin{document}
\begin{question}
My Question
\end{question}
\end{document}


This is what doesn't work, after renaming answer to solution:

\documentclass{article}
\usepackage{xsim}
\DeclareExerciseType{question}{
exercise-env = question,
solution-env = solution, % IF NAMED 'solution' throws an error!
exercise-name = Question,
exercise-template = default,
solution-template = default
}
\xsimsetup{solution/print=true}
\begin{document}
\begin{question}
My Question
\end{question}
\begin{solution}
\end{solution}
\end{document}


EDIT short answer: solution is a reserved keyword of the xsim package. Can't use it. Thanks egreg.

The solution environment is predefined. Why don't you simply change the printed names?

\documentclass{article}
\usepackage{xsim}

\xsimsetup{
exercise/name=Question,
solution/print=true,
}

\begin{document}
\begin{exercise}
My Question
\end{exercise}
\begin{solution}

• egreg, my question really was about using the question and solution environments together, as in begin{question}, etc. and begin{solution}, etc.. Not about the name of the environment as it gets printed. Sorry about the confusion. My workaround was to use a name other than solution (my first choice word). Examples of alternatives hint, key, solutionX, mcSolution and solutions (with an s). You may want to add this to your answer or if you can hack xsim to allow setting solution-env=solution that would be best. Thanks again. – PatrickT Apr 24 '18 at 9:10
• @PatrickT I tried undefining solution, but it doesn't work. Why is answer not good? – egreg Apr 24 '18 at 9:26
• Thanks for your help egreg. I'm already using answer for an environment that could not easily map to the xsim syntax. I was basically looking for a synonym to answer and I thought solution was the simplest, but hadn't realize that it's a reserved keyword of the xsim package (does the manual mention that?). I'm now using mc/hint with xsim and keeping my old answer for my other environment. I have hundreds of questions/answers, so it would be time consuming to rewrite it all to fit xsim. It was basically a stupid question with a simple workaround. Thanks! – PatrickT Apr 24 '18 at 12:51