답변1
Erik이 말한 것 외에도 저는 많은 수업에서 모든 질문의 텍스트와 각 질문 뒤에 공백이 있는 내용을 원한다는 것을 알게 되었습니다. 저는 문제를 한 번만 입력하고 컴파일러를 두 번 통과시키면 자동으로 이를 수행하도록 시험 클래스를 확장했습니다.
%\NeedsTeXFormat{Latex2e}[1996/06/01]
\ProvidesClass{examExt}[2016/11/09 v1.0]
\LoadClassWithOptions{exam}
\RequirePackage{etex}
\global\newwrite\examfile%
\newcommand\insertQuestions[1][plain]{
\begingroup
\IfFileExists{./\jobname.exm}{\thispagestyle{#1}\input{\jobname.exm}}{\typeout{Class exam Warning: Questions file created. Rerun to get expected output.}}
\endgroup
\immediate\openout\examfile=\jobname.exm
}
\AtEndDocument{
\immediate\closeout\examfile
}
\newcommand\create@environment[1]{
\newenvironment{my#1}{%
\begin{#1}
\immediate\write\examfile{\string\begin{#1}}
}{%
\immediate\write\examfile{\string\end{#1}}
\end{#1}
}
}
\newcommand\create@item[1]{
\expandafter\newcommand\csname my#1\endcsname[2]{%
\if\relax\detokenize{##1}\relax
\csname #1\endcsname ##2
\immediate\write\examfile{\string\csname \space #1\string\endcsname\relax \unexpanded{##2}}%
\else
\csname #1\endcsname[##1] ##2
\immediate\write\examfile{\string\csname \space #1\string\endcsname[##1] \unexpanded{##2}}%
\fi
}
}
\newcommand\create@titleditem[1]{
\expandafter\newcommand\csname my#1\endcsname[3]{%
\if\relax\detokenize{##2}\relax
\csname #1\endcsname{##1} ##3
\immediate\write\examfile{\string\csname \space #1\string\endcsname\unexpanded{\begingroup ##1\endgroup}\relax \unexpanded{##3}}%
\else
\csname #1\endcsname{##1}[##2] ##3
\immediate\write\examfile{\string\csname \space #1\string\endcsname\unexpanded{##1}[##2] \unexpanded{##3}}%
\fi
}
}
\create@environment{questions}
\create@environment{parts}
\create@environment{subparts}
\create@environment{subsubparts}
\create@item{question}
\create@item{part}
\create@item{subpart}
\create@item{subsubpart}
\create@titleditem{titledquestion}
\newcommand\insertClearPage{\immediate\write\examfile{\string\clearpage}}
다음은 사용 방법을 보여주는 MWE입니다. 다른 파일이 생성되고 두 번째 단계에서는 상단에 질문을 복사합니다.
\documentclass{examExt}
\usepackage{amsmath, amssymb}
\begin{document}
\insertQuestions
\clearpage
\begin{myquestions}
\myquestion{2}{This is a question $3\in\mathbb{R}$}
\begin{solutionbox}{3in}
This is a solution
\end{solutionbox}
\begin{myparts}
\mypart{2}{This is a part}
\begin{solutionbox}{3in}
This is a solution
\end{solutionbox}
\end{myparts}
\end{myquestions}
\end{document}
답변2
\Calculate{}
여기서는 문제 제시와 \Solution{}
답 제시를 위해 소개합니다 . "문제"를 첫 번째 줄로 자동으로 다시 지정 하고 \Solution
선택적 인수는 []
일반적으로 뒤따르는 줄 바꿈을 억제합니다(항목 1에 표시됨).
\documentclass[10pt]{amsart}
\usepackage{tabstackengine,enumitem}
\newcommand\Calculate[1]{Calculate $#1$\def\Question{#1}}
\newcommand\Solution[2][\\]{Solution: \Longunderstack[l]{\Question#1#2}}
\stackMath
% TO PROVIDE BLANK SOLUTION
%\renewcommand\Solution[2][\\]{Solution: \setbox0=\hbox{%
% \Longunderstack[l]{\Question#1#2}}\rule[-\dp0]{0pt}{\dimexpr\ht0+\dp0}}
% TO PROVIDE NO SOLUTION
%\renewcommand\Solution[2][\\]{}
\begin{document}
\sffamily
\begin{enumerate}[listparindent=0in,itemsep=5pt]
\item \Calculate{1 + 2}
\Solution[]{=3}
\item \Calculate{1 + 2 + 3}
\Solution{=3+3\\=6}
\item \Calculate{1+2+3+4}
\Solution{=3+3+4\\=6+4\\=10}
\item \Calculate{1+2+3+4+5}
\Solution{=3+3+4+5\\=6+4+5\\=10+5\\=15}
\item
\end{enumerate}
\end{document}
솔루션을 비워두려면 다음 \Solution
과 같이 재정의할 줄의 주석 처리를 해제하세요.
\renewcommand\Solution[2][\\]{Solution: \setbox0=\hbox{%
\Longunderstack[l]{\Question#1#2}}\rule[-\dp0]{0pt}{\dimexpr\ht0+\dp0}}
얻으려면아니요해결책을 찾으려면 다른 줄의 주석 처리를 제거하여 다음 \Solution
과 같이 재정의하세요.
\renewcommand\Solution[2][\\]{}
번갈아 하는
솔루션의 각 줄 시작 부분 에 를 입력할 필요가 없는 경우 =
문제를 다시 설명한 후 줄 바꿈을 억제하는 선택적 인수 기능을 포기해야만 달성할 수 있습니다(항목 1 비교).
\documentclass[10pt]{amsart}
\usepackage{tabstackengine,enumitem}
\def\stackalignment{l}
\newcommand\Calculate[1]{Calculate $#1$\def\Question{#1}}
\newcommand\Solution[1]{Solution: \stackunder{\Question}
{\tabbedLongunderstack[l]{#1}}}
\stackMath
\TABstackMath
\TABstackMathstyle{=}
% TO PROVIDE BLANK SOLUTION
%\renewcommand\Solution[1]{Solution: \setbox0=\hbox{\stackunder{\Question}%
% {\tabbedLongunderstack[l]{#1}}}\rule[-\dp0]{0pt}{\dimexpr\ht0+\dp0}}
% TO PROVIDE NO SOLUTION
%\renewcommand\Solution[1]{}
\begin{document}
\sffamily
\begin{enumerate}[listparindent=0in,itemsep=5pt]
\item \Calculate{1 + 2}
\Solution{3}
\item \Calculate{1 + 2 + 3}
\Solution{3+3\\6}
\item \Calculate{1+2+3+4}
\Solution{3+3+4\\6+4\\10}
\item \Calculate{1+2+3+4+5}
\Solution{3+3+4+5\\6+4+5\\10+5\\15}
\item
\end{enumerate}
\end{document}
답변3
exam
솔루션을 위한 공간을 남겨두는 클래스를 사용할 수도 있습니다 . 또한 질문이나 질문의 일부에 점수를 할당할 수도 있습니다(여기에서는 생략함).
\documentclass[
answers
]{exam}
\usepackage{mathtools}
\begin{document}
\begin{questions}
\question Calculate \(1 + 2\)
\begin{solution}
\(1 + 2 = 3\)
\end{solution}
\question Calculate \(1 + 2 + 3\)
\begin{solution}
\begin{align*}
& 1 + 2 + 3\\
& = 3 + 3\\
& = 6
\end{align*}
\end{solution}
\end{questions}
\end{document}