[OS X TeX] Tried comment environment in Memoir
David Arnold
dwarnold45 at suddenlink.net
Mon Apr 6 01:14:44 EDT 2009
All,
Aha! There is is the \end{writeberbatim}!
\begin{backanswer}
$1/2$
\end{writeverbatim}
\end{backanswer}
However, this might scare a few of our faculty that are already
nervous about Latex. Is there any way we can do this:
\begin{backanswer}
$1/2$
\end{backanswer}
And somehow get the \end{writeverbatim} into the enviroanment?
D.
On Apr 5, 2009, at 10:03 PM, David Arnold wrote:
> Ross,
>
> This works!
>
> Thanks. This is extremely helpful.
>
> I would never have found the \excludecomment macro, which is really
> a treasure! I've never seen this one before.
>
> However, It is very hard for me to understand why we don't write a
> closing \end{writeverbatim} (I've tried. It doesn't work.).
>
> In memman.pdf, there always seems to be a closing \endwriteverbatim.
>
> 1 \newoutputstream{tryout}
> 2 \openoutputfile{\jobname.fig}{tryout}
> 3 \newcounter{pseudo}
> 4 \renewcommand{\thefigure}{\thepseudo.\arabic{figure}}
> 5 \newenvironment{writefigure}{%
> 6 \ifnum\value{chapter}=\value{pseudo}\else
> 7 \setcounter{pseudo}{\value{chapter}}
> 8 \addtostream{tryout}{\protect\stepcounter{chapter}}
> 9 \addtostream{tryout}{\protect\addtocounter{chapter}{-1}}
> 10 \addtostream{tryout}{%
> 11 \protect\setcounter{pseudo}{\thechapter}}
> 12 \fi
> 13 \addtostream{tryout}{\protect\begin{figure}}
> 14 \writeverbatim{tryout}}%
> 15 {\endwriteverbatim\finishwritefigure}
> 16 \newcommand{\finishwritefigure}{%
> 17 \addtostream{tryout}{\protect\end{figure}}}
> 18 \newcommand{\printfigures}{%
> 19 \closeoutputstream{tryout}%
>
> So I am really puzzled.
>
> But because of your reply, progress is being made at this end, which
> is nice, particularly after a long day of no progress.
>
> Thanks.
>
> D.
>
>
> On Apr 5, 2009, at 9:08 PM, Ross Moore wrote:
>
>> Hi David,
>>
>> On 06/04/2009, at 12:38 PM, David Arnold wrote:
>>
>>> OK. Tried the following, but no go. Getting this error:
>>>
>>> ! Argument of \verbatim at start has an extra }.
>>> <inserted text>
>>> \par
>>> l.47 \begin{backanswer}
>>>
>>> ?
>>>
>>> Note sure why this doesn't work:
>>>
>>> \newenvironment{backanswer}%
>>> {\ifodd\theexercise{%
>>> \addtostream{backansout}{\par\noindent\textbf{\theexercise.}}
>>> \begin{writeverbatim}{backansout}}\else{\begin{comment}}\fi}
>>> {\ifodd\theexercise{%
>>> \end{writeverbatim}}\else{\end{comment}}\fi}
>>
>> This cannot work, as the first instance of
>> \begin{writeverbatim}
>> will never finish.
>>
>> It never encounters the corresponding \end{writeverbatim} ,
>> as the first (and every subsequent) \end{backanswer} does not
>> expand --- since we are in verbatim-mode at that point.
>>
>>
>>
>>
>>
>>>
>>> Here's the full code example:
>>
>> The coding that I attach works just fine.
>>
>> <arnoldAnswers.tex>
>>
>> The main tricks are:
>>
>> 1. write all the answers into the back-answer file,
>> tagged as {evenanswer} or {oddanswer} environments;
>>
>> 2. use \newenvironment{oddanswer}
>> and \newenvironment{evenanswer}
>> to layout the answers as you want, but ...
>>
>> 3. use \excludecomment{evenanswer} to bypass these
>> when you read the answers back in.
>> If you choose to show all the answers, simply
>> comment-out this single line!
>>
>> 4. organise your questions&solutions as follows:
>>
>>
>>>>> \begin{exercise}
>>>>> What is the sum of $-2$ and $-15$?
>>>>> \begin{backanswer}
>>>>> $-17$
>>>>> \end{writeverbatim}
>>>>> \end{backanswer}
>>>>>
>>>>> \end{exercise}
>>
>>
>>
>> The apparent extra \end{writeverbatim} closes of
>> the \begin{writeverbatim} in the expansion of
>> \begin{backanswer} .
>>
>> viz.
>>
>> \newenvironment{backanswer}%
>> {\ifodd\theexercise{%
>> \addtostream{backansout}{\protect\begin{oddexercise}
>> {\theexercise}}%
>> }\else{%
>> \addtostream{backansout}{\protect\begin{evenexercise}
>> {\theexercise}}%
>> }\fi
>> \begin{writeverbatim}{backansout}}%
>> %
>> {\ifodd\theexercise{%
>> \addtostream{backansout}{\protect\end{oddexercise}}%
>> }\else{%
>> \addtostream{backansout}{\protect\end{evenexercise}}%
>> }\fi}
>>
>> \newenvironment{oddexercise}[1]{\par\noindent\textbf{#1.}}{}
>> \newenvironment{evenexercise}[1]{\par\noindent\textbf{#1.}}{}
>>
>> %\includecomment{oddexercise}
>> \excludecomment{evenexercise}
>>
>>
>>> \end{Exercises}
>>>
>>> \subsection{Answers}
>>>
>>> \input{\jobname.backans}
>>>
>>> \end{document}
>>
>>
>> Hope this helps,
>>
>> Ross
>>
>> ------------------------------------------------------------------------
>> Ross Moore ross at maths.mq.edu.au
>> Mathematics Department office: E7A-419
>> Macquarie University tel: +61 (0)2 9850
>> 8955
>> Sydney, Australia 2109 fax: +61 (0)2 9850
>> 8114
>> ------------------------------------------------------------------------
>>
>>
>>
>> ----------- Please Consult the Following Before Posting -----------
>> TeX FAQ: http://www.tex.ac.uk/faq
>> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
>> List Archive: http://tug.org/pipermail/macostex-archives/
>> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
>> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
>>
>
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
>
More information about the MacOSX-TeX
mailing list