General ⇒ Questions and Solutions
Questions and Solutions
\item {Question}{Solution}
And then "tell" latex to only print out the questions (without solutions) for the study guide and then to print out only solutions (without the questions) when I'm creating the solution manual.
However, I'm still relatively new to latex and I don't know if this capability exists. So, I'm wondering if there's some built-in function or something I could add on to do this. If anyone can point me in the right direction, I'd appreciate it. Thanks!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
-
- Posts: 90
- Joined: Fri Nov 06, 2009 7:29 am
Questions and Solutions
I think this (messy) code should do what you want:
Code: Select all
\newcommand{\answers}{yes} %put 'yes' if you want answers displayed or leave blank if you don't want answers displayed
\newcommand{\questions}{yes} %put 'yes' if you want questions displayed or leave blank if you don't want questions displayed
\newcommand{\question}[4]{\ifthenelse{\equal{\questions}{yes}}{\textbf{#1} #2\newline}{} \ifthenelse{\equal{\answers}{yes}}{\textbf{#3} #4\newline}{}}
\question{Question 1}{question goes here}{Answer to Question 1}{answer goes here}
\question{Question 2}{question goes here}{Answer to Question 2}{answer goes here}
All you do is set questions or answers to 'yes' and they will display.
You can add counters and things to get the numbering right, but this will allow you to turn the questions and answers on or off.
There is probably a better way, but this will work

Hope that helps
Questions and Solutions
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/