![시험 수업: \printanswers에 의존하는 새로운 환경 정의](https://rvso.com/image/370296/%EC%8B%9C%ED%97%98%20%EC%88%98%EC%97%85%3A%20%5Cprintanswers%EC%97%90%20%EC%9D%98%EC%A1%B4%ED%95%98%EB%8A%94%20%EC%83%88%EB%A1%9C%EC%9A%B4%20%ED%99%98%EA%B2%BD%20%EC%A0%95%EC%9D%98.png)
시험 클래스의 \printanswers 옵션에 의존하는 새로운 환경을 정의하는 데 문제가 있습니다.
\documentclass{exam}
\usepackage{framed}
\printanswers
%\noprintanswers
\newenvironment{note}{\ifprintanswers\begin{framed}\noindent\textbf{Note:}\par\noindent}{\end{framed}\fi}
\begin{document}
\begin{questions}
\question
question
\begin{solution}
this is the solution
\end{solution}
\begin{note}
this is a note
\end{note}
\end{questions}
\end{document}
\printanswers를 사용하면 모든 것이 괜찮아 보이지만 \noprintanswers를 사용하면 오류가 발생합니다.
! Incomplete \iffalse; all text was ignored after line 17.
\noprintanswers를 사용할 때 Notes 환경을 숨기고 싶습니다.
답변1
{comment}
환경을 억제하는 한 가지 기술은 해당 환경을 축어 패키지에 정의된 환경 과 동일하게 만드는 것입니다 . 또 다른 방법은 명령 본문을 a에 넣고 시험 환경에서 사용하는 솔루션인 를 \vbox
버리는 것 입니다. 접근 방식 \vbox
은 다음과 같습니다 \vbox
.
\documentclass{exam}
\usepackage{framed}
\newenvironment{note}{%
\ifprintanswers
\begin{framed}\noindent\textbf{Note:}\par\noindent
\else
\setbox0\vbox\bgroup
\fi
}{%
\ifprintanswers
\end{framed}%
\else
\egroup
\fi%
}
\printanswers
%\noprintanswers
\begin{document}
\begin{questions}
\question
question
\begin{solution}
this is the solution
\end{solution}
\begin{note}
this is a note
\end{note}
\end{questions}
\end{document}