질문과 답변을 위한 환경을 정의하는 방법

질문과 답변을 위한 환경을 정의하는 방법

학생들을 위한 간단한 질문과 답안지를 작성하고 싶습니다. 나는 다음과 같은 것을 갖고 싶습니다 :

\section{Differential Equations}

    \begin{questions}

         \begin{question}
              ... Question here ...
         \end{question}

         \begin{answer}
              ... Answer here ...
         \end{answer}

    \end{questions}

열거와 같은 카운터를 갖는 환경 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)

답변이 있는 질문

귀하의 예에 비해 기능이 부족하지 않습니다.

관련 정보