I'm laying some foundations of a Mathematical document that will follow the standard format of
- examples
- exercises
and hope to have a 'solutions' section at the end. I'm having trouble getting started, as I have not understood how to write counters to files.
I've pasted the code below; the problem is that only the most recent value of '
\thequestioncounter
' is written to 'solutions.log'. If anyone has any ideas on how to fix this, or suggestions on a better way of accomplishing my goals, I'd very much like to hear them.
Chris
Code: Select all
\documentclass[10pt]{article}
\newwrite\solutionswrite
\openout\solutionswrite solutions.log\relax
\newcounter{questioncounter}
\setcounter{questioncounter}{0}
\newcommand{\question}[1]{
\addtocounter{questioncounter}{1} \thequestioncounter
\write\solutionswrite{Q\thequestioncounter. #1^^J}}
\begin{document}
\question{$x=3$} Solve the following equation for $x$
\[
2x=6
\]
\question{$x=0,4$} Solve the following equation for $x$
\[
x(x-4)=0
\]
\closeout\solutionswrite
%\input{solutions.log}
\end{document}