我正在排版一些练习,结构如下,
Exercise 1
Some introductory text.
1.1 The first question?
1.2 The second question?
使用练习包我可以通过以下方式实现这一点,
\begin{Exercise}
Some introductory text.
\Question The first question?
\Question The second question?
\end{Exercise}
现在我想为每个问题输入答案。我发现唯一的方法是自己在答案中设置编号,
\begin{Answer}[number=1.1]
The answer to Question 1.1.
\end{Answer}
\begin{Answer}[number=1.2]
The answer to Question 1.2.
\end{Answer}
当练习/问题的顺序改变时,它最终会失败。
正确的做法是什么?
我如何才能将单独的答案链接到每个问题?
答案1
当您感兴趣的问题时,可以使用ref=<ref>
或键:number=\ref{<ref>}
\label
\documentclass{article}
\usepackage{exercise}% http://ctan.org/pkg/exercise
\begin{document}
\begin{Exercise}
Some introductory text.
\Question \label{first}The first question?
\Question \label{second}The second question?
\end{Exercise}
\begin{Answer}[ref=first]
The answer to Question~\ref{first}.
\end{Answer}
\begin{Answer}[number=\ref{second}]
The answer to Question~\ref{second}.
\end{Answer}
\end{document}
答案2
作为替代方案,一个非常优雅的解决方案是由优秀的»外页“ 包裹。
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[load-tasks=true]{exsheets}
\settasks{
counter-format=qu.tsk,
item-indent=3em,
label-width=2em
}
\begin{document}
\section{Foo}
\begin{question}\label{qu:twopart}
Some introductory text.
\begin{tasks}
\task The first question?\label{qu-1:twopart}
\task The second question?\label{qu-2:twopart}
\end{tasks}
\end{question}
\begin{solution}
\begin{tasks}
\task Solution to question \ref{qu-1:twopart}.
\task Solution to question \ref{qu-2:twopart}.
\end{tasks}
\end{solution}
\printsolutions
\end{document}