
answer
나는 준비해야 할 시험 문제의 답을 표시하는 환경을 정의했습니다 .
아이디어는 답변이 표시되고 하나는 그렇지 않은 버전을 컴파일하는 것입니다(학생들을 테스트하기 위해).
환경을 비활성화하는 우아한 방법이 있습니까?
물론 명령을 정의한 \ifanswer
다음 \ifanswer{\begin{answer}foo\end{answer}}
. 각 환경마다. 그러나 이 접근 방식의 문제점은 매번 이 명령을 기억하고 삽입해야 하며, 물론 이것을 한 번 잊어버리면 당혹스러울 수 있다는 것입니다.
MWE:
\documentclass{article}
\newenvironment{answer}{\textit{Answer} }{\textit{the end.}}
\begin{document}
Question: Bla
\begin{answer}
Foo
\end{answer}
\end{document}
답변1
David가 말했듯이 comment
패키지를 사용할 수 있습니다.
\documentclass{article}
\usepackage{comment}
\newenvironment{answer}{\textit{Answer} }{\textit{the end.}}
\includecomment{answer} %%% comment out to show the answer
\begin{document}
Question: Bla
\begin{answer}
Foo answer
\end{answer}
\end{document}
힘들게 하고 싶으시다면-
\documentclass{article}
\usepackage{environ}
\usepackage{ifthen}
\newboolean{answers}
\setboolean{answers}{true} %%% uncomment to show answers properly
%\setboolean{answers}{false} %%% comment to show answers properly
\ifthenelse{\boolean{answers}}%
{%
\NewEnviron{answer}
{%
\textit{Answer}
\BODY{}
\textit{the end.}
}%
}%
{\NewEnviron{answer}
{%
\textit{Answer}
\textit{the end.}
}%
}%
\begin{document}
Question: Bla
\begin{answer}
Foo answer
\end{answer}
\end{document}