From 18c38aed8516ac9a857a98b0e40d6b4d556aee79 Mon Sep 17 00:00:00 2001
From: Sebastian Kuhnert
Date: Mon, 9 Feb 2009 13:17:01 +0000
Subject: update exercisesheets.sty to support references to items in
 enumerate-like environments on skipped sheets

---
 exercisesheets.sty | 43 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 4 deletions(-)

(limited to 'exercisesheets.sty')

diff --git a/exercisesheets.sty b/exercisesheets.sty
index 2b6316a..859e775 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -1,4 +1,4 @@
-\def\fileversion{0.5f}
+\def\fileversion{0.5g}
 \def\filedate{2008/11/25}
 
 % TODO: allow \and in author and solutionsby
@@ -354,18 +354,53 @@
   \clearpage
   \endgroup
 }
+\listadd{\exsh@enums}{enumerate}
+\listadd{\exsh@enums}{compactenum}
+\listadd{\exsh@enums}{asparaenum}
+\listadd{\exsh@enums}{inparaenum}
+\listadd{\exsh@nonenums}{itemize}
+\listadd{\exsh@nonenums}{compactitem}
+\listadd{\exsh@nonenums}{asparaitem}
+\listadd{\exsh@nonenums}{inparaitem}
+\listadd{\exsh@nonenums}{description}
+\listadd{\exsh@nonenums}{compactdesc}
+\listadd{\exsh@nonenums}{asparadesc}
+\listadd{\exsh@nonenums}{inparadesc}
+\listadd{\exsh@nonenums}{asparablank}
+\listadd{\exsh@nonenums}{inparablank}
+\listadd{\exsh@nonenums}{list}
 \long\def\exsh@skipsheet#1{%
   \ifstrequal{#1}{\begin}{\exsh@skipsheet@begin}{%
     \ifstrequal{#1}{\end}{\exsh@skipsheet@end}{%
       \ifstrequal{#1}{\label}{\exsh@skipsheet@label}{%
-        \exsh@skipsheet}}}%
+        \ifstrequal{#1}{\setcounter}{\expandafter\exsh@skipsheet\setcounter}{%
+          \ifstrequal{#1}{\item}{\ifdef{\@enumctr}{\@hyper@itemtrue\refstepcounter{\@enumctr}}{}}{}%
+          \exsh@skipsheet}}}}%
 }
 \def\exsh@skipsheet@end#1{%
-  \ifstrequal{#1}{sheet}{\end{sheet}}{\exsh@skipsheet}%
+  \ifstrequal{#1}{sheet}{\end{sheet}}{\endgroup\exsh@skipsheet}%
 }
 \def\exsh@skipsheet@begin#1{%
+  \begingroup
   \ifstrequal{#1}{exercise}{\refstepcounter{section}}{}%
-  \exsh@skipsheet%
+  \ifinlist{#1}{\exsh@enums}{%
+    \exsh@skipsheet@beginenum
+  }{%
+    \ifinlist{#1}{\exsh@nonenums}{%
+      \undef\@enumctr
+    }{}%
+    \exsh@skipsheet
+  }%
+}
+\def\exsh@skipsheet@beginenum{%
+  \ifnum\@enumdepth>\thr@@
+    \@toodeep
+  \else
+    \advance\@enumdepth\@ne
+    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+    \setcounter{\@enumctr}{0}%
+  \fi
+  \@ifnextchar[{\@enumlabel@{\exsh@skipsheet}[}{\exsh@skipsheet}%
 }
 \def\exsh@skipsheet@label#1{%
   \label{#1}\exsh@skipsheet
-- 
cgit v1.2.3

