Я хочу сделать простой лист вопросов и ответов для своих студентов. Я хотел бы иметь что-то вроде этого:
\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)
Я не вижу недостатка функциональности по сравнению с вашим примером.