I'm trying to hack together a way to generate solutions files to my quizzes and exams. Here is my current workflow.
I have a file quiz.tex:
\documentclass[12pt]{article}
\newcommand{\solutionscolor}{white}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{color}
\usepackage{thmtools}
\theoremstyle{definition}
\newtheorem{problem}{Problem}
\declaretheoremstyle[
headfont=\color{\solutionscolor}\normalfont\bfseries,
bodyfont=\color{\solutionscolor}
]{colored}
\declaretheorem[
style=colored,
% style=phantom,
name=Solution,
numbered=no
]{solution}
\newcommand{\fillblank}[2]{\underline{\hspace{#1}{\color{\solutionscolor}#2}\hspace{#1}}}
\title{Quiz}
\author{Name \fillblank{1.25in}{Solutions}}
\date{}
\begin{document}
\maketitle
\begin{problem}
Let $f(x)=\cos(2\,x)$. Determine the concavity of $f(x)$ at $x=\pi$.
\end{problem}
\begin{solution}
The first derivative of $f(x)$ may be computed using the chain rule
\[
f^{\prime}(x)
= -\sin(2\,x)(2)
= -2\sin(2\,x)
\]
The second derivative of $f(x)$ may then be computed by using the chain rule
again
\[
f^{\prime\prime}(x)
= -2\cos(2\,x)(2)
= -4\cos(2\,x)
\]
It follows that
\[
f^{\prime\prime}(\pi)=-4\cos(2\pi)=-4<0
\]
Since $f^{\prime\prime}(\pi)<0$, $f(x)$ is \emph{concave down} at $x=\pi$.
\end{solution}
\begin{problem}
Fill in the blanks.
\begin{align*}
\sin(\pi) &= \fillblank{.25in}{0} &
\cos(\pi) &= \fillblank{.25in}{-1} &
\sin\left(\frac{\pi}{2}\right) &= \fillblank{.25in}{1} &
\cos(34\pi) &= \fillblank{.25in}{1}
\end{align*}
\end{problem}
\end{document}
Compiling this document produces quiz.pdf:
If I change the value of \solutionscolor to blue, the result looks like this:
My problem is that I want two files: quiz.pdf (with no solutions) and quiz-solutions.pdf (with solutions). Currently I have to do this manually.
Is there a way to automate my output to produce two files?


examclass? http://www-math.mit.edu/~psh/exam/examdoc.pdf – Dan Nov 28 '17 at 19:54\if...switch then – Nov 28 '17 at 20:03\if...switch redirect output to a different file name? – Brian Fitzpatrick Nov 28 '17 at 20:22