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?
Use \newif
to create a new if-type construct, and set the default value.
\newif\ifshowsolutions
\showsolutionsfalse
Then use it in your \solution
command
\newcommand{solution}[1]{\ifshowsolutions #1 \fi}
To turn on solutions, use
\showsolutionstrue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With