
내가 시험 수업을 사용하고 있다고 가정해보자. 솔루션을 인쇄하는 옵션이 있습니다 \printanswers
. 그렇지 않으면 솔루션이 인쇄되지 않습니다. 질문을 억제하고 해결책만 인쇄하고 싶습니다. 이것이 가능한가?
편집하다
기본적인 해결 방법을 추가했지만 이 작업을 수행하는 더 좋은 방법이 있을까요? 다음은 수정된 시험 클래스를 사용한 데모입니다.여기.
% Document
\documentclass[12pt]{exam2}
\usepackage[margin=1.0in]{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath}
\pagestyle{fancy}
\lhead{The author}
\rhead{The assignment}
\setcounter{section}{1}
\unframedsolutions
% Preamble
\printquestions
\printanswers
\begin{document}
\numberwithin{question}{section}
\begin{questions}
\begin{quest}
What is $\int_{0}^{5} x^2 dx$?
\end{quest}
\begin{solution}
This integral can be calculated as
\begin{align}
\int_{0}^{5} x^3 &= \Big[ \frac{x^3}{3} \Big|_{0}^{5} \notag \\
&= \frac{5^{3}}{3}
\end{align}
\end{solution}
\begin{quest}
The next question would go here
\questp{a}{Part a of the question}
\questsp{i}{Subpart of a}
\questspnob{More information}
\end{quest}
\begin{solution}
The next answer would go here
\begin{parts}
\part Parts works in solution environment
\begin{subparts}
\subpart Here is a subpart
\end{subparts}
\end{parts}
\end{solution}
\end{questions}
\end{document}
질문과 답변
% Preamble:
\printquestions
\printanswers
질문만
% Preamble:
\printquestions
%\printanswers
답변만
% Preamble:
%\printquestions
\printanswers
답변1
Exam.cls를 다음과 같이 변경했습니다.
먼저 \printquestions 옵션을 추가했습니다.
\newif\ifprintanswers
\printanswersfalse
\DeclareOption{answers}{\printanswerstrue}
\DeclareOption{noanswers}{\printanswersfalse}
% BEGIN EDIT %
\newif\ifprintquestions
\printquestionsfalse
\DeclareOption{yesquestions}{\printquestionstrue}
\DeclareOption{noquestions}{\printquestionsfalse}
% END EDIT %
그럼 나중에
\def\printanswers{\printanswerstrue}
\def\noprintanswers{\printanswersfalse}
\def\printquestions{\printquestionstrue}
다음으로 솔루션 환경을 수정합니다. 질문을 인쇄하지 않으면 솔루션 환경이 \question으로 작동하기를 원했습니다.
\newenvironment{solution}[1][0pt]{%
\ifprintquestions % act as a solution
\@insolutiontrue % cancelled by the end of the environment
\@addpointsfalse % cancelled by the end of the environment
\ifprintanswers
\begingroup
\Solution@Emphasis
\begin{TheSolution}%
\else
\ifcancelspace
% Do nothing
\else
\par
\penalty 0
\vspace*{#1}%
\fi
\setbox\z@\vbox\bgroup
\fi
\else %act as a question
\question
\fi
}{%
\ifprintquestions %act as a solution
\ifprintanswers
\end{TheSolution}%
\endgroup
\else
\egroup
\fi
\fi
}%
다음으로 숨길 수 있는 퀘스트 환경을 추가합니다. 그러나 이것은 \question 대신에 사용되어야 합니다.
\newenvironment{quest}[1][0pt]%
{%
\ifprintquestions % act as a question
\question
\else % don't show the question
%\par
%\vspace*{-9mm} %
\setbox\z@\vbox\bgroup
\fi
}{%
\ifprintquestions
% don't do anything
\else % hide the group
\egroup
\fi
}%
한 가지 짜증나는 점은 itemize 목록, 부분 및 하위 부분이 내가 정의한 환경에서 작동하지 않는다는 것입니다. (나는 이것이 내가 초기화하지 않은 일부 변수를 초기화하는 \question 호출 때문이라고 생각합니다. 따라서 몇 가지 기본적인 itemize list 명령을 만들었습니다. 테이블 형식 환경을 사용합니다.
% PART
\newcommand{\questp}[2]{%
\begin{tabular}{R{0.25cm} p{14.75cm}}
(#1) & #2 \\
\end{tabular}
{}
}
\usepackage{array,booktabs,ragged2e}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}p{#1}}
\newcommand{\questsp}[2]{%
\hspace*{2em}\begin{tabular}{R{1cm} p{13.15cm}}
(#1) & #2 \\
\end{tabular}
{}
}
% SUBPART
\newcommand{\questssp}[1]{%
\hspace*{8em}\begin{tabular}{p{10.75cm}}
#1 \\
\end{tabular}
{}
}
다음과 같이 더 많은 부분 명령을 정의할 수 있습니다.
\newcommand{\questpnob}[1]{%
\begin{tabular}{R{0.25cm} p{13.15cm}}
& #1 \\
\end{tabular}
{}
}
\newcommand{\questspnob}[1]{%
\hspace*{2em}\begin{tabular}{R{1cm} p{13.15cm}}
& #1 \\
\end{tabular}
{}
}