summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/exercise
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-04-17 22:39:42 +0000
committerKarl Berry <karl@freefriends.org>2011-04-17 22:39:42 +0000
commit28e4833279c49989c8090e430ae116426000128b (patch)
tree9ae4a7a4c634468a3db43c1610d8d5839de6bffa /Master/texmf-dist/source/latex/exercise
parent9645fdc665d2bd438bfe8e5e616f0381f4ab5e45 (diff)
exercise 1.55 (17apr11)
git-svn-id: svn://tug.org/texlive/trunk@22107 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/exercise')
-rw-r--r--Master/texmf-dist/source/latex/exercise/exercise.dtx55
1 files changed, 53 insertions, 2 deletions
diff --git a/Master/texmf-dist/source/latex/exercise/exercise.dtx b/Master/texmf-dist/source/latex/exercise/exercise.dtx
index 47d0e8cd5cb..1252a1225b2 100644
--- a/Master/texmf-dist/source/latex/exercise/exercise.dtx
+++ b/Master/texmf-dist/source/latex/exercise/exercise.dtx
@@ -21,7 +21,7 @@
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{exercise}
-%<package> [2010/12/14 v1.54 Exercise package (P.Pichaureau)]
+%<package> [2011/03/13 v1.55 Exercise package (P.Pichaureau)]
%<*driver>
\documentclass{ltxdoc}
\usepackage{exercise}
@@ -84,7 +84,7 @@
% \DoNotIndex{\setlength,\string,\textbf,\textsc,\emph,\whiledo,\vbox}
% \DoNotIndex{\unvbox,\usefont,\usecounter,\value,\vskip,\setbox,\setcounter}
%
-%\CheckSum{1948}
+%\CheckSum{1982}
%
%
% \GetFileInfo{exercise.sty}
@@ -381,6 +381,41 @@
%The purpose of these commands is to select exercises within a long list
%stored on an auxiliary file.
%
+%\subsection{References}
+%
+%If you want to make a cross-reference to an exercise, you must use
+%the |label| key of the |Exercise| command. Afterward, you can use the
+%usual \LaTeX commands |\ref|, |\pageref| and so on.
+%
+%The |hyperref| package should work normaly, but you must load it
+%\emph{before} the |exercise| package.
+%
+%\begin{decl}
+% |\refAnswer|\marg{label}
+%\end{decl}
+%\DescribeMacro{\refAnswer} Whenever an answer is connected to an
+%exercise \emph{via} the |ref| key, a label \emph{Exercise
+%label}|-Answer| is created. In this way, you can easily make
+%reference to a given exercise.
+%
+%The |\refAnswer| command is another way to reference the answer of a
+%given exercise : its argument is the label of an exercise without the
+%postfix |-Answer|.
+%
+%In this way
+%\begin{verbatim}
+% \ref{ex1-Answer} \refAnswer{ex1}
+%\end{verbatim}
+%are two equivalent way to reference the answer of the preceding
+%exercise labeled |ex1|.
+%
+%Remember that inside an |Exercise| the command |\ExerciseLabel|
+%stores the label of the exercise. So another way to reference the
+%answer \emph{inside} the code of an exercise is
+%\begin{verbatim}
+% \ref{\ExerciseLabel}
+%\end{verbatim}
+%
%\subsection{Extra stuff}
%\DescribeMacro{\marker}
%\DescribeMacro{\DifficultyMarker}
@@ -876,7 +911,21 @@
% Now the counters
% \begin{macrocode}
\newcounter{Exercise}
+\newcounter{Answer}
\gdef\@ExerciseCounter{Exercise} %default exercise counter
+\gdef\@AnswerCounter{Answer} %default answer counter
+\@ifpackageloaded{hyperref}{
+\def\@setAnswerref#1#2#3#4{%
+ \ifx#1\relax
+ \protect\G@refundefinedtrue
+ \nfss@text{\reset@font\bfseries ??}%
+ \PackageWarning{exercise}{Reference to Answer of `#3' on page
+ \thepage \space undefined}%
+ \else
+ \hyperref[#4]{\expandafter#2#1}\null
+ \fi}
+\def\refAnswer#1{\expandafter\@setAnswerref\csname r@#1\endcsname\@firstoffive{#1}{#1-Answer}}}
+{\let\refAnswer\ref}
\newcounter{ExePart}[Exercise]
\newcounter{Question}[Exercise]
\newcounter{subQuestion}[Question]
@@ -1428,6 +1477,8 @@
\def\@getAnswerInfo{%
\if@AnswerRef%
\def\theExercise{\ref{\AnswerRef}}%
+\refstepcounter{Answer}%
+\recordExerciseLabel{\AnswerRef-Answer}%
\else
\if@AnswerNB
\def\ExerciseTitle{}%