From e616d8ef7c606c7c9c45a2fe8cb958e9d632fc67 Mon Sep 17 00:00:00 2001
From: Sebastian Kuhnert
Date: Tue, 8 Nov 2016 15:16:27 +0000
Subject: exercisesheets.sty: make pdf page labels unique

---
 exercisesheets.sty | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'exercisesheets.sty')

diff --git a/exercisesheets.sty b/exercisesheets.sty
index b5a81c7..1f5330c 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -357,10 +357,16 @@
 \renewcommand{\thepage}{\arabic{page}}%changed for every sheet
 \setcounter{secnumdepth}{-1}
 
-% make PDF destinations unique:
 \AfterPackage*{hyperref}{%
-  \def\theHsection{\arabic{part}.\arabic{section}}%
-  \def\theHpage{\arabic{part}-\arabic{page}}%
+  % make PDF destinations unique:
+  \def\theHsection{\arabic{sheetid}.\arabic{section}}%
+  \def\theHpage{\arabic{sheetid}-\arabic{page}}%
+  %
+  % open bookmarks when typesetting a single sheet
+  \AtEndPreamble{%
+    \exsh@checkrange{0}%
+    \ifexsh@singularrange\hypersetup{bookmarksopen}\fi
+  }%
 }
 
 % automatic title selection
@@ -391,8 +397,10 @@
     \title{\exsh@title}
   \fi
 }
+\newcounter{sheetid}% only used to disambiguate hyperref labels
 \newenvironment{sheet}[1][]{%
   \clearpage
+  \stepcounter{sheetid}%
   \pgfkeys{exsh,every sheet,#1}%
   \ifthenelse{\equal{}{\pgfkeysvalueof{/exsh/title}}}{%
     \numdef\exsh@tmp{\value{part}+1}%
-- 
cgit v1.2.3

