| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2003-2006 by Paul Pichaureau |
| 4 |
% |
| 5 |
% This program is free software; you can redistribute it and/or |
| 6 |
% modify it under the terms of the GNU General Public License |
| 7 |
% as published by the Free Software Foundation; either version 2 |
| 8 |
% of the License, or (at your option) any later version. |
| 9 |
% |
| 10 |
% This program is distributed in the hope that it will be useful, |
| 11 |
% but without any warranty; without even the implied warranty of |
| 12 |
% merchantability or fitness for a particular purpose. See the |
| 13 |
% GNU General Public License for more details. |
| 14 |
% |
| 15 |
% You should have received a copy of the GNU General Public License |
| 16 |
% along with this program; if not, write to the Free Software |
| 17 |
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
% Public LaTeX Project Public |
| 19 |
% |
| 20 |
% \fi |
| 21 |
% \iffalse |
| 22 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 23 |
%<package>\ProvidesPackage{exercise} |
| 24 |
%<package> [2014/10/20 v1.6 Exercise package (P.Pichaureau)] |
| 25 |
%<*driver> |
| 26 |
\documentclass{ltxdoc} |
| 27 |
\usepackage{exercise} |
| 28 |
\usepackage[latin1]{inputenc} |
| 29 |
\usepackage{xspace,fancyvrb} |
| 30 |
\usepackage{hyperref} |
| 31 |
%% \IfFileExists{hyperref.sty}{\usepackage[bookmarksopen]{hyperref}}{} |
| 32 |
%% \def\PrintDescribeMacro#1{} |
| 33 |
%% \def\PrintDescribeEnv#1{} |
| 34 |
\newenvironment{decl}[1][]% |
| 35 |
{\par\small\addvspace{4.5ex plus 1ex}% |
| 36 |
\vskip -\parskip |
| 37 |
\ifx\relax#1\relax |
| 38 |
\def\@decl@date{}% |
| 39 |
\else |
| 40 |
\def\@decl@date{\NEWfeature{#1}}% |
| 41 |
\fi |
| 42 |
\noindent\hspace{-\leftmargini}% |
| 43 |
\begin{tabular}{|l|}\hline\ignorespaces}% |
| 44 |
{\\\hline\end{tabular}\nobreak\@decl@date\par\nobreak |
| 45 |
\vspace{2.3ex}\vskip -\parskip} |
| 46 |
\makeatletter |
| 47 |
\EnableCrossrefs \PageIndex |
| 48 |
\makeatother |
| 49 |
\begin{document} |
| 50 |
\DocInput{exercise.dtx} |
| 51 |
\end{document} |
| 52 |
%</driver> |
| 53 |
% \fi |
| 54 |
%% \CharacterTable |
| 55 |
%% {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 |
| 56 |
%% 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 |
| 57 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 58 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 59 |
%% Dollar \$ Percent \% Ampersand \& |
| 60 |
%% Acute accent \' Left paren \( Right paren \) |
| 61 |
%% Asterisk \* Plus \+ Comma \, |
| 62 |
%% Minus \- Point \. Solidus \/ |
| 63 |
%% Colon \: Semicolon \; Less than \< |
| 64 |
%% Equals \= Greater than \> Question mark \? |
| 65 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 66 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 67 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 68 |
%% Right brace \} Tilde \~} |
| 69 |
%% |
| 70 |
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ } |
| 71 |
% \DoNotIndex{\@ne,\@auxout,\@ifnextchar,\@ifstar,\@ifundefined,\@bsphack,\@esphack,\@fleqnfalse} |
| 72 |
% \DoNotIndex{\advance,\begingroup,\begin,\bgroup,\catcode,\closein,\closeout} |
| 73 |
% \DoNotIndex{\day,\def,\edef,\else,\empty,\endgroup,\end,\egroup,\errmessage} |
| 74 |
% \DoNotIndex{\expandafter,\fi,\futurelet,\gdef,\global,\if,\ifeof} |
| 75 |
% \DoNotIndex{\ifx,\immediate,\let,\loop,\m@ne,\message,\month} |
| 76 |
% \DoNotIndex{\newcount} |
| 77 |
% \DoNotIndex{\newif,\newlinechar,\newread,\newtoks,\newwrite} |
| 78 |
% \DoNotIndex{\noexpand,\openin,\openout,\par,\quad,\read,\relax,\repeat} |
| 79 |
% \DoNotIndex{\space,\the,\undefined,\write,\xdef,\year,\z@} |
| 80 |
% \DoNotIndex{\item,\copy,\arabic,\addto,\addtolength,\alph} |
| 81 |
% \DoNotIndex{\ref,\Roman,\rmdefault,\or,\number,\medskip,\makebox} |
| 82 |
% \DoNotIndex{\fbox,\label,\ifcase,\ifnum,\ignorespaces,\newcommand} |
| 83 |
% \DoNotIndex{\renewenvironment,\renewcommand,\refstepcounter,\newenvironment} |
| 84 |
% \DoNotIndex{\setlength,\string,\textbf,\textsc,\emph,\whiledo,\vbox} |
| 85 |
% \DoNotIndex{\unvbox,\usefont,\usecounter,\value,\vskip,\setbox,\setcounter} |
| 86 |
% |
| 87 |
%\CheckSum{2004} |
| 88 |
% |
| 89 |
% |
| 90 |
% \GetFileInfo{exercise.sty} |
| 91 |
% |
| 92 |
% \makeatletter |
| 93 |
% \IndexPrologue{\section*{Index}% |
| 94 |
% \markboth{Index}{Index}% |
| 95 |
% For entries in type-writer font, numbers written in italic |
| 96 |
% refer to the page where the corresponding entry is |
| 97 |
% described; numbers underlined refer to the |
| 98 |
% \ifcodeline@index code line of the \fi definition; |
| 99 |
% numbers in roman refer to the \ifcodeline@index code |
| 100 |
% lines \else pages \fi where the entry is used. } |
| 101 |
% \makeatother |
| 102 |
%\title{\texttt{exercise.sty} : a package to typeset exercises} |
| 103 |
% |
| 104 |
%\date{\today} |
| 105 |
% |
| 106 |
%\author{Paul Pichaureau\\ \texttt{[email protected]}} |
| 107 |
% |
| 108 |
%\maketitle |
| 109 |
% |
| 110 |
%\begin{abstract} |
| 111 |
% This package offers a simple environment to typeset exercises, |
| 112 |
% and their questions, sub-questions, indications, answers and so |
| 113 |
% on. |
| 114 |
% |
| 115 |
% The layout of the exercises is fully customisable. Moreover, the |
| 116 |
% answers of the exercise could be typeset immediately or |
| 117 |
% later in the document. |
| 118 |
%\end{abstract} |
| 119 |
% |
| 120 |
% \tableofcontents |
| 121 |
%\section{Options of the package} |
| 122 |
% |
| 123 |
%\index{package>options}\index{options>of the package} |
| 124 |
% |
| 125 |
%Here we list the options of the package |exercise.sty|: |
| 126 |
% |
| 127 |
%\begin{description} |
| 128 |
% \item[|noexercise|] hide all the exercises |
| 129 |
% of a document. |
| 130 |
% |
| 131 |
% \item[|noanswer|] hide all the answers |
| 132 |
% of a document. The default behaviour is to show both the exercises |
| 133 |
% and the answers. |
| 134 |
% |
| 135 |
% |
| 136 |
% \item[|exerciseonly|] is a synonym of |noanswer|. |
| 137 |
% |
| 138 |
% \item[|answeronly|] is a synonym of |noexercise|. |
| 139 |
% |
| 140 |
% \item[|nothing|] hide answers and exercises (synonym of |
| 141 |
% |noanswer| and |noexercise|). |
| 142 |
% |
| 143 |
% \item[|answerdelayed|] save the answers instead of typeset |
| 144 |
% them. The answers can be included later in the document with the |
| 145 |
% command |\shipoutAnswer|. |
| 146 |
% |
| 147 |
% More precisely, the answers are stored |
| 148 |
% in a vertical box. When |\shipoutAnswer| is encountered, this box |
| 149 |
% is emptied and its contents is placed in the main vertical |
| 150 |
% list. The answers defined later are placed in this emptied |
| 151 |
% vertical box. In this way, you can have many group of answers in |
| 152 |
% the same document. |
| 153 |
% |
| 154 |
% \item[|exercisedelayed|] saves the exercises instead of |
| 155 |
% typeset them. The exercises can be included later with the command |
| 156 |
% |\shipoutExercise|. |
| 157 |
% |
| 158 |
% \item [|lastexercise|] if no references is given for an |
| 159 |
% answer, then the answer is supposed to refer to the last |
| 160 |
% exercise (see section \ref{sec:lastexercise}). |
| 161 |
% |
| 162 |
%\end{description} |
| 163 |
% |
| 164 |
% |
| 165 |
%\section{Commands} |
| 166 |
% |
| 167 |
%\label{sec:option} |
| 168 |
% |
| 169 |
%\subsection{Exercises and answers} |
| 170 |
% |
| 171 |
% |
| 172 |
%\begin{decl} |
| 173 |
% |\begin{Exercise}| \oarg{key val list} ... |\end{Exercise}| \\ |
| 174 |
% |\begin{Exercise*}| \oarg{key val list} ... |\end{Exercise*}| |
| 175 |
%\end{decl} |
| 176 |
% |
| 177 |
%\DescribeEnv{Exercise}\DescribeEnv{Exercise*} |
| 178 |
%The |Exercise| environment is used to typeset just one exercise. We |
| 179 |
%use the \textsf{keyval} package to give different informations about |
| 180 |
%an exercise. |
| 181 |
% |
| 182 |
%The |Exercise*| environment typeset an exercise without number, and |
| 183 |
% without puting it in the |listofexercices|. |
| 184 |
% |
| 185 |
%\vspace*{-\baselineskip} |
| 186 |
% |
| 187 |
%\index{options>of \texttt{Exercise}} |
| 188 |
%\index{keys>of \texttt{Exercise}} |
| 189 |
%\begin{decl} |
| 190 |
%|label|=\marg{string}\\ |
| 191 |
%|title|=\marg{string}\\ |
| 192 |
%|difficulty|=\marg{number}\\ |
| 193 |
%|origin|=\marg{string}\\ |
| 194 |
%|name|=\marg{string}\\ |
| 195 |
%|counter|=\marg{counter}\\ |
| 196 |
%|number|=\marg{string} |
| 197 |
%|exam|=\marg{string} |
| 198 |
%|year|=\marg{string} |
| 199 |
%\end{decl} |
| 200 |
%All these keys define commands that will be available later to typeset |
| 201 |
%the exercise. They are all optional. |
| 202 |
%\begin{description} |
| 203 |
% \item[|label|] The label of the exercise. This label can be |
| 204 |
% used later in cross-reference, or to link an answer to this |
| 205 |
% exercise. |
| 206 |
% \item[|title|] The title of the exercise. It will be available |
| 207 |
% later with the command |\ExerciseTitle|. |
| 208 |
% \item[|difficulty|] The difficulty of the exercise (a number). |
| 209 |
% It will be available later with the counter |
| 210 |
% |\ExerciseDifficulty|. |
| 211 |
% \item[|origin|] The origin of the exercise. |
| 212 |
% It will be available later with the command |\ExerciseOrigin|. |
| 213 |
% \item[|name|] In document, exercises can have multiple |
| 214 |
% denomination, like problem, exam, or even question. This key |
| 215 |
% allows to change the denomination. This denomination is accessible |
| 216 |
% with the command |\ExerciseName|. |
| 217 |
% \item[|counter|] Use the given counter to number this |
| 218 |
% exercise. Here, \marg{counter} must be a pre-defined counter. |
| 219 |
% \item[|number|] Use the given number for the exercise. In |
| 220 |
% fact, this number is a string, so you can number the exercise |
| 221 |
% with letters. |
| 222 |
% \item[|exam|] To keep track of exams associated with the exercise. |
| 223 |
% \item[|year|] To keep track of the year you have given the |
| 224 |
% exercise. |
| 225 |
%\end{description} |
| 226 |
% |
| 227 |
%\bigskip[1] |
| 228 |
% |
| 229 |
%As an example, with the default definitions, the following code: |
| 230 |
%\medskip |
| 231 |
%\begin{verbatim} |
| 232 |
%\begin{Exercise}[title={Euler's constant}, difficulty=2, label=ex1, |
| 233 |
% origin={P.Paelw}] |
| 234 |
%\end{Exercise} |
| 235 |
%\end{verbatim} |
| 236 |
%\noindent will give \par \medskip |
| 237 |
%\index{example} |
| 238 |
%\noindent \fbox{\begin{minipage}[t]{.95\textwidth} |
| 239 |
%\begin{Exercise}[title={Euler's constant}, difficulty=2, label=ex1, |
| 240 |
% origin={P.Paelw}] |
| 241 |
%\end{Exercise} |
| 242 |
%\end{minipage}} |
| 243 |
% |
| 244 |
%\DescribeEnv{Problem} |
| 245 |
%It is possible to define different type of exercise. For example, |
| 246 |
%you can define a |Problem| environment with the two lines: |
| 247 |
%\begin{verbatim} |
| 248 |
% \newcounter{Problem} |
| 249 |
% \newenvironment{Problem}{\begin{Exercise}[name={Problem}, |
| 250 |
% counter={Problem}]} |
| 251 |
% {\end{Exercise}} |
| 252 |
%\end{verbatim} |
| 253 |
%Anyway, all type of exercise will have the same layout in the document. |
| 254 |
% |
| 255 |
%\begin{decl} |
| 256 |
% |\begin{Answer}| \oarg{key val list} ... |\end{Answer}| |
| 257 |
%\end{decl} |
| 258 |
% |
| 259 |
%\DescribeEnv{Answer} |
| 260 |
%The |Answer| environment is used to typeset the answer of an |
| 261 |
%exercise. To determine to which exercise this answer is attributed |
| 262 |
%to, you can use the two following keys. |
| 263 |
% |
| 264 |
%\vspace*{-\baselineskip} |
| 265 |
%\index{options>of \texttt{Answer}} |
| 266 |
%\index{keys>of \texttt{Answer}} |
| 267 |
%\begin{decl} |
| 268 |
%|ref|=\marg{string}\\ |
| 269 |
%|number|=\marg{string} |
| 270 |
%\end{decl} |
| 271 |
%\begin{description} |
| 272 |
% \item[|ref|] a \LaTeX\ reference. \emph{Must} correspond to the |label| |
| 273 |
% key of an exercise. |
| 274 |
% \item[|number|] if the answer refers to an exercise in |
| 275 |
% another document, you can set the number of the exercise with this |
| 276 |
% key. It is in fact a string. |
| 277 |
%\end{description} |
| 278 |
% |
| 279 |
%\label{sec:lastexercise} If the package is loaded with the option |
| 280 |
% |lastexercise| and if no |ref| and no |number| key is given, then |
| 281 |
% the last exercise is taken as a reference for the answer. |
| 282 |
% |
| 283 |
%If no |ref| and no |number| key is given and the option |lastexercise| |
| 284 |
%is not activated, a Package Warning is displayed. |
| 285 |
% |
| 286 |
%\begin{decl} |
| 287 |
% |\begin{ExerciseList}| \\ |
| 288 |
% \quad |\Exercise|\oarg{key val list} \\ |
| 289 |
% \quad |\Answer|\oarg{key val list} \\ |
| 290 |
% |\end{ExerciseList}| |
| 291 |
%\end{decl} |
| 292 |
% |
| 293 |
%\DescribeEnv{ExerciseList} |
| 294 |
%The |ExerciseList| environment is a convenience to typeset a list of |
| 295 |
%small exercises. In |ExerciseList|, everything between two |\Exercise| |
| 296 |
%or |\Answer| tags is interpreted as the body of an exercise (or an |
| 297 |
%answer). |
| 298 |
% |
| 299 |
%\DescribeMacro{\Exercise} |
| 300 |
%\DescribeMacro{\Exercise*} |
| 301 |
%\DescribeMacro{\Answer} |
| 302 |
%The command |\Exercise| inside |ExerciseList| accepts the same keys |
| 303 |
%than the |Exercise| environment. The command |\Answer| inside |
| 304 |
%|ExerciseList| accepts the same keys than the |Answer| environment and |
| 305 |
%behaves in the same way. |
| 306 |
% |
| 307 |
%\subsection{Parts and questions} |
| 308 |
% |
| 309 |
%\begin{decl} |
| 310 |
% |\ExePart|\oarg{key val list} \\ |
| 311 |
% |\ExePart*|\oarg{key val list} |
| 312 |
%\end{decl} |
| 313 |
%\DescribeMacro{\ExePart} |
| 314 |
%\DescribeMacro{\ExePart*} |
| 315 |
%It is common to split large exercise in parts: it is the purpose of |
| 316 |
%the |\ExePart| command. |
| 317 |
%\index{options>of \texttt{\bslash ExePart}} |
| 318 |
%\index{keys>of \texttt{\bslash ExePart}} |
| 319 |
%The keys |title|, |name| and |difficulty| are |
| 320 |
%available for this command. |
| 321 |
% |
| 322 |
%For example, a non-numbered preliminary part is obtained with |
| 323 |
%\begin{verbatim} |
| 324 |
% \ExePart*[name={Preliminary}] |
| 325 |
%\end{verbatim} |
| 326 |
% |
| 327 |
%\begin{decl} |
| 328 |
% |\Question|\oarg{key val list}\\ |
| 329 |
% |\subQuestion|\oarg{key val list}\\ |
| 330 |
% |\subsubQuestion|\oarg{key val list} |
| 331 |
%\end{decl} |
| 332 |
%\DescribeMacro{\Question} |
| 333 |
%\DescribeMacro{\subQuestion} |
| 334 |
%\DescribeMacro{\subsubQuestion} |
| 335 |
%These three commands define the hierarchy of questions. A |
| 336 |
%|\subsubQuestion| cannot be preceded by a |\Question| or a |
| 337 |
%|\begin{Exercise}|. A |\subQuestion| cannot be preceded by a |
| 338 |
% |\begin{Exercise}|. If one of these cases is detected, a Package |
| 339 |
% Error is displayed. |
| 340 |
% |
| 341 |
%\index{options>of \texttt{\bslash Question}} |
| 342 |
%\index{keys>of \texttt{\bslash Question}} |
| 343 |
%\index{options>of \texttt{\bslash subQuestion}} |
| 344 |
%\index{keys>of \texttt{\bslash subQuestion}} |
| 345 |
%\index{options>of \texttt{\bslash subsubQuestion}} |
| 346 |
%\index{keys>of \texttt{\bslash subsubQuestion}} |
| 347 |
%Two keys are available for these commands: |title| and |difficulty|. |
| 348 |
% |
| 349 |
%\begin{decl} |
| 350 |
% |\ExeText| |
| 351 |
%\end{decl} |
| 352 |
%\DescribeMacro{\ExeText} |
| 353 |
%The text following this command has the same status that the first |
| 354 |
%indications of the exercise. So, the next level of the hierarchy must |
| 355 |
%be a |\ExePart| or a |\Question|. |
| 356 |
% |
| 357 |
% |
| 358 |
% |
| 359 |
%\subsection{Exercise selection} |
| 360 |
%\begin{decl} |
| 361 |
% |\ExerciseSelect|\oarg{key val list}\\ |
| 362 |
% |\ExerciseSelect*|\oarg{key val list}\\ |
| 363 |
% |\ExerciseStopSelect| |
| 364 |
%\end{decl} |
| 365 |
%\DescribeMacro{\ExerciseSelect} |
| 366 |
%\DescribeMacro{\ExerciseStopSelect} |
| 367 |
% |
| 368 |
% A very basic exercise selection mechanism is provided. When |
| 369 |
% |\ExerciseSelect| is used, an exercise is printed if and only |
| 370 |
% if the value of its keys are within the values specified after |
| 371 |
% |\ExerciseSelect|. For example, the following command |
| 372 |
%\begin{verbatim} |
| 373 |
% \ExerciseSelect[type={short}, difficulty={0,1}] |
| 374 |
%\end{verbatim} |
| 375 |
%selects the short exercises of difficulties 0 and 1, whereas |
| 376 |
%\begin{verbatim} |
| 377 |
% \ExerciseSelect[label={exe1,exe10,exe11}] |
| 378 |
%\end{verbatim} |
| 379 |
%selects the exercises with label |exe1|, |exe10| and |exe11|. It is important |
| 380 |
%to \emph{not} have spaces before or after the commas. |
| 381 |
% |
| 382 |
%With |\ExerciseStartSelect*|, the exercises which fit the conditions |
| 383 |
%are \emph{omited} instead of selected. |
| 384 |
% |
| 385 |
%Last, |\ExerciseStopSelect| stops the processus of selection: every |
| 386 |
%exercise will be displayed later. |
| 387 |
% |
| 388 |
%The purpose of these commands is to select exercises within a long list |
| 389 |
%stored on an auxiliary file. |
| 390 |
% |
| 391 |
%\subsection{References} |
| 392 |
% |
| 393 |
%If you want to make a cross-reference to an exercise, you must use |
| 394 |
%the |label| key of the |Exercise| command. Afterward, you can use the |
| 395 |
%usual \LaTeX commands |\ref|, |\pageref| and so on. |
| 396 |
% |
| 397 |
%The |hyperref| package should work normaly, but you must load it |
| 398 |
%\emph{before} the |exercise| package. |
| 399 |
% |
| 400 |
%\begin{decl} |
| 401 |
% |\refAnswer|\marg{label} |
| 402 |
%\end{decl} |
| 403 |
%\DescribeMacro{\refAnswer} Whenever an answer is connected to an |
| 404 |
%exercise \emph{via} the |ref| key, a label \emph{Exercise |
| 405 |
%label}|-Answer| is created. In this way, you can easily make |
| 406 |
%reference to a given exercise. |
| 407 |
% |
| 408 |
%The |\refAnswer| command is another way to reference the answer of a |
| 409 |
%given exercise : its argument is the label of an exercise without the |
| 410 |
%postfix |-Answer|. |
| 411 |
% |
| 412 |
%In this way |
| 413 |
%\begin{verbatim} |
| 414 |
% \ref{ex1-Answer} \refAnswer{ex1} |
| 415 |
%\end{verbatim} |
| 416 |
%are two equivalent ways to reference the answer of the preceding |
| 417 |
%exercise labeled~|ex1|. |
| 418 |
% |
| 419 |
%Remember that inside an |Exercise| the command |\ExerciseLabel| |
| 420 |
%stores the label of the exercise. So another way to reference the |
| 421 |
%exercise \emph{inside} is own code is |
| 422 |
%\begin{verbatim} |
| 423 |
% \ref{\ExerciseLabel} |
| 424 |
%\end{verbatim} |
| 425 |
% |
| 426 |
%\subsection{Extra stuff} |
| 427 |
%\DescribeMacro{\marker} |
| 428 |
%\DescribeMacro{\DifficultyMarker} |
| 429 |
%The difficulty of an exercise is represented by a certain amount of |
| 430 |
%stars. The command |\marker| is used to typeset the difficulty of an |
| 431 |
%exercise. |
| 432 |
%\begin{verbatim} |
| 433 |
% \marker<symbol><counter> |
| 434 |
%\end{verbatim} |
| 435 |
%displays |<symbol>| repeated |<counter>| times. For example |\marker*2| |
| 436 |
% gives **, and |\marker+{14}| gives ++++++++++++++ |
| 437 |
% |
| 438 |
%By default, the difficulty is symbolized by star. You can customise |
| 439 |
%this by redefining the command |\DifficultyMarker|. |
| 440 |
% |
| 441 |
%\bigskip |
| 442 |
%\changes{v1.3}{2009/03/26}{Added the 'listofexercices' features.} |
| 443 |
%\DescribeMacro{\listofexercises} |
| 444 |
%This command add a list of all the exercise in your document. |
| 445 |
% |
| 446 |
%\begin{decl} |
| 447 |
% |\ListOfExerciseInToc|\\ |
| 448 |
% |\ExerciseLevelInToc|\marg{level of exercices} |
| 449 |
%\end{decl} |
| 450 |
%\DescribeMacro{\ListOfExerciseInToc} |
| 451 |
%\DescribeMacro{\ExerciseLevelInToc} |
| 452 |
%If you prefer to display this list of exercises in the table of |
| 453 |
%contents, then use the command |\ListOfExerciseInToc|. |
| 454 |
% |
| 455 |
%By default, the exercises appear in the table of content at the same |
| 456 |
% level as the paragraphs. The command |\ExerciseLevelInToc| is used |
| 457 |
% to customize this behaviour. For example with the command |
| 458 |
% |\ExerciseLevelInToc{subsection}| the exercises will appear at the |
| 459 |
% same level as the subsctions. Avalaible levels are: section, |
| 460 |
% subsection, subsubsection, paragraph and subparagraph. |
| 461 |
% |
| 462 |
%\section{Customisation} |
| 463 |
% |
| 464 |
%\label{sec:custom} |
| 465 |
% |
| 466 |
%\subsection{Internationalisation} |
| 467 |
% |
| 468 |
%\begin{decl} |
| 469 |
%|\ExerciseName|\\ |
| 470 |
%|\ExerciseListName|\\ |
| 471 |
%|\AnswerName|\\ |
| 472 |
%|\AnswerListName|\\ |
| 473 |
%|\ExePartName|% |
| 474 |
%\end{decl} |
| 475 |
%\DescribeMacro{\ExerciseName} |
| 476 |
%\DescribeMacro{\ExerciseListName} |
| 477 |
%\DescribeMacro{\AnswerName} |
| 478 |
%\DescribeMacro{\AnswerListName} |
| 479 |
%\DescribeMacro{\ExePartName} |
| 480 |
%\DescribeMacro{\ExePartListName} |
| 481 |
%These commands store various hard-wired string. |\ExerciseListName| |
| 482 |
%is used in the |ExerciseList| environment: it is possibly an |
| 483 |
%abbreviation of the word ``Exercise". |
| 484 |
% |
| 485 |
%\textsf{Exercise.sty} automatically detects the usage of |
| 486 |
% \textsf{babel} and translate these terms in the language loaded... |
| 487 |
% if I (the author) know the translation! |
| 488 |
% |
| 489 |
% By now, and thanks to many contributors, english, french, spanish, |
| 490 |
% italian, dutch, german, portugese and russian are supported. |
| 491 |
% |
| 492 |
%If you sent me the translations in your language, I will be happy to |
| 493 |
%add them in the package. Anyway, you can redefine these |
| 494 |
%commands (with a |\renewcommand|). |
| 495 |
% |
| 496 |
%You must load the \textsf{exercise} package \emph{after} |
| 497 |
%\textsf{babel} to activate this option. |
| 498 |
% |
| 499 |
%\subsection{Layout} |
| 500 |
% |
| 501 |
%\subsubsection{Exercises, answers and parts} |
| 502 |
% |
| 503 |
%For the layout of the exercises, two levels of customisation are |
| 504 |
%available. First, you can customise the way the informations will be |
| 505 |
%typeset, and then you can customise the way these pieces of |
| 506 |
%informations are typeset together. |
| 507 |
% |
| 508 |
%\begin{decl} |
| 509 |
% |\ExerciseHeaderTitle| \\ |
| 510 |
% |\ExerciseHeaderDifficulty| \\ |
| 511 |
% |\ExerciseHeaderOrigin|\\ |
| 512 |
% |\ExerciseHeaderNB| |
| 513 |
%\end{decl} |
| 514 |
%\DescribeMacro{\ExerciseHeaderTitle} |
| 515 |
%\DescribeMacro{\ExerciseHeaderDifficulty} |
| 516 |
%\DescribeMacro{\ExerciseHeaderOrigin} |
| 517 |
%\DescribeMacro{\ExerciseHeaderNB} |
| 518 |
%These commands are used to typeset the corresponding information: |
| 519 |
%\\ |\ExerciseHeaderTitle| corresponds to the |title| key, \\ |
| 520 |
%|\ExerciseHeaderDifficulty| to the |difficulty| key, |
| 521 |
%|\ExerciseHeaderOrigin| to the |origin| key and |\ExerciseHeaderNB| to |
| 522 |
%the number of the exercise. |
| 523 |
% |
| 524 |
%In these commands, you specify the fonts to use, the space around the |
| 525 |
%information, some symbols (like dash or dot) you want to put here, and |
| 526 |
%so on. If the key is not present in the definition of the exercise, |
| 527 |
%then the corresponding part of the header will be emptied by the package. |
| 528 |
% |
| 529 |
%For example the default definition of |\ExerciseHeaderTitle| is |
| 530 |
%\begin{verbatim} |
| 531 |
% \newcommand{\ExerciseHeaderTitle}{\quad---\quad\ExerciseTitle} |
| 532 |
%\end{verbatim} |
| 533 |
%If an exercise has a title, then this title will be displayed preceded |
| 534 |
%by an emdash (as you can see in exercise \ref{ex1} of this |
| 535 |
%document). If an exercise doesn't have a title, then this command is |
| 536 |
%set to nothing (precisely to |{}|) during the exercise. |
| 537 |
% |
| 538 |
%These commands can be redefined with a |\renewcommand|. You don't have |
| 539 |
%to worry about the ``undefinition" mechanism: the package manages that |
| 540 |
%by itself. |
| 541 |
% |
| 542 |
%\begin{decl} |
| 543 |
% |\ExerciseHeader| \\ |
| 544 |
% |\ExerciseListHeader| |
| 545 |
%\end{decl} |
| 546 |
%\DescribeMacro{\ExerciseHeader} |
| 547 |
%\DescribeMacro{\ExerciseListHeader} |
| 548 |
%When the layout of all the elements has been fixed, they are collected |
| 549 |
%in the |\ExerciseHeader| command (or in |\ExerciseListHeader|). |
| 550 |
%Here, you specify the way the different elements are mixed |
| 551 |
%together. |
| 552 |
% |
| 553 |
%The default definition of |\ExerciseHeader| is |
| 554 |
%\begin{verbatim} |
| 555 |
% \newcommand{\ExerciseHeader}{\centerline{\textbf{\large |
| 556 |
% \ExerciseName\ExerciseHeaderNB\ExerciseHeaderTitle |
| 557 |
% \ExerciseHeaderOrigin\medskip}}} |
| 558 |
%\end{verbatim} |
| 559 |
%\noindent which displays all the informations in a centered line, using |
| 560 |
%a large bold default font. |
| 561 |
% |
| 562 |
%\begin{decl} |
| 563 |
% |\AnswerHeader| \\ |
| 564 |
% |\AnswerListHeader| |
| 565 |
%\end{decl} |
| 566 |
%\DescribeMacro{\AnswerHeader} |
| 567 |
%\DescribeMacro{\AnswerListHeader} |
| 568 |
%The same mechanism is implemented for the answers. |
| 569 |
%|\AnswerHeader| and |\AnswerListHeader| specifies the way the header |
| 570 |
%of answers are typeset. In the definition of these commands, you can |
| 571 |
%use freely the informations of the related exercise. For example, this |
| 572 |
%is the default definition of |\AnswerHeader|: |
| 573 |
% |
| 574 |
%\begin{verbatim} |
| 575 |
% \newcommand{\AnswerHeader}{\medskip\centerline{\textbf{ |
| 576 |
% Answer of \ExerciseName\ \ExerciseHeaderNB}\smallskip}} |
| 577 |
%\end{verbatim} |
| 578 |
% |
| 579 |
% |
| 580 |
%\begin{decl} |
| 581 |
% |\ExePartHeaderTitle| \\ |
| 582 |
% |\ExePartHeaderDifficulty| \\ |
| 583 |
% |\ExePartHeaderNB|\\ |
| 584 |
% |\ExePartHeader|\\ |
| 585 |
% |\ExePartListHeader| |
| 586 |
%\end{decl} |
| 587 |
%\DescribeMacro{\ExePartHeaderTitle} |
| 588 |
%\DescribeMacro{\ExePartHeaderDifficulty} |
| 589 |
%\DescribeMacro{\ExePartHeaderNB} |
| 590 |
%\DescribeMacro{\ExePartHeader} |
| 591 |
%\DescribeMacro{\ExePartListHeader} |
| 592 |
%The same kind of customisation is available for the |\ExePart| |
| 593 |
%command: |\ExePartHeaderTitle|, |\ExePartHeaderDifficulty| and |
| 594 |
%|\ExePartHeaderNB| \\ control the way the title (|\ExePartTitle|), the |
| 595 |
%difficulty (|\ExePartdifficulty|) and the number (|\theExePart|) of |
| 596 |
%the part are displayed. |
| 597 |
% |
| 598 |
%These pieces are collected in the command |\ExePartHeader| or |
| 599 |
%\\ |\ExePartListHeader|. |
| 600 |
% |
| 601 |
%\DescribeMacro{\AtBeginExercise} |
| 602 |
%\DescribeMacro{\AtBeginAnswer} |
| 603 |
%Finally, you can use the commands |\AtBeginExercise| |
| 604 |
%and |\AtBeginAnswer|. They are executed respectively at the beginning |
| 605 |
%of each exercise/each answer. |
| 606 |
% |
| 607 |
%For example, if you want all the answer typeset in italic shape, use |
| 608 |
% \begin{verbatim} |
| 609 |
%\newcommand{\AtBeginAnswer}{\itshape} |
| 610 |
% \end{verbatim} |
| 611 |
% |
| 612 |
%\changes{v1.6}{2014/10/20}{Added new commands |\AtBeginExercise| |
| 613 |
%and |\AtBeginAnswer|.} |
| 614 |
% |
| 615 |
% |
| 616 |
%\subsubsection{Questions, sub-questions and sub-sub-questions} |
| 617 |
% |
| 618 |
%The layout of the questions is a little more rigid. Somehow, it can be |
| 619 |
%customised. |
| 620 |
% |
| 621 |
%\begin{decl} |
| 622 |
% |\QuestionHeaderTitle| \\ |
| 623 |
% |\QuestionHeaderDifficulty| \\ |
| 624 |
% |\QuestionHeaderNB| |
| 625 |
%\end{decl} |
| 626 |
% |
| 627 |
%\DescribeMacro{\QuestionHeaderTitle} |
| 628 |
%\DescribeMacro{\QuestionHeaderDifficulty} |
| 629 |
%\DescribeMacro{\QuestionHeaderNB} |
| 630 |
%\DescribeMacro{\subQuestionHeaderTitle} |
| 631 |
%\DescribeMacro{\subQuestionHeaderDifficulty} |
| 632 |
%\DescribeMacro{\subQuestionHeaderNB} |
| 633 |
%\DescribeMacro{\subsubQuestionHeaderTitle} |
| 634 |
%\DescribeMacro{\subsubQuestionHeaderDifficulty} |
| 635 |
%\DescribeMacro{\subsubQuestionHeaderNB} |
| 636 |
%These commands plays the same role that the corresponding command |
| 637 |
%relating to exercises. But here, no |\QuestionHeader| is defined. |
| 638 |
% |
| 639 |
%The |subQuestion| and |subsubQuestion| versions of these commands are |
| 640 |
%also defined. |
| 641 |
% |
| 642 |
%All of these commands can be changed using |\renewcommand|. |
| 643 |
% |
| 644 |
% |
| 645 |
%\subsection{Lengths} |
| 646 |
% |
| 647 |
%\changes{v1.52}{2011/11/09}{Added the 'ExerciseSkipBefore' |
| 648 |
%and 'ExerciseSkipAfter' skip.} |
| 649 |
%\changes{v1.6}{2014/10/20}{Added the 'AnswerSkipBefore' |
| 650 |
%and 'AnswerSkipAfter' skip.} |
| 651 |
%\begin{decl} |
| 652 |
% \begin{tabular}{l} |
| 653 |
% |\ExerciseSkipBefore| \\ |
| 654 |
% |\ExerciseSkipAfter| \\ |
| 655 |
% |\AnswerSkipBefore| \\ |
| 656 |
% |\AnswerSkipAfter| |
| 657 |
%\end{tabular} |
| 658 |
%\end{decl} |
| 659 |
%\DescribeMacro{ExerciseSkipBefore} |
| 660 |
%\DescribeMacro{ExerciseSkipAfter} |
| 661 |
%\DescribeMacro{AnswerSkipBefore} |
| 662 |
%\DescribeMacro{AnswerSkipAfter} |
| 663 |
%Before every |Exercise| environment the vertical skip |
| 664 |
%|ExerciseSkipBefore| is added. The corresponding |ExerciseSkipAfter| |
| 665 |
%vertical skip is added after every |Exercise| environment. |
| 666 |
%|AnswerSkipBefore| and |AnswerSkipAfter| are the amount of vertical |
| 667 |
%spaces inserted before an after each answer. |
| 668 |
%\begin{decl} |
| 669 |
% \begin{tabular}{llll} |
| 670 |
% |\Exesep| & |\Exetopsep| & |\Exeparsep| & |
| 671 |
% |\Exepartopsep| \\ |
| 672 |
% |\Exeleftmargin| & |\Exerightmargin| & |\Exelabelwidth| |
| 673 |
% & |\Exelabelsep| |
| 674 |
%\end{tabular} |
| 675 |
%\end{decl} |
| 676 |
%\DescribeMacro{Exesep} |
| 677 |
%\DescribeMacro{Exetopsep} |
| 678 |
%\DescribeMacro{Exeparsep} |
| 679 |
%\DescribeMacro{Exepartopsep} |
| 680 |
%\DescribeMacro{Exeleftmargin} |
| 681 |
%\DescribeMacro{Exerightmargin} |
| 682 |
%\DescribeMacro{Exelabelsep} |
| 683 |
%These lengths have an effect only inside an |ExerciseList| environment. |
| 684 |
%This environment is nothing more than a |list| |
| 685 |
%environment. All the parameters of \LaTeX's lists are |
| 686 |
%available. Please consult your favourite source of information to have |
| 687 |
%the exact definitions of these lengths. |
| 688 |
% |
| 689 |
%\begin{decl} |
| 690 |
% \begin{tabular}{ll} |
| 691 |
% |\QuestionBefore| & |\QuestionIndent| \\ |
| 692 |
% |\subQuestionBefore| & |\subQuestionIndent| \\ |
| 693 |
% |\subsubQuestionBefore| & |\subsubQuestionIndent| \\ |
| 694 |
% \end{tabular} |
| 695 |
%\end{decl} |
| 696 |
%\DescribeMacro{QuestionBefore} |
| 697 |
%\DescribeMacro{QuestionIndent} |
| 698 |
%\DescribeMacro{subQuestionBefore} |
| 699 |
%\DescribeMacro{subQuestionIndent} |
| 700 |
%\DescribeMacro{subsubQuestionBefore} |
| 701 |
%\DescribeMacro{subsubQuestionIndent} |
| 702 |
%Here, |\QuestionBefore| is the vertical space above |\Question|, and\\ |
| 703 |
%|\QuestionIndent| it the horizontal distance added to the margin in |
| 704 |
%question. Same thing for |\subQuestion| and |\subsubQuestion|. |
| 705 |
% |
| 706 |
% \subsection{The \texttt{\textbackslash renewcounter} command} |
| 707 |
% |
| 708 |
%\changes{v1.1}{2004/09/05}{Added the 'renewcounter' command.} |
| 709 |
% |
| 710 |
% In a document, you will probably want to customise the way the |
| 711 |
% |Exercise| counter will reseted. Strangely, it is impossible to |
| 712 |
% redefined counter with \LaTeX. There is no equivalent of the |
| 713 |
% |\renewcommand| command for the counters. |
| 714 |
% |
| 715 |
% We provide such an equivalent with the command |\renewcounter|. |
| 716 |
%\DescribeMacro{\renewcounter} |
| 717 |
% |
| 718 |
%\begin{decl} |
| 719 |
% |\renewcounter|\marg{foo}\oarg{counter} |
| 720 |
%\end{decl} |
| 721 |
% The |\renewcounter| command defines a new counter named |foo|. The |
| 722 |
% counter is initialized to zero. |
| 723 |
% |
| 724 |
% The optional argument \oarg{counter} causes the counter |foo| to be |
| 725 |
% reset whenever the counter named in the optional argument is |
| 726 |
% incremented. |
| 727 |
% |
| 728 |
% If the counter |foo| was not previously defined, a \LaTeX\ error |
| 729 |
% occurs. |
| 730 |
% |
| 731 |
%\section{Known problems} |
| 732 |
% |
| 733 |
%The commands |\Question|, |\subQuestion|, etc. are heavily based |
| 734 |
%on |list| environment. These lists are hidden (I know it's bad!) to |
| 735 |
%simplify the syntax of the source file (I think it's nice!). |
| 736 |
% |
| 737 |
%In fact, every |\Question| is like the beginning of an environment, |
| 738 |
%which is closed at the next |\Question| (the exact mechanism is a |
| 739 |
%little bit more complicated). |
| 740 |
% |
| 741 |
%Consequently it's dangerous to put questions inside environment. |
| 742 |
%The following code will lead to an error: |
| 743 |
%\vspace*{-.5\baselineskip} |
| 744 |
%\begin{verbatim} |
| 745 |
% \begin{Exercise} |
| 746 |
% \begin{multicols}{2} |
| 747 |
% \Question ... |
| 748 |
% \Question ... |
| 749 |
% \end{multicols} |
| 750 |
% \end{Exercise} |
| 751 |
%\end{verbatim} |
| 752 |
%Of course, you can put entire exercise inside other environment (like |
| 753 |
%|minipage|). The following code will work: |
| 754 |
%\vspace*{-.5\baselineskip} |
| 755 |
%\begin{verbatim} |
| 756 |
% \begin{multicols}{2} |
| 757 |
% \begin{Exercise} |
| 758 |
% \Question ... |
| 759 |
% \Question ... |
| 760 |
% \end{Exercise} |
| 761 |
% \end{multicols} |
| 762 |
%\end{verbatim} |
| 763 |
% |
| 764 |
%\begin{decl} |
| 765 |
% |\EndCurrentQuestion|\\ |
| 766 |
% |\EndCurrentsubQuestion|\\ |
| 767 |
% |\EndCurrentsubsubQuestion| |
| 768 |
%\end{decl} |
| 769 |
%\DescribeMacro{\EndCurrentQuestion} |
| 770 |
%\DescribeMacro{\EndCurrentsubQuestion} |
| 771 |
%\DescribeMacro{\EndCurrentsubsubQuestion} |
| 772 |
%If you really need to put some questions inside environment, you must |
| 773 |
%use the command |\EndCurrentQuestion| just before ending the |
| 774 |
%environment. This command ends the question's ``environment". So, |
| 775 |
%this code will work: |
| 776 |
%\vspace*{-.5\baselineskip} |
| 777 |
%\begin{verbatim} |
| 778 |
% \begin{Exercise} |
| 779 |
% \begin{multicols}{2} |
| 780 |
% \Question ... |
| 781 |
% \Question ... |
| 782 |
% \EndCurrentQuestion |
| 783 |
% \end{multicols} |
| 784 |
% \end{Exercise} |
| 785 |
%\end{verbatim} |
| 786 |
% |
| 787 |
% |
| 788 |
% |
| 789 |
% |
| 790 |
% |
| 791 |
%In |ExerciseList| environment, the command |\Exercise| shouldn't be |
| 792 |
%followed by an empty line. |
| 793 |
% |
| 794 |
% \PrintChanges |
| 795 |
% |
| 796 |
%\makeatletter\c@IndexColumns = 2\makeatother |
| 797 |
% \StopEventually{\PrintIndex\newpage\tableofcontents } |
| 798 |
% |
| 799 |
% \section{Implementation} |
| 800 |
% |
| 801 |
% \subsection{Package options} |
| 802 |
% This part deals with the package options. Nothing more than an |
| 803 |
% affair of boolean. |
| 804 |
% \begin{macrocode} |
| 805 |
\newif\if@AnswerOutput \@AnswerOutputtrue |
| 806 |
\newif\if@AnswerDelay \@AnswerDelayfalse |
| 807 |
\newif\if@ExerciseOutput \@ExerciseOutputtrue |
| 808 |
\newif\if@ExerciseDelay \@ExerciseDelayfalse |
| 809 |
\newif\if@AswLastExe \@AswLastExefalse |
| 810 |
|
| 811 |
\DeclareOption{noanswer} {\@AnswerOutputfalse} |
| 812 |
\DeclareOption{answeronly} {\@AnswerOutputtrue\@ExerciseOutputfalse} |
| 813 |
\DeclareOption{noexercise} {\@ExerciseOutputfalse} |
| 814 |
\DeclareOption{exerciseonly} {\@AnswerOutputfalse} |
| 815 |
\DeclareOption{outputnothing}{\@ExerciseOutputfalse\@AnswerOutputfalse} |
| 816 |
\DeclareOption{exercisedelayed}{\@ExerciseDelaytrue} |
| 817 |
\DeclareOption{answerdelayed}{\@AnswerDelaytrue} |
| 818 |
\DeclareOption{lastexercise} {\@AswLastExetrue} |
| 819 |
% \end{macrocode} |
| 820 |
% The following option, which displays the exercise label in margin, is |
| 821 |
% not implemented yet. |
| 822 |
% \begin{macrocode} |
| 823 |
\newif\if@ShowLabel \@ShowLabelfalse |
| 824 |
\DeclareOption{showlabel} {\@ShowLabeltrue} |
| 825 |
|
| 826 |
\ProcessOptions |
| 827 |
% \end{macrocode} |
| 828 |
% The only required package are \textsf{keyval} and \textsf{ifthen}. |
| 829 |
% \begin{macrocode} |
| 830 |
\RequirePackage{keyval, ifthen} |
| 831 |
% \end{macrocode} |
| 832 |
% |
| 833 |
%\subsection{Customisation} |
| 834 |
% |
| 835 |
%\subsubsection{Internationalisation} |
| 836 |
%\changes{v1.11}{2004/09/08}{Corrected a bug preventing the correct |
| 837 |
%use of the \textsf{babel} package.} |
| 838 |
% \begin{macrocode} |
| 839 |
\def\listexercisename{List of exercises}% |
| 840 |
\def\ExerciseName{Exercise}% |
| 841 |
\def\AnswerName{Answer of exercise}% |
| 842 |
\def\ExerciseListName{Ex.}% |
| 843 |
\def\AnswerListName{Answer}% |
| 844 |
\def\ExePartName{Part}% |
| 845 |
\def\ArticleOf{of\ }% |
| 846 |
\@ifpackageloaded{babel}{ |
| 847 |
\addto{\captionsfrenchb}{ |
| 848 |
\def\listexercisename{Liste des exercices}% |
| 849 |
\def\ExerciseName{Exercice}% |
| 850 |
\def\AnswerName{Solution de l'exercice}% |
| 851 |
\def\ExerciseListName{Ex.}% |
| 852 |
\def\AnswerListName{Solution}% |
| 853 |
\def\ExePartName{Partie}% |
| 854 |
} |
| 855 |
\addto{\captionsspanish}{ |
| 856 |
\def\listexercisename{\'{I}ndice de \es@uclc Eejercicios}% |
| 857 |
\def\ExerciseName{Ejercicio}% |
| 858 |
\def\AnswerName{Soluci\'on del ejercicio}% |
| 859 |
\def\ExerciseListName{Ej.}% |
| 860 |
\def\AnswerListName{Soluci\'on}% |
| 861 |
\def\ExePartName{Parte}% |
| 862 |
\def\ArticleOf{del\ }% |
| 863 |
} |
| 864 |
\addto\captionsitalian{% |
| 865 |
\def\listexercisename{Indice degli esercizi} |
| 866 |
\def\ExerciseName{Esercizio}% |
| 867 |
\def\AnswerName{Soluzione dell'esercizio}% |
| 868 |
\def\ExerciseListName{Es.}% |
| 869 |
\def\AnswerListName{Soluzione}% |
| 870 |
\def\ExePartName{Parte}% |
| 871 |
} |
| 872 |
\addto\captionsdutch{% |
| 873 |
\def\listexercisename{Lijst van opdrachten} |
| 874 |
\def\ExerciseName{Opdracht} |
| 875 |
\def\AnswerName{Oplossing van opdracht} |
| 876 |
\def\ExerciseListName{Opg.} |
| 877 |
\def\AnswerListName{Oplossing} |
| 878 |
\def\ExePartName{Deel} |
| 879 |
\def\ArticleOf{van\ } |
| 880 |
} |
| 881 |
\addto\captionsgerman{% |
| 882 |
\def\listexercisename{Liste der {\"U}bungen}% |
| 883 |
\def\ExerciseName{{\"U}bung}% |
| 884 |
\def\AnswerName{L{\"o}sung zu {\"U}bung}% |
| 885 |
\def\ExerciseListName{{\"U}b.}% |
| 886 |
\def\AnswerListName{L{\"o}sung}% |
| 887 |
\def\ExePartName{Teil}% |
| 888 |
\def\ArticleOf{von\ }% |
| 889 |
} |
| 890 |
\addto\captionsngerman{% |
| 891 |
\def\listexercisename{Liste der {\"U}bungen}% |
| 892 |
\def\ExerciseName{{\"U}bung}% |
| 893 |
\def\AnswerName{L{\"o}sung zu {\"U}bung}% |
| 894 |
\def\ExerciseListName{{\"U}b.}% |
| 895 |
\def\AnswerListName{L{\"o}sung}% |
| 896 |
\def\ExePartName{Teil}% |
| 897 |
\def\ArticleOf{von\ }% |
| 898 |
} |
| 899 |
\addto\captionsportugese{% |
| 900 |
\def\listexercisename{Lista de exerc\'icios}% |
| 901 |
\def\ExerciseName{Exerc\'icio}% |
| 902 |
\def\AnswerName{Solução do exerc\'icio}% |
| 903 |
\def\ExerciseListName{Ex.}% |
| 904 |
\def\AnswerListName{Solu\c{c}\~ao}% |
| 905 |
\def\ExePartName{Parte}% |
| 906 |
\def\ArticleOf{de\ }% |
| 907 |
} |
| 908 |
\addto{\captionsrussian}{ |
| 909 |
\def\listexercisename{Список упражнений}% |
| 910 |
\def\ExerciseName{Упражнение}% |
| 911 |
\def\AnswerName{Ответ к упражнению}% |
| 912 |
\def\ExerciseListName{Упр.}% |
| 913 |
\def\AnswerListName{Ответ}% |
| 914 |
\def\ExePartName{Часть}% |
| 915 |
\def\ArticleOf{из\ }% |
| 916 |
} |
| 917 |
}{} |
| 918 |
% \end{macrocode} |
| 919 |
%\subsubsection{Layout} |
| 920 |
% First a bunch of length definitions. |
| 921 |
% \begin{macrocode} |
| 922 |
\newlength{\ExerciseSkipBefore} |
| 923 |
\setlength{\ExerciseSkipBefore}{1\baselineskip} |
| 924 |
\newlength{\ExerciseSkipAfter} |
| 925 |
\setlength{\ExerciseSkipAfter}{0\baselineskip} |
| 926 |
\newlength{\AnswerSkipBefore} |
| 927 |
\setlength{\AnswerSkipBefore}{0\baselineskip} |
| 928 |
\newlength{\AnswerSkipAfter} |
| 929 |
\setlength{\AnswerSkipAfter}{0\baselineskip} |
| 930 |
\newlength{\Exesep} |
| 931 |
\setlength{\Exesep}{1\baselineskip} |
| 932 |
\newlength{\Exetopsep} |
| 933 |
\setlength{\Exetopsep}\z@ |
| 934 |
\newlength{\Exeparsep} |
| 935 |
\setlength{\Exeparsep}{\parskip} |
| 936 |
\newlength{\Exepartopsep} |
| 937 |
\setlength{\Exepartopsep}\z@ |
| 938 |
\newlength{\Exeleftmargin} |
| 939 |
\setlength{\Exeleftmargin}\z@ |
| 940 |
\newlength{\Exerightmargin} |
| 941 |
\setlength{\Exerightmargin}\z@ |
| 942 |
\newlength{\Exelabelwidth} |
| 943 |
\setlength{\Exelabelwidth}\z@ |
| 944 |
\newlength{\Exelabelsep} |
| 945 |
\setlength{\Exelabelsep}\z@ |
| 946 |
\newlength{\ExerciseBefore} |
| 947 |
\setlength{\ExerciseBefore}{0em} |
| 948 |
\newlength{\QuestionBefore} |
| 949 |
\setlength{\QuestionBefore}{.25em} |
| 950 |
\newlength{\subQuestionBefore} |
| 951 |
\setlength{\subQuestionBefore}{0em} |
| 952 |
\newlength{\subsubQuestionBefore} |
| 953 |
\setlength{\subsubQuestionBefore}{0em} |
| 954 |
\newlength{\QuestionIndent} |
| 955 |
\setlength{\QuestionIndent}{3em} |
| 956 |
\newlength{\subQuestionIndent} |
| 957 |
\setlength{\subQuestionIndent}{2em} |
| 958 |
\newlength{\subsubQuestionIndent} |
| 959 |
\setlength{\subsubQuestionIndent}{2.5em} |
| 960 |
% \end{macrocode} |
| 961 |
% Now the counters |
| 962 |
% \begin{macrocode} |
| 963 |
\newcounter{Exercise} |
| 964 |
\newcounter{Answer} |
| 965 |
\gdef\@ExerciseCounter{Exercise} %default exercise counter |
| 966 |
\gdef\@AnswerCounter{Answer} %default answer counter |
| 967 |
\@ifpackageloaded{hyperref}{ |
| 968 |
\def\@setAnswerref#1#2#3#4{% |
| 969 |
\ifx#1\relax |
| 970 |
\protect\G@refundefinedtrue |
| 971 |
\nfss@text{\reset@font\bfseries ??}% |
| 972 |
\PackageWarning{exercise}{Reference to Answer of `#3' on page |
| 973 |
\thepage \space undefined}% |
| 974 |
\else |
| 975 |
\hyperref[#4]{\expandafter#2#1}\null |
| 976 |
\fi} |
| 977 |
\def\refAnswer#1{\expandafter\@setAnswerref\csname r@#1\endcsname\@firstoffive{#1}{#1-Answer}}} |
| 978 |
{\let\refAnswer\ref} |
| 979 |
\newcounter{ExePart}[Exercise] |
| 980 |
\newcounter{Question}[Exercise] |
| 981 |
\newcounter{subQuestion}[Question] |
| 982 |
\newcounter{subsubQuestion}[subQuestion] |
| 983 |
% \end{macrocode} |
| 984 |
% Presentation of these labels in cross references |
| 985 |
% \begin{macrocode} |
| 986 |
\renewcommand{\theExercise}{\if@ExeStared\else\arabic{\@ExerciseCounter}\fi} |
| 987 |
\renewcommand{\theExePart}{\Roman{ExePart}} |
| 988 |
\renewcommand{\theQuestion}{\arabic{Question}} |
| 989 |
\renewcommand{\thesubQuestion}{\alph{subQuestion}} |
| 990 |
\renewcommand{\thesubsubQuestion}{\roman{subsubQuestion}} |
| 991 |
% \end{macrocode} |
| 992 |
% For internal purposes |
| 993 |
% \begin{macrocode} |
| 994 |
\newcounter{savedQuestion} |
| 995 |
\newcounter{savedsubQuestion} |
| 996 |
\newcounter{savedsubsubQuestion} |
| 997 |
% \end{macrocode} |
| 998 |
% The |\marker| command. |
| 999 |
% \begin{macrocode} |
| 1000 |
\def\marker#1#2{\@tempcnta#2\whiledo{\@tempcnta>0}{#1\advance |
| 1001 |
\@tempcnta by -1 }} |
| 1002 |
% \end{macrocode} |
| 1003 |
% Symbol used to indicate the difficulty of an exercise or a question |
| 1004 |
% \begin{macrocode} |
| 1005 |
\def\DifficultyMarker{*} |
| 1006 |
% \end{macrocode} |
| 1007 |
% Commands executed respectively at the begin of an exercise and at the |
| 1008 |
% beginning of an Answer (in both case, \emph{after} the header). |
| 1009 |
% \begin{macrocode} |
| 1010 |
\newcommand{\AtBeginExercise}{} |
| 1011 |
\newcommand{\AtBeginAnswer}{} |
| 1012 |
% \end{macrocode} |
| 1013 |
% Presentation of informations in the header of exercises |
| 1014 |
% \begin{macrocode} |
| 1015 |
\newcommand{\ExerciseHeaderTitle}{\qquad\ExerciseTitle} |
| 1016 |
\newcommand{\ExerciseHeaderExam}{\ExerciseExam} |
| 1017 |
\newcommand{\ExerciseHeaderYear}{\ \ExerciseYear} |
| 1018 |
\newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ } |
| 1019 |
\newcommand{\ExerciseHeaderOrigin}{% |
| 1020 |
\ ({\usefont{\encodingdefault}{\rmdefault}{m}{it}\ExerciseOrigin})} |
| 1021 |
\newcommand{\ExerciseHeaderNB}{\theExercise} |
| 1022 |
\newcommand{\ExerciseHeaderLabel}{\fbox{\textsc{\ExerciseLabel}}} |
| 1023 |
% \end{macrocode} |
| 1024 |
% The header itself |
| 1025 |
% \begin{macrocode} |
| 1026 |
\newcommand{\ExerciseHeader}{\centerline{% |
| 1027 |
\textbf{\large\ExerciseHeaderDifficulty\ExerciseName\ % |
| 1028 |
\ExerciseHeaderNB\ExerciseHeaderTitle\ExerciseHeaderOrigin}}\medskip} |
| 1029 |
% \end{macrocode} |
| 1030 |
% The header of exercise in ExerciseList environment |
| 1031 |
% \begin{macrocode} |
| 1032 |
\newcommand{\ExerciseListHeader}{\ExerciseHeaderDifficulty% |
| 1033 |
\textbf{\ExerciseListName\ \ExerciseHeaderNB% |
| 1034 |
\ --- \ \ExerciseHeaderTitle}% |
| 1035 |
\ExerciseHeaderOrigin\ignorespaces} |
| 1036 |
% \end{macrocode} |
| 1037 |
% Presentation of informations in the header of ExePart |
| 1038 |
% \begin{macrocode} |
| 1039 |
\newcommand{\ExePartHeaderNB}{\ \theExePart} |
| 1040 |
\newcommand{\ExePartHeaderTitle}{\quad --- \quad {\ExePartTitle}} |
| 1041 |
\newcommand{\ExePartHeaderDifficulty}{\theExePartDifficulty\ } |
| 1042 |
% \end{macrocode} |
| 1043 |
% The header of |ExePart| |
| 1044 |
% \begin{macrocode} |
| 1045 |
\newcommand{\ExePartHeader}{% |
| 1046 |
\medskip\centerline{\emph{\large\ExePartHeaderDifficulty\ExePartName% |
| 1047 |
\ExePartHeaderNB\ExePartHeaderTitle}}} |
| 1048 |
\newcommand{\ExePartListHeader}{\bigskip% |
| 1049 |
\emph{\ExePartHeaderDifficulty\ExePartName% |
| 1050 |
\ExePartHeaderNB\ExePartHeaderTitle}\par\medskip} |
| 1051 |
% \end{macrocode} |
| 1052 |
% Presentation of Questions |
| 1053 |
% \begin{macrocode} |
| 1054 |
\newcommand{\QuestionNB}{\arabic{Question}.\ } |
| 1055 |
\newcommand{\QuestionHeaderTitle}{\emph{(\QuestionTitle)}\ } |
| 1056 |
\newcommand{\QuestionHeaderDifficulty}{\theQuestionDifficulty\ } |
| 1057 |
\newcommand{\theQuestionDifficulty}{\marker{\DifficultyMarker}% |
| 1058 |
{\QuestionDifficulty}} |
| 1059 |
\newcommand{\subQuestionNB}{\alph{subQuestion})} |
| 1060 |
\newcommand{\subQuestionHeaderTitle}{\emph{(\subQuestionTitle)}\ } |
| 1061 |
\newcommand{\subQuestionHeaderDifficulty}{\thesubQuestionDifficulty\ } |
| 1062 |
\newcommand{\subQuestionHeader}{\subQuestionHeaderDifficulty% |
| 1063 |
\subQuestionNB)\ \emph{\subQuestionHeaderTitle}} |
| 1064 |
\newcommand{\thesubQuestionDifficulty}{\marker{\DifficultyMarker}% |
| 1065 |
{\subQuestionDifficulty}} |
| 1066 |
\newcommand{\subsubQuestionNB}{\roman{subsubQuestion} -- } |
| 1067 |
\newcommand{\subsubQuestionHeaderTitle}{\emph{(\subsubQuestionTitle)}\ } |
| 1068 |
\newcommand{\subsubQuestionHeaderDifficulty}{\thesubsubQuestionDifficulty\ } |
| 1069 |
\newcommand{\subsubQuestionHeader}{\subsubQuestionHeaderDifficulty% |
| 1070 |
\subsubQuestionNB \emph{\subsubQuestionHeaderTitle} --} |
| 1071 |
\newcommand{\thesubsubQuestionDifficulty}{% |
| 1072 |
\marker{\DifficultyMarker}{\subsubQuestionDifficulty}} |
| 1073 |
% \end{macrocode} |
| 1074 |
% \subsection{Macros definition} |
| 1075 |
% \begin{macrocode} |
| 1076 |
\newcount\@QuestionLevel \@QuestionLevel=0 |
| 1077 |
\newcommand{\the@QuestionLevel}{\number\@QuestionLevel} |
| 1078 |
\newbox\@Exercisebox |
| 1079 |
\newbox\all@Exercisebox |
| 1080 |
\newbox\temp@Exercisebox |
| 1081 |
\newbox\all@Answerbox |
| 1082 |
\newbox\temp@Answerbox |
| 1083 |
\newif\if@echapq \@echapqfalse |
| 1084 |
\newif\if@Answer \@Answerfalse |
| 1085 |
\def\termineliste#1{\global\@echapqfalse% |
| 1086 |
\whiledo{\@QuestionLevel>#1}% |
| 1087 |
{\ifnum\@QuestionLevel=\colonnesLevel\end{multicols}\colonnesLevel=-10\fi% |
| 1088 |
\end{list}\advance\@QuestionLevel by -1}% |
| 1089 |
\ifnum\@QuestionLevel=\colonnesLevel\end{multicols}\colonnesLevel=-10\fi} |
| 1090 |
% \end{macrocode} |
| 1091 |
% |
| 1092 |
% \subsubsection{Definition of \texttt{Exercise}} |
| 1093 |
% |
| 1094 |
% The keyval package is used to specify various information about an exercise. |
| 1095 |
% \begin{macrocode} |
| 1096 |
\newif\if@ExeTitle \@ExeTitlefalse |
| 1097 |
\newif\if@ExeExam \@ExeExamfalse |
| 1098 |
\newif\if@ExeYear \@ExeYearfalse |
| 1099 |
\newif\if@ExeReName \@ExeReNamefalse |
| 1100 |
\global\newcount\ExerciseDifficulty \ExerciseDifficulty=0 |
| 1101 |
\newif\if@ExeDifficulty \@ExeDifficultyfalse |
| 1102 |
\newif\if@ExeOrigin \@ExeOriginfalse |
| 1103 |
\newif\if@ExeType \@ExeTypefalse |
| 1104 |
\newif\if@ExeLabel \@ExeLabelfalse |
| 1105 |
\newif\if@ExeNB \@ExeNBfalse |
| 1106 |
% |
| 1107 |
\def\theExerciseDifficulty{\marker{\DifficultyMarker}{\ExerciseDifficulty}} |
| 1108 |
% |
| 1109 |
\define@key{PPExercise}{title}% |
| 1110 |
{\global\@ExeTitletrue\gdef\ExerciseTitle{#1}} |
| 1111 |
\define@key{PPExercise}{exam}% |
| 1112 |
{\global\@ExeExamtrue\gdef\ExerciseExam{#1}} |
| 1113 |
\define@key{PPExercise}{year}% |
| 1114 |
{\global\@ExeYeartrue\gdef\ExerciseYear{#1}} |
| 1115 |
\define@key{PPExercise}{difficulty}% |
| 1116 |
{\global\@ExeDifficultytrue\global\ExerciseDifficulty=\number#1} |
| 1117 |
\define@key{PPExercise}{name}% |
| 1118 |
{\global\@ExeReNametrue\gdef\@ExerciseName{#1}} |
| 1119 |
\define@key{PPExercise}{origin}% |
| 1120 |
{\global\@ExeOrigintrue\gdef\ExerciseOrigin{#1}} |
| 1121 |
\define@key{PPExercise}{type}% |
| 1122 |
{\global\@ExeTypetrue\gdef\ExerciseType{#1}} |
| 1123 |
\define@key{PPExercise}{counter}% |
| 1124 |
{\gdef\@ExerciseCounter{#1}} |
| 1125 |
\define@key{PPExercise}{label}% |
| 1126 |
{\global\@ExeLabeltrue\gdef\ExerciseLabel{#1}\gdef\ExerciseTrueLabel{#1}} |
| 1127 |
\define@key{PPExercise}{number}% |
| 1128 |
{\global\@ExeNBtrue\gdef\ExerciseLocalNB{#1}} |
| 1129 |
\define@key{PPExercise}{class}% |
| 1130 |
{\gdef\ExerciseClass{#1}} |
| 1131 |
% |
| 1132 |
\newif\if@ExeStared |
| 1133 |
\@ExeStaredfalse |
| 1134 |
% |
| 1135 |
\def\@InitExe{\@savemathindent\global\@echapqfalse% |
| 1136 |
\gdef\ExerciseTitle{}% |
| 1137 |
\gdef\ExerciseExam{}% |
| 1138 |
\gdef\ExerciseYear{}% |
| 1139 |
\gdef\@ExerciseName{}% |
| 1140 |
\gdef\ExerciseOrigin{}% |
| 1141 |
\gdef\ExerciseType{}% |
| 1142 |
\gdef\ExerciseTrueLabel{}% |
| 1143 |
\global\ExerciseDifficulty=0% |
| 1144 |
\global\@ExeTitlefalse% |
| 1145 |
\global\@ExeExamfalse% |
| 1146 |
\global\@ExeYearfalse% |
| 1147 |
\global\@ExeReNamefalse% |
| 1148 |
\global\@ExeDifficultyfalse% |
| 1149 |
\global\@ExeOriginfalse% |
| 1150 |
\global\@ExeTypefalse% |
| 1151 |
\global\@ExeNBfalse% |
| 1152 |
\gdef\@ExerciseCounter{Exercise}% |
| 1153 |
\setcounter{ExePart}{0}% |
| 1154 |
\setcounter{Question}{0}% |
| 1155 |
\global\@ExeLabelfalse% |
| 1156 |
} |
| 1157 |
% |
| 1158 |
\def\@getExerciseInfo{% |
| 1159 |
\if@ExeReName\def\ExerciseName{\@ExerciseName}\fi% |
| 1160 |
\if@ExeTitle\else\def\ExerciseHeaderTitle{}\fi% |
| 1161 |
\if@ExeExam\else\def\ExerciseHeaderExam{}\fi% |
| 1162 |
\if@ExeYear\else\def\ExerciseHeaderYear{}\fi% |
| 1163 |
\if@ExeOrigin\else\def\ExerciseHeaderOrigin{}\fi% |
| 1164 |
\if@ExeType\else\def\ExerciseHeaderType{}\fi% |
| 1165 |
\if@ExeNB\setcounter{Exercise}{\ExerciseLocalNB} |
| 1166 |
\protected@edef\@currentlabel{\p@Exercise\theExercise}% |
| 1167 |
\fi% |
| 1168 |
\if@ExeDifficulty\else\def\ExerciseHeaderDifficulty{}\fi% |
| 1169 |
\if@ExeStared\def\ExerciseHeaderNB{}\fi% |
| 1170 |
\if@ExeLabel\recordExerciseLabel{\ExerciseLabel}\else\def\ExerciseHeaderLabel{}\fi% |
| 1171 |
} |
| 1172 |
% |
| 1173 |
\def\refstepExecounter{\if@ShipThisExercise\if@ExeStared\else\if@ExeNB\else% |
| 1174 |
\refstepcounter{\@ExerciseCounter}\fi\fi\fi} |
| 1175 |
% |
| 1176 |
\def\recordExerciseLabel#1{\label{#1}} |
| 1177 |
% |
| 1178 |
\def\@BeginExeBox{\global\setbox\@Exercisebox\vbox\bgroup} |
| 1179 |
\def\@EndExeBox{\egroup\if@Answer\if@AnswerOutput\@DelayAnswerBox\fi% |
| 1180 |
\else\if@ExerciseOutput\@DelayExerciseBox\fi\fi} |
| 1181 |
% |
| 1182 |
\def\@DelayAnswerBox{% |
| 1183 |
\if@ShipThisAnswer\if@AnswerDelay\global\setbox\temp@Answerbox% |
| 1184 |
\vbox{\unvbox\all@Answerbox\vskip\Exesep\unvbox\@Exercisebox\vskip\z@}% |
| 1185 |
\global\setbox\all@Answerbox\copy\temp@Answerbox% |
| 1186 |
\else\unvbox\@Exercisebox\fi\fi} |
| 1187 |
% |
| 1188 |
\def\@DelayExerciseBox{\if@ShipThisExercise\if@ExerciseDelay% |
| 1189 |
\global\setbox\temp@Exercisebox% |
| 1190 |
\vbox{\unvbox\all@Exercisebox\vskip\Exesep\unvbox\@Exercisebox\vskip\z@}% |
| 1191 |
\global\setbox\all@Exercisebox\copy\temp@Exercisebox% |
| 1192 |
\else\unvbox\@Exercisebox\fi\fi} |
| 1193 |
% |
| 1194 |
\newcommand{\shipoutAnswer}{\if@AnswerOutput\unvbox\all@Answerbox\fi} |
| 1195 |
\newcommand{\shipoutExercise}{\if@ExerciseOutput\unvbox\all@Exercisebox\fi} |
| 1196 |
% \end{macrocode} |
| 1197 |
% The commands for the \texttt{Exercise} environment. |
| 1198 |
% \begin{macrocode} |
| 1199 |
\def\beginExerciseEnv{\@InitExe\@ifnextchar[\@@ExeEnv{\@@ExeEnv[]}}%] |
| 1200 |
% |
| 1201 |
\def\@@ExeEnv[#1]{\setkeys{PPExercise}{#1}% |
| 1202 |
\@selectExercise\global\@Answerfalse\@BeginExeBox\@@@ExeEnv} |
| 1203 |
% |
| 1204 |
\newcommand{\@@@ExeEnv}{% |
| 1205 |
\pagebreak[1]\vskip\ExerciseSkipBefore |
| 1206 |
\@QuestionLevel1 |
| 1207 |
\refstepExecounter |
| 1208 |
\begingroup\@getExerciseInfo\ExerciseHeader |
| 1209 |
\addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\ |
| 1210 |
\theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}} |
| 1211 |
\endgroup\AtBeginExercise} |
| 1212 |
% |
| 1213 |
% |
| 1214 |
\def\endExerciseEnv{\termineliste{1}\@EndExeBox% |
| 1215 |
\vskip\ExerciseSkipAfter} |
| 1216 |
% \end{macrocode} |
| 1217 |
% The commands for exercise within <ExerciseList> environment |
| 1218 |
% \begin{macrocode} |
| 1219 |
\def\ExerciseCmd{\@InitExe\@ifstar{\global\@ExeStaredtrue\@ExeCmd}% |
| 1220 |
{\global\@ExeStaredfalse\@ExeCmd}} |
| 1221 |
% |
| 1222 |
\def\@ExeCmd{\@ifnextchar[\@@ExeCmd{\@@ExeCmd[]}}%] for emacs |
| 1223 |
% |
| 1224 |
\def\@@ExeCmd[#1]{\setkeys{PPExercise}{#1}\@@@ExeCmd} |
| 1225 |
% |
| 1226 |
\newcommand{\@@@ExeCmd}{% |
| 1227 |
\ifnum\@QuestionLevel=0 |
| 1228 |
\advance \@QuestionLevel by 1 |
| 1229 |
\begin{list}{\@getExerciseInfo\ExerciseListHeader}% |
| 1230 |
{\partopsep\Exepartopsep \labelsep\Exelabelsep \itemsep \Exesep% |
| 1231 |
\parsep\Exeparsep \topsep\Exetopsep \labelwidth\Exelabelwidth% |
| 1232 |
\leftmargin\Exeleftmargin \rightmargin\Exerightmargin} |
| 1233 |
\else |
| 1234 |
\termineliste{1}\@EndExeBox |
| 1235 |
\fi |
| 1236 |
\@selectExercise |
| 1237 |
\global\@Answerfalse\@BeginExeBox\refstepExecounter% |
| 1238 |
\addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\ |
| 1239 |
\theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}} |
| 1240 |
\item\ignorespaces\AtBeginExercise |
| 1241 |
} |
| 1242 |
% |
| 1243 |
\def\defineExePartInEnv{\def\@ExePartHeader{\ExePartHeader}} |
| 1244 |
\def\defineExePartInList{\def\@ExePartHeader{\ExePartListHeader}} |
| 1245 |
\def\defineExerciseEnv{% |
| 1246 |
\defineExePartInEnv |
| 1247 |
\renewenvironment{Exercise}{\global\@ExeStaredfalse\global\beginExerciseEnv}% |
| 1248 |
{\endExerciseEnv} |
| 1249 |
\renewenvironment{Exercise*}{\global\@ExeStaredtrue\beginExerciseEnv}% |
| 1250 |
{\endExerciseEnv} |
| 1251 |
} |
| 1252 |
\newenvironment{Exercise}{}{} |
| 1253 |
\newenvironment{Exercise*}{}{} |
| 1254 |
% |
| 1255 |
\def\defineExerciseCmd{\def\Exercise{\ExerciseCmd}} |
| 1256 |
% |
| 1257 |
\renewcommand{\Exercise}{} |
| 1258 |
% |
| 1259 |
\defineExerciseEnv |
| 1260 |
% |
| 1261 |
\def\beginExerciseListEnv{\defineExerciseCmd\defineAnswerCmd% |
| 1262 |
\defineExePartInList} |
| 1263 |
% |
| 1264 |
\def\endExerciseListEnv{\termineliste{1}\@EndExeBox\termineliste{0}% |
| 1265 |
\defineExerciseEnv\defineAnswerEnv} |
| 1266 |
% |
| 1267 |
\newenvironment{ExerciseList}{\beginExerciseListEnv}{\endExerciseListEnv} |
| 1268 |
% \end{macrocode} |
| 1269 |
% \subsubsection{Definition of \texttt{questions}} |
| 1270 |
% \begin{macrocode} |
| 1271 |
\def\QuestionTitle{} |
| 1272 |
\newif\if@QuestionTitle \@QuestionTitlefalse |
| 1273 |
\global\newcount\QuestionDifficulty \QuestionDifficulty=0 |
| 1274 |
\newif\if@QuestionDifficulty \@QuestionDifficultyfalse |
| 1275 |
% |
| 1276 |
\define@key{PPQuestion}{title}{% |
| 1277 |
\global\@QuestionTitletrue\gdef\QuestionTitle{#1}} |
| 1278 |
\define@key{PPQuestion}{difficulty}{% |
| 1279 |
\global\@QuestionDifficultytrue\global\QuestionDifficulty=\number#1} |
| 1280 |
% |
| 1281 |
\def\@InitQuestion{\nopagebreak |
| 1282 |
\gdef\QuestionTitle{}% |
| 1283 |
\global\QuestionDifficulty=0% |
| 1284 |
\global\@QuestionTitlefalse% |
| 1285 |
\global\@QuestionDifficultyfalse} |
| 1286 |
% |
| 1287 |
\def\@getQuestionInfo{% |
| 1288 |
\if@QuestionTitle\else\def\QuestionHeaderTitle{}\fi |
| 1289 |
\if@QuestionDifficulty\else\def\QuestionHeaderDifficulty{}\fi |
| 1290 |
} |
| 1291 |
% |
| 1292 |
\def\EndCurrentQuestion{\termineliste{1}} |
| 1293 |
% |
| 1294 |
\def\Question{\@InitQuestion\@ifnextchar[\@@Question{\@@Question[]}}%] |
| 1295 |
% |
| 1296 |
\def\@@Question[#1]{\setkeys{PPQuestion}{#1}\@@@Question} |
| 1297 |
% |
| 1298 |
\def\@QuestionHeader{\item[{\makebox[0cm][r]{\begingroup\@getQuestionInfo% |
| 1299 |
\QuestionHeaderDifficulty\QuestionNB\endgroup}}]% |
| 1300 |
\begingroup\@getQuestionInfo\QuestionHeaderTitle\endgroup\ignorespaces} |
| 1301 |
\newcommand{\@@@Question}{% |
| 1302 |
\ifnum\@QuestionLevel=1 |
| 1303 |
\advance \@QuestionLevel by 1 |
| 1304 |
\begin{list}{}{\leftmargin \QuestionIndent |
| 1305 |
\partopsep0pt \parsep\parskip \topsep \QuestionBefore |
| 1306 |
\itemsep \QuestionBefore \labelwidth 2em |
| 1307 |
\labelsep .33em |
| 1308 |
\usecounter{Question}} |
| 1309 |
\if@echapq |
| 1310 |
\setcounter{Question}{\value{savedQuestion}}\global\@echapqfalse |
| 1311 |
\fi |
| 1312 |
\refstepcounter{Question} |
| 1313 |
\@restoremathindent |
| 1314 |
\@decalemathindent{\QuestionIndent} |
| 1315 |
\@QuestionHeader |
| 1316 |
\else |
| 1317 |
\ifnum\@QuestionLevel=2 |
| 1318 |
\refstepcounter{Question} |
| 1319 |
\@QuestionHeader |
| 1320 |
\else |
| 1321 |
\ifnum\@QuestionLevel>2 |
| 1322 |
\termineliste{2} |
| 1323 |
\refstepcounter{Question} |
| 1324 |
\@QuestionHeader |
| 1325 |
\else |
| 1326 |
\PackageError{exercise}{You don't respect the hierarchy of |
| 1327 |
questions}{Verify the Question} |
| 1328 |
\fi |
| 1329 |
\fi |
| 1330 |
\fi |
| 1331 |
} |
| 1332 |
% \end{macrocode} |
| 1333 |
% \subsubsection{Definition of \texttt{sub-questions} and |
| 1334 |
%\texttt{sub-sub-questions}} |
| 1335 |
% Here a good factorization is possible, but I prefer readibility over |
| 1336 |
% efficacity. |
| 1337 |
% \begin{macrocode} |
| 1338 |
\def\subQuestionTitle{} |
| 1339 |
\newif\if@subQuestionTitle\@subQuestionTitlefalse |
| 1340 |
\global\newcount\subQuestionDifficulty\subQuestionDifficulty=0 |
| 1341 |
\newif\if@subQuestionDifficulty\@subQuestionDifficultyfalse |
| 1342 |
% |
| 1343 |
\define@key{PPsubQuestion}{title}{% |
| 1344 |
\gdef\subQuestionTitle{#1}\global\@subQuestionTitletrue} |
| 1345 |
\define@key{PPsubQuestion}{difficulty}{% |
| 1346 |
\global\@subQuestionDifficultytrue\global\subQuestionDifficulty=\number#1} |
| 1347 |
% |
| 1348 |
\def\@InitsubQuestion{\gdef\subQuestionTitle{}% |
| 1349 |
\global\subQuestionDifficulty=0% |
| 1350 |
\global\@subQuestionTitlefalse% |
| 1351 |
\global\@subQuestionDifficultyfalse} |
| 1352 |
% |
| 1353 |
\def\@getsubQuestionInfo{% |
| 1354 |
\if@subQuestionTitle\else\def\subQuestionHeaderTitle{}\fi |
| 1355 |
\if@subQuestionDifficulty\else\def\subQuestionHeaderDifficulty{}\fi |
| 1356 |
} |
| 1357 |
% |
| 1358 |
\def\EndCurrentsubQuestion{\termineliste{2}} |
| 1359 |
% |
| 1360 |
\def\subQuestion{\@InitsubQuestion% |
| 1361 |
\@ifnextchar[\@@subQuestion{\@@subQuestion[]}}%] |
| 1362 |
\def\@@subQuestion[#1]{\setkeys{PPsubQuestion}{#1}\@@@subQuestion} |
| 1363 |
% |
| 1364 |
\def\@subQuestionHeader{\item[{\makebox[0cm][r]% |
| 1365 |
{\begingroup\@getsubQuestionInfo\subQuestionHeaderDifficulty% |
| 1366 |
\subQuestionNB\endgroup}}]% |
| 1367 |
\begingroup\@getsubQuestionInfo\subQuestionHeaderTitle\endgroup% |
| 1368 |
\ignorespaces} |
| 1369 |
\newcommand{\@@@subQuestion}{% |
| 1370 |
\ifnum\@QuestionLevel=2 |
| 1371 |
\advance \@QuestionLevel by 1 |
| 1372 |
\begin{list}{}{\leftmargin \subQuestionIndent |
| 1373 |
\partopsep0pt \parsep\parskip \topsep \subQuestionBefore |
| 1374 |
\itemsep \subQuestionBefore \labelwidth 2em |
| 1375 |
\labelsep .33em |
| 1376 |
\usecounter{subQuestion}} |
| 1377 |
\if@echapq |
| 1378 |
\setcounter{subQuestion}{\value{savedsubQuestion}}% |
| 1379 |
\global\@echapqfalse |
| 1380 |
\fi |
| 1381 |
\refstepcounter{subQuestion} |
| 1382 |
\@restoremathindent |
| 1383 |
\@decalemathindent{\subQuestionIndent} |
| 1384 |
\@subQuestionHeader |
| 1385 |
\else |
| 1386 |
\ifnum\@QuestionLevel=3 |
| 1387 |
\refstepcounter{subQuestion} |
| 1388 |
\@subQuestionHeader |
| 1389 |
\else |
| 1390 |
\ifnum\@QuestionLevel>3 |
| 1391 |
\termineliste{3} |
| 1392 |
\refstepcounter{subQuestion} |
| 1393 |
\@subQuestionHeader |
| 1394 |
\else |
| 1395 |
\PackageError{exercise}{You don't respect the hierarchy of |
| 1396 |
subQuestion}{Verify the subQuestion} |
| 1397 |
\fi |
| 1398 |
\fi |
| 1399 |
\fi |
| 1400 |
} |
| 1401 |
% |
| 1402 |
\def\subsubQuestionTitle{} |
| 1403 |
\newif\if@subsubQuestionTitle\@subsubQuestionTitlefalse |
| 1404 |
\global\newcount\subsubQuestionDifficulty\subsubQuestionDifficulty=0 |
| 1405 |
\newif\if@subsubQuestionDifficulty\@subsubQuestionDifficultyfalse |
| 1406 |
% |
| 1407 |
\define@key{PPsubsubQuestion}{title}{% |
| 1408 |
\gdef\subsubQuestionTitle{#1}\global\@subsubQuestionTitletrue} |
| 1409 |
\define@key{PPsubsubQuestion}{difficulty}{% |
| 1410 |
\global\@subsubQuestionDifficultytrue% |
| 1411 |
\global\subsubQuestionDifficulty=\number#1} |
| 1412 |
% |
| 1413 |
\def\@InitsubsubQuestion{\gdef\subsubQuestionTitle{}% |
| 1414 |
\global\subsubQuestionDifficulty=0% |
| 1415 |
\global\@subsubQuestionTitlefalse% |
| 1416 |
\global\@subsubQuestionDifficultyfalse} |
| 1417 |
% |
| 1418 |
\def\@getsubsubQuestionInfo{% |
| 1419 |
\if@subsubQuestionTitle\else\def\subsubQuestionHeaderTitle{}\fi |
| 1420 |
\if@subsubQuestionDifficulty\else\def\subsubQuestionHeaderDifficulty{}\fi |
| 1421 |
} |
| 1422 |
% |
| 1423 |
\def\EndCurrentsubsubQuestion{\termineliste{3}} |
| 1424 |
\def\subsubQuestion{\@InitsubsubQuestion% |
| 1425 |
\@ifnextchar[\@@subsubQuestion{\@@subsubQuestion[]}}%] |
| 1426 |
\def\@@subsubQuestion[#1]{\setkeys{PPsubsubQuestion}{#1}\@@@subsubQuestion} |
| 1427 |
% |
| 1428 |
\def\@subsubQuestionHeader{\item[{\makebox[0cm][r]% |
| 1429 |
{\begingroup\@getsubsubQuestionInfo\subsubQuestionHeaderDifficulty% |
| 1430 |
\subsubQuestionNB\endgroup}}]% |
| 1431 |
\begingroup\@getsubsubQuestionInfo\subsubQuestionHeaderTitle\endgroup% |
| 1432 |
\ignorespaces} |
| 1433 |
\newcommand{\@@@subsubQuestion}{% |
| 1434 |
\ifnum\@QuestionLevel=3 |
| 1435 |
\advance \@QuestionLevel by 1 |
| 1436 |
\begin{list}{}{\leftmargin \subsubQuestionIndent |
| 1437 |
\partopsep0pt \parsep\parskip \topsep \subsubQuestionBefore |
| 1438 |
\itemsep \subsubQuestionBefore \labelwidth 2em |
| 1439 |
\labelsep .33em |
| 1440 |
\usecounter{subsubQuestion}} |
| 1441 |
\if@echapq |
| 1442 |
\setcounter{subsubQuestion}{\value{savedsubsubQuestion}}% |
| 1443 |
\global\@echapqfalse |
| 1444 |
\fi |
| 1445 |
\refstepcounter{subsubQuestion} |
| 1446 |
\@restoremathindent |
| 1447 |
\@decalemathindent{\subsubQuestionIndent} |
| 1448 |
\@subsubQuestionHeader |
| 1449 |
\else |
| 1450 |
\ifnum\@QuestionLevel=4 |
| 1451 |
\refstepcounter{subsubQuestion} |
| 1452 |
\@subsubQuestionHeader |
| 1453 |
\else |
| 1454 |
\ifnum\@QuestionLevel>4 |
| 1455 |
\termineliste{4} |
| 1456 |
\refstepcounter{subsubQuestion} |
| 1457 |
\@subsubQuestionHeader |
| 1458 |
\else |
| 1459 |
\PackageError{exercise}{You don't respect the hierarchy of |
| 1460 |
subsubQuestion}{Verify the subsubQuestion} |
| 1461 |
\fi |
| 1462 |
\fi |
| 1463 |
\fi |
| 1464 |
} |
| 1465 |
% \end{macrocode} |
| 1466 |
% \subsubsection{ Presentation of part (within an exercise)} |
| 1467 |
% \begin{macrocode} |
| 1468 |
\newif\if@ExePartStared \@ExePartStaredfalse |
| 1469 |
\newif\if@ExePartTitle \@ExePartTitlefalse |
| 1470 |
\newif\if@ExePartReName \@ExePartReNamefalse |
| 1471 |
\newif\if@ExePartDifficulty \@ExePartDifficultyfalse |
| 1472 |
\global\newcount\ExePartDifficulty \ExePartDifficulty=0 |
| 1473 |
% |
| 1474 |
\def\theExePartDifficulty{\marker{\DifficultyMarker}{\ExePartDifficulty}} |
| 1475 |
% |
| 1476 |
\def\@InitExePart{\global\@echapqfalse% |
| 1477 |
\gdef\ExePartTitle{}% |
| 1478 |
\gdef\@ExePartName{}% |
| 1479 |
\global\ExePartDifficulty=0% |
| 1480 |
\global\@ExePartTitlefalse% |
| 1481 |
\global\@ExePartReNamefalse% |
| 1482 |
\global\@ExePartDifficultyfalse% |
| 1483 |
\setcounter{Question}{0}\termineliste{1}} |
| 1484 |
% |
| 1485 |
\define@key{PPExePart}{title}{\gdef\ExePartTitle{#1}% |
| 1486 |
\global\@ExePartTitletrue} |
| 1487 |
\define@key{PPExePart}{name}{\gdef\@ExePartName{#1}% |
| 1488 |
\global\@ExePartReNametrue} |
| 1489 |
\define@key{PPExePart}{difficulty}{\global\@ExePartDifficultytrue% |
| 1490 |
\global\ExePartDifficulty=\number#1} |
| 1491 |
% |
| 1492 |
\def\@getExePartInfo{% |
| 1493 |
\if@ExePartReName\def\ExePartName{\@ExePartName}\fi |
| 1494 |
\if@ExePartTitle\else\def\ExePartHeaderTitle{}\fi |
| 1495 |
\if@ExePartDifficulty\else\def\ExePartHeaderDifficulty{}\fi |
| 1496 |
\if@ExePartStared\def\ExePartHeaderNB{}\fi |
| 1497 |
} |
| 1498 |
% |
| 1499 |
\def\ExePart{\@InitExePart\@ifstar{\global\@ExePartStaredtrue\@ExePart}% |
| 1500 |
{\global\@ExePartStaredfalse\@ExePart}} |
| 1501 |
% |
| 1502 |
\def\@ExePart{\@ifnextchar[\@@ExePart{\@@ExePart[]}}%] for emacs |
| 1503 |
% |
| 1504 |
\def\@@ExePart[#1]{\setkeys{PPExePart}{#1}\@@@ExePart} |
| 1505 |
% |
| 1506 |
\newcommand{\@@@ExePart}{% |
| 1507 |
\if@ExePartStared\else\refstepcounter{ExePart}\fi |
| 1508 |
\begingroup\@getExePartInfo\@ExePartHeader\endgroup} |
| 1509 |
% |
| 1510 |
% \end{macrocode} |
| 1511 |
% \subsubsection{Presentation of answers} |
| 1512 |
% \begin{macrocode} |
| 1513 |
\newbox\@Answerbox |
| 1514 |
% |
| 1515 |
%\changes{v1.3}{2009/03/26}{Header of answers are now correct.} |
| 1516 |
% |
| 1517 |
\newcommand{\AnswerHeader}{\medskip\centerline{\textbf{\AnswerName\ % |
| 1518 |
\ExerciseHeaderNB}\smallskip}} |
| 1519 |
% |
| 1520 |
\newcommand{\AnswerListHeader}{\textbf{\AnswerListName\ |
| 1521 |
(\ExerciseListName\ \ExerciseHeaderNB)\ ---\ }} |
| 1522 |
% |
| 1523 |
% The commands for <Exercise> environment |
| 1524 |
% |
| 1525 |
\def\@InitAnswer{\@savemathindent\global\@echapqfalse% |
| 1526 |
\gdef\AnswerRef{}% |
| 1527 |
\global\@AnswerReffalse% |
| 1528 |
\gdef\AnswerNB{}% |
| 1529 |
\global\@AnswerNBfalse% |
| 1530 |
\setcounter{ExePart}{0}% |
| 1531 |
\setcounter{Question}{0}} |
| 1532 |
% |
| 1533 |
\def\@getAnswerInfo{% |
| 1534 |
\if@AnswerRef% |
| 1535 |
\def\theExercise{\ref{\AnswerRef}}% |
| 1536 |
\refstepcounter{Answer}% |
| 1537 |
\recordExerciseLabel{\AnswerRef-Answer}% |
| 1538 |
\else |
| 1539 |
\if@AnswerNB |
| 1540 |
\def\ExerciseTitle{}% |
| 1541 |
\def\ExerciseName{}% |
| 1542 |
\def\ExerciseOrigin{}% |
| 1543 |
\def\ExerciseType{}% |
| 1544 |
\ExerciseDifficulty=0% |
| 1545 |
\def\theExercise{\AnswerNB}% |
| 1546 |
\else |
| 1547 |
\if@AswLastExe |
| 1548 |
\else |
| 1549 |
\PackageWarning{Exercise}% |
| 1550 |
{An answer has no reference and no number}{}% |
| 1551 |
\def\AnswerHeaderRef{\AnswerName\ ???}% |
| 1552 |
\def\AnswerListHeaderRef{\AnswerName\ ???}% |
| 1553 |
\fi\fi\fi} |
| 1554 |
% |
| 1555 |
\newif\if@AnswerRef \@AnswerReffalse |
| 1556 |
\newif\if@AnswerNB \@AnswerNBfalse |
| 1557 |
% |
| 1558 |
\define@key{PPAnswer}{ref}{\global\@AnswerReftrue\gdef\AnswerRef{#1}} |
| 1559 |
\define@key{PPAnswer}{number}{\global\@AnswerNBtrue\gdef\AnswerNB{#1}} |
| 1560 |
% |
| 1561 |
\def\beginAnswerEnv{\@InitAnswer\@ifnextchar[\@@AnswerEnv{\@@AnswerEnv[]}}%] |
| 1562 |
% |
| 1563 |
\def\@@AnswerEnv[#1]{\setkeys{PPAnswer}{#1}% |
| 1564 |
\global\@Answertrue\@selectAnswer\@BeginExeBox\@@@AnswerEnv} |
| 1565 |
% |
| 1566 |
\newcommand{\@@@AnswerEnv}{% |
| 1567 |
\pagebreak[1]\vskip\AnswerSkipBefore\@QuestionLevel1 |
| 1568 |
\begingroup\@getAnswerInfo\AnswerHeader\endgroup\AtBeginAnswer} |
| 1569 |
% |
| 1570 |
\gdef\endAnswerEnv{\termineliste{1}\@EndExeBox\termineliste{0}\vskip\AnswerSkipAfter} |
| 1571 |
% |
| 1572 |
\newenvironment{Answer}{}{} |
| 1573 |
\gdef\defineAnswerEnv{ |
| 1574 |
\gdef\@AnswerHeaderRef{\AnswerHeader} |
| 1575 |
\renewenvironment{Answer}{\beginAnswerEnv}{\endAnswerEnv}} |
| 1576 |
% |
| 1577 |
\defineAnswerEnv |
| 1578 |
% |
| 1579 |
\def\AnswerCmd{\@InitAnswer\@ifnextchar[\@@AnswerCmd{\@@AnswerCmd[]}} |
| 1580 |
% |
| 1581 |
\def\@@AnswerCmd[#1]{\setkeys{PPAnswer}{#1}\@@@AnswerCmd} |
| 1582 |
% |
| 1583 |
\newcommand{\@@@AnswerCmd}{% |
| 1584 |
\ifnum\@QuestionLevel=0 |
| 1585 |
\advance \@QuestionLevel by 1 |
| 1586 |
\begin{list}{}{\partopsep\Exepartopsep \labelsep\Exelabelsep |
| 1587 |
\itemsep \Exesep \parsep\Exeparsep |
| 1588 |
\topsep\Exetopsep \labelwidth\Exelabelwidth |
| 1589 |
\leftmargin\Exeleftmargin |
| 1590 |
\rightmargin\Exerightmargin } |
| 1591 |
%% \refstepExecounter |
| 1592 |
\else |
| 1593 |
\termineliste{1}\@EndExeBox |
| 1594 |
\fi |
| 1595 |
\global\@Answertrue\@selectAnswer\@BeginExeBox% |
| 1596 |
\item[\bgroup\@getAnswerInfo\AnswerListHeader\egroup]\AtBeginAnswer\ignorespaces |
| 1597 |
} |
| 1598 |
% |
| 1599 |
\def\defineAnswerCmd{\gdef\@AnswerHeaderRef{\AnswerListHeader}% |
| 1600 |
\def\Answer{\AnswerCmd}} |
| 1601 |
% \end{macrocode} |
| 1602 |
% \subsubsection{Exercises selection} |
| 1603 |
% |
| 1604 |
%\changes{v1.4}{2010/08/27}{Exercises selection completly review.} |
| 1605 |
% |
| 1606 |
% \begin{macrocode} |
| 1607 |
|
| 1608 |
|
| 1609 |
\newif\if@ShipThisExercise \@ShipThisExercisetrue |
| 1610 |
\newif\if@@ShipThisExercise \@@ShipThisExercisetrue |
| 1611 |
\newif\if@ExerciseSelected \@ExerciseSelectedtrue |
| 1612 |
\newif\if@ShipThisAnswer \@ShipThisAnswertrue |
| 1613 |
\newif\if@@ShipThisAnswer \@@ShipThisAnswertrue |
| 1614 |
\newif\if@ExeSelectExam \@ExeSelectExamfalse |
| 1615 |
\newif\if@ExeSelectYear \@ExeSelectYearfalse |
| 1616 |
\newif\if@ExeSelectDifficulty \@ExeSelectDifficultyfalse |
| 1617 |
\newif\if@ExeSelectOrigin \@ExeSelectOriginfalse |
| 1618 |
\newif\if@ExeSelectClass \@ExeSelectClassfalse |
| 1619 |
\newif\if@ExeSelectType \@ExeSelectTypefalse |
| 1620 |
\newif\if@ExeSelectLabel \@ExeSelectLabelfalse |
| 1621 |
|
| 1622 |
\define@key{PPExerciseSelect}{exam}% |
| 1623 |
{\global\@ExeSelectExamtrue\gdef\ExerciseSelectExam{#1}} |
| 1624 |
\define@key{PPExerciseSelect}{year}% |
| 1625 |
{\global\@ExeSelectYeartrue\gdef\ExerciseSelectYear{#1}} |
| 1626 |
\define@key{PPExerciseSelect}{difficulty}% |
| 1627 |
{\global\@ExeSelectDifficultytrue\gdef\ExerciseSelectDifficulty{#1}} |
| 1628 |
\define@key{PPExerciseSelect}{type}% |
| 1629 |
{\global\@ExeSelectTypetrue\gdef\ExerciseSelectType{#1}} |
| 1630 |
\define@key{PPExerciseSelect}{origin}% |
| 1631 |
{\global\@ExeSelectOrigintrue\gdef\ExerciseSelectOrigin{#1}} |
| 1632 |
\define@key{PPExerciseSelect}{class}% |
| 1633 |
{\global\@ExeSelectClasstrue\gdef\ExerciseSelectClass{#1}} |
| 1634 |
\define@key{PPExerciseSelect}{label}% |
| 1635 |
{\global\@ExeSelectLabeltrue\gdef\ExerciseSelectLabel{#1}} |
| 1636 |
|
| 1637 |
\newcommand{\ExerciseStopSelect}{ |
| 1638 |
\@ExeSelectExamfalse |
| 1639 |
\@ExeSelectYearfalse |
| 1640 |
\@ExeSelectDifficultyfalse |
| 1641 |
\@ExeSelectTypefalse |
| 1642 |
\@ExeSelectOriginfalse |
| 1643 |
\@ExeSelectClassfalse |
| 1644 |
\@ExeSelectLabelfalse |
| 1645 |
\@ExeSelectTypefalse |
| 1646 |
} |
| 1647 |
|
| 1648 |
\newcommand{\ExerciseSelect}{\@ifstar{\global\@ExerciseSelectedfalse\@ExerciseSelect}{\global\@ExerciseSelectedtrue\@ExerciseSelect}} |
| 1649 |
\newcommand{\@ExerciseSelect}[1][]{\setkeys{PPExerciseSelect}{#1}} |
| 1650 |
|
| 1651 |
\def\@selectExercise{% |
| 1652 |
\global\@ShipThisExercisetrue |
| 1653 |
\global\@@ShipThisExercisefalse |
| 1654 |
\if@ExeSelectExam |
| 1655 |
\@for\@exam:=\ExerciseSelectExam\do |
| 1656 |
{\ifthenelse{\equal{\@exam}{\ExerciseExam}}{ |
| 1657 |
\global\@@ShipThisExercisetrue |
| 1658 |
}{} |
| 1659 |
} |
| 1660 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1661 |
\global\@@ShipThisExercisefalse |
| 1662 |
\fi |
| 1663 |
% |
| 1664 |
\if@ExeSelectYear |
| 1665 |
\@for\@year:=\ExerciseSelectYear\do |
| 1666 |
{ \ifthenelse{\equal{\@year}{\ExerciseYear}}{ |
| 1667 |
\global\@@ShipThisExercisetrue |
| 1668 |
}{} |
| 1669 |
} |
| 1670 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1671 |
\global\@@ShipThisExercisefalse |
| 1672 |
\fi |
| 1673 |
% |
| 1674 |
\if@ExeSelectDifficulty |
| 1675 |
\@for\@difficulty:=\ExerciseSelectDifficulty\do |
| 1676 |
{ \ifthenelse{\equal{\@difficulty}{\ExerciseDifficulty}}{ |
| 1677 |
\global\@@ShipThisExercisetrue |
| 1678 |
}{} |
| 1679 |
} |
| 1680 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1681 |
\global\@@ShipThisExercisefalse |
| 1682 |
\fi |
| 1683 |
% |
| 1684 |
\if@ExeSelectOrigin |
| 1685 |
\@for\@origin:=\ExerciseSelectOrigin\do |
| 1686 |
{ \ifthenelse{\equal{\@origin}{\ExerciseOrigin}}{ |
| 1687 |
\global\@@ShipThisExercisetrue |
| 1688 |
}{} |
| 1689 |
} |
| 1690 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1691 |
\global\@@ShipThisExercisefalse |
| 1692 |
\fi |
| 1693 |
% |
| 1694 |
\if@ExeSelectClass |
| 1695 |
\@for\@origin:=\ExerciseSelectClass\do |
| 1696 |
{ \ifthenelse{\equal{\@origin}{\ExerciseClass}}{ |
| 1697 |
\global\@@ShipThisExercisetrue |
| 1698 |
}{} |
| 1699 |
} |
| 1700 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1701 |
\global\@@ShipThisExercisefalse |
| 1702 |
\fi |
| 1703 |
% |
| 1704 |
\if@ExeSelectLabel |
| 1705 |
\@for\@label:=\ExerciseSelectLabel\do |
| 1706 |
{ \ifthenelse{\equal{\@label}{\ExerciseLabel}}{ |
| 1707 |
\global\@@ShipThisExercisetrue |
| 1708 |
}{} |
| 1709 |
} |
| 1710 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1711 |
\global\@@ShipThisExercisefalse |
| 1712 |
\fi |
| 1713 |
% |
| 1714 |
\if@ExeSelectType |
| 1715 |
\@for\@type:=\ExerciseSelectType\do |
| 1716 |
{ \ifthenelse{\equal{\@type}{\ExerciseType}}{ |
| 1717 |
\global\@@ShipThisExercisetrue |
| 1718 |
}{} |
| 1719 |
} |
| 1720 |
\if@@ShipThisExercise\else\@ShipThisExercisefalse\fi |
| 1721 |
\global\@@ShipThisExercisefalse |
| 1722 |
\fi |
| 1723 |
\if@ExerciseSelected\else\if@ShipThisExercise\global\@ShipThisExercisefalse\else\global\@ShipThisExercisetrue\fi\fi |
| 1724 |
} |
| 1725 |
\def\@selectAnswer{% |
| 1726 |
\global\@ShipThisAnswertrue |
| 1727 |
\global\@@ShipThisAnswerfalse |
| 1728 |
% |
| 1729 |
\if@ExeSelectLabel |
| 1730 |
\@for\@label:=\ExerciseSelectLabel\do |
| 1731 |
{ \ifthenelse{\equal{\@label}{\AnswerRef}}{ |
| 1732 |
\global\@@ShipThisAnswertrue |
| 1733 |
}{} |
| 1734 |
} |
| 1735 |
\if@@ShipThisAnswer\else\@ShipThisAnswerfalse\fi |
| 1736 |
\global\@@ShipThisAnswerfalse |
| 1737 |
\fi |
| 1738 |
\if@ExerciseSelected\else\if@ShipThisAnswer\global\@ShipThisAnswerfalse\else\global\@ShipThisAnswertrue\fi\fi |
| 1739 |
} |
| 1740 |
% \end{macrocode} |
| 1741 |
% \subsubsection{Some extra stuff} |
| 1742 |
% \begin{macrocode} |
| 1743 |
\newcommand{\ExeText}{\setcounter{savedQuestion}{\value{Question}}% |
| 1744 |
\termineliste{1}\@echapqtrue} |
| 1745 |
% \end{macrocode} |
| 1746 |
% \subsubsection{Secret stuff} |
| 1747 |
% \begin{macrocode} |
| 1748 |
% |
| 1749 |
% Il est possible de présenter un niveau de sectionnement sur |
| 1750 |
% deux colonnes avec la commande \colonnesLevel |
| 1751 |
% |
| 1752 |
\newcount\colonnesLevel \colonnesLevel=-10 |
| 1753 |
\newskip\tempskipa |
| 1754 |
\newskip\tempskipb |
| 1755 |
\def\deuxcolonnes{\tempskipa=\multicolsep\colonnesLevel=\@QuestionLevel |
| 1756 |
\ifcase\@QuestionLevel \multicolsep=\QuestionBefore % |
| 1757 |
\or |
| 1758 |
\multicolsep=\subQuestionBefore\or\multicolsep=\subsubQuestionBefore\fi% |
| 1759 |
\begin{multicols}{2}} |
| 1760 |
% |
| 1761 |
% Tenir compte de l'option fleqn |
| 1762 |
% |
| 1763 |
\@ifundefined{if@fleqn}{\newif\if@fleqn\@fleqnfalse}{} |
| 1764 |
% |
| 1765 |
\newlength{\@savedmathindent} |
| 1766 |
\newcommand{\@savemathindent}{\relax} |
| 1767 |
\newcommand{\@decalemathindent}[1]{\relax} |
| 1768 |
\newcommand{\@restoremathindent}{\relax} |
| 1769 |
\if@fleqn % |
| 1770 |
\renewcommand{\@savemathindent}{\setlength{\@savedmathindent}{\mathindent}} |
| 1771 |
\renewcommand{\@decalemathindent}[1]{\addtolength{\mathindent}{#1}} |
| 1772 |
\renewcommand{\@restoremathindent}{\setlength{\mathindent}{\@savedmathindent}} |
| 1773 |
\else |
| 1774 |
\renewcommand{\@savemathindent}{\relax} |
| 1775 |
\renewcommand{\@decalemathindent}[1]{\relax} |
| 1776 |
\renewcommand{\@restoremathindent}{\relax} |
| 1777 |
\fi |
| 1778 |
% \end{macrocode} |
| 1779 |
% \subsection{The \texttt{\textbackslash renewcounter} command} |
| 1780 |
% This commands is the equivalent of the well--known |\renewcommand|, |
| 1781 |
% but for counter. It allows you to redefine the |Exercise| counter, |
| 1782 |
% in order to reset it at each chapter (for example). |
| 1783 |
% \begin{macrocode} |
| 1784 |
\def\renewcounter#1{% |
| 1785 |
\@ifundefined{c@#1} |
| 1786 |
{\@latex@error{counter #1 undefined}\@ehc}% |
| 1787 |
\relax |
| 1788 |
\let\@ifdefinable\@rc@ifdefinable |
| 1789 |
\@ifnextchar[{\@newctr{#1}}{}} |
| 1790 |
% \end{macrocode} |
| 1791 |
% \begin{macrocode} |
| 1792 |
\def\ext@exercise{loe} |
| 1793 |
\newcommand{\ExerciseLevelInToc}[1]{\def\toc@exercise{#1}} |
| 1794 |
\ExerciseLevelInToc{exercise} |
| 1795 |
\newcommand{\ListOfExerciseInToc}{\def\ext@exercise{toc}\ExerciseLevelInToc{paragraph}} |
| 1796 |
\newcommand\listofexercises{% |
| 1797 |
\section*{\listexercisename}% |
| 1798 |
\@mkboth{\MakeUppercase\listexercisename}% |
| 1799 |
{\MakeUppercase\listexercisename}% |
| 1800 |
\@starttoc{\ext@exercise}% |
| 1801 |
} |
| 1802 |
\newcommand*\l@exercise{\@dottedtocline{2}{1.5em}{2.3em}} |
| 1803 |
% \end{macrocode} |
| 1804 |
|
| 1805 |
% \Finale |
| 1806 |
\endinput |