summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/ans
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex209/contrib/ans
Initial commit
Diffstat (limited to 'macros/latex209/contrib/ans')
l---------macros/latex209/contrib/ans/README1
-rw-r--r--macros/latex209/contrib/ans/ans.sty543
-rw-r--r--macros/latex209/contrib/ans/ansdoc.dvibin0 -> 20992 bytes
-rw-r--r--macros/latex209/contrib/ans/ansdoc.pdfbin0 -> 83145 bytes
-rw-r--r--macros/latex209/contrib/ans/ansdoc.tex490
-rw-r--r--macros/latex209/contrib/ans/ansread.me4
-rw-r--r--macros/latex209/contrib/ans/onceexam.tex46
7 files changed, 1084 insertions, 0 deletions
diff --git a/macros/latex209/contrib/ans/README b/macros/latex209/contrib/ans/README
new file mode 120000
index 0000000000..30bf9f095e
--- /dev/null
+++ b/macros/latex209/contrib/ans/README
@@ -0,0 +1 @@
+ansread.me \ No newline at end of file
diff --git a/macros/latex209/contrib/ans/ans.sty b/macros/latex209/contrib/ans/ans.sty
new file mode 100644
index 0000000000..28f9d588a1
--- /dev/null
+++ b/macros/latex209/contrib/ans/ans.sty
@@ -0,0 +1,543 @@
+\typeout{Exercise and Answer macros}
+\typeout{Charles Wells cfw2@po.cwru.edu}
+\typeout{24 February 1994}
+
+% Copyright 1994 by Charles Frederick Wells.
+% May be freely redistributed, provided that the files ans.sty,
+% ansdoc.tex and onceexam.tex are distributed together and are not
+% changed.
+
+\makeatletter
+% Counters for exercise and subexercise numbers
+\newcounter{exercounter}
+\newcounter{subexercounter}[exercounter]
+% % \renewcommand{\thesubexercounter}{\subexerstyle{subexercounter}}
+\newif\ifsols
+\newif\ifanswerson
+\newif\ifanswer
+\newif\ifsubanswer
+% Used to determine if the current exercise or subexercise
+% has an answer
+
+
+\def\exerbody{%
+\setcounter{exercounter}{0}%
+\ifanswerson\answerfalse\subanswerfalse\@wrheader\fi%
+\ifsols\@wrsolheader\fi}
+\newcommand{\exes}[1]{\exersection{#1}\exerbody}
+% You can comment out the forms you don't want:
+\newcommand{\exercises}{\exes{Exercises}}
+\newcommand{\exercise}{\exes{Exercise}}
+\newcommand{\problems}{\exes{Problems}}
+\newcommand{\extraproblems}{\exes{Extra Credit Problems}}
+\newcommand{\samplequestions}{\exes{Sample Test Questions}}
+
+% Amount of vertical space between exercises.
+% It would be better to have this space depend on the
+% type size. In hindsight, I think each exercise section
+% should be a specially created LaTeX list environment.
+% But that's for the next revision!
+\newskip\exerskipamount
+\exerskipamount=6pt plus 1 pt
+\newcommand{\medgap}{\par\vskip\exerskipamount\noindent}
+
+% \answermark is the symbol that marks questions with answers.
+% Put another symbol here in place of \bullet if you wish. The
+% spacing will take care of itself. I hope.
+\newcommand\answermark{\mbox{$^\bullet$}}
+
+% The following commands set the numbering style for exercises and
+% subexercises. See page 92 of LaTeX book for other
+% possibilities.
+\def\exerstyle{\arabic}
+\def\subexerstyle{\alph}
+
+% The quantities below control the spacing after the problem number
+% before the problem starts. If you change \exerspace all the
+% others should change automatically. The idea is that all the
+% problems start with the same indentation and the answer and hard
+% symbols are stuck between without affecting the indentation.
+% \newdimen{\hardback}
+\newdimen{\answerspace}
+\newdimen{\exerspace}
+\newdimen{\tempdim}
+\newdimen{\labeldim}
+\settowidth{\labeldim}{\bf5}
+\setlength{\exerspace}{\parindent}
+\advance\exerspace by -\labeldim
+\setlength{\answerspace}{\exerspace}
+\settowidth{\tempdim}{\answermark}
+\advance\answerspace by -\tempdim
+
+% \@pns is the style of the problem number. It is set to
+% boldface. Changing \@pns will change the styles of all the
+% problem numbers and subproblem letters in both the exercise
+% sections and the answer sections. If you don't want them all
+% the same you will have to search the file and change them by
+% hand.
+\def\@pns{\bf}
+
+% The following commands head exercises and subexercises. (See
+% ansdoc.tex for a more complete explanation.)
+\newcommand{\exer}{%
+\ifnum\c@exercounter>0
+\pagebreak[2]\else\nopagebreak\fi\medgap%
+\ifanswerson\ifanswer\noanserror\fi\answerfalse%
+\ifsubanswer\nosubanserror\fi\subanswerfalse\fi
+\refstepcounter{exercounter}\setcounter{subexercounter}{0}%
+\@pns\exerstyle{exercounter}.\hspace{\exerspace}\rm}
+
+% \exhead is a header for a set of exercises
+\newcommand{\exhead}[1]{\ifnum\c@exercounter>0
+\pagebreak[3]\else\nopagebreak\fi
+\par\bigskip\noindent{\fbox{%
+\advance\textwidth by -1em\parbox{\textwidth}{#1}}}}
+
+% The two lines below produce a version of exhead that does
+% not enclose the header in a box. I changed to the boxed
+% version when I noticed that a substantial number of students
+% overlooked the header.
+% \newcommand{\exhead}{\ifnum\c@exercounter>0
+% \pagebreak[3]\else\nopagebreak\fi\par\bigskip\noindent}
+
+
+\newcommand{\@ssa}% "offset subanswer"
+{\phantom{\bf\exerstyle{exercounter}.\ }%
+\bf\subexerstyle{subexercounter}}
+
+\newcommand{\exera}{\ifnum\c@exercounter>0
+\pagebreak[2]\else\nopagebreak\fi\medgap%
+\ifanswerson\ifanswer\noanserror\fi%
+\ifsubanswer\nosubanserror\fi\subanswerfalse\answertrue\fi
+\refstepcounter{exercounter}\setcounter{subexercounter}{0}%
+\@pns\exerstyle{exercounter}.\answermark\hspace{\answerspace}\rm}
+
+\def\eexer{\ifanswerson\ifanswer\noanserror\fi%
+\ifsubanswer\nosubanserror\fi\pagebreak[3]\@wrtail\fi%
+\ifsols\@wrsoltail\fi}
+
+\newcommand{\subexer}{\ifanswerson%
+\ifsubanswer\nosubanserror\fi\subanswerfalse\fi%
+\refstepcounter{subexercounter}%
+\nopagebreak[1]\par\noindent\@ssa.\hspace{\exerspace}\rm}
+
+\newcommand{\subexera}{\ifanswerson%
+\ifsubanswer\nosubanserror\fi\answerfalse\subanswertrue\fi%
+\refstepcounter{subexercounter}%
+\nopagebreak[1]\par\noindent\@ssa.%
+\answermark\hspace{\answerspace}\rm}
+
+\newcommand{\immsubexer}{\ifanswerson%
+\ifsubanswer\nosubanserror\fi\subanswerfalse\fi%
+\refstepcounter{subexercounter}
+\hspace{-\labeldim}\@pns\subexerstyle{subexercounter}.%
+\hspace{\exerspace}\rm}
+
+\newcommand{\immsubexera}{\ifanswerson%
+\ifsubanswer\nosubanserror\fi\answerfalse\subanswertrue\fi%
+\refstepcounter{subexercounter}%
+\hspace{-\labeldim}\@pns\subexerstyle{subexercounter}.%
+\answermark\hspace{\answerspace}\rm}
+
+%%The following places the word "(#1)" in boldface after the
+% exercise number.
+% I use it to mark exercises "hard", "requires Mathematica",
+% etc.
+\def\annot#1{\hspace{-\answerspace}{{\bf (#1)}}}
+
+% These are the error messages for problems marked with the
+% answermark that don't have answers and vice versa.
+\newcommand\anserror{
+\typeout{Warning:}
+\typeout{Exercise \exerstyle{exercounter} has an answer but is not %
+marked}}
+\newcommand\noanserror{
+\typeout{Warning:}
+\typeout{Exercise \exerstyle{exercounter} has no answer}}
+\newcommand\nosubanserror{
+\typeout{Warning:}
+\typeout{Exercise \exerstyle{exercounter}.%
+\subexerstyle{subexercounter} %
+has no answer}}
+\newcommand\subanserror{
+\typeout{Warning:}
+\typeout{Exercise \exerstyle{exercounter}.%
+\subexerstyle{subexercounter} %
+has an answer but is not marked}}
+
+% Following is a modification of the makeindex code.
+% It defines the various answer macros that write appropriate
+% headers to the answer file. The answer file has the same name
+% as the main file, with the extension ".ans".
+% The stuff concerning rightmark etc. control the running heads in
+% the answer section. They won't appear unless you put
+% \pagestyle{headings} in the preamble.
+% The line in @wrheader beginning \string\ansection* controls what
+% is printed before the answers to each section.
+% The line saying \typeout controls the message on the screen.
+\def\makeanswers{\answersontrue\if@filesw \newwrite\answerfile
+ \immediate\openout\answerfile=\jobname.ans%
+%makeanswers continues...
+ \def\answer{\ifanswer\else\anserror\fi\answerfalse\par
+\putinans{\string\antwort[\exerstyle{exercounter}]}\copytoblankline}%
+%makeanswers continues...
+ \def\subanswer{\ifsubanswer\else\subanserror\fi\subanswerfalse\par
+ \ifnum\value{subexercounter}=1
+ \putinans{\string\immsubantwort[\exerstyle{exercounter}]%
+[\subexerstyle{subexercounter}]}\else
+ \putinans{\string\subantwort[%\string\phantom%
+\exerstyle{exercounter}]%
+[\subexerstyle{subexercounter}]}\fi
+ \copytoblankline}%
+%makeanswers continues...
+ \def\immsubanswer{\subanswerfalse\par
+ \putinans{\string\immsubantwort[\exerstyle{exercounter}]%
+[\subexerstyle{subexercounter}]}%
+ \copytoblankline}%
+ \typeout{Writing answer file \jobname.ans }\fi}% END \makeanswers
+
+% The command \makesolutions below produces a second file of
+% answers for the problems that aren't marked as having answers!
+% By putting \dosolutions at the very end of the printout you can
+% have a booklet of "answers to problems not answered in the
+% text."
+\def\makesolutions{\solstrue\if@filesw \newwrite\solutionfile
+\newwrite\solutionfile
+ \immediate\openout\solutionfile=\jobname.sol%
+ \def\solution{\par
+ \putinsol%
+ {\string\antwort[\exerstyle{exercounter}]}%
+ \copysoltoblankline\@esphack}%
+ \def\subsolution{\par
+ \ifnum\value{subexercounter}=1
+ \putinsol{\string\immsubantwort[\exerstyle{exercounter}]%
+[\subexerstyle{subexercounter}]}\else
+ \putinans{\string\subantwort[%\string\phantom%
+{\exerstyle{exercounter}}]%
+[\subexerstyle{subexercounter}]}\fi
+ \copysoltoblankline}%
+ \def\immsubsolution{\par
+ \putinsol{\string\immsubantwort[\exerstyle{exercounter}]%
+[\subexerstyle{subexercounter}]}%
+ \copysoltoblankline}%
+ \typeout{Writing solutions file \jobname.sol}\fi}% END
+
+
+\def\skiplf{\catcode`\^^J=9}
+
+% The following is by D. Knuth
+% It reads a line up to a CR then writes it to file #1
+% If it comes to a blank line it quits
+% DON'T MESS WITH THIS CODE. EVEN BREAKING OR COMBINING THE
+% LINES CAN MESS IT UP.
+\def\copytoblankline{\begingroup\setupcopy\copyans}
+\def\copysoltoblankline{\begingroup\setupcopy\copysol}
+ \def\setupcopy{\def\do##1{\catcode`##1=\other}\dospecials
+ \catcode`\|=\other \obeylines}
+ {\obeylines \gdef\copyans#1
+ {\def\next{#1}%
+ \ifx\next\empty\let\next=\endgroup%
+ \else\immediate\write\answerfile{\next} \let\next=\copyans\fi\next}}
+ {\obeylines \gdef\copysol#1
+ {\def\next{#1}%
+ \ifx\next\empty\let\next=\endgroup%
+ \else\immediate\write\solutionfile{\next} \let\next=\copysol\fi\next}}
+
+% The following modification of copytoblankline is used
+% when answers are turned off
+\def\throwaway{\begingroup\setupcopy\killans}
+ {\obeylines \gdef\killans#1
+ {\def\next{#1}%
+ \ifx\next\empty\let\next=\endgroup %
+ \else\let\next=\killans\fi\next}}
+
+\chardef\other=12
+
+% The following commands take effect if \makeanswers is not
+% in preamble
+% They are intended to do nothing
+\def\@wrheader{\relax}
+\def\@wrtail{\relax}
+\def\@wrsolheader{\relax}
+\def\@wrsoltail{\relax}
+\def\answer{\throwaway}
+\def\solution{\throwaway}
+\def\subanswer{\throwaway}
+\def\immsubanswer{\throwaway}
+
+
+
+\answersonfalse
+\solsfalse
+
+% The words containing "antwort" format the answers in the
+% answer file.
+
+\def\ant{\@startsection
+ {paragraph}{4}{\z@}{-6pt plus -2pt minus -1pt}{-1em plus
+-.2em}{\normalsize\@pns}}
+
+
+\def\antwort[#1]{\ant{#1.}} %%Note the period
+% \def\subantwort[#1][#2]{\par\noindent\@pns#1\phantom{.}\ \ #2.\ \rm}
+\def\subantwort[#1][#2]{\pagebreak[1]%
+\medgap\@pns\phantom{#1.}\ \ #2.\ \rm}
+\def\immsubantwort[#1][#2]{\pagebreak[2]\medgap\@pns#1.\ \ #2.\ \rm}
+
+
+% Here are some commands used repeatedly in \makeanswers and in
+% the option commands \artsec, \bkchap, etc.
+\def\putinans{\immediate\write\answerfile}
+\def\putinsol{\immediate\write\solutionfile}
+\def\putbreak{\string\pagebreak[3]\string\medbreak\noindent}
+
+% This command is called by doanswers and can be used to customize
+% the answer section. For example, if you want the answers in
+% small type, you could put "\def\@therstuff{\small}" in the
+% preamble.
+\def\@therstuff{\relax}
+
+\def\do@nswers[#1]{
+\ifanswerson\putinans{\string\par}
+\immediate\closeout\answerfile% \fi
+\@therstuff
+\def\rightmark{\expandafter\@rightmark\botmark}
+\def\leftmark{\expandafter\@leftmark\firstmark}\fi
+\answersonfalse % minor kludge because answerfile is closed
+\anshead
+\input{#1.ans}
+\eject}
+
+% The following command should be put at place in the book where the
+% answers go, e.g. after the bibliography and before the index.
+% "Answers to selected exercises" heads the whole section.
+% Answers to each section are headed by "Section #.#".
+% That is controlled by \@wrheader (above).
+\def\doanswers{\@ifnextchar [{\do@nswers}{\do@nswers[\jobname]}}
+
+\def\dos@ls[#1]{
+\immediate\write\solutionfile{\string\par}
+\immediate\closeout\solutionfile
+\@therstuff
+\setcounter{page}{1}
+\def\rightmark{\expandafter\@rightmark\botmark}
+\def\leftmark{\expandafter\@leftmark\firstmark}
+\raggedbottom% In case not used earlier
+\solhead
+\input{#1.sol}
+\eject}
+
+% The command \dosolutions produces a booklet of answers to
+% questions not answered in the text (provided you write the
+% answers!) It could be put at the end of the .tex file after
+% resetting the page number.
+\def\dosolutions{\@ifnextchar [{\dos@ls}{\dos@ls[\jobname]}}
+
+% The following commands allow ans.sty to be used with book.sty or
+% article.sty, with various arrangements of the exercises.
+
+% Use this command in your preamble if you are using article style
+% and have (at most) one section of exercises per section.
+\def\artsec{%
+ \def\exersection{\subsection}%
+ \def\ansection{\section}%
+ \def\anshead{%
+ \section*{Answers to selected exercises}\label{ansec}
+ \sectionmark{}}
+ \def\solhead{%
+ \noindent\section*{Solutions to exercises\protect\\
+not answered in text}%
+ \sectionmark{}}
+ \def\@wrheader{\begingroup
+ \xdef\@gtempa{%
+\putinans{\string\ansection*{Section \thesection}\string\nopagebreak}
+ \putinans{\string\typeout{Answers to Section \thesection}}
+ \putinans{\string\markboth{Answers for Section \thesection}
+{Answers for Section \thesection\string\enskip}}}
+ \@gtempa\endgroup}%
+ \def\@wrsolheader{\begingroup
+ \xdef\@gtempa{%
+ \putinsol{\string\ansection*{Section \thesection}\string\nopagebreak}
+ \putinsol{\string\typeout{Solutions to Section \thesection}}
+ \putinsol{\string\markboth{Solutions for Section \thesection}
+{Solutions for Section \thesection\string\enskip}}}
+ \@gtempa\endgroup}%
+ \def\@wrtail{\xdef\@gtempa{%
+ \putinans{\string\markboth{Answers for Section \thesection}
+{Answers for Section \thesection\string\enskip}}
+ \putinans{\putbreak}}
+ \@gtempa}
+ \def\@wrsoltail{
+\xdef\@gtempa{\putinsol{\string\markboth{Solutions for Section
+ \thesection}
+{Solutions for Section \thesection\string\enskip}}
+ \putinsol{\string\pagebreak[3]\string\medbreak\noindent}}
+ \@gtempa}}% end \artsec
+
+% Use this command if you are using bookstyle and have at most one
+% set of exercises per chapter.
+\def\bkchap{%
+ \def\exersection{\section}%
+ \def\anstochap{\section}%
+ \def\anshead{%
+ \addcontentsline{toc}{part}{Answers to selected problems}
+ \chapter*{Answers to selected problems}\label{ansec}
+ \chaptermark{}}
+ \def\solhead{%
+ \chapter*{Solutions to problems\protect\\
+ not answered in text}
+ \chaptermark{}}
+ \def\@wrheader{\begingroup
+ \xdef\@gtempa{%
+ \putinans{\string\anstochap*{Chapter \thechapter}\string\nopagebreak}
+ \putinans{\string\typeout{Answers to Chapter \thechapter}}
+ \putinans{\string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}
+% \putinans{%
+% % The following causes the string "Solutions for Chapter n"
+% % to be added IN THE FORMAT OF A SECTION ENTRY in the t.o.c
+% \string\addcontentsline{toc}{section}{\string\protect
+% \string\numberline{0}{Solutions for Chapter \thechapter}}}
+}
+ \@gtempa\endgroup}%
+ \def\@wrsolheader{\begingroup
+ \xdef\@gtempa%
+ {\putinsol{\string\anstochap*{Chapter \thechapter}\string\nopagebreak}
+ \putinsol{\string\typeout{Solutions to Chapter \thechapter}}
+ \putinsol{\string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}}
+ \@gtempa\endgroup}%
+ \def\@wrtail{\xdef\@gtempa{%
+ \putinans{\string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}
+ \putinans{\putbreak}}
+ \@gtempa}
+ \def\@wrsoltail{
+\xdef\@gtempa{\immediate\write\solutionfile{%
+ \string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}
+ \immediate\write\solutionfile{\string\pagebreak[3]
+ \string\medbreak\noindent}}
+ \@gtempa}}% end\bkchap
+
+\def\twocolbkchap{%
+ \def\exersection{\section}%
+ \def\anstochap{\section}%
+ \def\anshead{%
+ \addcontentsline{toc}{part}{Answers to selected problems}
+ \chapter*{Answers to selected problems}\label{ansec}
+ \chaptermark{}}
+ \def\solhead{%
+ \chapter*{Solutions to problems\protect\\
+ not answered in text}
+ \chaptermark{}}
+ \def\@wrheader{\begingroup
+ \xdef\@gtempa{%
+ \putinans{\string\anstochap*{Chapter \thechapter}\string\nopagebreak}
+ \putinans{\string\typeout{Answers to Chapter \thechapter}}
+ \putinans{\string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}
+% \putinans{%
+% % The following causes the string "Solutions for Chapter n"
+% % to be added IN THE FORMAT OF A SECTION ENTRY in the t.o.c
+% \string\addcontentsline{toc}{section}{\string\protect
+% \string\numberline{0}{Solutions for Chapter \thechapter}}}
+}
+ \@gtempa\endgroup}%
+ \def\@wrsolheader{\begingroup
+ \xdef\@gtempa%
+ {\putinsol{\string\anstochap*{Chapter \thechapter}\string\nopagebreak}
+ \putinsol{\string\typeout{Solutions to Chapter \thechapter}}
+ \putinsol{\string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}}
+ \@gtempa\endgroup}%
+ \def\@wrtail{\xdef\@gtempa{%
+ \putinans{\string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}
+ \putinans{\putbreak}}
+ \@gtempa}
+ \def\@wrsoltail{
+\xdef\@gtempa{\immediate\write\solutionfile{%
+ \string\markboth{Solutions for Chapter \thechapter}
+{Solutions for Chapter \thechapter\string\enskip}}
+ \immediate\write\solutionfile{\string\pagebreak[3]
+ \string\medbreak\noindent}}
+ \@gtempa}}% end\bkchap
+
+
+% Use this command if you are using book style and have at most
+% one set of exercises per section.
+\def\bksec{%
+ \def\exersection{\section}%
+ \def\anstochap{\section}%
+ \def\ansection{\subsection}%
+ \def\anshead{%
+ \setcounter{chapter}{-1}
+ \setcounter{section}{0}
+ \chapter{Answers to selected exercises}\label{ansec}
+ \chaptermark{Answers to exercises}}
+ \def\solhead{%
+ \chapter*{Solutions to exercises\protect\\ not answered in text}
+ \chaptermark{Solutions to exercises}}
+ \def\@nschap{\ifnum \c@chapter >\z@
+ {\begingroup
+ \xdef\@gtempa{\putinans{%
+ \string\typeout{Chapter \thechapter\space solutions}}
+% using several \writes keeps the answer file lines from being too long
+ \putinans{%
+ \string\noindent%
+ \string\anstochap*{Solutions for Chapter \thechapter}%
+ \string\nopagebreak}
+ \putinans{%
+ \string\addcontentsline{toc}{chapter}{\string\protect
+ \string\numberline{0}{Solutions for Chapter \thechapter}}}}
+ \@gtempa\endgroup}\fi}%
+ \def\s@lchap{\ifnum \c@chapter >\z@
+ {\begingroup
+ \xdef\@gtempa{\putinsol{%
+ \string\typeout{Chapter \thechapter\space solutions}}
+% using several \writes keeps the answer file lines from being too long
+ \putinsol{%
+ \string\noindent%
+ \string\anstochap*{Solutions for Chapter \thechapter}%
+ \string\nopagebreak}}%
+ \@gtempa\endgroup}\fi}%
+ \def\@wrheader{\begingroup
+ \xdef\@gtempa{\putinans{%
+ \string\ansection*{Section \thesection}\string\nopagebreak
+ \string\markboth{Solutions for section \thesection}
+{Solutions for section \thesection\string\enskip}}}
+ \@gtempa\endgroup}%
+ \def\@wrsolheader{\begingroup
+ \xdef\@gtempa{%
+ \putinsol{\string\anstochap*{Section \thesection}\string\nopagebreak}
+ \putinsol{\string\typeout{Solutions to Section \thesection}}
+ \putinsol{\string\markboth{Solutions for Section \thesection}
+{Solutions for Section \thesection\string\enskip}}}
+ \@gtempa\endgroup}%
+% Following rewrites chapter to write heading in answer section
+ \let\ch@@@p=\chapter
+ \def\chapter{\ch@@@p\@nschap\s@lchap}
+ \def\@wrtail{
+\xdef\@gtempa{\putinans{%
+ \string\markboth{Solutions for section \thesection}
+{Solutions for section \thesection\string\enskip}}
+ \putinans{\putbreak}}
+ \@gtempa}
+ \def\@wrsoltail{
+\xdef\@gtempa{\putinsol{\string\markboth{Solutions for Section
+ \thesection}
+{Solutions for Section \thesection\string\enskip}}
+ \putinsol{\string\pagebreak[3]\string\medbreak\noindent}}
+ \@gtempa}}% end\bksec
+
+\def\once{%
+ \renewcommand{\exercises}{\setcounter{exercounter}{0}%
+ \ifanswerson\answerfalse\subanswerfalse\fi\@wrheader}
+ \def\anshead{\relax}
+ \def\@wrheader{\putinans{\string\typeout{Answers}}}
+ \def\@wrtail{\relax}
+ \ifsols{%
+\typeout{Sorry, you can't make a Solutions Manual in this style}
+\solsfalse}\fi}% end \once
+
diff --git a/macros/latex209/contrib/ans/ansdoc.dvi b/macros/latex209/contrib/ans/ansdoc.dvi
new file mode 100644
index 0000000000..67446e18ac
--- /dev/null
+++ b/macros/latex209/contrib/ans/ansdoc.dvi
Binary files differ
diff --git a/macros/latex209/contrib/ans/ansdoc.pdf b/macros/latex209/contrib/ans/ansdoc.pdf
new file mode 100644
index 0000000000..f263658acf
--- /dev/null
+++ b/macros/latex209/contrib/ans/ansdoc.pdf
Binary files differ
diff --git a/macros/latex209/contrib/ans/ansdoc.tex b/macros/latex209/contrib/ans/ansdoc.tex
new file mode 100644
index 0000000000..11faaa5c33
--- /dev/null
+++ b/macros/latex209/contrib/ans/ansdoc.tex
@@ -0,0 +1,490 @@
+\documentstyle[ans,11pt]{article}
+% \input smalbold
+\pagestyle{empty}
+\makeanswers\artsec
+\makesolutions
+\emergencystretch10pt
+\newcommand{\setpage}[1]{\setcounter{page}{#1}}
+
+% The following arcane code defines bkslsh to be a textmode
+% backslash. In \LaTeX, \backslash defines backslash for mathmode
+% but it doesn't look right in text mode.
+% This definition gives the right size backslash for any Computer
+% Modern size.
+{\catcode`|=0\catcode`\\=\other
+|def|bsl{{|tt\}}
+|catcode`\=0 \global\let\bkslsh=|bsl}
+
+\def\cmd#1{{\tt\bkslsh #1}}
+
+\title{Exercises and answers for \LaTeX
+\footnote{Copyright \copyright\number\year\ by Charles Frederick
+Wells}\\
+\normalsize Revision 25 February 1994}
+\author{Charles Wells \\ Department of Mathematics \\
+Case Western Reserve University \\ University Circle \\
+Cleveland, OH 44106-7058 \\ USA\\ {\tt cfw2@po.cwru.edu}}
+
+\begin{document}
+\maketitle
+
+\section{Description}\label{dessec}
+
+{\tt Ans.sty} is a \LaTeX\ style file.
+It allows you to write exercises and their answers together in a
+\LaTeX\ document. When composed, the answers will appear in a
+separate chapter or section elsewhere in the document (you
+determine where they appear).
+
+{\tt Ans.sty} allows several variations. In the current
+release, you can use {\tt article.sty} or style files derived
+from {\tt article.sty} and have exercises in a subsection at the end
+of each section; or you can use {\tt book.sty} and have
+exercises at the end of each section or at the end of each
+chapter. I hope to have a version that allows exercises
+interspersed throughout the document (as in The \TeX book) in a
+later version.
+
+This document is written using {\tt article.sty}. Below are
+some exercises. The ones that are marked with a dot have
+answers on page~\pageref{ansec}. Some of those not marked with
+a dot have answers in the booklet called ``Solutions to
+exercises not answered in text'' that is generated with
+this article.
+Later in the document
+you will find more elaborate exercises along with their source.
+
+\exercises
+
+\exera This the first exercise of section~\ref{dessec}.
+\answer{This is the answer to the first exercise of
+section~\ref{dessec}.}
+
+\exera This is the second exercise of section~\ref{dessec}.
+\answer This is the answer to the second exercise of
+section~\ref{dessec}.
+
+\exer This has an answer in the Solution Manual.
+\solution This is an answer in the Solution Manual.
+
+
+\eexer
+
+\section{Using ans.sty}\label{seca}
+
+\subsection{At the beginning of the document}
+
+The beginning of your document should look like this:
+
+\begin{verbatim}
+\documentstyle[ans]{article}
+\makeanswers\artsec %% Use \bkchap or \bksec in book style
+%% Other preamble commands you might want here
+\begin{document}
+\end{verbatim}
+If you want a booklet printed with answers to exercises not
+answered in the article, you should also put \cmd{makesolutions}
+in the preamble.
+
+\subsubsection{Options}
+One of the options commands
+must come after \cmd{makeanswers}. The options commands are
+\begin{description}
+\item[\cmd{artsec}] This is used in article style. It allows
+(no more than one) subsection of exercises in each section.
+\item[\cmd{artscattered}] {\bf Not currently implemented.}
+For article style. Allows exercises
+to be interspersed throughout the document, as in The \TeX book.
+\item[\cmd{once}]
+This must be used in article style and allows
+just one section of exercises for the whole document.
+See~\ref{once} below. You cannot make a solution manual in this
+style. The file {\tt onceexam.tex} contains an example of its
+use.
+\item[\cmd{bkchap}] Used with {\tt book.sty}, allowing one
+section of exercises per chapter.
+\item[\cmd{bksec}] Used with {\tt book.sty}, allowing one
+section of exercises per section.
+\item[\cmd{bkscattered}] {\bf Not currently implemented.}
+Like \cmd{artscattered} for
+{\tt book.sty}.
+\end{description}
+
+If you omit the \cmd{makeanswers}
+command, the document will
+compose without complaint but the answers won't appear at the
+end. This may be useful for draft purposes.
+
+If you include \cmd{makeanswers}, the option command is
+mandatory.
+If you omit it, you will get an error message the
+first time you include an exercise.
+
+\subsubsection{Using \protect\bkslsh once}\label{once}
+This option is for documents with just one section of exercises.
+It may be useful for class handouts whose answers are printed
+separately to be handed out later.
+
+It is used a little differently from the others.
+In the other options, \cmd{exercises} puts a section or
+subsection heading on each
+section of exercises and writes the appropriate heading for the
+answers to that set to the answer file. In this option,
+\cmd{exercises} does neither. You must write the title of the
+exercise section if you want one, and you must write the title
+of the answer section, putting in a page break and setting the
+page number to 1 if that is what you want. The document
+``onceexam.tex'' illustrates the use of the \cmd{once} option.
+
+% \subsubsection{Scattered exercises} I have no current plans to
+% implement \cmd{artscattered} and \cmd{bkscattered} because I
+% don't particularly like that style. I have some thoughts on it
+% for anyone who wants to try it: You could have an exercise
+% environment based on \cmd{newtheorem} (page 58 of Lamport's book
+% on \LaTeX) or you could make each exercise a subsection in book
+% style or a subsubsection in article style.
+
+\subsection{To print the answers}
+
+At the place in the document where you want the answers printed,
+put
+
+\begin{verbatim}
+\doanswers
+\end{verbatim}
+
+You can put this any place after the last
+batch of exercises.
+This will produce an unnumbered section
+titled ``Solutions'',
+followed by the solutions to the problems
+in each section. (The \cmd{once} option will not produce a
+section title, although it will print the answers.)
+When using {\tt book.sty}, the section of answers will be
+formatted as an unnumbered chapter, therefore starting on a new
+page. In {\tt article.sty},
+the answer section will not start on a new page.
+If you want it to, type
+\cmd{newpage} before \cmd{doanswers}. If you want the page
+numbers to start over, type
+
+\begin{verbatim}
+\newpage
+\setcounter{page}{1}
+\end{verbatim}
+
+You could then bind the answer section as a separate document.
+
+The command \cmd{dosolutions} prints the answers you wrote to
+exercises that are not marked as having answers. Normally, you
+would set the page counter to 1 as above
+before invoking \cmd{dosolutions}.
+This article does this, as you can see by examining the source
+code.
+
+
+\subsection{Entering the exercises}
+
+\subsubsection{The exercise header}
+A subsection with exercises begins with the command
+\cmd{exercises} and ends with \cmd{eexer}. If the subsection
+has only one exercise, you can use \cmd{exercise}.
+The word \cmd{exercises} produces a subsection in the same
+format as other subsections, headed with the word ``Exercises''.
+{\it There should be at most one exercise subsection for each
+section of the document}.
+
+\subsubsection{The exercises}
+Each exercise is preceded by the word \cmd{exer} if you are not
+going to answer it, and by \cmd{exera} if you are going to
+answer it. You can mix answered and unanswered exercises in any
+way you wish; the numbering will be correct in the answer
+section. Exercises with answers will be marked like
+this\answermark. You can change the answer mark by putting a
+command such as
+\cmd{\renewcommand\answermark{\mbox{$\mymark$}}}
+in the preamble.
+
+\subsubsection{The answers}\label{anss}
+{\bf Warning: The answers must be entered in exactly the way
+spelled out here. This aspect of {\tt ans.sty} is very
+user-unfriendly. Deviation will result in answers appearing in
+the text or part of the next problem appearing in the answer.}
+
+The answer should start immediately after the exercise without a
+blank line intervening, preceded
+by the word \cmd{answer}. You can type anything you want in the
+answer, subject to the following three
+requirements:{\bf\begin{itemize}
+\item The answer should start on the same line as the command
+\cmd{answer}.
+\item The answer should contain no
+blank lines.
+\item The answer should be followed by at least
+one blank line.
+\end{itemize}} If you want more than one
+paragraph in an answer, insert the command \cmd{par} at the end
+of each paragraph except the last.
+
+The reason for these requirements is that the program uses the
+blank line to delimit the answers (using an idea of Donald
+Knuth's).
+
+\subsubsection{Subexercises}
+
+To write an exercise with subexercises, start the exercise with
+\cmd{exer} or \cmd{exera}, and then introduce each subexercise
+with \cmd{subexer} or \cmd{subexera}. You can mix answered and
+nonanswered subexercises as you wish.
+
+If the exercise begins with a subexercise without any preceding
+text, it should begin
+``\cmd{exer}\cmd{immsubexer}'' (either may be followed by an
+``a'').
+The remaining subexercises are labeled \cmd{subexer} or
+\cmd{subexera} as before.
+The answer to a subexercise beginning with
+\cmd{immsubexer} should be labeled \cmd{immsubanswer}.
+The use of \cmd{immsubexer(a)} and \cmd{immsubanswer} keeps the
+spacing straight (although the current version, \today,
+still doesn't get
+the spacing right when the exercise has a double-digit number).
+
+I apologize for the necessity of using \cmd{immsubexer} and
+\cmd{immsubanswer}, but it seems quite complicated to create a
+version that knows whether the exercise has any beginning text
+or not.
+
+\subsubsection{Problems with special marks} To mark an exercise
+hard, type
+
+\begin{verbatim}
+\exer\annot{hard}
+\end{verbatim}
+
+In general, you can annotate a problem with any sort of remark
+in this way.
+
+\subsection{Error messages}
+If you type \cmd{exera} for an exercise but don't give it an
+answer, you will get an error message.
+Likewise if you give an
+exercise an answer but headed it with \cmd{exer}. Neither error
+stops the document from composing, and if you have given an
+exercise headed \cmd{exer} an answer, the answer will be printed
+in the correct place with the correct number, but the spacing in
+the exercise section may be wrong.
+
+If you use \cmd{exer(a)} when you should have used
+\cmd{immsubexer(a)} you will not get an error message; the
+spacing will merely be wrong.
+
+\subsection{Sample exercises}
+This section ends with a set of exercises illustrating all these
+points. The next section has a few, too, so you can see how the
+answer section handled the answers to different sections.
+
+The answers to this section were entered as illustrated below.
+If you removed the percent signs from
+in front of the exercises that are commented out and compose
+this document again, you can see how the error messages work.
+
+This example also illustrates the use of the \cmd{exhead}
+command, which allows you to insert instructions for doing the
+next several exercises.
+
+%%%RECOPY THIS!!!
+\begin{verbatim}
+
+\exercises
+\exera This the first exercise of section~\ref{seca}.
+\answer{This is the answer to the first exercise of
+section~\ref{seca}.}
+
+\exera This is the second exercise of section~\ref{seca}.
+\answer This is the answer to the second exercise of
+section~\ref{seca}.
+
+\exer This exercise has no answer.
+
+% \exera This exercise tests an error message.
+% It is marked to
+% have an answer, but does not.
+
+% \exer This exercise tests an error message too.
+% \answer This should not be here.
+
+\exhead{This header applies to Exercises~\ref{firste}
+through~\ref{laste}.}
+
+\exera\annot{hard}\label{firste} Yet another
+exercise with an answer.
+\answer This is yet another answer.
+It is longer than the
+others, and illustrates how you can
+have more than one
+paragraph.\par
+This is the second paragraph.
+
+\exer\annot{hard} This is an exercise with subexercises.
+\subexera First subexercise.
+\subanswer Answer to first subexercise.
+
+\subexer Second subexercise.
+
+\subexera Third subexercise.
+\subanswer Answer to third subexercise.
+
+\exer\label{laste}\immsubexera This
+is the first subexercise of an exercise
+that has no text before the subexercises.
+\immsubanswer This is an answer.
+
+\subexera Another subexercise.
+\subanswer Another answer.
+
+\exer\label{solans} This exercise has an answer
+in the Solution Manual.
+\solution Answer to Exercise~\ref{solans} on
+page~\pageref{solans}.
+
+\eexer
+\end{verbatim}
+
+
+
+\exercises
+\exera This the first exercise of section\ref{seca}.
+\answer{This is the answer to the first exercise of
+section~\ref{seca}.}
+
+\exera This is the second exercise of section~\ref{seca}.
+\answer This is the answer to the second exercise of
+section~\ref{seca}.
+
+\exer This exercise has no answer.
+
+% \exera This exercise tests an error message.
+% It is marked to
+% have an answer, but does not.
+
+% \exer This exercise tests an error message too.
+% \answer This should not be here.
+
+\exhead{This header applies to Exercises~\ref{firste}
+through~\ref{laste}.}
+
+\exera\annot{hard}\label{firste} Yet another
+exercise with an answer.
+\answer This is yet another answer.
+It is longer than the
+others, and illustrates how you can
+have more than one
+paragraph.\par
+This is the second paragraph.
+
+\exer\annot{hard} This is an exercise with subexercises.
+\subexera First subexercise.
+\subanswer Answer to first subexercise.
+
+\subexer Second subexercise.
+
+\subexera Third subexercise.
+\subanswer Answer to third subexercise.
+
+\exer\label{laste}\immsubexera This
+is the first subexercise of an exercise
+that has no text before the subexercises.
+\immsubanswer This is an answer.
+
+\subexera Another subexercise.
+\subanswer Another answer.
+
+\exer\label{solans} This exercise has an answer
+in the Solution Manual.
+\solution Answer to Exercise~\ref{solans} on
+page~\pageref{solans}.
+
+\eexer
+
+\section{Bugs}\label{probsec}
+
+\subsection{Answers appearing in the text\protect\\ or text appearing in
+the answers}
+If you enter an exercise and answer like this
+\begin{verbatim}
+\exera This is an exercise.
+\answer
+I did this wrong.
+\end{verbatim}
+the answer will
+appear in the text instead of in the answer section. The point
+is that the answer must start on the same line as the word
+\cmd{answer}.
+
+If you do this
+\begin{verbatim}
+\exera This is an exercise.
+\answer I did this wrong too.
+\exera This exercise will disappear.
+\answer Here is an answer.
+\end{verbatim}
+the second exercise will wind up as part of the answer to the
+first exercise, because a blank line must follow the answer.
+Reread Section~\ref{anss} carefully.
+
+
+\subsection{Spaces between carriage returns}
+Most text editors allow you to type return
+(``enter'' on some computers), one or more spaces, then return.
+\TeX\ {\it will not interpret the result as a blank line} for
+the purposes of ending answers. The file has to contain two
+returns in a row without any intervening spaces. If in your
+printout you discover than an answer has swallowed the following
+exercise (or more), this may be the reason. Blanks are inserted
+between returns by some word processors or editors, and
+sometimes (apparently) by e-mail systems.
+
+Many text editors allow you to detect blanks because the cursor
+changes shape on a blank. Your editor may allow you to search
+for the sequence carriage return, blank(s), carriage return, and
+change such sequences globally to carriage return, carriage
+return.
+
+\section{Customizing} If you look in the file {\tt
+ans.sty},
+you will discover numerous hints for customizing the file.
+
+\subsection{Headings}
+The headings put on the answer section and on the solutions
+booklet are determined by the option, \cmd{artsec},
+\cmd{bkchap}, etc. and can easily be changed.
+
+\subsection{Other style files}
+{\tt Ans.sty} will very likely work with many other style files
+besides the standard {\tt art\-icle.sty}, but of course I can't
+guarantee this. Since \cmd{exersection} uses \cmd{subsection},
+a different style file with a different definition of subsection
+will place the exercise header in the same style as the other
+subsections.
+
+\exercises
+
+\exera Prove that for any integer $n>2$ there are no nonzero
+integers $x$, $y$ and $z$ for which $x^n+y^n=z^n$.
+\answer If I knew how to do \cmd{marginpar} in \LaTeX\ I would
+have written it in the margin. But that's the way the cookie
+crumbles.
+
+\exer An exercise without an answer.
+
+\exera The very last exercise.
+\answer The very last answer.
+
+\doanswers
+
+\setpage{1}
+\dosolutions
+
+\end{document}
+
diff --git a/macros/latex209/contrib/ans/ansread.me b/macros/latex209/contrib/ans/ansread.me
new file mode 100644
index 0000000000..229d8c1eb3
--- /dev/null
+++ b/macros/latex209/contrib/ans/ansread.me
@@ -0,0 +1,4 @@
+The file ans.sty provides a mechanism for writing exercises with
+answers, with the answers being printed later in the document.
+Its use is explained in ansdoc.tex, and onceexam.tex is an
+example of using one of the options in ans.sty.
diff --git a/macros/latex209/contrib/ans/onceexam.tex b/macros/latex209/contrib/ans/onceexam.tex
new file mode 100644
index 0000000000..bcf28f9034
--- /dev/null
+++ b/macros/latex209/contrib/ans/onceexam.tex
@@ -0,0 +1,46 @@
+\documentstyle[ans]{article}
+\pagestyle{empty}
+\makeanswers\once
+\emergencystretch10pt
+
+% The following arcane code defines bkslsh to be a textmode
+% backslash. In \LaTeX, \backslash defines backslash for mathmode
+% but it doesn't look right in text mode.
+% This definition gives the right size backslash for any Computer
+% Modern size.
+{\catcode`|=0\catcode`\\=\other
+|def|bsl{{|tt\}}
+|catcode`\=0 \global\let\bkslsh=|bsl}
+
+\def\cmd#1{{\tt\bkslsh #1}}
+
+\begin{document}
+\begin{center}{\LARGE\bf Example of Class Handout}\end{center}
+
+\section*{Sample Problems}
+
+Here are some sample exercises. The answers are on
+the back of the page. (Or: The answers will be handed out
+later.)
+\medbreak
+
+\exercises
+
+\exera Prove that for any integer $n\geq 3$ there are no nonzero
+integers $x$, $y$ and $z$ for which $x^n+y^n=z^n$.
+\answer If I knew how to do \cmd{marginpar} in \LaTeX\ I would
+have written it in the margin. But that's the way the cookie
+crumbles.
+
+\exer An exercise without an answer.
+
+\exera The very last exercise.
+\answer The very last answer.
+
+\pagebreak
+\setcounter{page}{1}
+\section*{Answers to the exercises}
+\doanswers
+\end{document}
+
+