# [OS X TeX] Tried comment environment in Memoir

Mon Apr 6 04:38:20 CEST 2009

OK. Tried the following, but no go. Getting this error:

! Argument of \verbatim at start has an extra }.
<inserted text>
\par

?

Note sure why this doesn't work:

{\ifodd\theexercise{%
\begin{writeverbatim}{backansout}}\else{\begin{comment}}\fi}
{\ifodd\theexercise{%
\end{writeverbatim}}\else{\end{comment}}\fi}

Here's the full code example:

\documentclass{memoir}

\chapterstyle{bianchi}

\newoutputstream{backansout}

\newenvironment{Exercises}
{\openoutputfile{\jobname.backans}{backansout}}
{\closeoutputstream{backansout}}

\newcounter{exercise}[section]
\renewcommand{\theexercise}{\arabic{exercise}}

\newenvironment{exercise}%
{\refstepcounter{exercise}
\par\noindent\textbf{\theexercise}.}
{\par}

\input{\jobname.backans}}

{\ifodd\theexercise{%
\begin{writeverbatim}{backansout}}\else{\begin{comment}}\fi}
{\ifodd\theexercise{%
\end{writeverbatim}}\else{\end{comment}}\fi}

\begin{document}

\chapter{The Whole Numbers}

\section{Introduction to the Whole Numbers}

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\subsection{Exercises}

\begin{Exercises}

\begin{exercise}
What is the sum of $-2$ and $-15$?
$-17$

\end{exercise}

\begin{exercise}
What is the sum of 2 and 15?

$17$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and 15?

$13$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and $-15$?
$-17$

\end{exercise}

\begin{exercise}
What is the sum of 2 and 15?

$17$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and 15?

$13$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and $-15$?
$-17$

\end{exercise}

\begin{exercise}
What is the sum of 2 and 15?

$17$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and 15?

$13$

\end{exercise}

\end{Exercises}