[PATCH -perfbook 1/5] qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This avoids occasional missing destination of hyperlink with hyperref
v7.00j and later.
\refstepcounter is changed to be breakable in vertical mode, and if
it causes a page break the destination is discarded by tcolorbox.
This can be avoided by leaving vmode before using \refstepcounter.

This workaround was suggested by Ulrike Fischer in a GitHub issue
Akira opened [1].

By this change, some lines in the macro definitions need tail
comments to avoid unnecessary horizontal skips.

Also move \refstepcounter of \EQuickQuiz{} inside tcolorbox for
noqqz build.

While we are here, remove a redundant \hyperref macro in
\QuickQuizAnswer for noqqz build.  It caused a lot of warnings
from hyperref in -nq builds, which the log checker in runlatex.sh
ignores.

[1]: https://github.com/latex3/hyperref/issues/186

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 qqz.sty | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/qqz.sty b/qqz.sty
index 897d1ab6..0992c027 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -87,15 +87,14 @@
 \newcommand{\QuickQuizE}[1]{%
 	\refstepcounter{quickquizctr}%
 	\QuickQHeadingEnd{QQ}{QQA}{\thechapter.\thequickquizctr}}
-\newcommand{\EQuickQuiz}[1]{
-	\refstepcounter{quickquizctr}
+\newcommand{\EQuickQuiz}[1]{%
 	\begin{tcolorbox}[breakable]
-	\small\QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}
+	\leavevmode\refstepcounter{quickquizctr}%
+	\small\QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}%
 	{#1}
 }
 \newcommand{\QuickQuizAnswer}[1]{%
 	\refstepcounter{quickquizctrE}%
-	\hyperref[QQA.\thechapter.\thequickquizctr]{}%
 	\label{QQE.\thechapter.\thequickquizctrE}}
 \newcommand{\QuickQuizAnswerB}[1]{\QuickQuizAnswer{#1}}
 \newcommand{\QuickQuizAnswerM}[1]{\QuickQuizAnswer{#1}}
@@ -116,7 +115,7 @@
 \IfQqzBg{
 \newcommand{\QuickQuiz}[1]{
 	\begin{tcolorbox}[breakable]
-	\refstepcounter{quickquizctr}
+	\leavevmode\refstepcounter{quickquizctr}%
 	\small\QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}
 	{#1}
 }
@@ -209,7 +208,7 @@
 \IfQqzBg{
 \newcommand{\QuickQ}[1]{
 	\begin{tcolorbox}[breakable]
-	\refstepcounter{quickquizctrC}
+	\leavevmode\refstepcounter{quickquizctrC}%
 	\QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC} \\
 }
 
@@ -220,7 +219,7 @@
 }{\IfNoQqz{
 \newcommand{\QuickQ}[1]{
 	\begin{tcolorbox}[breakable]
-	\refstepcounter{quickquizctrC}
+	\leavevmode\refstepcounter{quickquizctrC}%
 	\QuickQHeadingPage{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
 }
 
-- 
2.17.1





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux