summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/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/source/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/source/latex/exercise')
-rw-r--r--Master/texmf-dist/source/latex/exercise/exercise.dtx136
-rw-r--r--Master/texmf-dist/source/latex/exercise/exercise.ins130
2 files changed, 159 insertions, 107 deletions
diff --git a/Master/texmf-dist/source/latex/exercise/exercise.dtx b/Master/texmf-dist/source/latex/exercise/exercise.dtx
index 30776f692d3..04f6b15a0c2 100644
--- a/Master/texmf-dist/source/latex/exercise/exercise.dtx
+++ b/Master/texmf-dist/source/latex/exercise/exercise.dtx
@@ -23,7 +23,7 @@
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{exercise}
-%<package> [2004/09/05 v1.1 Exercise package (P.Pichaureau)]
+%<package> [2009/03/26 v1.3 Exercise package (P.Pichaureau)]
%<*driver>
\documentclass{ltxdoc}
\usepackage{exercise}
@@ -85,7 +85,7 @@
% \DoNotIndex{\setlength,\string,\textbf,\textsc,\emph,\whiledo,\vbox}
% \DoNotIndex{\unvbox,\usefont,\usecounter,\value,\vskip,\setbox,\setcounter}
%
-%\CheckSum{1554}
+%\CheckSum{1615}
%
%
% \GetFileInfo{exercise.sty}
@@ -507,8 +507,29 @@
%displays |<symbol>| repeated |<counter>| times. For example |\marker*2|
% gives **, and |\marker+{14}| gives ++++++++++++++
%
-% By default, the difficulty is symbolized by star. You can customise
-% this by redefining the command |\DifficultyMarker|.
+%By default, the difficulty is symbolized by star. You can customise
+%this by redefining the command |\DifficultyMarker|.
+%
+%\bigskip
+%\changes{v1.3}{2009/03/26}{Added the 'listofexercices' features.}
+%\DescribeMacro{\listofexercices}
+%This command add a list of all the exercise in your document.
+%
+%\begin{decl}
+% |\ListOfExerciseInToc|\\
+% |\ExerciseLevelInToc|\marg{level of exercices}
+%\end{decl}
+%\DescribeMacro{\ListOfExerciseInToc}
+%\DescribeMacro{\ExerciseLevelInToc}
+%If you prefer to display this list of exercises in the table of
+%contents, then use the command |\ListOfExerciseInToc|.
+%
+%By default, the exercises appear in the table of content at the same
+% level as the paragraphs. The command |\ExerciseLevelInToc| is used
+% to customize this behaviour. For example with the command
+% |\ExerciseLevelInToc{subsection}| the exercises will appear at the
+% same level as the subsctions. Avalaible levels are: section,
+% subsection, subsubsection, paragraph and subparagraph.
%
%\section{Customisation}
%
@@ -824,7 +845,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}
@@ -851,19 +872,31 @@
%\changes{v1.11}{2004/09/08}{Corrected a bug preventing the correct
%use of the \textsf{babel} package.}
% \begin{macrocode}
+\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\ }%
+ }}{}
% \end{macrocode}
%\subsubsection{Layout}
% First a bunch of length definitions.
@@ -937,19 +970,19 @@
\newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ }
\newcommand{\ExerciseHeaderOrigin}{%
\ ({\usefont{\encodingdefault}{\rmdefault}{m}{it}\ExerciseOrigin})}
-\newcommand{\ExerciseHeaderNB}{\ \theExercise}
+\newcommand{\ExerciseHeaderNB}{\theExercise}
\newcommand{\ExerciseHeaderLabel}{\fbox{\textsc{\ExerciseLabel}}}
% \end{macrocode}
% The header itself
% \begin{macrocode}
\newcommand{\ExerciseHeader}{\centerline{%
-\textbf{\large\ExerciseHeaderDifficulty\ExerciseName%
+\textbf{\large\ExerciseHeaderDifficulty\ExerciseName\ %
\ExerciseHeaderNB\ExerciseHeaderTitle\ExerciseHeaderOrigin}}\medskip}
% \end{macrocode}
% The header of exercise in ExerciseList environment
% \begin{macrocode}
\newcommand{\ExerciseListHeader}{\ExerciseHeaderDifficulty%
-\textbf{\ExerciseListName\ExerciseHeaderNB%
+\textbf{\ExerciseListName\ \ExerciseHeaderNB%
\ --- \ \ExerciseHeaderTitle}%
\ExerciseHeaderOrigin\ignorespaces}
% \end{macrocode}
@@ -1023,19 +1056,19 @@
\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}{}
@@ -1065,7 +1098,8 @@
\gdef\@ExerciseCounter{Exercise}%
\setcounter{ExePart}{0}%
\setcounter{Question}{0}%
-\global\@ExeLabelfalse}
+\global\@ExeLabelfalse%
+}
%
\def\@getExerciseInfo{%
\if@ExeReName\def\ExerciseName{\@ExerciseName}\fi%
@@ -1078,8 +1112,8 @@
\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{}%
@@ -1100,7 +1134,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}
@@ -1116,7 +1150,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}
@@ -1142,6 +1180,8 @@
\fi
\@selectExercise{\ExerciseTrueLabel}
\global\@Answerfalse\@BeginExeBox\refstepExecounter%
+ \addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
+ \theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}}
\item\ignorespaces
}
%
@@ -1179,11 +1219,12 @@
\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}
@@ -1208,7 +1249,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
@@ -1245,7 +1286,7 @@
\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}
%
@@ -1276,7 +1317,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}}%
@@ -1309,7 +1350,7 @@
\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}
@@ -1340,7 +1381,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}}%
@@ -1386,9 +1427,9 @@
\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}
@@ -1416,14 +1457,13 @@
% \begin{macrocode}
\newbox\@Answerbox
%
-%% \newcommand{\AnswerHeaderRef}{Answer of \ExerciseName\ \theExercise}
-%% \newcommand{\AnswerListHeaderRef}{Answer (ex.\ \theExercise)\ ---\ }
+%\changes{v1.3}{2009/03/26}{Header of answers are now correct.}
%
-\newcommand{\AnswerHeader}{\medskip\centerline{\textbf{Answer of
- \ExerciseName \ExerciseHeaderNB}\smallskip}}
+\newcommand{\AnswerHeader}{\medskip\centerline{\textbf{\AnswerName\ %
+ \ExerciseHeaderNB}\smallskip}}
%
-\newcommand{\AnswerListHeader}{\textbf{Answer (ex.\
- \ExerciseHeaderNB)\ ---\ }}
+\newcommand{\AnswerListHeader}{\textbf{\AnswerListName\
+ (\ExerciseListName\ \ExerciseHeaderNB)\ ---\ }}
%
% The commands for <Exercise> environment
%
@@ -1450,7 +1490,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}
@@ -1470,7 +1510,7 @@
\@QuestionLevel1
\begingroup\@getExerciseInfo\@getAnswerInfo\AnswerHeader\endgroup}
%
-\def\endAnswerEnv{\termineliste{1}\@EndExeBox}
+\def\endAnswerEnv{\termineliste{1}\@EndExeBox\termineliste{0}}
%
\newenvironment{Answer}{}{}
\def\defineAnswerEnv{
@@ -1491,7 +1531,7 @@
\topsep\Exetopsep \labelwidth\Exelabelwidth
\leftmargin\Exeleftmargin
\rightmargin\Exerightmargin }
- \refstepExecounter
+%% \refstepExecounter
\else
\termineliste{1}\@EndExeBox
\fi
@@ -1515,7 +1555,6 @@
\def\def@ListOfExercise#1{\gdef\@ListOfExercise{#1}}
\def\@selectExercise#1{%
\ifx#1\@empty
- \message{PAs de label}
\if@ExerciseNoLabelSelected
\global\@ShipThisExercisetrue
\else
@@ -1526,7 +1565,6 @@
\global\@ShipThisExercisefalse
\@for\@label:=\@ListOfExercise\do
{ \ifthenelse{\equal{\@label}{#1}}{
- \message{[\@label = #1] OK !!!}
\global\@ShipThisExercisetrue
}{}
}
@@ -1591,5 +1629,19 @@
\let\@ifdefinable\@rc@ifdefinable
\@ifnextchar[{\@newctr{#1}}{}}
% \end{macrocode}
+% \begin{macrocode}
+\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}}
+% \end{macrocode}
+
% \Finale
\endinput
diff --git a/Master/texmf-dist/source/latex/exercise/exercise.ins b/Master/texmf-dist/source/latex/exercise/exercise.ins
index 57d5817637f..c2a5b09dcd7 100644
--- a/Master/texmf-dist/source/latex/exercise/exercise.ins
+++ b/Master/texmf-dist/source/latex/exercise/exercise.ins
@@ -1,66 +1,66 @@
-%% 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
-
-\input docstrip.tex
-
-%\keepsilent
-
-\usedir{tex/latex/exercise}
-
-\preamble
-
-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
-
-\endpreamble
-
-\generate{\file{exercise.sty}{\from{exercise.dtx}{package}}}
-
-\Msg{*********************************************************}
-\Msg{*}
-\Msg{* To finish the installation you have to move the}
-\Msg{* following file into a directory searched by TeX:}
-\Msg{*}
-\Msg{* \space\space exercise.sty}
-\Msg{*}
-\Msg{* To produce the documentation run the file exercise.dtx}
-\Msg{* through LaTeX.}
-\Msg{*}
-\Msg{* Don't forget to produce Index and Change History with}
-\Msg{* makeindex -s gind.ist -o exercise.ind exercise.idx}
-\Msg{* makeindex -s gglo.ist -o exercise.gls exercise.glo}
-\Msg{*}
-\Msg{* Happy TeXing!}
-\Msg{*********************************************************}
-
+%% 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
+
+\input docstrip.tex
+
+%\keepsilent
+
+\usedir{tex/latex/exercise}
+
+\preamble
+
+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
+
+\endpreamble
+
+\generate{\file{exercise.sty}{\from{exercise.dtx}{package}}}
+
+\Msg{*********************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the}
+\Msg{* following file into a directory searched by TeX:}
+\Msg{*}
+\Msg{* \space\space exercise.sty}
+\Msg{*}
+\Msg{* To produce the documentation run the file exercise.dtx}
+\Msg{* through LaTeX.}
+\Msg{*}
+\Msg{* Don't forget to produce Index and Change History with}
+\Msg{* makeindex -s gind.ist -o exercise.ind exercise.idx}
+\Msg{* makeindex -s gglo.ist -o exercise.gls exercise.glo}
+\Msg{*}
+\Msg{* Happy TeXing!}
+\Msg{*********************************************************}
+
\endbatchfile \ No newline at end of file