正确使用健身包

正确使用健身包

请根据需要更正我的代码。由于以下原因,它无法编译

! Package exercise Error: You don't respect the hierarchy of questions.

See the exercise package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.13 \begin{Question}W
                      hat is the symbol for copper?\end{Question}
? 

代码如下:

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{mhchem}


\usepackage[lastexercise]{exercise}

\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}

\begin{Exercise}[title=DIY]\end{Exercise}
\begin{ExePart}Question 1\end{ExePart}
\begin{Question}What is the symbol for copper?\end{Question}
\begin{Answer}\ce{Cu}\end{Answer}

\end{document}

可能是我遗漏了一些东西,但文档甚至没有提供该包的使用示例。

答案1

我设法使用 ExerciseList 环境使其工作:

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{mhchem}


\usepackage[lastexercise]{exercise}

\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}

\begin{ExerciseList}
  \Exercise[title=DIY]
  \ExePart{Question 1}
  \Question{What is the symbol for copper?}
  \Answer{\ce{Cu}}
\end{ExerciseList}

\end{document}

使用 \ExePart 或重新定义 \QuestionNB

也就是说,您不需要\ExePart只打印“问题 1”。最好重新定义\QuestionNB,如下所示:

\renewcommand{\QuestionNB}{Question~\arabic{Question}.\ }

理论上,这应该可以实现您想要实现的目标,尽管在实践中,它有点混乱。我觉得原因是标签在包中是硬编码的,没有变量。但是,可以通过重置来“修复”这个问题\QuestionIndent

\setlength{\QuestionIndent}{7em}

因此你的例子就变成:

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{mhchem}


\usepackage[lastexercise]{exercise}

\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}

\renewcommand{\QuestionNB}{Question~\arabic{Question}.\ }
\setlength{\QuestionIndent}{7em}

\begin{ExerciseList}
  \Exercise[title=DIY]
  \Question{What is the symbol for copper?}
  \Answer{\ce{Cu}}
\end{ExerciseList}

\end{document}

这对我有用(虽然我个人觉得把问题放在下一行更好——注意:我没有使用该mhchem包):

练习示例

在玩了更多问题/答案之后,我确实认为它在某处缺少换行符:

更多问题

我也不太确定间距:答案最终更接近下一个问题而不是与它们相关的问题......

练习标题

事实上,换行符的问题似乎来自于你使用\Exercise[title=DIY]而不是简单的\Exercise{DIY}来定义练习名称。当我更改此设置时:

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{mhchem}


\usepackage[lastexercise]{exercise}

\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}

\renewcommand{\QuestionNB}{Question~\arabic{Question}.\ }
\setlength{\QuestionIndent}{7em}

\begin{ExerciseList}
  \Exercise{DIY}
  \Question{What is the symbol for copper?}
  \Answer{\ce{Cu}}
  \Question{What is the symbol for aluminum?}
  \Answer{\ce{Al}}
  \Question{What is the symbol for iron?}
  \Answer{\ce{Fe}}
\end{ExerciseList}

\end{document}

我得到了一个换行符:

正确的换行符

并且不再需要重新定义\QuestionIndent

无需重新定义 QuestionIndent

答案2

\Question是命令,而不是环境。这就是您收到错误的原因。

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}


\usepackage[lastexercise]{exercise}

\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}



\begin{Exercise}[title=DIY,label=E1]
\ExePart[name=simple]
\Question{What is the symbol for copper?}\label{Q1}
\Question{What is the symbol for oxygen?}\label{Q2}

\ExePart[name=difficult]
\Question{What 42?}
\end{Exercise}

\begin{Answer}[ref=E1]\ref{Q1}. Cu  \quad\ref{Q2}. O \end{Answer}
\end{document}

答案3

答案必须不在列表中。这样,计数器才能正常工作。

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}


\usepackage[lastexercise, answerdelayed]{exercise}


\begin{document}
\section{Naming of Chemical Compounds - A ``DIY'' Tutorial}


\begin{ExerciseList}
  \Exercise[title=DIY, label=E1]
  \ExePart{Question 1}
  \Question{What is the symbol for copper?}
  \Question{What is the symbol for iron?}
  \ExePart{Question 1}
  \Question{What is the symbol for copper?}
  \Question{What is the symbol for iron?}

  \Exercise[title=DIY, label=E2]
  \ExePart{Question 1}
  \Question{What is the symbol for oxigen?}
  \Question{What is the symbol for hidrogen?}
  \ExePart{Question 1}
  \Question{What is the symbol for oxigen?}
  \Question{What is the symbol for hidrogen?}



\end{ExerciseList}



  \begin{Answer}[ref=E1]
  \ExePart{Question 1}
  \Question{Cu}
  \Question{Fe}     
  \ExePart{Question 1}
  \Question{Cu}
  \Question{Fe}     
  \end{Answer}

  \begin{Answer}[ref=E2]
  \ExePart{Question 1}
  \Question{O}
  \Question{H}      
  \ExePart{Question 1}
  \Question{O}
  \Question{H}      
  \end{Answer}


\paragraph*{ Solutions:}   Now, let's see te solutions
\shipoutAnswer 
\end{document}

相关内容