I'm making a study guide for my students with several practice questions. I'm also working on a separate solution manual. Until now, I was using two separate documents. The problem is that if I rearrange the questions in the study guide, I have to sort through the solution manual and find the corresponding solution and move it accordingly. It occurred to me that there might be a way to combine the two into a single document and possibly have the questions and solutions "attached" to each other in some way. Something like:
\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!
General ⇒ Questions and Solutions
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Posts: 90
- Joined: Fri Nov 06, 2009 7:29 am
Questions and Solutions
Hi,
I think this (messy) code should do what you want:
(you will need the ifthen package)
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
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
LaTeX Resources: http://www.dickimaw-books.com/latexresources.html
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/
Creating a Minimal Example: http://www.dickimaw-books.com/latex/minexample/