summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/exercise/exercise.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-11-28 00:31:39 +0000
committerKarl Berry <karl@freefriends.org>2010-11-28 00:31:39 +0000
commit4990be51499132d2118e1e5c8902806dfe2b26b7 (patch)
tree93c37e2b60dce8e288de4efa44218580fc37c205 /Master/texmf-dist/source/latex/exercise/exercise.dtx
parenta71d255dc4a69bebb54dea17ce8e53b28f78fa8e (diff)
exercise 1.53 (28nov10)
git-svn-id: svn://tug.org/texlive/trunk@20583 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/exercise/exercise.dtx')
-rw-r--r--Master/texmf-dist/source/latex/exercise/exercise.dtx302
1 files changed, 124 insertions, 178 deletions
diff --git a/Master/texmf-dist/source/latex/exercise/exercise.dtx b/Master/texmf-dist/source/latex/exercise/exercise.dtx
index a4f6952fa0d..81d39587011 100644
--- a/Master/texmf-dist/source/latex/exercise/exercise.dtx
+++ b/Master/texmf-dist/source/latex/exercise/exercise.dtx
@@ -8,8 +8,8 @@
% 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
+% 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
@@ -18,17 +18,16 @@
% Public LaTeX Project Public
%
% \fi
-
-
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{exercise}
-%<package> [2010/08/27 v1.4 Exercise package (P.Pichaureau)]
+%<package> [2010/11/27 v1.53 Exercise package (P.Pichaureau)]
%<*driver>
\documentclass{ltxdoc}
\usepackage{exercise}
\usepackage[latin1]{inputenc}
\usepackage{xspace,fancyvrb}
+\usepackage{hyperref}
%% \IfFileExists{hyperref.sty}{\usepackage[bookmarksopen]{hyperref}}{}
%% \def\PrintDescribeMacro#1{}
%% \def\PrintDescribeEnv#1{}
@@ -85,7 +84,7 @@
% \DoNotIndex{\setlength,\string,\textbf,\textsc,\emph,\whiledo,\vbox}
% \DoNotIndex{\unvbox,\usefont,\usecounter,\value,\vskip,\setbox,\setcounter}
%
-%\CheckSum{1826}
+%\CheckSum{1933}
%
%
% \GetFileInfo{exercise.sty}
@@ -104,7 +103,7 @@
%
%\date{\today}
%
-%\author{Paul Pichaureau\\ \texttt{paul.pichaureau@nerim.net}}
+%\author{Paul Pichaureau\\ \texttt{paul.pichaureau@alcandre.net}}
%
%\maketitle
%
@@ -118,129 +117,7 @@
% later in the document.
%\end{abstract}
%
-%\section{Simple usage}
-%
-%This package defines two environments. The environment |Exercise|
-%is used to typeset one exercise. For example, the following
-%output:\medskip\index{example}
-%
-%\noindent \fbox{\begin{minipage}[t]{.95\textwidth}
-%\begin{Exercise}[title={Duhamel's Rule}, label={ex:one}]
-% \label{exe:ex1}
-% Assume that the series $\sum x_n$ satisfies
-% $$
-% \frac{x_{n+1}}{x_n} = 1 - \frac{b}{n}+\frac{\varepsilon(n)}{n}
-% $$
-% where $b$ is a real number and the function $\varepsilon$ satisfies
-% $$
-% \lim_{n\rightarrow + \infty} \varepsilon(n) = 0.
-% $$
-%
-% \Question Show that if $b < 1$, then the series $\sum x_n$ is
-% divergent.
-%
-% \Question Show that if $b > 1$, then the series $\sum x_n$ is
-% convergent.
-%
-% \Question What happens to $\sum x_n$ if $b=1$?
-%
-% \end{Exercise}
-%
-%\end{minipage}}
-%
-%\medskip \noindent is obtained by the following code (the text has been cut to underscore
-%the structure of the code):
-%\begin{verbatim}
-%\begin{Exercise}[title={Duhamel's Rule}]
-% Assume...
-% \Question Show that if $b < 1$...
-% \Question Show that if $b > 1$...
-% \Question What happens to if $b=1$?
-%\end{Exercise}
-%\end{verbatim}
-%
-%Up to three level of question are available, and a part level (between
-%exercise and question) is implemented:
-%\begin{verbatim}
-%\begin{Exercise}[title={Example}]
-% Assume...
-% \ExePart
-% \Question
-% \subQuestion Show that...
-% \subQuestion In this question...
-% \subsubQuestion Show that...
-% \subsubQuestion Conclude...
-% \subQuestion Conclude.
-% \Question Show that if $b > 1$...
-% \ExePart
-% \Question What happens to if $b=1$?
-%\end{Exercise}
-%\end{verbatim}
-%
-%
-%The commands to typeset question, sub-question and sub-sub-question
-%are |Question|, |subQuestion|, and
-%|subsubQuestion|. The exercise is split in parts with the
-%command |ExePart|.
-%
-%The environment \texttt{Exercise} can be stared (no number is
-%typeset). The options of these commands are described in section
-%\ref{sec:option}. The layout of exercises can be customised in many
-%way: see section \ref{sec:custom}.
-%
-%It is common to have a long list of exercise to typeset, and the usage
-%of the |Exercise| environment could be cumbersome. Another
-%environment is available: the |ExerciseList| environment.
-%
-%\medskip
-%
-%\noindent \fbox{\begin{minipage}[t]{.95\textwidth}
-%\begin{ExerciseList}
-% \Exercise[label={ex:two}] Discuss the convergence or divergence of $
-% \left[1 + \sin \left(\frac1{an}\right)\right]^{bn}$
-% where $a$ and $b$ are two parameters.
-%
-% \Exercise Discuss the convergence or divergence of $
-% n^{\frac{(-1)^n}{n}} - 1$.
-%
-% \Exercise* Discuss the convergence or divergence of $
-% \frac{(-1)^n}{n+(-1)^n}$.
-%
-% \Answer[ref={ex:two}] $ \displaystyle \lim_{n\rightarrow
-% +\infty} \left[1 + \sin \left(\frac1{an}\right)\right]^{bn}= {\mathrm{e}}^{\frac{b}{a}}$
-%
-%\end{ExerciseList}
-%\end{minipage}}
-%
-%\medskip
-%
-%\begin{verbatim}
-%\begin{ExerciseList}
-% \Exercise[label={ex:two}] Discuss...
-% \Exercise Discuss...
-% \Exercise* Discuss...
-% \Answer[ref={ex:two}] $...$
-%\end{ExerciseList}
-%\end{verbatim}
-%
-%This example show two new commands: |\Exercise*| (for an exercise
-%without number) and |\Answer|. These commands are explained in detail
-%later in this document.
-%
-%Of course, the |\Question|, |\subQuestion|, and |\subsubQuestion|
-%hierarchy is also available in |ExerciseList|:
-%
-%\begin{verbatim}
-%\begin{ExerciseList}
-% \Exercise Discuss...
-% \Exercise Let $u$...
-% \Question ...
-% \subQuestion ...
-% \Question
-% \Exercise What...
-%\end{ExerciseList}
-%\end{verbatim}
-%
+% \tableofcontents
%\section{Options of the package}
%
%\index{package>options}\index{options>of the package}
@@ -298,7 +175,10 @@
%\DescribeEnv{Exercise}\DescribeEnv{Exercise*}
%The |Exercise| environment is used to typeset just one exercise. We
%use the \textsf{keyval} package to give different informations about
-%an exercise.
+%an exercise.
+%
+%The |Exercise*| environment typeset an exercise without number, and
+% without puting it in the |listofexercices|.
%
%\vspace*{-\baselineskip}
%
@@ -339,14 +219,14 @@
%As an example, with the default definitions, the following code:
%\medskip
%\begin{verbatim}
-%\begin{Exercise}[title={Euler's constant}, difficulty=2,
+%\begin{Exercise}[title={Euler's constant}, difficulty=2, label=ex1,
% origin={P.Paelw}]
%\end{Exercise}
%\end{verbatim}
%\noindent will give \par \medskip
%\index{example}
%\noindent \fbox{\begin{minipage}[t]{.95\textwidth}
-%\begin{Exercise}[title={Euler's constant}, difficulty=2,
+%\begin{Exercise}[title={Euler's constant}, difficulty=2, label=ex1,
% origin={P.Paelw}]
%\end{Exercise}
%\end{minipage}}
@@ -398,7 +278,7 @@
% |\begin{ExerciseList}| \\
% \quad |\Exercise|\oarg{key val list} \\
% \quad |\Answer|\oarg{key val list} \\
-% |\end{Exercise}|
+% |\end{ExerciseList}|
%\end{decl}
%
%\DescribeEnv{ExerciseList}
@@ -469,7 +349,8 @@
%
%\subsection{Exercise selection}
%\begin{decl}
-% |\ExerciseSelect|\marg{key val list}\\
+% |\ExerciseSelect|\oarg{key val list}\\
+% |\ExerciseSelect*|\oarg{key val list}\\
% |\ExerciseStopSelect|
%\end{decl}
%\DescribeMacro{\ExerciseSelect}
@@ -480,14 +361,23 @@
% if the value of its keys are within the values specified after
% |\ExerciseSelect|. For example, the following command
%\begin{verbatim}
-% \ExerciseSelect{type={short}, difficulty={0,1}}
+% \ExerciseSelect[type={short}, difficulty={0,1}]
%\end{verbatim}
%selects the short exercises of difficulties 0 and 1, whereas
%\begin{verbatim}
-% \ExerciseSelect{label={exe1, exe10, exe11}}
+% \ExerciseSelect[label={exe1, exe10, exe11}]
%\end{verbatim}
%selects the exercises with label |exe1|, |exe10| and |exe11|.
%
+%With |\ExerciseStartSelect*|, the exercises which fit the conditions
+%are \emph{omited} instead of selected.
+%
+%Last, |\ExerciseStopSelect| stops the processus of selection: every
+%exercise will be displayed later.
+%
+%The purpose of these commands is to select exercises within a long list
+%stored on an auxiliary file.
+%
%\subsection{Extra stuff}
%\DescribeMacro{\marker}
%\DescribeMacro{\DifficultyMarker}
@@ -505,7 +395,7 @@
%
%\bigskip
%\changes{v1.3}{2009/03/26}{Added the 'listofexercices' features.}
-%\DescribeMacro{\listofexercices}
+%\DescribeMacro{\listofexercises}
%This command add a list of all the exercise in your document.
%
%\begin{decl}
@@ -560,6 +450,7 @@
%You must load the \textsf{exercise} package \emph{after}
%\textsf{babel} to activate this option.
%
+%\changes{v1.41}{2010/11/03}{Added dutch translation (provided by F.A.J. Koenders).}
%\subsection{Layout}
%
%\subsubsection{Exercises, answers and parts}
@@ -595,7 +486,7 @@
% \newcommand{\ExerciseHeaderTitle}{\quad---\quad\ExerciseTitle}
%\end{verbatim}
%If an exercise has a title, then this title will be displayed preceded
-%by an emdash (as you can see in exercise \ref{exe:ex1} of this
+%by an emdash (as you can see in exercise \ref{ex1} of this
%document). If an exercise doesn't have a title, then this command is
%set to nothing (precisely to |{}|) during the exercise.
%
@@ -695,6 +586,19 @@
%
%\subsection{Lengths}
%
+%\changes{v1.52}{201/11/09}{Added the 'ExerciseSkipBefore'
+%and 'ExerciseListAfter' skip.}
+%\begin{decl}
+% \begin{tabular}{l}
+% |\ExerciseSkipBefore| \\
+% |\ExerciseSkipAfter| \\
+%\end{tabular}
+%\end{decl}
+%\DescribeMacro{ExerciseSkipBefore}
+%\DescribeMacro{ExerciseSkipAfter}
+%Before every |Exercise| environment the vertical skip
+%|ExerciseSkipBefore| is added. The corresponding |ExerciseSkipAfter|
+%vertical skip is added after every |Exercise| environment.
%\begin{decl}
% \begin{tabular}{llll}
% |\Exesep| & |\Exetopsep| & |\Exeparsep| &
@@ -710,7 +614,8 @@
%\DescribeMacro{Exeleftmargin}
%\DescribeMacro{Exerightmargin}
%\DescribeMacro{Exelabelsep}
-%The |ExerciseList| environment is nothing more than a |list|
+%These lengths have an effect only inside an |ExerciseList| environment.
+%This environment is nothing more than a |list|
%environment. All the parameters of \LaTeX's lists are
%available. Please consult your favourite source of information to have
%the exact definitions of these lengths.
@@ -898,11 +803,42 @@
\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 den {\"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 den {\"U}bung}%
+ \def\ExerciseListName{{\"U}b.}%
+ \def\AnswerListName{L{\"o}sung}%
+ \def\ExePartName{Teil}%
+ \def\ArticleOf{von\ }%
+}
}{}
% \end{macrocode}
%\subsubsection{Layout}
% First a bunch of length definitions.
% \begin{macrocode}
+\newlength{\ExerciseSkipBefore}
+\setlength{\ExerciseSkipBefore}{1\baselineskip}
+\newlength{\ExerciseSkipAfter}
+\setlength{\ExerciseSkipAfter}{0\baselineskip}
\newlength{\Exesep}
\setlength{\Exesep}{1\baselineskip}
\newlength{\Exetopsep}
@@ -945,7 +881,7 @@
% \end{macrocode}
% Presentation of these labels in cross references
% \begin{macrocode}
-\renewcommand{\theExercise}{\arabic{\@ExerciseCounter}}
+\renewcommand{\theExercise}{\if@ExeStared\else\arabic{\@ExerciseCounter}\fi}
\renewcommand{\theExePart}{\Roman{ExePart}}
\renewcommand{\theQuestion}{\arabic{Question}}
\renewcommand{\thesubQuestion}{\alph{subQuestion}}
@@ -968,7 +904,7 @@
% \end{macrocode}
% Presentation of informations in the header of exercises
% \begin{macrocode}
-\newcommand{\ExerciseHeaderTitle}{\qquad \ExerciseTitle}
+\newcommand{\ExerciseHeaderTitle}{\qquad\ExerciseTitle}
\newcommand{\ExerciseHeaderConcours}{\ExerciseConcours}
\newcommand{\ExerciseHeaderAnnee}{\ \ExerciseAnnee}
\newcommand{\ExerciseHeaderDifficulty}{\theExerciseDifficulty\ }
@@ -1086,14 +1022,7 @@
{\gdef\ExerciseClass{#1}}
%
\newif\if@ExeStared
-\newif\if@staredpb
-\newif\if@staredpart
-\newif\if@renamepart
-%
\@ExeStaredfalse
-\@staredpbfalse
-\@staredpartfalse
-\@renamepartfalse
%
\def\@InitExe{\@savemathindent\global\@echapqfalse%
\gdef\ExerciseTitle{}%
@@ -1125,29 +1054,25 @@
\if@ExeAnnee\else\def\ExerciseHeaderAnnee{}\fi%
\if@ExeOrigin\else\def\ExerciseHeaderOrigin{}\fi%
\if@ExeType\else\def\ExerciseHeaderType{}\fi%
-\if@ExeLabel\else\def\ExerciseHeaderLabel{}\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@ExeNB\def\theExercise{\ExerciseLocalNB}\fi%
-\if@ExeLabel\label{\ExerciseLabel}
-%%\recordExerciseLabel{\ExerciseLabel}
-\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{\@bsphack
- \protected@write\@auxout{}%
- {\string\newlabel{PP#1}{{\@AnswerHeaderRef}{\thepage}}}%
- \@esphack}
+\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@ShipThisExercise\if@AnswerDelay\global\setbox\temp@Answerbox%
+\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}
@@ -1166,20 +1091,22 @@
\def\beginExerciseEnv{\@InitExe\@ifnextchar[\@@ExeEnv{\@@ExeEnv[]}}%]
%
\def\@@ExeEnv[#1]{\setkeys{PPExercise}{#1}%
-\global\@Answerfalse\@BeginExeBox\@@@ExeEnv}
+\@selectExercise\global\@Answerfalse\@BeginExeBox\@@@ExeEnv}
%
\newcommand{\@@@ExeEnv}{%
- \@selectExercise%{\ExerciseTrueLabel}
+ \vskip\ExerciseSkipBefore
\@QuestionLevel1
\refstepExecounter
\begingroup\@getExerciseInfo\ExerciseHeader
+ \if@ExeStared\else%
\addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
- \theExercise\ \expandafter{\itshape
- \ExerciseTitle}\hspace{.66em}}
+ \theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}}
+ \fi%
\endgroup}
%
%
-\def\endExerciseEnv{\termineliste{1}\@EndExeBox}
+\def\endExerciseEnv{\termineliste{1}\@EndExeBox%
+\vskip\ExerciseSkipAfter}
% \end{macrocode}
% The commands for exercise within <ExerciseList> environment
% \begin{macrocode}
@@ -1200,10 +1127,12 @@
\else
\termineliste{1}\@EndExeBox
\fi
- \@selectExercise %{\ExerciseTrueLabel}
+ \@selectExercise
\global\@Answerfalse\@BeginExeBox\refstepExecounter%
+ \if@ExeStared\else%
\addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
\theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}}
+ \fi%
\item\ignorespaces
}
%
@@ -1499,16 +1428,16 @@
%
\def\@getAnswerInfo{%
\if@AnswerRef%
-%% \def\AnswerHeader{\ref{PP\AnswerRef}}%
-%% \def\AnswerListHeader{\ref{PP\AnswerRef}}%
+\def\theExercise{\ref{\AnswerRef}}%
+\def\AnswerListHeader{\@AnswerHeaderRef}
\else
\if@AnswerNB
-\def\ExerciseTitle{}
-\def\ExerciseName{}
-\def\ExerciseOrigin{}
-\def\ExerciseType{}
-\ExerciseDifficulty=0
-\def\theExercise{\AnswerNB}
+\def\ExerciseTitle{}%
+\def\ExerciseName{}%
+\def\ExerciseOrigin{}%
+\def\ExerciseType{}%
+\ExerciseDifficulty=0%
+\def\theExercise{\AnswerNB}%
\else
\if@AswLastExe
\else
@@ -1527,11 +1456,11 @@
\def\beginAnswerEnv{\@InitAnswer\@ifnextchar[\@@AnswerEnv{\@@AnswerEnv[]}}%]
%
\def\@@AnswerEnv[#1]{\setkeys{PPAnswer}{#1}%
-\global\@Answertrue\@BeginExeBox\@@@AnswerEnv}
+\global\@Answertrue\@selectAnswer\@BeginExeBox\@@@AnswerEnv}
%
\newcommand{\@@@AnswerEnv}{%
\@QuestionLevel1
- \begingroup\@getExerciseInfo\@getAnswerInfo\AnswerHeader\endgroup}
+ \begingroup\@getAnswerInfo\AnswerHeader\endgroup}
%
\def\endAnswerEnv{\termineliste{1}\@EndExeBox\termineliste{0}}
%
@@ -1558,7 +1487,7 @@
\else
\termineliste{1}\@EndExeBox
\fi
- \global\@Answertrue\@BeginExeBox%
+ \global\@Answertrue\@selectAnswer\@BeginExeBox%
\item[\bgroup\@getAnswerInfo\AnswerListHeader\egroup]\ignorespaces
}
%
@@ -1575,11 +1504,13 @@
\newif\if@ShipThisExercise \@ShipThisExercisetrue
\newif\if@@ShipThisExercise \@@ShipThisExercisetrue
\newif\if@ExerciseSelected \@ExerciseSelectedtrue
+\newif\if@ShipThisAnswer \@ShipThisAnswertrue
+\newif\if@@ShipThisAnswer \@@ShipThisAnswertrue
\newif\if@ExeSelectConcours \@ExeSelectConcoursfalse
\newif\if@ExeSelectAnnee \@ExeSelectAnneefalse
-%% \newif\if@ExeSelectDifficulty \@ExeSelectDifficultyfalse
+%% \newif\if@ExeSelectDifficulty \@ExeSelectDifficultyfalse
\newif\if@ExeSelectOrigin \@ExeSelectOriginfalse
-\newif\if@ExeSelectClass \@ExeSelectClassfalse
+\newif\if@ExeSelectClass \@ExeSelectClassfalse
\newif\if@ExeSelectType \@ExeSelectTypefalse
\newif\if@ExeSelectLabel \@ExeSelectLabelfalse
@@ -1673,6 +1604,21 @@
\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
+}
% \end{macrocode}
% \subsubsection{Some extra stuff}
% \begin{macrocode}