我希望为我的学生做一份简单的问答表。我希望有类似这样的内容:
\section{Differential Equations}
\begin{questions}
\begin{question}
... Question here ...
\end{question}
\begin{answer}
... Answer here ...
\end{answer}
\end{questions}
我希望 QUESTIONS 环境有像 enumerate 这样的计数器。也就是说,每个环境的行为\begin{question} ... \end{question}
都应该像\item
\begin{question}
\item
\end{question}
环境\begin{question} ... \end{question}
应该采用“正常”的 LaTeX 命令。
如果可能的话,我希望延迟打印以在文档末尾打印答案。
我第一次尝试这个
\makeatletter
\newtoks\answerscollect
\newcounter{question}
\setcounter{question}{0}
\def\thequestion{{\bfseries{Question \arabic{question}. }}\\}
\def\answer#1{%
\protected@edef\answertmp{%
\the\answerscollect\vspace{.5\baselineskip}\noindent\thequestion#1\par}%
\par\answerscollect=\expandafter{\answertmp}}
\def\printanswers{\the\answerscollect\answerscollect={}}
\def\initbox{\answerscollect={\par\noindent Answers:\par}}
\newcommand{\question}[1]{\stepcounter{question}\par\noindent\thequestion#1}
\makeatother
但它的表现并不像我希望的那样......
答案1
包的简单使用 exam
:
\documentclass{exam}
%\printanswers
\begin{document}
\section{Differential Equations}
\begin{questions}
\question ... Short question here ... \answerline[Short answer]
\question ... Question here ...
\begin{solution}[.2in]
... Answer here ...
\end{solution}
\question Long descriptive question about everything
\begin{solutionorlines}[2in]
Long descriptive answer is a long descriptive answer that is a long descriptive answer that is along descriptive answer that is along descriptive answer that is along descriptive answer that is a lie.
\end{solutionorlines}
\question Draw an arrow showing north direction.
\begin{solutionorbox}[2in]
$\uparrow$
\end{solutionorbox}
\end{questions}
\ifprintanswers
Stuff to appear only when answers \textbf{are} being printed.
\else
Stuff to appear only when answers \textbf{are not} being printed.
\fi
\end{document}
注释或取消注释\printanswers
将产生以下两种结果之一:
1)
2)
与您的示例相比,我没有发现任何功能缺陷。