我想為我的學生做一個簡單的問答表。我想要這樣的東西:
\section{Differential Equations}
\begin{questions}
\begin{question}
... Question here ...
\end{question}
\begin{answer}
... Answer here ...
\end{answer}
\end{questions}
我希望有環境問題來擁有像枚舉這樣的計數器。也就是說,每個人的行為都\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)
與您的範例相比,我沒有發現任何功能缺失。