[OS X TeX] Tried comment environment in Memoir
Alain Schremmer
schremmer.alain at gmail.com
Mon Apr 6 15:11:21 EDT 2009
On Apr 6, 2009, at 2:43 PM, David Arnold wrote:
> \documentclass{memoir}
> \usepackage{amsmath}
> \usepackage{comment}
> \chapterstyle{bianchi}
>
> \newoutputstream{backansout}
> \newoutputstream{solutionsout}
>
> \newenvironment{Exercises}
> {\openoutputfile{\jobname.backans}{backansout}
> \openoutputfile{\jobname.solns}{solutionsout}}
> {\closeoutputstream{backansout}
> \closeoutputstream{solutionsout}}
>
> \newcounter{exercise}[section]
> \renewcommand{\theexercise}{\arabic{exercise}}
>
> \newenvironment{exercise}%
> {\refstepcounter{exercise}
> \par\noindent\textbf{\theexercise}.}
> {\par}
>
> \makeatletter
>
> \newenvironment{genericout}[1]{%
> \@bsphack
> \ifodd\theexercise
> \addtostream{#1}{\protect\begin{oddexercise}{\theexercise}}%
> \else
> \addtostream{#1}{\protect\begin{evenexercise}{\theexercise}}%
> \fi
> \def\genericoutfile{#1}%
> \writeverbatim{#1}%
>
> }{%
>
> \endwriteverbatim
> \ifodd\theexercise
> \addtostream{\genericoutfile}{\protect\end{oddexercise}}%
> \else
> \addtostream{\genericoutfile}{\protect\end{evenexercise}}%
> \fi
> \@esphack
>
>
> }
>
> \newenvironment{backanswer}{%
> \genericout{backansout}%
>
>
> }{%
> \endgenericout
> }%
>
> \newenvironment{solution}{%
> \genericout{solutionsout}%
>
>
> }{%
> \endgenericout
> }%
>
> \newenvironment{oddexercise}[1]{\par\noindent\textbf{#1.}}{}
> \newenvironment{evenexercise}[1]{\par\noindent\textbf{#1.}}{}
> %\includecomment{oddexercise}
> \excludecomment{evenexercise}
>
> \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}
> Solve for $x$:\quad $2x+3=5-2x$.
>
> \begin{backanswer}
> $1/2$
> \end{backanswer}
>
> \begin{solution}
> Isolate terms with $x$ on the left, simplify, then divide by the
> coefficient of $x$.
> \begin{align*}
> 2x+3&=5-2x\\
> 2x+2x&=5-3\\
> 4x&=2\\
> \frac{4x}{4}&=\frac{2}{4}\\
> x&=\frac{1}{2}
> \end{align*}
>
> Next, raise each side to the second power.
> \begin{align*}
> x&=\frac{1}{2}\\
> x^2&\left(\frac12\right)^2\\
> x^2&=\frac14
> \end{align*}
>
> This is the square of the solution.
> \end{solution}
>
> \end{exercise}
>
> \begin{exercise}
> Solve for $x$:\quad $2x+3=5-2x$.
>
> \begin{backanswer}
> $1/2$
> \end{backanswer}
>
> \begin{solution}
> Isolate terms with $x$ on the left, simplify, then divide by the
> coefficient of $x$.
> \begin{align*}
> 2x+3&=5-2x\\
> 2x+2x&=5-3\\
> 4x&=2\\
> \frac{4x}{4}&=\frac{2}{4}\\
> x&=\frac{1}{2}
> \end{align*}
> \end{solution}
>
> \end{exercise}
>
> \begin{exercise}
> Solve for $x$:\quad $2x+3=5-2x$.
>
> \begin{backanswer}
> $1/2$
> \end{backanswer}
>
> \begin{solution}
> Isolate terms with $x$ on the left, simplify, then divide by the
> coefficient of $x$.
> \begin{align*}
> 2x+3&=5-2x\\
> 2x+2x&=5-3\\
> 4x&=2\\
> \frac{4x}{4}&=\frac{2}{4}\\
> x&=\frac{1}{2}
> \end{align*}
> \end{solution}
>
> \end{exercise}
>
> \begin{exercise}
> Solve for $x$:\quad $2x+3=5-2x$.
>
> \begin{backanswer}
> $1/2$
> \end{backanswer}
>
> \begin{solution}
> Isolate terms with $x$ on the left, simplify, then divide by the
> coefficient of $x$.
> \begin{align*}
> 2x+3&=5-2x\\
> 2x+2x&=5-3\\
> 4x&=2\\
> \frac{4x}{4}&=\frac{2}{4}\\
> x&=\frac{1}{2}
> \end{align*}
> \end{solution}
>
> \end{exercise}
>
> \begin{exercise}
> Solve for $x$:\quad $2x+3=5-2x$.
>
> \begin{backanswer}
> $1/2$
> \end{backanswer}
>
> \begin{solution}
> Isolate terms with $x$ on the left, simplify, then divide by the
> coefficient of $x$.
> \begin{align*}
> 2x+3&=5-2x\\
> 2x+2x&=5-3\\
> 4x&=2\\
> \frac{4x}{4}&=\frac{2}{4}\\
> x&=\frac{1}{2}
> \end{align*}
> \end{solution}
>
> \end{exercise}
>
> \begin{exercise}
> Solve for $x$:\quad $2x+3=5-2x$.
>
> \begin{backanswer}
> $1/2$
> \end{backanswer}
>
> \begin{solution}
> Isolate terms with $x$ on the left, simplify, then divide by the
> coefficient of $x$.
> \begin{align*}
> 2x+3&=5-2x\\
> 2x+2x&=5-3\\
> 4x&=2\\
> \frac{4x}{4}&=\frac{2}{4}\\
> x&=\frac{1}{2}
> \end{align*}
> \end{solution}
>
> \end{exercise}
>
> \end{Exercises}
>
> \subsection{Answers}
>
> \input{\jobname.backans}
>
> \subsection{Solutions}
>
> \input{\jobname.solns}
>
> \end{document}
>
Out of sheer curiosity, I tried the above but got the error
LaTeX Font Warning: Font shape `OT1/cmss/m/it' in size <12> not
available
(Font) Font shape `OT1/cmss/m/sl' tried instead on input
line 72.
Runaway argument?
! Paragraph ended before \verbatim at start was complete.
<to be read again>
\par
l.90 \begin{backanswer}
Of course, I don't even know if memoir is anywhere in Mac's guts so I
tried book instead and got the error
Excluding comment 'comment')
! Undefined control sequence.
<recently read> \chapterstyle
l.5 \chapterstyle
{bianchi}
?
That looked plausible so I commented out
\chapterstyle{bianchi}
which gave me this time
Excluding comment 'comment')
! Undefined control sequence.
l.7 \newoutputstream
{backansout}
?
But now I have no idea even what to try.
Merely curious regards
--schremmer
More information about the MacOSX-TeX
mailing list