2

I am trying to make a thorough header in LaTeX that will save time later when I write quizzes and tests. I'd like to include solutions to each question in the .tex file, with some flag that toggles whether they appear when compiled.

So in a document like this...

\begin{document}

Some question
\solution{ the answer to the question}

\end{document}

..the solution would be invisible unless I include a "\showsolutions" flag.

Is there a command I can create that will do this?

4

1 に答える 1

3

\newif新しい if 型構造を作成し、デフォルト値を設定するために使用します。

\newif\ifshowsolutions
\showsolutionsfalse

次に、\solutionコマンドで使用します

\newcommand{solution}[1]{\ifshowsolutions #1 \fi}

ソリューションを有効にするには、次を使用します

\showsolutionstrue
于 2012-08-29T21:55:46.727 に答える