summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/exercise
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-03-27 17:40:43 +0000
committerKarl Berry <karl@freefriends.org>2009-03-27 17:40:43 +0000
commit4e48c40524429be6f6d610def065c2110f93d8de (patch)
treeb91444380f45f0966baa0e865fe9e3eed2d4a11e /Master/texmf-dist/tex/latex/exercise
parentb06455ca8236ce81cad6e5880960a0dfa90b01f3 (diff)
exercise 1.3 (26mar09)
git-svn-id: svn://tug.org/texlive/trunk@12536 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/exercise')
-rw-r--r--Master/texmf-dist/tex/latex/exercise/exercise.sty106
1 files changed, 67 insertions, 39 deletions
diff --git a/Master/texmf-dist/tex/latex/exercise/exercise.sty b/Master/texmf-dist/tex/latex/exercise/exercise.sty
index 523c29060e5..e6e29c8b082 100644
--- a/Master/texmf-dist/tex/latex/exercise/exercise.sty
+++ b/Master/texmf-dist/tex/latex/exercise/exercise.sty
@@ -28,7 +28,7 @@
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{exercise}
- [2004/09/05 v1.1 Exercise package (P.Pichaureau)]
+ [2009/03/26 v1.3 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
@@ -52,7 +52,7 @@
\newif\if@AswLastExe \@AswLastExefalse
\DeclareOption{noanswer} {\@AnswerOutputfalse}
-\DeclareOption{answeronly} {\@ExerciseOutputfalse}
+\DeclareOption{answeronly} {\@AnswerOutputtrue\@ExerciseOutputfalse}
\DeclareOption{noexercise} {\@ExerciseOutputfalse}
\DeclareOption{exerciseonly} {\@AnswerOutputfalse}
\DeclareOption{outputnothing}{\@ExerciseOutputfalse\@AnswerOutputfalse}
@@ -64,19 +64,31 @@
\ProcessOptions
\RequirePackage{keyval, ifthen}
+\def\listexercisename{List of exercises}%
\def\ExerciseName{Exercise}%
-\def\AnswerName{Answer}%
+\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}%
+ \def\AnswerName{Solution de l'exercice}%
\def\ExerciseListName{Ex.}%
- \def\AnswerListName{Sol.}%
+ \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\ }%
+ }}{}
\newlength{\Exesep}
\setlength{\Exesep}{1\baselineskip}
\newlength{\Exetopsep}
@@ -128,13 +140,13 @@
\newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ }
\newcommand{\ExerciseHeaderOrigin}{%
\ ({\usefont{\encodingdefault}{\rmdefault}{m}{it}\ExerciseOrigin})}
-\newcommand{\ExerciseHeaderNB}{\ \theExercise}
+\newcommand{\ExerciseHeaderNB}{\theExercise}
\newcommand{\ExerciseHeaderLabel}{\fbox{\textsc{\ExerciseLabel}}}
\newcommand{\ExerciseHeader}{\centerline{%
-\textbf{\large\ExerciseHeaderDifficulty\ExerciseName%
+\textbf{\large\ExerciseHeaderDifficulty\ExerciseName\ %
\ExerciseHeaderNB\ExerciseHeaderTitle\ExerciseHeaderOrigin}}\medskip}
\newcommand{\ExerciseListHeader}{\ExerciseHeaderDifficulty%
-\textbf{\ExerciseListName\ExerciseHeaderNB%
+\textbf{\ExerciseListName\ \ExerciseHeaderNB%
\ --- \ \ExerciseHeaderTitle}%
\ExerciseHeaderOrigin\ignorespaces}
\newcommand{\ExePartHeaderNB}{\ \theExePart}
@@ -188,19 +200,19 @@
\newif\if@ExeNB \@ExeNBfalse
\def\theExerciseDifficulty{\marker{\DifficultyMarker}{\ExerciseDifficulty}}
\define@key{PPExercise}{title}%
-{\global\@ExeTitletrue\gdef\ExerciseTitle{\string#1}}
+{\global\@ExeTitletrue\gdef\ExerciseTitle{#1}}
\define@key{PPExercise}{difficulty}%
{\global\@ExeDifficultytrue\global\ExerciseDifficulty=\number#1}
\define@key{PPExercise}{name}%
-{\global\@ExeReNametrue\gdef\@ExerciseName{\string#1}}
+{\global\@ExeReNametrue\gdef\@ExerciseName{#1}}
\define@key{PPExercise}{origin}%
{\global\@ExeOrigintrue\gdef\ExerciseOrigin{#1}}
\define@key{PPExercise}{counter}%
-{\gdef\@ExerciseCounter{\string#1}}
+{\gdef\@ExerciseCounter{#1}}
\define@key{PPExercise}{label}%
-{\global\@ExeLabeltrue\gdef\ExerciseLabel{\string#1}\gdef\ExerciseTrueLabel{#1}}
+{\global\@ExeLabeltrue\gdef\ExerciseLabel{#1}\gdef\ExerciseTrueLabel{#1}}
\define@key{PPExercise}{number}%
-{\global\@ExeNBtrue\gdef\ExerciseLocalNB{\string#1}}
+{\global\@ExeNBtrue\gdef\ExerciseLocalNB{#1}}
%% \define@key{PPExercise}{domain}{}
%% \define@key{PPExercise}{sdomain}{}
%% \define@key{PPExercise}{keyword}{}
@@ -226,7 +238,8 @@
\gdef\@ExerciseCounter{Exercise}%
\setcounter{ExePart}{0}%
\setcounter{Question}{0}%
-\global\@ExeLabelfalse}
+\global\@ExeLabelfalse%
+}
\def\@getExerciseInfo{%
\if@ExeReName\def\ExerciseName{\@ExerciseName}\fi%
\if@ExeTitle\else\def\ExerciseHeaderTitle{}\fi%
@@ -237,8 +250,8 @@
\if@ExeNB\def\theExercise{\ExerciseLocalNB}\fi%
\if@ExeLabel\label{\ExerciseLabel}\recordExerciseLabel{\ExerciseLabel}\fi%
}
-\def\refstepExecounter{\if@ExeStared\else\if@ExeNB\else%
-\refstepcounter{\@ExerciseCounter}\fi\fi}
+\def\refstepExecounter{\if@ShipThisExercise\if@ExeStared\else\if@ExeNB\else%
+\refstepcounter{\@ExerciseCounter}\fi\fi\fi}
\def\recordExerciseLabel#1{\@bsphack
\protected@write\@auxout{}%
{\string\newlabel{PP#1}{{\@AnswerHeaderRef}{\thepage}}}%
@@ -255,7 +268,7 @@
\global\setbox\temp@Exercisebox%
\vbox{\unvbox\all@Exercisebox\vskip\Exesep\unvbox\@Exercisebox\vskip\z@}%
\global\setbox\all@Exercisebox\copy\temp@Exercisebox%
-\else\vskip\Exesep\unvbox\@Exercisebox\fi\fi}
+\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[]}}%]
@@ -265,7 +278,11 @@
\@selectExercise{\ExerciseTrueLabel}
\@QuestionLevel1
\refstepExecounter
- \begingroup\@getExerciseInfo\ExerciseHeader\endgroup}
+ \begingroup\@getExerciseInfo\ExerciseHeader
+ \addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
+ \theExercise\ \expandafter{\itshape
+ \ExerciseTitle}\hspace{.66em}}
+ \endgroup}
\def\endExerciseEnv{\termineliste{1}\@EndExeBox}
\def\ExerciseCmd{\@InitExe\@ifstar{\global\@ExeStaredtrue\@ExeCmd}%
{\global\@ExeStaredfalse\@ExeCmd}}
@@ -283,6 +300,8 @@
\fi
\@selectExercise{\ExerciseTrueLabel}
\global\@Answerfalse\@BeginExeBox\refstepExecounter%
+ \addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
+ \theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}}
\item\ignorespaces
}
\def\defineExePartInEnv{\def\@ExePartHeader{\ExePartHeader}}
@@ -309,10 +328,11 @@
\global\newcount\QuestionDifficulty \QuestionDifficulty=0
\newif\if@QuestionDifficulty \@QuestionDifficultyfalse
\define@key{PPQuestion}{title}{%
-\global\@QuestionTitletrue\gdef\QuestionTitle{\string#1}}
+\global\@QuestionTitletrue\gdef\QuestionTitle{#1}}
\define@key{PPQuestion}{difficulty}{%
\global\@QuestionDifficultytrue\global\QuestionDifficulty=\number#1}
-\def\@InitQuestion{\gdef\QuestionTitle{}%
+\def\@InitQuestion{\nopagebreak
+\gdef\QuestionTitle{}%
\global\QuestionDifficulty=0%
\global\@QuestionTitlefalse%
\global\@QuestionDifficultyfalse}
@@ -332,7 +352,7 @@
\begin{list}{}{\leftmargin \QuestionIndent
\partopsep0pt \parsep\parskip \topsep \QuestionBefore
\itemsep \QuestionBefore \labelwidth 2em
- \labelsep .5em
+ \labelsep .33em
\usecounter{Question}}
\if@echapq
\setcounter{Question}{\value{savedQuestion}}\global\@echapqfalse
@@ -362,7 +382,7 @@
\global\newcount\subQuestionDifficulty\subQuestionDifficulty=0
\newif\if@subQuestionDifficulty\@subQuestionDifficultyfalse
\define@key{PPsubQuestion}{title}{%
-\gdef\subQuestionTitle{\string#1}\global\@subQuestionTitletrue}
+\gdef\subQuestionTitle{#1}\global\@subQuestionTitletrue}
\define@key{PPsubQuestion}{difficulty}{%
\global\@subQuestionDifficultytrue\global\subQuestionDifficulty=\number#1}
\def\@InitsubQuestion{\gdef\subQuestionTitle{}%
@@ -388,7 +408,7 @@
\begin{list}{}{\leftmargin \subQuestionIndent
\partopsep0pt \parsep\parskip \topsep \subQuestionBefore
\itemsep \subQuestionBefore \labelwidth 2em
- \labelsep .5em
+ \labelsep .33em
\usecounter{subQuestion}}
\if@echapq
\setcounter{subQuestion}{\value{savedsubQuestion}}%
@@ -419,7 +439,7 @@
\global\newcount\subsubQuestionDifficulty\subsubQuestionDifficulty=0
\newif\if@subsubQuestionDifficulty\@subsubQuestionDifficultyfalse
\define@key{PPsubsubQuestion}{title}{%
-\gdef\subsubQuestionTitle{\string#1}\global\@subsubQuestionTitletrue}
+\gdef\subsubQuestionTitle{#1}\global\@subsubQuestionTitletrue}
\define@key{PPsubsubQuestion}{difficulty}{%
\global\@subsubQuestionDifficultytrue%
\global\subsubQuestionDifficulty=\number#1}
@@ -446,7 +466,7 @@
\begin{list}{}{\leftmargin \subsubQuestionIndent
\partopsep0pt \parsep\parskip \topsep \subsubQuestionBefore
\itemsep \subsubQuestionBefore \labelwidth 2em
- \labelsep .5em
+ \labelsep .33em
\usecounter{subsubQuestion}}
\if@echapq
\setcounter{subsubQuestion}{\value{savedsubsubQuestion}}%
@@ -486,9 +506,9 @@
\global\@ExePartReNamefalse%
\global\@ExePartDifficultyfalse%
\setcounter{Question}{0}\termineliste{1}}
-\define@key{PPExePart}{title}{\gdef\ExePartTitle{\string#1}%
+\define@key{PPExePart}{title}{\gdef\ExePartTitle{#1}%
\global\@ExePartTitletrue}
-\define@key{PPExePart}{name}{\gdef\@ExePartName{\string#1}%
+\define@key{PPExePart}{name}{\gdef\@ExePartName{#1}%
\global\@ExePartReNametrue}
\define@key{PPExePart}{difficulty}{\global\@ExePartDifficultytrue%
\global\ExePartDifficulty=\number#1}
@@ -506,12 +526,10 @@
\if@ExePartStared\else\refstepcounter{ExePart}\fi
\begingroup\@getExePartInfo\@ExePartHeader\endgroup}
\newbox\@Answerbox
-%% \newcommand{\AnswerHeaderRef}{Answer of \ExerciseName\ \theExercise}
-%% \newcommand{\AnswerListHeaderRef}{Answer (ex.\ \theExercise)\ ---\ }
-\newcommand{\AnswerHeader}{\medskip\centerline{\textbf{Answer of
- \ExerciseName \ExerciseHeaderNB}\smallskip}}
-\newcommand{\AnswerListHeader}{\textbf{Answer (ex.\
- \ExerciseHeaderNB)\ ---\ }}
+\newcommand{\AnswerHeader}{\medskip\centerline{\textbf{\AnswerName\ %
+ \ExerciseHeaderNB}\smallskip}}
+\newcommand{\AnswerListHeader}{\textbf{\AnswerListName\
+ (\ExerciseListName\ \ExerciseHeaderNB)\ ---\ }}
\def\@InitAnswer{\@savemathindent\global\@echapqfalse%
\gdef\AnswerRef{}%
\global\@AnswerReffalse%
@@ -534,7 +552,7 @@
\if@AswLastExe
\else
\PackageWarning{Exercise}%
-{A answer has no reference and no number}{}%
+{An answer has no reference and no number}{}%
\def\AnswerHeaderRef{\AnswerName\ ???}%
\def\AnswerListHeaderRef{\AnswerName\ ???}%
\fi\fi\fi}
@@ -548,7 +566,7 @@
\newcommand{\@@@AnswerEnv}{%
\@QuestionLevel1
\begingroup\@getExerciseInfo\@getAnswerInfo\AnswerHeader\endgroup}
-\def\endAnswerEnv{\termineliste{1}\@EndExeBox}
+\def\endAnswerEnv{\termineliste{1}\@EndExeBox\termineliste{0}}
\newenvironment{Answer}{}{}
\def\defineAnswerEnv{
\gdef\@AnswerHeaderRef{\AnswerHeader}
@@ -564,7 +582,7 @@
\topsep\Exetopsep \labelwidth\Exelabelwidth
\leftmargin\Exeleftmargin
\rightmargin\Exerightmargin }
- \refstepExecounter
+%% \refstepExecounter
\else
\termineliste{1}\@EndExeBox
\fi
@@ -584,7 +602,6 @@
\def\def@ListOfExercise#1{\gdef\@ListOfExercise{#1}}
\def\@selectExercise#1{%
\ifx#1\@empty
- \message{PAs de label}
\if@ExerciseNoLabelSelected
\global\@ShipThisExercisetrue
\else
@@ -595,7 +612,6 @@
\global\@ShipThisExercisefalse
\@for\@label:=\@ListOfExercise\do
{ \ifthenelse{\equal{\@label}{#1}}{
- \message{[\@label = #1] OK !!!}
\global\@ShipThisExercisetrue
}{}
}
@@ -639,6 +655,18 @@
\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'.