summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/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/source/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/source/latex/exercise')
-rw-r--r--Master/texmf-dist/source/latex/exercise/exercise.dtx176
1 files changed, 132 insertions, 44 deletions
diff --git a/Master/texmf-dist/source/latex/exercise/exercise.dtx b/Master/texmf-dist/source/latex/exercise/exercise.dtx
index 72d34436437..30776f692d3 100644
--- a/Master/texmf-dist/source/latex/exercise/exercise.dtx
+++ b/Master/texmf-dist/source/latex/exercise/exercise.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2003 by Paul Pichaureau
+% Copyright (C) 2003-2006 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
@@ -45,7 +45,7 @@
{\\\hline\end{tabular}\nobreak\@decl@date\par\nobreak
\vspace{2.3ex}\vskip -\parskip}
\makeatletter
- \EnableCrossrefs \PageIndex \RecordChanges
+ \EnableCrossrefs \PageIndex
\makeatother
\begin{document}
\DocInput{exercise.dtx}
@@ -85,7 +85,7 @@
% \DoNotIndex{\setlength,\string,\textbf,\textsc,\emph,\whiledo,\vbox}
% \DoNotIndex{\unvbox,\usefont,\usecounter,\value,\vskip,\setbox,\setcounter}
%
-%\CheckSum{1426}
+%\CheckSum{1554}
%
%
% \GetFileInfo{exercise.sty}
@@ -118,9 +118,6 @@
% later in the document.
%\end{abstract}
%
-%\changes{v1.0}{2004/08/17}{Initial version}
-%\changes{v1.01}{2004/08/18}{Many typos corrected, improved index.}
-%
%\section{Simple usage}
%
%This package defines two environments. The environment |Exercise|
@@ -469,6 +466,35 @@
%be a |\ExePart| or a |\Question|.
%
%
+%
+%\subsection{Exercise selection}
+%\begin{decl}
+% |\ExerciseStartSelect|\marg{comma separated list}\\
+% |\ExerciseStopSelect|
+%\end{decl}
+%\DescribeMacro{\ExerciseStartSelect}
+%\DescribeMacro{\ExerciseStopSelect}
+%
+% A very basic exercise selection mechanism is provided. When
+% |\ExerciseStartSelect| is used, an exercise is printed if and only
+% if its label is in the list of labels. For example, the following
+% command
+%\begin{verbatim}
+% \ExerciseStartSelect{exe1, exe10, exe11}
+%\end{verbatim}
+%selects the exercises with label |exe1|, |exe10| and |exe11|.
+%
+%\begin{decl}
+% |\ExerciseStartSelectNoLabel| \\
+% |\ExerciseStopSelectNoLabel|
+%\end{decl}
+%\DescribeMacro{\ExerciseStartSelectNoLabel}
+%\DescribeMacro{\ExerciseStopSelectNoLabel}
+%
+% By default, exercises which have no label are printed. With the command
+% |\ExerciseStopSelectNoLabel|, these exercises are \emph{not}
+% printed.
+%
%\subsection{Extra stuff}
%\DescribeMacro{\marker}
%\DescribeMacro{\DifficultyMarker}
@@ -517,6 +543,9 @@
%add them in the package. Anyway, you can redefine these
%commands (with a |\renewcommand|).
%
+%You must load the \textsf{exercise} package \emph{after}
+%\textsf{babel} to activate this option.
+%
%\subsection{Layout}
%
%\subsubsection{Exercises, answers and parts}
@@ -702,7 +731,7 @@
%\DescribeMacro{\renewcounter}
%
%\begin{decl}
-% |\newcounter|\marg{foo}\oarg{counter}
+% |\renewcounter|\marg{foo}\oarg{counter}
%\end{decl}
% The |\renewcounter| command defines a new counter named |foo|. The
% counter is initialized to zero.
@@ -711,7 +740,7 @@
% reset whenever the counter named in the optional argument is
% incremented.
%
-% If the counter |foo| was not previously defined, an \LaTeX\ error
+% If the counter |foo| was not previously defined, a \LaTeX\ error
% occurs.
%
%\section{Known problems}
@@ -819,6 +848,8 @@
%\subsection{Customisation}
%
%\subsubsection{Internationalisation}
+%\changes{v1.11}{2004/09/08}{Corrected a bug preventing the correct
+%use of the \textsf{babel} package.}
% \begin{macrocode}
\def\ExerciseName{Exercise}%
\def\AnswerName{Answer}%
@@ -827,12 +858,12 @@
\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}%
-}}
+ \def\ExePartName{Partie}%
+}}{}
% \end{macrocode}
%\subsubsection{Layout}
% First a bunch of length definitions.
@@ -842,7 +873,7 @@
\newlength{\Exetopsep}
\setlength{\Exetopsep}\z@
\newlength{\Exeparsep}
-\setlength{\Exeparsep}\z@
+\setlength{\Exeparsep}{\parskip}
\newlength{\Exepartopsep}
\setlength{\Exepartopsep}\z@
\newlength{\Exeleftmargin}
@@ -866,7 +897,7 @@
\newlength{\subQuestionIndent}
\setlength{\subQuestionIndent}{2em}
\newlength{\subsubQuestionIndent}
-\setlength{\subsubQuestionIndent}{1.5em}
+\setlength{\subsubQuestionIndent}{2.5em}
% \end{macrocode}
% Now the counters
% \begin{macrocode}
@@ -883,7 +914,7 @@
\renewcommand{\theExePart}{\Roman{ExePart}}
\renewcommand{\theQuestion}{\arabic{Question}}
\renewcommand{\thesubQuestion}{\alph{subQuestion}}
-\renewcommand{\thesubsubQuestion}{\arabic{subsubQuestion}}
+\renewcommand{\thesubsubQuestion}{\roman{subsubQuestion}}
% \end{macrocode}
% For internal purposes
% \begin{macrocode}
@@ -902,7 +933,7 @@
% \end{macrocode}
% Presentation of informations in the header of exercises
% \begin{macrocode}
-\newcommand{\ExerciseHeaderTitle}{\quad --- \quad \ExerciseTitle}
+\newcommand{\ExerciseHeaderTitle}{\qquad \ExerciseTitle}
\newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ }
\newcommand{\ExerciseHeaderOrigin}{%
\ ({\usefont{\encodingdefault}{\rmdefault}{m}{it}\ExerciseOrigin})}
@@ -933,6 +964,9 @@
\newcommand{\ExePartHeader}{%
\medskip\centerline{\emph{\large\ExePartHeaderDifficulty\ExePartName%
\ExePartHeaderNB\ExePartHeaderTitle}}}
+\newcommand{\ExePartListHeader}{\bigskip%
+\emph{\ExePartHeaderDifficulty\ExePartName%
+\ExePartHeaderNB\ExePartHeaderTitle}\par\medskip}
% \end{macrocode}
% Presentation of Questions
% \begin{macrocode}
@@ -948,7 +982,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%
@@ -999,7 +1033,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}}
%
@@ -1021,7 +1055,7 @@
\gdef\ExerciseTitle{}%
\gdef\@ExerciseName{}%
\gdef\ExerciseOrigin{}%
-\gdef\labelexe{}%
+\gdef\ExerciseTrueLabel{}%
\global\ExerciseDifficulty=0%
\global\@ExeTitlefalse%
\global\@ExeReNamefalse%
@@ -1029,6 +1063,7 @@
\global\@ExeOriginfalse%
\global\@ExeNBfalse%
\gdef\@ExerciseCounter{Exercise}%
+\setcounter{ExePart}{0}%
\setcounter{Question}{0}%
\global\@ExeLabelfalse}
%
@@ -1056,16 +1091,16 @@
\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}
+\else\unvbox\@Exercisebox\fi\fi}
%
-\def\@DelayExerciseBox{\if@ExerciseDelay%
+\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}
@@ -1078,6 +1113,7 @@
\global\@Answerfalse\@BeginExeBox\@@@ExeEnv}
%
\newcommand{\@@@ExeEnv}{%
+ \@selectExercise{\ExerciseTrueLabel}
\@QuestionLevel1
\refstepExecounter
\begingroup\@getExerciseInfo\ExerciseHeader\endgroup}
@@ -1104,15 +1140,19 @@
\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*}{}{}
@@ -1123,7 +1163,8 @@
%
\defineExerciseEnv
%
-\def\beginExerciseListEnv{\defineExerciseCmd\defineAnswerCmd}
+\def\beginExerciseListEnv{\defineExerciseCmd\defineAnswerCmd%
+\defineExePartInList}
%
\def\endExerciseListEnv{\termineliste{1}\@EndExeBox\termineliste{0}%
\defineExerciseEnv\defineAnswerEnv}
@@ -1138,9 +1179,9 @@
\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%
@@ -1165,8 +1206,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
@@ -1203,9 +1245,9 @@
\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%
@@ -1232,8 +1274,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}}%
@@ -1266,9 +1309,10 @@
\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%
@@ -1294,8 +1338,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}}%
@@ -1339,11 +1384,13 @@
\global\@ExePartTitlefalse%
\global\@ExePartReNamefalse%
\global\@ExePartDifficultyfalse%
-\setcounter{Question}{0}}
+\setcounter{Question}{0}\termineliste{1}}
%
-\define@key{PPExePart}{title}{\gdef\ExePartTitle{\string#1}\@ExePartTitletrue}
-\define@key{PPExePart}{name}{\gdef\@ExePartName{\string#1}\@ExePartReNametrue}
-\define@key{PPExePart}{difficulty}{\@ExePartDifficultytrue%
+\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{%
@@ -1362,7 +1409,7 @@
%
\newcommand{\@@@ExePart}{%
\if@ExePartStared\else\refstepcounter{ExePart}\fi
- \begingroup\@getExePartInfo\ExePartHeader\endgroup}
+ \begingroup\@getExePartInfo\@ExePartHeader\endgroup}
%
% \end{macrocode}
% \subsubsection{ Presentation of answers}
@@ -1385,6 +1432,7 @@
\global\@AnswerReffalse%
\gdef\AnswerNB{}%
\global\@AnswerNBfalse%
+\setcounter{ExePart}{0}%
\setcounter{Question}{0}}
%
\def\@getAnswerInfo{%
@@ -1420,7 +1468,7 @@
%
\newcommand{\@@@AnswerEnv}{%
\@QuestionLevel1
- \begingroup\@getAnswerInfo\AnswerHeader\endgroup}
+ \begingroup\@getExerciseInfo\@getAnswerInfo\AnswerHeader\endgroup}
%
\def\endAnswerEnv{\termineliste{1}\@EndExeBox}
%
@@ -1454,7 +1502,46 @@
\def\defineAnswerCmd{\gdef\@AnswerHeaderRef{\AnswerListHeader}%
\gdef\Answer{\AnswerCmd}}
% \end{macrocode}
-% \subsubsection{ Some extra stuff}
+% \subsubsection{Exercises selection}
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \subsubsection{Some extra stuff}
% \begin{macrocode}
\newcommand{\ExeText}{\setcounter{savedQuestion}{\value{Question}}%
\termineliste{1}\@echapqtrue}
@@ -1478,6 +1565,7 @@
%
\@ifundefined{if@fleqn}{\newif\if@fleqn\@fleqnfalse}{}
%
+\newlength{\@savedmathindent}
\newcommand{\@savemathindent}{\relax}
\newcommand{\@decalemathindent}[1]{\relax}
\newcommand{\@restoremathindent}{\relax}