summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/exercise/exercise.sty
blob: da42657713c2e11490e54c833aecd5d2ab8a31aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%% 
%% This is file `exercise.sty' generated
%% on <1991/12/4> with the docstrip utility (v1.1l test). 
%% 
%% The original source file was `exercise.doc'.
%% 
%% 
%% Copyright (C) 1991 by Anselm Lingnau. All rights reserved. 
%% 
%% IMPORTANT NOTICE: 
%% 
%% You are not allowed to change this file. You may however copy this file 
%% to a different name and then change this copy. 
%% 
%% You are allowed to distribute this file under the condition that it is 
%% distributed together with all files mentioned in the appropriate README 
%% file. If you received only some of these files from someone, complain! 
%% 
%% You are NOT ALLOWED to distribute this file alone. You are NOT ALLOWED 
%% to take money for the distribution or use of this file (or a changed 
%% version) except for some nominal charge for copying etc. 
%% 
%% Error Reports in case of UNCHANGED versions to 
%% 
%% Anselm Lingnau 
%% Buchenweg 1 
%% D-6239 Eppstein 2 
%% Federal Republic of Germany 
%% Internet: <lingnau@informatik.uni-frankfurt.de> 
%% 
\def\fileversion{v1.0c}
\def\filedate{91/10/08}
\def\docdate{91/10/08}

%% \CheckSum{139}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%% Style-option `exercise' to use with LaTeX v2.09
%% Copyright (C) 1991 by Anselm Lingnau, all rights reserved.
\@ifundefined{exercise}{}{\endinput}
\wlog{Style-Option: `exercise'
   \fileversion \space <\filedate>  (AL)}
\wlog{English Documentation
   \@spaces \@spaces \space <\docdate>  (AL)}
\newcounter{exercise}
\newif\if@exnofixed
\def\numberexercises#1{%
  \if@exnofixed\@warning{Exercise numbering already fixed}
  \else\@addtoreset{exercise}{#1}%
     \renewcommand{\theexercise}{\csname
        the#1\endcsname--\arabic{exercise}}\fi
  \@exnofixedtrue}
\def\exercisehead#1#2{\def\exercise@head{#1{\theexercise}#2}}
\exercisehead{\bf}{}
\def\exenvname{exercise}
\def\exercise{\medbreak\@exnofixedtrue
     \refstepcounter{exercise}\trivlist\item[]{\exercise@head}}
\def\endexercise{\endtrivlist}
\def\answer{%
  \ifx\@currenvir\exenvname\let\next\@answer
    \else\let\next\@answererr\fi\next}
\def\@answererr{\errhelp{There may be no unmatched `\begin' between
     the^^J`\begin{exercise}' and `\answer'.}%
    \errmessage{LaTeX error: Wrong \string\answer\space (current
      environment is `\@currenvir')}%
    \edef\@tempa{{\@currenvir}} \expandafter\end\@tempa \answer}
\def\@answer{%
   \immediate\write\ans{\string\ansno{\theexercise}}
  \let\do\@makeother\dospecials \catcode`\^^M\active
  \let\verbatim@processline=\answer@processline
  \verbatim@start}
\def\answer@processline{\immediate\write\ans{\the\verbatim@line}}
\def\exercisetitle{Exercises}
\@ifundefined{chapter}{\let\exsection\subsection}%
    {\let\exsection\section}
\newenvironment{exercises}{\exsection*{\exercisetitle}}{}
\newwrite\ans
\immediate\openout\ans=\jobname.ans
\typeout{Writing answers to \jobname.ans.}
\def\listanswers{\immediate\closeout\ans \input\jobname.ans\relax}
\def\ansno#1{\par{\def\theexercise{#1}\exercise@head}}
\endinput
%% 
%% End of file `exercise.sty'.