From 28e4833279c49989c8090e430ae116426000128b Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 17 Apr 2011 22:39:42 +0000
Subject: exercise 1.55 (17apr11)

git-svn-id: svn://tug.org/texlive/trunk@22107 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/exercise/exercise.sty | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'Master/texmf-dist/tex/latex/exercise/exercise.sty')

diff --git a/Master/texmf-dist/tex/latex/exercise/exercise.sty b/Master/texmf-dist/tex/latex/exercise/exercise.sty
index ada490082a6..1a3f6d3005f 100644
--- a/Master/texmf-dist/tex/latex/exercise/exercise.sty
+++ b/Master/texmf-dist/tex/latex/exercise/exercise.sty
@@ -27,7 +27,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{exercise}
- [2010/12/14 v1.54 Exercise package (P.Pichaureau)]
+ [2011/03/13 v1.55 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
@@ -159,7 +159,21 @@
 \newlength{\subsubQuestionIndent}
 \setlength{\subsubQuestionIndent}{2.5em}
 \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]
@@ -590,6 +604,8 @@
 \def\@getAnswerInfo{%
 \if@AnswerRef%
 \def\theExercise{\ref{\AnswerRef}}%
+\refstepcounter{Answer}%
+\recordExerciseLabel{\AnswerRef-Answer}%
 \else
 \if@AnswerNB
 \def\ExerciseTitle{}%
-- 
cgit v1.2.3

