%% %% This is file `exercise.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% exercise.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright (C) 2003 by Paul Pichaureau %% %% This program is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public License %% as published by the Free Software Foundation; either version 2 %% of the License, or (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %% GNU General Public License for more details. %% %% You should have received a copy of the GNU General Public License %% along with this program; if not, write to the Free Software %% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. %% Public LaTeX Project Public %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{exercise} [2014/10/20 v1.6 Exercise package (P.Pichaureau)] %% \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 \~} %% \newif\if@AnswerOutput \@AnswerOutputtrue \newif\if@AnswerDelay \@AnswerDelayfalse \newif\if@ExerciseOutput \@ExerciseOutputtrue \newif\if@ExerciseDelay \@ExerciseDelayfalse \newif\if@AswLastExe \@AswLastExefalse \DeclareOption{noanswer} {\@AnswerOutputfalse} \DeclareOption{answeronly} {\@AnswerOutputtrue\@ExerciseOutputfalse} \DeclareOption{noexercise} {\@ExerciseOutputfalse} \DeclareOption{exerciseonly} {\@AnswerOutputfalse} \DeclareOption{outputnothing}{\@ExerciseOutputfalse\@AnswerOutputfalse} \DeclareOption{exercisedelayed}{\@ExerciseDelaytrue} \DeclareOption{answerdelayed}{\@AnswerDelaytrue} \DeclareOption{lastexercise} {\@AswLastExetrue} \newif\if@ShowLabel \@ShowLabelfalse \DeclareOption{showlabel} {\@ShowLabeltrue} \ProcessOptions \RequirePackage{keyval, ifthen} \def\listexercisename{List of exercises}% \def\ExerciseName{Exercise}% \def\AnswerName{Answer of exercise}% \def\ExerciseListName{Ex.}% \def\AnswerListName{Answer}% \def\ExePartName{Part}% \def\ArticleOf{of\ }% \@ifpackageloaded{babel}{ \addto{\captionsfrenchb}{ \def\listexercisename{Liste des exercices}% \def\ExerciseName{Exercice}% \def\AnswerName{Solution de l'exercice}% \def\ExerciseListName{Ex.}% \def\AnswerListName{Solution}% \def\ExePartName{Partie}% } \addto{\captionsspanish}{ \def\listexercisename{\'{I}ndice de \es@uclc Eejercicios}% \def\ExerciseName{Ejercicio}% \def\AnswerName{Soluci\'on del ejercicio}% \def\ExerciseListName{Ej.}% \def\AnswerListName{Soluci\'on}% \def\ExePartName{Parte}% \def\ArticleOf{del\ }% } \addto\captionsitalian{% \def\listexercisename{Indice degli esercizi} \def\ExerciseName{Esercizio}% \def\AnswerName{Soluzione dell'esercizio}% \def\ExerciseListName{Es.}% \def\AnswerListName{Soluzione}% \def\ExePartName{Parte}% } \addto\captionsdutch{% \def\listexercisename{Lijst van opdrachten} \def\ExerciseName{Opdracht} \def\AnswerName{Oplossing van opdracht} \def\ExerciseListName{Opg.} \def\AnswerListName{Oplossing} \def\ExePartName{Deel} \def\ArticleOf{van\ } } \addto\captionsgerman{% \def\listexercisename{Liste der {\"U}bungen}% \def\ExerciseName{{\"U}bung}% \def\AnswerName{L{\"o}sung zu {\"U}bung}% \def\ExerciseListName{{\"U}b.}% \def\AnswerListName{L{\"o}sung}% \def\ExePartName{Teil}% \def\ArticleOf{von\ }% } \addto\captionsngerman{% \def\listexercisename{Liste der {\"U}bungen}% \def\ExerciseName{{\"U}bung}% \def\AnswerName{L{\"o}sung zu {\"U}bung}% \def\ExerciseListName{{\"U}b.}% \def\AnswerListName{L{\"o}sung}% \def\ExePartName{Teil}% \def\ArticleOf{von\ }% } \addto\captionsportugese{% \def\listexercisename{Lista de exerc\'icios}% \def\ExerciseName{Exerc\'icio}% \def\AnswerName{Solução do exerc\'icio}% \def\ExerciseListName{Ex.}% \def\AnswerListName{Solu\c{c}\~ao}% \def\ExePartName{Parte}% \def\ArticleOf{de\ }% } \addto{\captionsrussian}{ \def\listexercisename{Список упражнений}% \def\ExerciseName{Упражнение}% \def\AnswerName{Ответ к упражнению}% \def\ExerciseListName{Упр.}% \def\AnswerListName{Ответ}% \def\ExePartName{Часть}% \def\ArticleOf{из\ }% } }{} \newlength{\ExerciseSkipBefore} \setlength{\ExerciseSkipBefore}{1\baselineskip} \newlength{\ExerciseSkipAfter} \setlength{\ExerciseSkipAfter}{0\baselineskip} \newlength{\AnswerSkipBefore} \setlength{\AnswerSkipBefore}{0\baselineskip} \newlength{\AnswerSkipAfter} \setlength{\AnswerSkipAfter}{0\baselineskip} \newlength{\Exesep} \setlength{\Exesep}{1\baselineskip} \newlength{\Exetopsep} \setlength{\Exetopsep}\z@ \newlength{\Exeparsep} \setlength{\Exeparsep}{\parskip} \newlength{\Exepartopsep} \setlength{\Exepartopsep}\z@ \newlength{\Exeleftmargin} \setlength{\Exeleftmargin}\z@ \newlength{\Exerightmargin} \setlength{\Exerightmargin}\z@ \newlength{\Exelabelwidth} \setlength{\Exelabelwidth}\z@ \newlength{\Exelabelsep} \setlength{\Exelabelsep}\z@ \newlength{\ExerciseBefore} \setlength{\ExerciseBefore}{0em} \newlength{\QuestionBefore} \setlength{\QuestionBefore}{.25em} \newlength{\subQuestionBefore} \setlength{\subQuestionBefore}{0em} \newlength{\subsubQuestionBefore} \setlength{\subsubQuestionBefore}{0em} \newlength{\QuestionIndent} \setlength{\QuestionIndent}{3em} \newlength{\subQuestionIndent} \setlength{\subQuestionIndent}{2em} \newlength{\subsubQuestionIndent} \setlength{\subsubQuestionIndent}{2.5em} \newcounter{Exercise} \newcounter{Answer} \gdef\@ExerciseCounter{Exercise} %default exercise counter \gdef\@AnswerCounter{Answer} %default answer counter \@ifpackageloaded{hyperref}{ \def\@setAnswerref#1#2#3#4{% \ifx#1\relax \protect\G@refundefinedtrue \nfss@text{\reset@font\bfseries ??}% \PackageWarning{exercise}{Reference to Answer of `#3' on page \thepage \space undefined}% \else \hyperref[#4]{\expandafter#2#1}\null \fi} \def\refAnswer#1{\expandafter\@setAnswerref\csname r@#1\endcsname\@firstoffive{#1}{#1-Answer}}} {\let\refAnswer\ref} \newcounter{ExePart}[Exercise] \newcounter{Question}[Exercise] \newcounter{subQuestion}[Question] \newcounter{subsubQuestion}[subQuestion] \renewcommand{\theExercise}{\if@ExeStared\else\arabic{\@ExerciseCounter}\fi} \renewcommand{\theExePart}{\Roman{ExePart}} \renewcommand{\theQuestion}{\arabic{Question}} \renewcommand{\thesubQuestion}{\alph{subQuestion}} \renewcommand{\thesubsubQuestion}{\roman{subsubQuestion}} \newcounter{savedQuestion} \newcounter{savedsubQuestion} \newcounter{savedsubsubQuestion} \def\marker#1#2{\@tempcnta#2\whiledo{\@tempcnta>0}{#1\advance \@tempcnta by -1 }} \def\DifficultyMarker{*} \newcommand{\AtBeginExercise}{} \newcommand{\AtBeginAnswer}{} \newcommand{\ExerciseHeaderTitle}{\qquad\ExerciseTitle} \newcommand{\ExerciseHeaderExam}{\ExerciseExam} \newcommand{\ExerciseHeaderYear}{\ \ExerciseYear} \newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ } \newcommand{\ExerciseHeaderOrigin}{% \ ({\usefont{\encodingdefault}{\rmdefault}{m}{it}\ExerciseOrigin})} \newcommand{\ExerciseHeaderNB}{\theExercise} \newcommand{\ExerciseHeaderLabel}{\fbox{\textsc{\ExerciseLabel}}} \newcommand{\ExerciseHeader}{\centerline{% \textbf{\large\ExerciseHeaderDifficulty\ExerciseName\ % \ExerciseHeaderNB\ExerciseHeaderTitle\ExerciseHeaderOrigin}}\medskip} \newcommand{\ExerciseListHeader}{\ExerciseHeaderDifficulty% \textbf{\ExerciseListName\ \ExerciseHeaderNB% \ --- \ \ExerciseHeaderTitle}% \ExerciseHeaderOrigin\ignorespaces} \newcommand{\ExePartHeaderNB}{\ \theExePart} \newcommand{\ExePartHeaderTitle}{\quad --- \quad {\ExePartTitle}} \newcommand{\ExePartHeaderDifficulty}{\theExePartDifficulty\ } \newcommand{\ExePartHeader}{% \medskip\centerline{\emph{\large\ExePartHeaderDifficulty\ExePartName% \ExePartHeaderNB\ExePartHeaderTitle}}} \newcommand{\ExePartListHeader}{\bigskip% \emph{\ExePartHeaderDifficulty\ExePartName% \ExePartHeaderNB\ExePartHeaderTitle}\par\medskip} \newcommand{\QuestionNB}{\arabic{Question}.\ } \newcommand{\QuestionHeaderTitle}{\emph{(\QuestionTitle)}\ } \newcommand{\QuestionHeaderDifficulty}{\theQuestionDifficulty\ } \newcommand{\theQuestionDifficulty}{\marker{\DifficultyMarker}% {\QuestionDifficulty}} \newcommand{\subQuestionNB}{\alph{subQuestion})} \newcommand{\subQuestionHeaderTitle}{\emph{(\subQuestionTitle)}\ } \newcommand{\subQuestionHeaderDifficulty}{\thesubQuestionDifficulty\ } \newcommand{\subQuestionHeader}{\subQuestionHeaderDifficulty% \subQuestionNB)\ \emph{\subQuestionHeaderTitle}} \newcommand{\thesubQuestionDifficulty}{\marker{\DifficultyMarker}% {\subQuestionDifficulty}} \newcommand{\subsubQuestionNB}{\roman{subsubQuestion} -- } \newcommand{\subsubQuestionHeaderTitle}{\emph{(\subsubQuestionTitle)}\ } \newcommand{\subsubQuestionHeaderDifficulty}{\thesubsubQuestionDifficulty\ } \newcommand{\subsubQuestionHeader}{\subsubQuestionHeaderDifficulty% \subsubQuestionNB \emph{\subsubQuestionHeaderTitle} --} \newcommand{\thesubsubQuestionDifficulty}{% \marker{\DifficultyMarker}{\subsubQuestionDifficulty}} \newcount\@QuestionLevel \@QuestionLevel=0 \newcommand{\the@QuestionLevel}{\number\@QuestionLevel} \newbox\@Exercisebox \newbox\all@Exercisebox \newbox\temp@Exercisebox \newbox\all@Answerbox \newbox\temp@Answerbox \newif\if@echapq \@echapqfalse \newif\if@Answer \@Answerfalse \def\termineliste#1{\global\@echapqfalse% \whiledo{\@QuestionLevel>#1}% {\ifnum\@QuestionLevel=\colonnesLevel\end{multicols}\colonnesLevel=-10\fi% \end{list}\advance\@QuestionLevel by -1}% \ifnum\@QuestionLevel=\colonnesLevel\end{multicols}\colonnesLevel=-10\fi} \newif\if@ExeTitle \@ExeTitlefalse \newif\if@ExeExam \@ExeExamfalse \newif\if@ExeYear \@ExeYearfalse \newif\if@ExeReName \@ExeReNamefalse \global\newcount\ExerciseDifficulty \ExerciseDifficulty=0 \newif\if@ExeDifficulty \@ExeDifficultyfalse \newif\if@ExeOrigin \@ExeOriginfalse \newif\if@ExeType \@ExeTypefalse \newif\if@ExeLabel \@ExeLabelfalse \newif\if@ExeNB \@ExeNBfalse \def\theExerciseDifficulty{\marker{\DifficultyMarker}{\ExerciseDifficulty}} \define@key{PPExercise}{title}% {\global\@ExeTitletrue\gdef\ExerciseTitle{#1}} \define@key{PPExercise}{exam}% {\global\@ExeExamtrue\gdef\ExerciseExam{#1}} \define@key{PPExercise}{year}% {\global\@ExeYeartrue\gdef\ExerciseYear{#1}} \define@key{PPExercise}{difficulty}% {\global\@ExeDifficultytrue\global\ExerciseDifficulty=\number#1} \define@key{PPExercise}{name}% {\global\@ExeReNametrue\gdef\@ExerciseName{#1}} \define@key{PPExercise}{origin}% {\global\@ExeOrigintrue\gdef\ExerciseOrigin{#1}} \define@key{PPExercise}{type}% {\global\@ExeTypetrue\gdef\ExerciseType{#1}} \define@key{PPExercise}{counter}% {\gdef\@ExerciseCounter{#1}} \define@key{PPExercise}{label}% {\global\@ExeLabeltrue\gdef\ExerciseLabel{#1}\gdef\ExerciseTrueLabel{#1}} \define@key{PPExercise}{number}% {\global\@ExeNBtrue\gdef\ExerciseLocalNB{#1}} \define@key{PPExercise}{class}% {\gdef\ExerciseClass{#1}} \newif\if@ExeStared \@ExeStaredfalse \def\@InitExe{\@savemathindent\global\@echapqfalse% \gdef\ExerciseTitle{}% \gdef\ExerciseExam{}% \gdef\ExerciseYear{}% \gdef\@ExerciseName{}% \gdef\ExerciseOrigin{}% \gdef\ExerciseType{}% \gdef\ExerciseTrueLabel{}% \global\ExerciseDifficulty=0% \global\@ExeTitlefalse% \global\@ExeExamfalse% \global\@ExeYearfalse% \global\@ExeReNamefalse% \global\@ExeDifficultyfalse% \global\@ExeOriginfalse% \global\@ExeTypefalse% \global\@ExeNBfalse% \gdef\@ExerciseCounter{Exercise}% \setcounter{ExePart}{0}% \setcounter{Question}{0}% \global\@ExeLabelfalse% } \def\@getExerciseInfo{% \if@ExeReName\def\ExerciseName{\@ExerciseName}\fi% \if@ExeTitle\else\def\ExerciseHeaderTitle{}\fi% \if@ExeExam\else\def\ExerciseHeaderExam{}\fi% \if@ExeYear\else\def\ExerciseHeaderYear{}\fi% \if@ExeOrigin\else\def\ExerciseHeaderOrigin{}\fi% \if@ExeType\else\def\ExerciseHeaderType{}\fi% \if@ExeNB\setcounter{Exercise}{\ExerciseLocalNB} \protected@edef\@currentlabel{\p@Exercise\theExercise}% \fi% \if@ExeDifficulty\else\def\ExerciseHeaderDifficulty{}\fi% \if@ExeStared\def\ExerciseHeaderNB{}\fi% \if@ExeLabel\recordExerciseLabel{\ExerciseLabel}\else\def\ExerciseHeaderLabel{}\fi% } \def\refstepExecounter{\if@ShipThisExercise\if@ExeStared\else\if@ExeNB\else% \refstepcounter{\@ExerciseCounter}\fi\fi\fi} \def\recordExerciseLabel#1{\label{#1}} \def\@BeginExeBox{\global\setbox\@Exercisebox\vbox\bgroup} \def\@EndExeBox{\egroup\if@Answer\if@AnswerOutput\@DelayAnswerBox\fi% \else\if@ExerciseOutput\@DelayExerciseBox\fi\fi} \def\@DelayAnswerBox{% \if@ShipThisAnswer\if@AnswerDelay\global\setbox\temp@Answerbox% \vbox{\unvbox\all@Answerbox\vskip\Exesep\unvbox\@Exercisebox\vskip\z@}% \global\setbox\all@Answerbox\copy\temp@Answerbox% \else\unvbox\@Exercisebox\fi\fi} \def\@DelayExerciseBox{\if@ShipThisExercise\if@ExerciseDelay% \global\setbox\temp@Exercisebox% \vbox{\unvbox\all@Exercisebox\vskip\Exesep\unvbox\@Exercisebox\vskip\z@}% \global\setbox\all@Exercisebox\copy\temp@Exercisebox% \else\unvbox\@Exercisebox\fi\fi} \newcommand{\shipoutAnswer}{\if@AnswerOutput\unvbox\all@Answerbox\fi} \newcommand{\shipoutExercise}{\if@ExerciseOutput\unvbox\all@Exercisebox\fi} \def\beginExerciseEnv{\@InitExe\@ifnextchar[\@@ExeEnv{\@@ExeEnv[]}}%] \def\@@ExeEnv[#1]{\setkeys{PPExercise}{#1}% \@selectExercise\global\@Answerfalse\@BeginExeBox\@@@ExeEnv} \newcommand{\@@@ExeEnv}{% \pagebreak[1]\vskip\ExerciseSkipBefore \@QuestionLevel1 \refstepExecounter \begingroup\@getExerciseInfo\ExerciseHeader \addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\ \theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}} \endgroup\AtBeginExercise} \def\endExerciseEnv{\termineliste{1}\@EndExeBox% \vskip\ExerciseSkipAfter} \def\ExerciseCmd{\@InitExe\@ifstar{\global\@ExeStaredtrue\@ExeCmd}% {\global\@ExeStaredfalse\@ExeCmd}} \def\@ExeCmd{\@ifnextchar[\@@ExeCmd{\@@ExeCmd[]}}%] for emacs \def\@@ExeCmd[#1]{\setkeys{PPExercise}{#1}\@@@ExeCmd} \newcommand{\@@@ExeCmd}{% \ifnum\@QuestionLevel=0 \advance \@QuestionLevel by 1 \begin{list}{\@getExerciseInfo\ExerciseListHeader}% {\partopsep\Exepartopsep \labelsep\Exelabelsep \itemsep \Exesep% \parsep\Exeparsep \topsep\Exetopsep \labelwidth\Exelabelwidth% \leftmargin\Exeleftmargin \rightmargin\Exerightmargin} \else \termineliste{1}\@EndExeBox \fi \@selectExercise \global\@Answerfalse\@BeginExeBox\refstepExecounter% \addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\ \theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}} \item\ignorespaces\AtBeginExercise } \def\defineExePartInEnv{\def\@ExePartHeader{\ExePartHeader}} \def\defineExePartInList{\def\@ExePartHeader{\ExePartListHeader}} \def\defineExerciseEnv{% \defineExePartInEnv \renewenvironment{Exercise}{\global\@ExeStaredfalse\global\beginExerciseEnv}% {\endExerciseEnv} \renewenvironment{Exercise*}{\global\@ExeStaredtrue\beginExerciseEnv}% {\endExerciseEnv} } \newenvironment{Exercise}{}{} \newenvironment{Exercise*}{}{} \def\defineExerciseCmd{\def\Exercise{\ExerciseCmd}} \renewcommand{\Exercise}{} \defineExerciseEnv \def\beginExerciseListEnv{\defineExerciseCmd\defineAnswerCmd% \defineExePartInList} \def\endExerciseListEnv{\termineliste{1}\@EndExeBox\termineliste{0}% \defineExerciseEnv\defineAnswerEnv} \newenvironment{ExerciseList}{\beginExerciseListEnv}{\endExerciseListEnv} \def\QuestionTitle{} \newif\if@QuestionTitle \@QuestionTitlefalse \global\newcount\QuestionDifficulty \QuestionDifficulty=0 \newif\if@QuestionDifficulty \@QuestionDifficultyfalse \define@key{PPQuestion}{title}{% \global\@QuestionTitletrue\gdef\QuestionTitle{#1}} \define@key{PPQuestion}{difficulty}{% \global\@QuestionDifficultytrue\global\QuestionDifficulty=\number#1} \def\@InitQuestion{\nopagebreak \gdef\QuestionTitle{}% \global\QuestionDifficulty=0% \global\@QuestionTitlefalse% \global\@QuestionDifficultyfalse} \def\@getQuestionInfo{% \if@QuestionTitle\else\def\QuestionHeaderTitle{}\fi \if@QuestionDifficulty\else\def\QuestionHeaderDifficulty{}\fi } \def\EndCurrentQuestion{\termineliste{1}} \def\Question{\@InitQuestion\@ifnextchar[\@@Question{\@@Question[]}}%] \def\@@Question[#1]{\setkeys{PPQuestion}{#1}\@@@Question} \def\@QuestionHeader{\item[{\makebox[0cm][r]{\begingroup\@getQuestionInfo% \QuestionHeaderDifficulty\QuestionNB\endgroup}}]% \begingroup\@getQuestionInfo\QuestionHeaderTitle\endgroup\ignorespaces} \newcommand{\@@@Question}{% \ifnum\@QuestionLevel=1 \advance \@QuestionLevel by 1 \begin{list}{}{\leftmargin \QuestionIndent \partopsep0pt \parsep\parskip \topsep \QuestionBefore \itemsep \QuestionBefore \labelwidth 2em \labelsep .33em \usecounter{Question}} \if@echapq \setcounter{Question}{\value{savedQuestion}}\global\@echapqfalse \fi \refstepcounter{Question} \@restoremathindent \@decalemathindent{\QuestionIndent} \@QuestionHeader \else \ifnum\@QuestionLevel=2 \refstepcounter{Question} \@QuestionHeader \else \ifnum\@QuestionLevel>2 \termineliste{2} \refstepcounter{Question} \@QuestionHeader \else \PackageError{exercise}{You don't respect the hierarchy of questions}{Verify the Question} \fi \fi \fi } \def\subQuestionTitle{} \newif\if@subQuestionTitle\@subQuestionTitlefalse \global\newcount\subQuestionDifficulty\subQuestionDifficulty=0 \newif\if@subQuestionDifficulty\@subQuestionDifficultyfalse \define@key{PPsubQuestion}{title}{% \gdef\subQuestionTitle{#1}\global\@subQuestionTitletrue} \define@key{PPsubQuestion}{difficulty}{% \global\@subQuestionDifficultytrue\global\subQuestionDifficulty=\number#1} \def\@InitsubQuestion{\gdef\subQuestionTitle{}% \global\subQuestionDifficulty=0% \global\@subQuestionTitlefalse% \global\@subQuestionDifficultyfalse} \def\@getsubQuestionInfo{% \if@subQuestionTitle\else\def\subQuestionHeaderTitle{}\fi \if@subQuestionDifficulty\else\def\subQuestionHeaderDifficulty{}\fi } \def\EndCurrentsubQuestion{\termineliste{2}} \def\subQuestion{\@InitsubQuestion% \@ifnextchar[\@@subQuestion{\@@subQuestion[]}}%] \def\@@subQuestion[#1]{\setkeys{PPsubQuestion}{#1}\@@@subQuestion} \def\@subQuestionHeader{\item[{\makebox[0cm][r]% {\begingroup\@getsubQuestionInfo\subQuestionHeaderDifficulty% \subQuestionNB\endgroup}}]% \begingroup\@getsubQuestionInfo\subQuestionHeaderTitle\endgroup% \ignorespaces} \newcommand{\@@@subQuestion}{% \ifnum\@QuestionLevel=2 \advance \@QuestionLevel by 1 \begin{list}{}{\leftmargin \subQuestionIndent \partopsep0pt \parsep\parskip \topsep \subQuestionBefore \itemsep \subQuestionBefore \labelwidth 2em \labelsep .33em \usecounter{subQuestion}} \if@echapq \setcounter{subQuestion}{\value{savedsubQuestion}}% \global\@echapqfalse \fi \refstepcounter{subQuestion} \@restoremathindent \@decalemathindent{\subQuestionIndent} \@subQuestionHeader \else \ifnum\@QuestionLevel=3 \refstepcounter{subQuestion} \@subQuestionHeader \else \ifnum\@QuestionLevel>3 \termineliste{3} \refstepcounter{subQuestion} \@subQuestionHeader \else \PackageError{exercise}{You don't respect the hierarchy of subQuestion}{Verify the subQuestion} \fi \fi \fi } \def\subsubQuestionTitle{} \newif\if@subsubQuestionTitle\@subsubQuestionTitlefalse \global\newcount\subsubQuestionDifficulty\subsubQuestionDifficulty=0 \newif\if@subsubQuestionDifficulty\@subsubQuestionDifficultyfalse \define@key{PPsubsubQuestion}{title}{% \gdef\subsubQuestionTitle{#1}\global\@subsubQuestionTitletrue} \define@key{PPsubsubQuestion}{difficulty}{% \global\@subsubQuestionDifficultytrue% \global\subsubQuestionDifficulty=\number#1} \def\@InitsubsubQuestion{\gdef\subsubQuestionTitle{}% \global\subsubQuestionDifficulty=0% \global\@subsubQuestionTitlefalse% \global\@subsubQuestionDifficultyfalse} \def\@getsubsubQuestionInfo{% \if@subsubQuestionTitle\else\def\subsubQuestionHeaderTitle{}\fi \if@subsubQuestionDifficulty\else\def\subsubQuestionHeaderDifficulty{}\fi } \def\EndCurrentsubsubQuestion{\termineliste{3}} \def\subsubQuestion{\@InitsubsubQuestion% \@ifnextchar[\@@subsubQuestion{\@@subsubQuestion[]}}%] \def\@@subsubQuestion[#1]{\setkeys{PPsubsubQuestion}{#1}\@@@subsubQuestion} \def\@subsubQuestionHeader{\item[{\makebox[0cm][r]% {\begingroup\@getsubsubQuestionInfo\subsubQuestionHeaderDifficulty% \subsubQuestionNB\endgroup}}]% \begingroup\@getsubsubQuestionInfo\subsubQuestionHeaderTitle\endgroup% \ignorespaces} \newcommand{\@@@subsubQuestion}{% \ifnum\@QuestionLevel=3 \advance \@QuestionLevel by 1 \begin{list}{}{\leftmargin \subsubQuestionIndent \partopsep0pt \parsep\parskip \topsep \subsubQuestionBefore \itemsep \subsubQuestionBefore \labelwidth 2em \labelsep .33em \usecounter{subsubQuestion}} \if@echapq \setcounter{subsubQuestion}{\value{savedsubsubQuestion}}% \global\@echapqfalse \fi \refstepcounter{subsubQuestion} \@restoremathindent \@decalemathindent{\subsubQuestionIndent} \@subsubQuestionHeader \else \ifnum\@QuestionLevel=4 \refstepcounter{subsubQuestion} \@subsubQuestionHeader \else \ifnum\@QuestionLevel>4 \termineliste{4} \refstepcounter{subsubQuestion} \@subsubQuestionHeader \else \PackageError{exercise}{You don't respect the hierarchy of subsubQuestion}{Verify the subsubQuestion} \fi \fi \fi } \newif\if@ExePartStared \@ExePartStaredfalse \newif\if@ExePartTitle \@ExePartTitlefalse \newif\if@ExePartReName \@ExePartReNamefalse \newif\if@ExePartDifficulty \@ExePartDifficultyfalse \global\newcount\ExePartDifficulty \ExePartDifficulty=0 \def\theExePartDifficulty{\marker{\DifficultyMarker}{\ExePartDifficulty}} \def\@InitExePart{\global\@echapqfalse% \gdef\ExePartTitle{}% \gdef\@ExePartName{}% \global\ExePartDifficulty=0% \global\@ExePartTitlefalse% \global\@ExePartReNamefalse% \global\@ExePartDifficultyfalse% \setcounter{Question}{0}\termineliste{1}} \define@key{PPExePart}{title}{\gdef\ExePartTitle{#1}% \global\@ExePartTitletrue} \define@key{PPExePart}{name}{\gdef\@ExePartName{#1}% \global\@ExePartReNametrue} \define@key{PPExePart}{difficulty}{\global\@ExePartDifficultytrue% \global\ExePartDifficulty=\number#1} \def\@getExePartInfo{% \if@ExePartReName\def\ExePartName{\@ExePartName}\fi \if@ExePartTitle\else\def\ExePartHeaderTitle{}\fi \if@ExePartDifficulty\else\def\ExePartHeaderDifficulty{}\fi \if@ExePartStared\def\ExePartHeaderNB{}\fi } \def\ExePart{\@InitExePart\@ifstar{\global\@ExePartStaredtrue\@ExePart}% {\global\@ExePartStaredfalse\@ExePart}} \def\@ExePart{\@ifnextchar[\@@ExePart{\@@ExePart[]}}%] for emacs \def\@@ExePart[#1]{\setkeys{PPExePart}{#1}\@@@ExePart} \newcommand{\@@@ExePart}{% \if@ExePartStared\else\refstepcounter{ExePart}\fi \begingroup\@getExePartInfo\@ExePartHeader\endgroup} \newbox\@Answerbox \newcommand{\AnswerHeader}{\medskip\centerline{\textbf{\AnswerName\ % \ExerciseHeaderNB}\smallskip}} \newcommand{\AnswerListHeader}{\textbf{\AnswerListName\ (\ExerciseListName\ \ExerciseHeaderNB)\ ---\ }} \def\@InitAnswer{\@savemathindent\global\@echapqfalse% \gdef\AnswerRef{}% \global\@AnswerReffalse% \gdef\AnswerNB{}% \global\@AnswerNBfalse% \setcounter{ExePart}{0}% \setcounter{Question}{0}} \def\@getAnswerInfo{% \if@AnswerRef% \def\theExercise{\ref{\AnswerRef}}% \refstepcounter{Answer}% \recordExerciseLabel{\AnswerRef-Answer}% \else \if@AnswerNB \def\ExerciseTitle{}% \def\ExerciseName{}% \def\ExerciseOrigin{}% \def\ExerciseType{}% \ExerciseDifficulty=0% \def\theExercise{\AnswerNB}% \else \if@AswLastExe \else \PackageWarning{Exercise}% {An answer has no reference and no number}{}% \def\AnswerHeaderRef{\AnswerName\ ???}% \def\AnswerListHeaderRef{\AnswerName\ ???}% \fi\fi\fi} \newif\if@AnswerRef \@AnswerReffalse \newif\if@AnswerNB \@AnswerNBfalse \define@key{PPAnswer}{ref}{\global\@AnswerReftrue\gdef\AnswerRef{#1}} \define@key{PPAnswer}{number}{\global\@AnswerNBtrue\gdef\AnswerNB{#1}} \def\beginAnswerEnv{\@InitAnswer\@ifnextchar[\@@AnswerEnv{\@@AnswerEnv[]}}%] \def\@@AnswerEnv[#1]{\setkeys{PPAnswer}{#1}% \global\@Answertrue\@selectAnswer\@BeginExeBox\@@@AnswerEnv} \newcommand{\@@@AnswerEnv}{% \pagebreak[1]\vskip\AnswerSkipBefore\@QuestionLevel1 \begingroup\@getAnswerInfo\AnswerHeader\endgroup\AtBeginAnswer} \gdef\endAnswerEnv{\termineliste{1}\@EndExeBox\termineliste{0}\vskip\AnswerSkipAfter} \newenvironment{Answer}{}{} \gdef\defineAnswerEnv{ \gdef\@AnswerHeaderRef{\AnswerHeader} \renewenvironment{Answer}{\beginAnswerEnv}{\endAnswerEnv}} \defineAnswerEnv \def\AnswerCmd{\@InitAnswer\@ifnextchar[\@@AnswerCmd{\@@AnswerCmd[]}} \def\@@AnswerCmd[#1]{\setkeys{PPAnswer}{#1}\@@@AnswerCmd} \newcommand{\@@@AnswerCmd}{% \ifnum\@QuestionLevel=0 \advance \@QuestionLevel by 1 \begin{list}{}{\partopsep\Exepartopsep \labelsep\Exelabelsep \itemsep \Exesep \parsep\Exeparsep \topsep\Exetopsep \labelwidth\Exelabelwidth \leftmargin\Exeleftmargin \rightmargin\Exerightmargin } %% \refstepExecounter \else \termineliste{1}\@EndExeBox \fi \global\@Answertrue\@selectAnswer\@BeginExeBox% \item[\bgroup\@getAnswerInfo\AnswerListHeader\egroup]\AtBeginAnswer\ignorespaces } \def\defineAnswerCmd{\gdef\@AnswerHeaderRef{\AnswerListHeader}% \def\Answer{\AnswerCmd}} \newif\if@ShipThisExercise \@ShipThisExercisetrue \newif\if@@ShipThisExercise \@@ShipThisExercisetrue \newif\if@ExerciseSelected \@ExerciseSelectedtrue \newif\if@ShipThisAnswer \@ShipThisAnswertrue \newif\if@@ShipThisAnswer \@@ShipThisAnswertrue \newif\if@ExeSelectExam \@ExeSelectExamfalse \newif\if@ExeSelectYear \@ExeSelectYearfalse \newif\if@ExeSelectDifficulty \@ExeSelectDifficultyfalse \newif\if@ExeSelectOrigin \@ExeSelectOriginfalse \newif\if@ExeSelectClass \@ExeSelectClassfalse \newif\if@ExeSelectType \@ExeSelectTypefalse \newif\if@ExeSelectLabel \@ExeSelectLabelfalse \define@key{PPExerciseSelect}{exam}% {\global\@ExeSelectExamtrue\gdef\ExerciseSelectExam{#1}} \define@key{PPExerciseSelect}{year}% {\global\@ExeSelectYeartrue\gdef\ExerciseSelectYear{#1}} \define@key{PPExerciseSelect}{difficulty}% {\global\@ExeSelectDifficultytrue\gdef\ExerciseSelectDifficulty{#1}} \define@key{PPExerciseSelect}{type}% {\global\@ExeSelectTypetrue\gdef\ExerciseSelectType{#1}} \define@key{PPExerciseSelect}{origin}% {\global\@ExeSelectOrigintrue\gdef\ExerciseSelectOrigin{#1}} \define@key{PPExerciseSelect}{class}% {\global\@ExeSelectClasstrue\gdef\ExerciseSelectClass{#1}} \define@key{PPExerciseSelect}{label}% {\global\@ExeSelectLabeltrue\gdef\ExerciseSelectLabel{#1}} \newcommand{\ExerciseStopSelect}{ \@ExeSelectExamfalse \@ExeSelectYearfalse \@ExeSelectDifficultyfalse \@ExeSelectTypefalse \@ExeSelectOriginfalse \@ExeSelectClassfalse \@ExeSelectLabelfalse \@ExeSelectTypefalse } \newcommand{\ExerciseSelect}{\@ifstar{\global\@ExerciseSelectedfalse\@ExerciseSelect}{\global\@ExerciseSelectedtrue\@ExerciseSelect}} \newcommand{\@ExerciseSelect}[1][]{\setkeys{PPExerciseSelect}{#1}} \def\@selectExercise{% \global\@ShipThisExercisetrue \global\@@ShipThisExercisefalse \if@ExeSelectExam \@for\@exam:=\ExerciseSelectExam\do {\ifthenelse{\equal{\@exam}{\ExerciseExam}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi % \if@ExeSelectYear \@for\@year:=\ExerciseSelectYear\do { \ifthenelse{\equal{\@year}{\ExerciseYear}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi % \if@ExeSelectDifficulty \@for\@difficulty:=\ExerciseSelectDifficulty\do { \ifthenelse{\equal{\@difficulty}{\ExerciseDifficulty}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi % \if@ExeSelectOrigin \@for\@origin:=\ExerciseSelectOrigin\do { \ifthenelse{\equal{\@origin}{\ExerciseOrigin}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi % \if@ExeSelectClass \@for\@origin:=\ExerciseSelectClass\do { \ifthenelse{\equal{\@origin}{\ExerciseClass}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi % \if@ExeSelectLabel \@for\@label:=\ExerciseSelectLabel\do { \ifthenelse{\equal{\@label}{\ExerciseLabel}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi % \if@ExeSelectType \@for\@type:=\ExerciseSelectType\do { \ifthenelse{\equal{\@type}{\ExerciseType}}{ \global\@@ShipThisExercisetrue }{} } \if@@ShipThisExercise\else\@ShipThisExercisefalse\fi \global\@@ShipThisExercisefalse \fi \if@ExerciseSelected\else\if@ShipThisExercise\global\@ShipThisExercisefalse\else\global\@ShipThisExercisetrue\fi\fi } \def\@selectAnswer{% \global\@ShipThisAnswertrue \global\@@ShipThisAnswerfalse % \if@ExeSelectLabel \@for\@label:=\ExerciseSelectLabel\do { \ifthenelse{\equal{\@label}{\AnswerRef}}{ \global\@@ShipThisAnswertrue }{} } \if@@ShipThisAnswer\else\@ShipThisAnswerfalse\fi \global\@@ShipThisAnswerfalse \fi \if@ExerciseSelected\else\if@ShipThisAnswer\global\@ShipThisAnswerfalse\else\global\@ShipThisAnswertrue\fi\fi } \newcommand{\ExeText}{\setcounter{savedQuestion}{\value{Question}}% \termineliste{1}\@echapqtrue} \newcount\colonnesLevel \colonnesLevel=-10 \newskip\tempskipa \newskip\tempskipb \def\deuxcolonnes{\tempskipa=\multicolsep\colonnesLevel=\@QuestionLevel \ifcase\@QuestionLevel \multicolsep=\QuestionBefore % \or \multicolsep=\subQuestionBefore\or\multicolsep=\subsubQuestionBefore\fi% \begin{multicols}{2}} \@ifundefined{if@fleqn}{\newif\if@fleqn\@fleqnfalse}{} \newlength{\@savedmathindent} \newcommand{\@savemathindent}{\relax} \newcommand{\@decalemathindent}[1]{\relax} \newcommand{\@restoremathindent}{\relax} \if@fleqn % \renewcommand{\@savemathindent}{\setlength{\@savedmathindent}{\mathindent}} \renewcommand{\@decalemathindent}[1]{\addtolength{\mathindent}{#1}} \renewcommand{\@restoremathindent}{\setlength{\mathindent}{\@savedmathindent}} \else \renewcommand{\@savemathindent}{\relax} \renewcommand{\@decalemathindent}[1]{\relax} \renewcommand{\@restoremathindent}{\relax} \fi \def\renewcounter#1{% \@ifundefined{c@#1} {\@latex@error{counter #1 undefined}\@ehc}% \relax \let\@ifdefinable\@rc@ifdefinable \@ifnextchar[{\@newctr{#1}}{}} \def\ext@exercise{loe} \newcommand{\ExerciseLevelInToc}[1]{\def\toc@exercise{#1}} \ExerciseLevelInToc{exercise} \newcommand{\ListOfExerciseInToc}{\def\ext@exercise{toc}\ExerciseLevelInToc{paragraph}} \newcommand\listofexercises{% \section*{\listexercisename}% \@mkboth{\MakeUppercase\listexercisename}% {\MakeUppercase\listexercisename}% \@starttoc{\ext@exercise}% } \newcommand*\l@exercise{\@dottedtocline{2}{1.5em}{2.3em}} \endinput %% %% End of file `exercise.sty'.