xsim:问题/解决方案抛出“环境已定义”

xsim:问题/解决方案抛出“环境已定义”

xsim想将一个question环境与另一个solution环境结合起来。我收到一个错误:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! LaTeX 错误:“xparse/environment-already-defined” ! 环境“solution”已定义! ! 有关更多信息,请参阅 LaTeX3 文档。 ! 如需立即获得帮助,请输入 H 。

我以前会命名我的环境question/answer,但我想使用该名称solution而不是answer--- 其余一切都保持不变。可以吗?

这是有效的:

\documentclass{article}
\usepackage{xsim}
\DeclareExerciseType{question}{
  exercise-env = question,
  solution-env = answer, % would like to rename answer -> solution 
  exercise-name = Question,
  solution-name = Answer,
  exercise-template = default,
  solution-template = default
}
\xsimsetup{answer/print=true} % would like to rename answer -> solution 
\begin{document}
\begin{question}
My Question
\end{question}
\begin{answer}% would like to rename answer -> solution 
My Answer
\end{answer}% would like to rename answer -> solution 
\end{document}

answer重命名为后,这是不起作用的solution

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

编辑 简短回答:solution是包的保留关键字xsim。不能使用它。谢谢埃格尔

答案1

环境solution是预定义的。为什么不直接更改打印的名称呢?

\documentclass{article}
\usepackage{xsim}

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

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

在此处输入图片描述

相关内容