summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/exercise
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-07-05 23:44:42 +0000
committerKarl Berry <karl@freefriends.org>2006-07-05 23:44:42 +0000
commitdad8f2bc9542c572d6989e68e5ef5786841133a2 (patch)
tree61622d4c6e1e7cd37d345cf5709d7a35a494efb2 /Master/texmf-dist/tex/latex/exercise
parent32395df63443f788daae99f0537b26f0553e1cc1 (diff)
exercise update
git-svn-id: svn://tug.org/texlive/trunk@1778 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/exercise')
-rw-r--r--Master/texmf-dist/tex/latex/exercise/exercise.sty122
1 files changed, 88 insertions, 34 deletions
diff --git a/Master/texmf-dist/tex/latex/exercise/exercise.sty b/Master/texmf-dist/tex/latex/exercise/exercise.sty
index 7030e923157..523c29060e5 100644
--- a/Master/texmf-dist/tex/latex/exercise/exercise.sty
+++ b/Master/texmf-dist/tex/latex/exercise/exercise.sty
@@ -71,18 +71,18 @@
\def\ExePartName{Part}%
\@ifpackageloaded{babel}{
\addto{\captionsfrenchb}{
- \def\ExerciseName{Exercise}%
+ \def\ExerciseName{Exercice}%
\def\AnswerName{Solution}%
\def\ExerciseListName{Ex.}%
\def\AnswerListName{Sol.}%
\def\ExePartName{Partie}%
-}}
+}}{}
\newlength{\Exesep}
\setlength{\Exesep}{1\baselineskip}
\newlength{\Exetopsep}
\setlength{\Exetopsep}\z@
\newlength{\Exeparsep}
-\setlength{\Exeparsep}\z@
+\setlength{\Exeparsep}{\parskip}
\newlength{\Exepartopsep}
\setlength{\Exepartopsep}\z@
\newlength{\Exeleftmargin}
@@ -106,7 +106,7 @@
\newlength{\subQuestionIndent}
\setlength{\subQuestionIndent}{2em}
\newlength{\subsubQuestionIndent}
-\setlength{\subsubQuestionIndent}{1.5em}
+\setlength{\subsubQuestionIndent}{2.5em}
\newcounter{Exercise}
\gdef\@ExerciseCounter{Exercise} %default exercise counter
\newcounter{ExePart}[Exercise]
@@ -117,14 +117,14 @@
\renewcommand{\theExePart}{\Roman{ExePart}}
\renewcommand{\theQuestion}{\arabic{Question}}
\renewcommand{\thesubQuestion}{\alph{subQuestion}}
-\renewcommand{\thesubsubQuestion}{\arabic{subsubQuestion}}
+\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{\ExerciseHeaderTitle}{\quad --- \quad \ExerciseTitle}
+\newcommand{\ExerciseHeaderTitle}{\qquad \ExerciseTitle}
\newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ }
\newcommand{\ExerciseHeaderOrigin}{%
\ ({\usefont{\encodingdefault}{\rmdefault}{m}{it}\ExerciseOrigin})}
@@ -143,6 +143,9 @@
\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\ }
@@ -155,7 +158,7 @@
\subQuestionNB)\ \emph{\subQuestionHeaderTitle}}
\newcommand{\thesubQuestionDifficulty}{\marker{\DifficultyMarker}%
{\subQuestionDifficulty}}
-\newcommand{\subsubQuestionNB}{\arabic{subsubQuestion} -- }
+\newcommand{\subsubQuestionNB}{\roman{subsubQuestion} -- }
\newcommand{\subsubQuestionHeaderTitle}{\emph{(\subsubQuestionTitle)}\ }
\newcommand{\subsubQuestionHeaderDifficulty}{\thesubsubQuestionDifficulty\ }
\newcommand{\subsubQuestionHeader}{\subsubQuestionHeaderDifficulty%
@@ -195,7 +198,7 @@
\define@key{PPExercise}{counter}%
{\gdef\@ExerciseCounter{\string#1}}
\define@key{PPExercise}{label}%
-{\global\@ExeLabeltrue\gdef\ExerciseLabel{\string#1}}
+{\global\@ExeLabeltrue\gdef\ExerciseLabel{\string#1}\gdef\ExerciseTrueLabel{#1}}
\define@key{PPExercise}{number}%
{\global\@ExeNBtrue\gdef\ExerciseLocalNB{\string#1}}
%% \define@key{PPExercise}{domain}{}
@@ -213,7 +216,7 @@
\gdef\ExerciseTitle{}%
\gdef\@ExerciseName{}%
\gdef\ExerciseOrigin{}%
-\gdef\labelexe{}%
+\gdef\ExerciseTrueLabel{}%
\global\ExerciseDifficulty=0%
\global\@ExeTitlefalse%
\global\@ExeReNamefalse%
@@ -221,6 +224,7 @@
\global\@ExeOriginfalse%
\global\@ExeNBfalse%
\gdef\@ExerciseCounter{Exercise}%
+\setcounter{ExePart}{0}%
\setcounter{Question}{0}%
\global\@ExeLabelfalse}
\def\@getExerciseInfo{%
@@ -243,21 +247,22 @@
\def\@EndExeBox{\egroup\if@Answer\if@AnswerOutput\@DelayAnswerBox\fi%
\else\if@ExerciseOutput\@DelayExerciseBox\fi\fi}
\def\@DelayAnswerBox{%
-\if@AnswerDelay\global\setbox\temp@Answerbox%
-\vbox{\unvbox\all@Answerbox\vskip12pt\unvbox\@Exercisebox\vskip\z@}%
+\if@ShipThisExercise\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}
-\def\@DelayExerciseBox{\if@ExerciseDelay%
+\else\unvbox\@Exercisebox\fi\fi}
+\def\@DelayExerciseBox{\if@ShipThisExercise\if@ExerciseDelay%
\global\setbox\temp@Exercisebox%
-\vbox{\unvbox\all@Exercisebox\vskip12pt\unvbox\@Exercisebox\vskip\z@}%
+\vbox{\unvbox\all@Exercisebox\vskip\Exesep\unvbox\@Exercisebox\vskip\z@}%
\global\setbox\all@Exercisebox\copy\temp@Exercisebox%
-\else\unvbox\@Exercisebox\fi}
+\else\vskip\Exesep\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}%
\global\@Answerfalse\@BeginExeBox\@@@ExeEnv}
\newcommand{\@@@ExeEnv}{%
+ \@selectExercise{\ExerciseTrueLabel}
\@QuestionLevel1
\refstepExecounter
\begingroup\@getExerciseInfo\ExerciseHeader\endgroup}
@@ -276,21 +281,26 @@
\else
\termineliste{1}\@EndExeBox
\fi
+ \@selectExercise{\ExerciseTrueLabel}
\global\@Answerfalse\@BeginExeBox\refstepExecounter%
\item\ignorespaces
}
+\def\defineExePartInEnv{\def\@ExePartHeader{\ExePartHeader}}
+\def\defineExePartInList{\def\@ExePartHeader{\ExePartListHeader}}
\def\defineExerciseEnv{%
- \renewenvironment{Exercise}{\global\@ExeStaredfalse\beginExerciseEnv}%
-{\endExerciseEnv}
+ \defineExePartInEnv
+ \renewenvironment{Exercise}{\global\beginExerciseEnv}%
+{\@ExeStaredfalse\endExerciseEnv}
\renewenvironment{Exercise*}{\global\@ExeStaredtrue\beginExerciseEnv}%
-{\endExerciseEnv}
+{\@ExeStaredfalse\endExerciseEnv}
}
\newenvironment{Exercise}{}{}
\newenvironment{Exercise*}{}{}
\def\defineExerciseCmd{\def\Exercise{\ExerciseCmd}}
\renewcommand{\Exercise}{}
\defineExerciseEnv
-\def\beginExerciseListEnv{\defineExerciseCmd\defineAnswerCmd}
+\def\beginExerciseListEnv{\defineExerciseCmd\defineAnswerCmd%
+\defineExePartInList}
\def\endExerciseListEnv{\termineliste{1}\@EndExeBox\termineliste{0}%
\defineExerciseEnv\defineAnswerEnv}
\newenvironment{ExerciseList}{\beginExerciseListEnv}{\endExerciseListEnv}
@@ -299,9 +309,9 @@
\global\newcount\QuestionDifficulty \QuestionDifficulty=0
\newif\if@QuestionDifficulty \@QuestionDifficultyfalse
\define@key{PPQuestion}{title}{%
-\gdef\QuestionTitle{\string#1}\@QuestionTitletrue}
+\global\@QuestionTitletrue\gdef\QuestionTitle{\string#1}}
\define@key{PPQuestion}{difficulty}{%
-\@QuestionDifficultytrue\global\QuestionDifficulty=\number#1}
+\global\@QuestionDifficultytrue\global\QuestionDifficulty=\number#1}
\def\@InitQuestion{\gdef\QuestionTitle{}%
\global\QuestionDifficulty=0%
\global\@QuestionTitlefalse%
@@ -320,8 +330,9 @@
\ifnum\@QuestionLevel=1
\advance \@QuestionLevel by 1
\begin{list}{}{\leftmargin \QuestionIndent
- \partopsep0pt \parsep0pt \topsep \QuestionBefore
+ \partopsep0pt \parsep\parskip \topsep \QuestionBefore
\itemsep \QuestionBefore \labelwidth 2em
+ \labelsep .5em
\usecounter{Question}}
\if@echapq
\setcounter{Question}{\value{savedQuestion}}\global\@echapqfalse
@@ -351,9 +362,9 @@
\global\newcount\subQuestionDifficulty\subQuestionDifficulty=0
\newif\if@subQuestionDifficulty\@subQuestionDifficultyfalse
\define@key{PPsubQuestion}{title}{%
-\gdef\subQuestionTitle{\string#1}\@subQuestionTitletrue}
+\gdef\subQuestionTitle{\string#1}\global\@subQuestionTitletrue}
\define@key{PPsubQuestion}{difficulty}{%
-\@subQuestionDifficultytrue\global\subQuestionDifficulty=\number#1}
+\global\@subQuestionDifficultytrue\global\subQuestionDifficulty=\number#1}
\def\@InitsubQuestion{\gdef\subQuestionTitle{}%
\global\subQuestionDifficulty=0%
\global\@subQuestionTitlefalse%
@@ -375,8 +386,9 @@
\ifnum\@QuestionLevel=2
\advance \@QuestionLevel by 1
\begin{list}{}{\leftmargin \subQuestionIndent
- \partopsep0pt \parsep0pt \topsep \subQuestionBefore
+ \partopsep0pt \parsep\parskip \topsep \subQuestionBefore
\itemsep \subQuestionBefore \labelwidth 2em
+ \labelsep .5em
\usecounter{subQuestion}}
\if@echapq
\setcounter{subQuestion}{\value{savedsubQuestion}}%
@@ -407,9 +419,10 @@
\global\newcount\subsubQuestionDifficulty\subsubQuestionDifficulty=0
\newif\if@subsubQuestionDifficulty\@subsubQuestionDifficultyfalse
\define@key{PPsubsubQuestion}{title}{%
-\gdef\subsubQuestionTitle{\string#1}\@QuestionTitletrue}
+\gdef\subsubQuestionTitle{\string#1}\global\@subsubQuestionTitletrue}
\define@key{PPsubsubQuestion}{difficulty}{%
-\@QuestionDifficultytrue\global\subsubQuestionDifficulty=\number#1}
+\global\@subsubQuestionDifficultytrue%
+\global\subsubQuestionDifficulty=\number#1}
\def\@InitsubsubQuestion{\gdef\subsubQuestionTitle{}%
\global\subsubQuestionDifficulty=0%
\global\@subsubQuestionTitlefalse%
@@ -431,8 +444,9 @@
\ifnum\@QuestionLevel=3
\advance \@QuestionLevel by 1
\begin{list}{}{\leftmargin \subsubQuestionIndent
- \partopsep0pt \parsep0pt \topsep \subsubQuestionBefore
+ \partopsep0pt \parsep\parskip \topsep \subsubQuestionBefore
\itemsep \subsubQuestionBefore \labelwidth 2em
+ \labelsep .5em
\usecounter{subsubQuestion}}
\if@echapq
\setcounter{subsubQuestion}{\value{savedsubsubQuestion}}%
@@ -471,10 +485,12 @@
\global\@ExePartTitlefalse%
\global\@ExePartReNamefalse%
\global\@ExePartDifficultyfalse%
-\setcounter{Question}{0}}
-\define@key{PPExePart}{title}{\gdef\ExePartTitle{\string#1}\@ExePartTitletrue}
-\define@key{PPExePart}{name}{\gdef\@ExePartName{\string#1}\@ExePartReNametrue}
-\define@key{PPExePart}{difficulty}{\@ExePartDifficultytrue%
+\setcounter{Question}{0}\termineliste{1}}
+\define@key{PPExePart}{title}{\gdef\ExePartTitle{\string#1}%
+\global\@ExePartTitletrue}
+\define@key{PPExePart}{name}{\gdef\@ExePartName{\string#1}%
+\global\@ExePartReNametrue}
+\define@key{PPExePart}{difficulty}{\global\@ExePartDifficultytrue%
\global\ExePartDifficulty=\number#1}
\def\@getExePartInfo{%
\if@ExePartReName\def\ExePartName{\@ExePartName}\fi
@@ -488,7 +504,7 @@
\def\@@ExePart[#1]{\setkeys{PPExePart}{#1}\@@@ExePart}
\newcommand{\@@@ExePart}{%
\if@ExePartStared\else\refstepcounter{ExePart}\fi
- \begingroup\@getExePartInfo\ExePartHeader\endgroup}
+ \begingroup\@getExePartInfo\@ExePartHeader\endgroup}
\newbox\@Answerbox
%% \newcommand{\AnswerHeaderRef}{Answer of \ExerciseName\ \theExercise}
%% \newcommand{\AnswerListHeaderRef}{Answer (ex.\ \theExercise)\ ---\ }
@@ -501,6 +517,7 @@
\global\@AnswerReffalse%
\gdef\AnswerNB{}%
\global\@AnswerNBfalse%
+\setcounter{ExePart}{0}%
\setcounter{Question}{0}}
\def\@getAnswerInfo{%
\if@AnswerRef%
@@ -530,7 +547,7 @@
\global\@Answertrue\@BeginExeBox\@@@AnswerEnv}
\newcommand{\@@@AnswerEnv}{%
\@QuestionLevel1
- \begingroup\@getAnswerInfo\AnswerHeader\endgroup}
+ \begingroup\@getExerciseInfo\@getAnswerInfo\AnswerHeader\endgroup}
\def\endAnswerEnv{\termineliste{1}\@EndExeBox}
\newenvironment{Answer}{}{}
\def\defineAnswerEnv{
@@ -556,6 +573,42 @@
}
\def\defineAnswerCmd{\gdef\@AnswerHeaderRef{\AnswerListHeader}%
\gdef\Answer{\AnswerCmd}}
+\newif\if@ExerciseSelected\@ExerciseSelectedfalse
+\newif\if@ExerciseNoLabelSelected\@ExerciseNoLabelSelectedtrue
+\newif\if@ExerciseOmitted\@ExerciseOmittedfalse
+\newif\if@ShipThisExercise\@ShipThisExercisetrue
+\newcommand{\ExerciseStartSelectNoLabel}{\@ExerciseNoLabelSelectedtrue}
+\newcommand{\ExerciseStopSelectNoLabel}{\@ExerciseNoLabelSelectedfalse}
+\newcommand{\ExerciseStopSelect}{\@ExerciseSelectedfalse}
+\newcommand{\ExerciseStartSelect}{\@ExerciseSelectedtrue\@ifstar{\@ExerciseOmittedtrue\def@ListOfExercise}{\@ExerciseOmittedfalse\def@ListOfExercise}}
+\def\def@ListOfExercise#1{\gdef\@ListOfExercise{#1}}
+\def\@selectExercise#1{%
+ \ifx#1\@empty
+ \message{PAs de label}
+ \if@ExerciseNoLabelSelected
+ \global\@ShipThisExercisetrue
+ \else
+ \global\@ShipThisExercisefalse
+ \fi
+ \else
+ \if@ExerciseSelected
+ \global\@ShipThisExercisefalse
+ \@for\@label:=\@ListOfExercise\do
+ { \ifthenelse{\equal{\@label}{#1}}{
+ \message{[\@label = #1] OK !!!}
+ \global\@ShipThisExercisetrue
+ }{}
+ }
+ \if@ExerciseOmitted
+ \if@ShipThisExercise
+ \global\@ShipThisExercisefalse
+ \else
+ \global\@ShipThisExercisetrue
+ \fi
+ \fi
+ \fi
+\fi
+}
\newcommand{\ExeText}{\setcounter{savedQuestion}{\value{Question}}%
\termineliste{1}\@echapqtrue}
\newcount\colonnesLevel \colonnesLevel=-10
@@ -567,6 +620,7 @@
\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}