Skip to contentSkip to conversation

Updates of qqz.sty

PATCH In review Akira Yokosawa 2 participants 11 messages Apr 14, 2021 – Apr 15, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Updates of qqz.sty

Hi Paul,

A change in upstream hyperref package (v7.00j) breaks code in qqz.sty.
Now, \refstepcounter in vertical mode can cause a page break. Our use of \refstepcounter in framed Quick Quiz is in vertical mode and if a page break happens at that point, destination point set by \refstepcounter is discarded by tcolorbox, which results in a missing destination.

This can be fixed by leaving vertical mode in front of \refstepcounter, which is what Patch 1/5 does.

The updated code is compatible with older versions of hyperref as long as our usage patterns are concerned.
Aa a bonus, new link-target positions look nicer (not too close to the "Quick Quiz" labels).

Patches 2/5--4/5 are (in my opinion) improvements to the -nq build. Seeing both Quizzes and Answers in the final section, one would just see the answer without taking time to think about a quiz. So these patches modify the -nq build so that chapter-wise sections have only the quiz parts.
Answers are presented in Appendix E in the same way as the other builds.

Patch 5/5 adds page references in the answers of non-nq builds.

Thanks, Akira

--
Akira Yokosawa (5):
qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox qqz.sty: Modify -nq build to have chapterwise quiz-only section perfbook-lt.tex: Remove boolean qqzchpend
howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full' qqz.sty: Add page reference to QQA Appendix as the same as -nq build

 Makefile               |   5 +-
 advsync/rt.tex         |  18 -------
 howto/howto.tex        |  17 +-----
 perfbook-lt.tex        |   3 --
 qqz.sty                | 118 ++++++++++++++++++++++++-----------------
 utilities/divideqqz.pl |  25 ++++++++-
 6 files changed, 97 insertions(+), 89 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

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

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

---
 qqz.sty | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
qqz.sty +6 -7
index 897d1ab6..0992c027 100644
@@ -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}\\
 }
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/5 qqz.sty: Modify -nq build to have chapterwise quiz-only section

In reply to Akira Yokosawa

Presenting answers in chapter-wise sections would deprive of chances to think before seeing answers.

So, modify -nq builds so that each chapter has a quiz-only section and Appendix E provides answers in the same manner of the official builds.

This is done by the set of changes listed below:

o divideqqz.sh now extracts quiz part only, with renaming of macros "\QuickQAC -> \QuickQQC", "\QuickQ -> \QuickQQ", and "\QuickE -> \QuickQE".

o Add definitions for those -nq only macros in qqz.sty.

o Hyperlinks are made in the following way:

- Inline QQ marker -> Chapter-wise Quiz -> Answer in Appendix
- Page number marker in Quiz part -> Inline QQ marker
- Answer in Appendix -> Inline QQ marker

- Essential Quizzes are directly linked to their answers, and the white boxes at the end of the answers are linked to the end markers of inline Quizzes.

o Use \phantomsection instead of \refstepcounter{quickquizctrE}, because the counter value for labeling is always the same as quickquizctr or quickquizctrP.

o Remove conditional contents for \IfQqzChpEnd{} (answers are in Appendix now).

---
 Makefile               |  2 +-
 advsync/rt.tex         | 18 --------
 howto/howto.tex        | 14 ------
 qqz.sty                | 97 ++++++++++++++++++++++++------------------
 utilities/divideqqz.pl | 25 ++++++++++-
 5 files changed, 81 insertions(+), 75 deletions(-)
Makefile +1 -1
index cd8ee7ff..cec7e878 100644
@@ -375,7 +375,7 @@ perfbook-ebsfnq.tex: perfbook-ebsf.tex
 perfbook-nq.tex perfbook-sfnq.tex perfbook-1cnq.tex perfbook-1csfnq.tex perfbook-ebnq.tex perfbook-ebsfnq.tex:
 	sed -e 's/setboolean{qqzbg}{true}/setboolean{qqzbg}{false}/' \
 	    -e 's/setboolean{noqqz}{false}/setboolean{noqqz}{true}/' \
-	    -e 's/{qqzchpend}{false}/{qqzchpend}{true}/' < $< > $@
+	    -e 's/{qqzchpend}{false}/{qqzchpend}{false}/' < $< > $@
 
 perfbook-ix.tex: $(PERFBOOK_BASE)
 perfbook-1cix.tex: perfbook-1c.tex
advsync/rt.tex +0 -18
index 2732f9ed..96c22d25 100644
@@ -1996,42 +1996,24 @@ non-real-time computing, using real-time when it is not required is
 unwise, as fancifully depicted by
 \cref{fig:advsync:The Dark Side of Real-Time Computing}.
 
-\IfQqzChpEnd{
 \begin{figure}
 \centering
 \resizebox{3.2in}{!}{\includegraphics{cartoons/RealTimeNotRealFast}}
 \caption{The Dark Side of Real-Time Computing}
 \ContributedBy{Figure}{fig:advsync:The Dark Side of Real-Time Computing}{Sarah McKenney}
 \end{figure}
-}{
-\begin{figure}
-\centering
-\resizebox{3.2in}{!}{\includegraphics{cartoons/RealTimeNotRealFast}}
-\caption{The Dark Side of Real-Time Computing}
-\ContributedBy{Figure}{fig:advsync:The Dark Side of Real-Time Computing}{Sarah McKenney}
-\end{figure}
-}
 
 On the other hand, failing to use real-time when it \emph{is} required
 can also cause problems, as fancifully depicted by
 \cref{fig:advsync:The Dark Side of Real-Fast Computing}.
 It is almost enough to make you feel sorry for the boss!
 
-\IfQqzChpEnd{
 \begin{figure}
 \centering
 \resizebox{3.2in}{!}{\includegraphics{cartoons/RealFastNotRealTime}}
 \caption{The Dark Side of Real-Fast Computing}
 \ContributedBy{Figure}{fig:advsync:The Dark Side of Real-Fast Computing}{Sarah McKenney}
 \end{figure}
-}{
-\begin{figure}
-\centering
-\resizebox{3.2in}{!}{\includegraphics{cartoons/RealFastNotRealTime}}
-\caption{The Dark Side of Real-Fast Computing}
-\ContributedBy{Figure}{fig:advsync:The Dark Side of Real-Fast Computing}{Sarah McKenney}
-\end{figure}
-}
 
 One rule of thumb uses the following four questions to help you choose:
 
howto/howto.tex +0 -14
index a4ed4f4c..42e3d626 100644
@@ -134,11 +134,9 @@ This chapter is followed by a number of appendices.
 The most popular of these appears to be
 \cref{chp:app:whymb:Why Memory Barriers?},
 which delves even further into memory ordering.
-\IfQqzChpEnd{}{
 \Cref{chp:Answers to Quick Quizzes}
 contains the answers to the infamous Quick Quizzes, which are discussed in
 the next section.
-}
 
 \section{Quick Quizzes}
 \label{sec:howto:Quick Quizzes}
@@ -148,15 +146,8 @@ the next section.
 
 ``Quick quizzes'' appear throughout this book, and the answers may
 be found in
-\IfQqzChpEnd{%
-the final section of each chapter.\footnote{
-	In the official release/edition of this book, all the answers are
-	gathered in an Appendix.
-}
-}{%
 \cref{chp:Answers to Quick Quizzes} starting on
 \cpageref{chp:Answers to Quick Quizzes}.
-}
 Some of them are based on material in which that quick quiz
 appears, but others require you to think beyond that section, and,
 in some cases, beyond the realm of current knowledge.
@@ -171,13 +162,8 @@ of parallel programming.
 \QuickQuizB{
 	Where are the answers to the Quick Quizzes found?
 }\QuickQuizAnswerB{
-\IfQqzChpEnd{
-	At the end of each chapter as you see here in
-        \cref{sec:qqzhowto:Answers to Quick Quizzes}.
-}{
 	In \cref{chp:Answers to Quick Quizzes} starting on
 	\cpageref{chp:Answers to Quick Quizzes}.
-}
 	Hey, I thought I owed you an easy one!
 }\QuickQuizEndB
 %
qqz.sty +56 -41

180 lines not on this page · raw message

utilities/divideqqz.pl +24 -1
index 7387f683..7895fb23 100755
@@ -25,18 +25,41 @@ use warnings;
 my $src_file = "qqz.tex";
 my $chp_name;
 my $QAC_ptn = "\\\\QuickQAC\\{[^}]*}\\{[^}]*}\\{([^}]*)}" ;
+my $QA_ptn  = "\\\\QuickA\\{" ;
+my $QQ_ptn  = "\\\\QuickQ\\{" ;
 my $out_h;
 my $out_file;
+my $skip = 0;
 
 open(my $in_h, "<", $src_file) or die "cannot open $src_file: $!" ;
 while (my $line = <$in_h>) {
     if ($line =~ /$QAC_ptn/) {
+	if ($out_h) {
+	    print $out_h "\\QuickQE{}\n";
+	}
 	$out_file = $1 . ".tex" ;
 	open ($out_h, ">", $out_file) or die "cannot open $out_file: $!" ;
 	print $out_h "% mainfile: perfbook.tex\n" ;
 	print $out_h "% Do not edit! Generated by divideqqz.pl\n" ;
+	$line =~ s/QuickQAC/QuickQQC/;
+	$skip = 0;
     }
     if ($out_h) {
-	print $out_h $line ;
+	if ($line =~ /$QA_ptn/) {
+	    $skip = 1;
+	}
+	if ($skip == 1 && $line =~ /$QQ_ptn/) {
+	    print $out_h "\\QuickQE{}\n";
+	    $skip = 0;
+	}
+	if ($skip == 0) {
+	    if ($line =~ /$QQ_ptn/) {
+		print $out_h "\\QuickQQ{}\n";
+	    } else {
+		print $out_h $line ;
+	    }
+	}
     }
 }
+# need to print file line
+print $out_h "\\QuickQE{}\n";
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/5 perfbook-lt.tex: Remove boolean qqzchpend

In reply to Akira Yokosawa

Now that -nq builds have answers in appendix, and independent of qqzchpend, remove the boolean and \IfQqzChpEnd macro.
Also remove a sed pattern substituting its value in Makefile.

---
 Makefile        | 3 +--
 perfbook-lt.tex | 3 ---
 2 files changed, 1 insertion(+), 5 deletions(-)
Makefile +1 -2
index cec7e878..1d26cfbb 100644
@@ -374,8 +374,7 @@ perfbook-ebnq.tex: perfbook-eb.tex
 perfbook-ebsfnq.tex: perfbook-ebsf.tex
 perfbook-nq.tex perfbook-sfnq.tex perfbook-1cnq.tex perfbook-1csfnq.tex perfbook-ebnq.tex perfbook-ebsfnq.tex:
 	sed -e 's/setboolean{qqzbg}{true}/setboolean{qqzbg}{false}/' \
-	    -e 's/setboolean{noqqz}{false}/setboolean{noqqz}{true}/' \
-	    -e 's/{qqzchpend}{false}/{qqzchpend}{false}/' < $< > $@
+	    -e 's/setboolean{noqqz}{false}/setboolean{noqqz}{true}/' < $< > $@
 
 perfbook-ix.tex: $(PERFBOOK_BASE)
 perfbook-1cix.tex: perfbook-1c.tex
perfbook-lt.tex +0 -3
index 41371abf..d8786baa 100644
@@ -99,9 +99,6 @@
 \newboolean{noqqz}
 \setboolean{noqqz}{false}
 \newcommand{\IfNoQqz}[2]{\ifthenelse{\boolean{noqqz}}{#1}{#2}}
-\newboolean{qqzchpend}
-\setboolean{qqzchpend}{false}
-\newcommand{\IfQqzChpEnd}[2]{\ifthenelse{\boolean{qqzchpend}}{#1}{#2}}
 
 \input{autodate} % need to input here to reflect tag state
 \usepackage{qqz}
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/5 howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full'

In reply to Akira Yokosawa

Now chapter-wise sections contain Quizzes only.

---
 Makefile        | 2 +-
 howto/howto.tex | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
Makefile +1 -1
index 1d26cfbb..4beb2c17 100644
@@ -520,7 +520,7 @@ help-semiofficial:
 	@echo
 	@echo "Semi-official targets:"
 	@echo "  Full,              Abbr."
-	@echo "  perfbook-nq.pdf,   nq:   2c without inline Quick Quizzes (chapterwise Q&As)"
+	@echo "  perfbook-nq.pdf,   nq:   2c without inline Quick Quizzes (chapterwise Qs)"
 	@echo "  perfbook-sf.pdf,   sf:   2c with sans serif font"
 	@echo "  perfbook-sfnq.pdf, sfnq: sf + nq"
 
howto/howto.tex +1 -2
index 42e3d626..74bbed4c 100644
@@ -226,8 +226,7 @@ Here are a few possible strategies:
 	produce a \co{perfbook-nq.pdf}.
 	This PDF contains unobtrusive boxed tags where the Quick Quizzes
 	would otherwise be, and gathers each chapter's Quick Quizzes
-	and their answers at the end of that chapter in the
-	classic textbook style.
+	at the end of that chapter in the classic textbook style.
 \item	Learn to like (or at least tolerate) the Quick Quizzes.
 	Experience indicates that quizzing yourself periodically
 	while reading greatly increases comprehension and depth
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/5 qqz.sty: Add page reference to QQA Appendix as the same as -nq build

In reply to Akira Yokosawa

The page references in -nq build are nice to have. Add similar refs in other build targets.

---
 qqz.sty | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
qqz.sty +10 -2
index 9b1d4c35..4e1a138a 100644
@@ -59,8 +59,16 @@
 \newcommand{\QuickQuizAnswerChapter}{\textbf{Unknown QuickQAC!!!}}
 
 \newcommand{\QuickQHeading}[3]{\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}\label{#1.#3}}
+\IfNoQqz{
 \newcommand{\QuickQHeadingPage}[3]{\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}\label{#1.#3}%
 	\hfill\raisebox{0.5ex}{\footnotesize\fbox{p.\pageref{QQP.#3}}}}
+}{\IfQqzBg{
+\newcommand{\QuickQHeadingPage}[3]{\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}\label{#1.#3}%
+	\hfill\raisebox{0.5ex}{\footnotesize\fbox{p.\pageref{QQ.#3}}}}
+}{% draft build
+\newcommand{\QuickQHeadingPage}[3]{\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}\label{#1.#3}%
+	\hfill{\footnotesize{[p.\pageref{QQ.#3}]}}}
+}}
 \newcommand{\QuickQHeadingLight}[3]{\scriptsize QQ~\hyperref[#2.#3]{#3}\label{#1.#3}}
 \newcommand{\QuickQHeadingBegin}[3]{\scriptsize QQ~\hyperref[#2.#3]{#3}\label{#1.#3},}
 \newcommand{\QuickQHeadingMiddle}[3]{\scriptsize\hyperref[#2.#3]{{ #3}}\label{#1.#3},}
@@ -213,7 +221,7 @@
 \newcommand{\QuickQ}[1]{
 	\begin{tcolorbox}[breakable]
 	\leavevmode\refstepcounter{quickquizctrC}%
-	\QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC} \\
+	\QuickQHeadingPage{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC} \\
 }
 
 \newcommand{\QuickA}[1]{%
@@ -247,7 +255,7 @@
 	\par
 	\refstepcounter{quickquizctrC}%
 	\noindent
-	\QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC} #1 ~ \\ }
+	\QuickQHeadingPage{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC}\\}
 
 \newcommand{\QuickA}[1]{%
 	\hyperref[QQ.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
Signature · 1 line
2.17.1
#6 lore raw
In reply to Akira Yokosawa
Quoted 26 lines · Akira Yokosawa

Hi Paul,

A change in upstream hyperref package (v7.00j) breaks code in qqz.sty.
Now, \refstepcounter in vertical mode can cause a page break. Our use of \refstepcounter in framed Quick Quiz is in vertical mode and if a page break happens at that point, destination point set by \refstepcounter is discarded by tcolorbox, which results in a missing destination.

This can be fixed by leaving vertical mode in front of \refstepcounter, which is what Patch 1/5 does.

The updated code is compatible with older versions of hyperref as long as our usage patterns are concerned.
Aa a bonus, new link-target positions look nicer (not too close to the "Quick Quiz" labels).

Patches 2/5--4/5 are (in my opinion) improvements to the -nq build. Seeing both Quizzes and Answers in the final section, one would just see the answer without taking time to think about a quiz. So these patches modify the -nq build so that chapter-wise sections have only the quiz parts.
Answers are presented in Appendix E in the same way as the other builds.

Quoted 1 line

Patch 5/5 adds page references in the answers of non-nq builds.

Good points, queued and pushed, thank you!

On interesting thing is that if you click on the small bubble in the text, you are taken to the corresponding QQ at the end of that chapter. If you click on the square, you are taken to the answer. If you click on the page number in the square in the upper right-hand corner of the QQ question, you get taken back to the original small bubble, all of which is goodness.

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

This is probably not a big deal, given that clicking on the small bubble will take them to that list, but I figured that it was worth asking the question.

Thanx, Paul

Quoted 21 lines

Thanks, Akira

--
Akira Yokosawa (5):
qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox qqz.sty: Modify -nq build to have chapterwise quiz-only section perfbook-lt.tex: Remove boolean qqzchpend
howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full' qqz.sty: Add page reference to QQA Appendix as the same as -nq build

 Makefile               |   5 +-
 advsync/rt.tex         |  18 -------
 howto/howto.tex        |  17 +-----
 perfbook-lt.tex        |   3 --
 qqz.sty                | 118 ++++++++++++++++++++++++-----------------
 utilities/divideqqz.pl |  25 ++++++++-
 6 files changed, 97 insertions(+), 89 deletions(-)
Signature · 1 line
2.17.1
#7 lore raw
Quoted 38 lines · Paul E. McKenney
Quoted 26 lines · Akira Yokosawa

Hi Paul,

A change in upstream hyperref package (v7.00j) breaks code in qqz.sty.
Now, \refstepcounter in vertical mode can cause a page break. Our use of \refstepcounter in framed Quick Quiz is in vertical mode and if a page break happens at that point, destination point set by \refstepcounter is discarded by tcolorbox, which results in a missing destination.

This can be fixed by leaving vertical mode in front of \refstepcounter, which is what Patch 1/5 does.

The updated code is compatible with older versions of hyperref as long as our usage patterns are concerned.
Aa a bonus, new link-target positions look nicer (not too close to the "Quick Quiz" labels).

Patches 2/5--4/5 are (in my opinion) improvements to the -nq build. Seeing both Quizzes and Answers in the final section, one would just see the answer without taking time to think about a quiz. So these patches modify the -nq build so that chapter-wise sections have only the quiz parts.
Answers are presented in Appendix E in the same way as the other builds.

Quoted 1 line

Patch 5/5 adds page references in the answers of non-nq builds.

Good points, queued and pushed, thank you!

On interesting thing is that if you click on the small bubble in the text, you are taken to the corresponding QQ at the end of that chapter. If you click on the square, you are taken to the answer. If you click on the page number in the square in the upper right-hand corner of the QQ question, you get taken back to the original small bubble, all of which is goodness.

Quoted 3 lines

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Ya, that's as described in the commit log of Patch 2/5:

o Hyperlinks are made in the following way:

- Inline QQ marker -> Chapter-wise Quiz -> Answer in Appendix
- Page number marker in Quiz part -> Inline QQ marker
- Answer in Appendix -> Inline QQ marker

Quoted 4 lines

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

It is possible, but the white box at the end of the answer is supposed to be a short-cut for those wanting to resume reading text.

So, appended is a compromise modifying the links of "Quick Quiz" and black box in the answer to go back to chapter-wise quiz section.

Thoughts?

Thanks, Akira

Quoted 7 lines

This is probably not a big deal, given that clicking on the small bubble will take them to that list, but I figured that it was worth asking the question.

Thanx, Paul

Quoted 1 line

Thanks, Akira

[...]

----8<--------
From: Akira Yokosawa <[email protected]>
Date: Thu, 15 Apr 2021 12:31:26 +0900
Subject: [PATCH] qqz.sty: Link chapter-wise quizzes from answers in -nq build

Paul's suggestion:

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

Akira's take on reader's expectation:

The white boxes at the end of answers are meant as short-cuts to go back to the text by a single click for those want to resume reading.

So, this commit is a compromise and changes the link of "Quick Quiz" and black square so that they go back to the chapter-end quiz. The white box at the end of the answer is kept linking back to the small bubble in the text.

Also add a tail comment in \QuickQE to avoid an extra skip in front of the black square.

---
 qqz.sty | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qqz.sty +3 -3
index 4e1a138a..86b50c79 100644
@@ -235,7 +235,7 @@
 	\QuickQHeadingPage{QQ}{QQA}{\thechapter.\thequickquizctr}\\
 }
 
-\newcommand{\QuickQE}[1]{
+\newcommand{\QuickQE}[1]{%
 	\hyperref[QQA.\thechapter.\thequickquizctr]{\rule{7pt}{7pt}}%
 	\end{tcolorbox}
 }
@@ -243,11 +243,11 @@
 \newcommand{\QuickQ}[1]{
 	\begin{tcolorbox}[breakable]
 	\leavevmode\refstepcounter{quickquizctrC}%
-	\QuickQHeadingPage{QQA}{QQP}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
+	\QuickQHeadingPage{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
 }
 
 \newcommand{\QuickA}[1]{%
-	\hyperref[QQP.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
+	\hyperref[QQ.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
 	\end{tcolorbox}
 	\noindent\textbf{Answer:} \\ }
 }{
Signature · 1 line
2.17.1
#8 lore raw
Quoted 43 lines · Akira Yokosawa
Quoted 38 lines · Paul E. McKenney
Quoted 26 lines · Akira Yokosawa

Hi Paul,

A change in upstream hyperref package (v7.00j) breaks code in qqz.sty.
Now, \refstepcounter in vertical mode can cause a page break. Our use of \refstepcounter in framed Quick Quiz is in vertical mode and if a page break happens at that point, destination point set by \refstepcounter is discarded by tcolorbox, which results in a missing destination.

This can be fixed by leaving vertical mode in front of \refstepcounter, which is what Patch 1/5 does.

The updated code is compatible with older versions of hyperref as long as our usage patterns are concerned.
Aa a bonus, new link-target positions look nicer (not too close to the "Quick Quiz" labels).

Patches 2/5--4/5 are (in my opinion) improvements to the -nq build. Seeing both Quizzes and Answers in the final section, one would just see the answer without taking time to think about a quiz. So these patches modify the -nq build so that chapter-wise sections have only the quiz parts.
Answers are presented in Appendix E in the same way as the other builds.

Quoted 1 line

Patch 5/5 adds page references in the answers of non-nq builds.

Good points, queued and pushed, thank you!

On interesting thing is that if you click on the small bubble in the text, you are taken to the corresponding QQ at the end of that chapter. If you click on the square, you are taken to the answer. If you click on the page number in the square in the upper right-hand corner of the QQ question, you get taken back to the original small bubble, all of which is goodness.

Quoted 3 lines

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Quoted 7 lines

Ya, that's as described in the commit log of Patch 2/5:

o Hyperlinks are made in the following way:

- Inline QQ marker -> Chapter-wise Quiz -> Answer in Appendix
- Page number marker in Quiz part -> Inline QQ marker
- Answer in Appendix -> Inline QQ marker

OK, my reading comprehension was clearly substandard. :-/

Quoted 5 lines
Quoted 2 lines

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

It is possible, but the white box at the end of the answer is supposed to be a short-cut for those wanting to resume reading text.

True enough.

Quoted 4 lines

So, appended is a compromise modifying the links of "Quick Quiz" and black box in the answer to go back to chapter-wise quiz section.

Thoughts?

It does work well, and removes one layer of clicking that otherwise needs to happen. Let's see what people think about it.

We also have the page-number marker that goes back to the text, so we do have the option of making the black and white boxes go to the beginning and end of the quick-quiz box at the end of the chapter. But again, let's see how this patch works for people.

Any objection to my pushing it as is, or should I wait for a second version. (I have queued it, but not yet pushed it out.)

Thanx, Paul

Quoted 77 lines

Thanks, Akira

Quoted 7 lines

This is probably not a big deal, given that clicking on the small bubble will take them to that list, but I figured that it was worth asking the question.

Thanx, Paul

Quoted 1 line

Thanks, Akira

[...]

----8<--------
From: Akira Yokosawa <[email protected]>
Date: Thu, 15 Apr 2021 12:31:26 +0900
Subject: [PATCH] qqz.sty: Link chapter-wise quizzes from answers in -nq build

Paul's suggestion:

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

Akira's take on reader's expectation:

The white boxes at the end of answers are meant as short-cuts to go back to the text by a single click for those want to resume reading.

So, this commit is a compromise and changes the link of "Quick Quiz" and black square so that they go back to the chapter-end quiz. The white box at the end of the answer is kept linking back to the small bubble in the text.

Also add a tail comment in \QuickQE to avoid an extra skip in front of the black square.

---
 qqz.sty | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qqz.sty +3 -3
index 4e1a138a..86b50c79 100644
@@ -235,7 +235,7 @@
 	\QuickQHeadingPage{QQ}{QQA}{\thechapter.\thequickquizctr}\\
 }
 
-\newcommand{\QuickQE}[1]{
+\newcommand{\QuickQE}[1]{%
 	\hyperref[QQA.\thechapter.\thequickquizctr]{\rule{7pt}{7pt}}%
 	\end{tcolorbox}
 }
@@ -243,11 +243,11 @@
 \newcommand{\QuickQ}[1]{
 	\begin{tcolorbox}[breakable]
 	\leavevmode\refstepcounter{quickquizctrC}%
-	\QuickQHeadingPage{QQA}{QQP}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
+	\QuickQHeadingPage{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
 }
 
 \newcommand{\QuickA}[1]{%
-	\hyperref[QQP.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
+	\hyperref[QQ.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
 	\end{tcolorbox}
 	\noindent\textbf{Answer:} \\ }
 }{
Signature · 1 line
2.17.1
#9 lore raw
Quoted 65 lines · Paul E. McKenney
Quoted 43 lines · Akira Yokosawa
Quoted 38 lines · Paul E. McKenney
Quoted 26 lines · Akira Yokosawa

Hi Paul,

A change in upstream hyperref package (v7.00j) breaks code in qqz.sty.
Now, \refstepcounter in vertical mode can cause a page break. Our use of \refstepcounter in framed Quick Quiz is in vertical mode and if a page break happens at that point, destination point set by \refstepcounter is discarded by tcolorbox, which results in a missing destination.

This can be fixed by leaving vertical mode in front of \refstepcounter, which is what Patch 1/5 does.

The updated code is compatible with older versions of hyperref as long as our usage patterns are concerned.
Aa a bonus, new link-target positions look nicer (not too close to the "Quick Quiz" labels).

Patches 2/5--4/5 are (in my opinion) improvements to the -nq build. Seeing both Quizzes and Answers in the final section, one would just see the answer without taking time to think about a quiz. So these patches modify the -nq build so that chapter-wise sections have only the quiz parts.
Answers are presented in Appendix E in the same way as the other builds.

Quoted 1 line

Patch 5/5 adds page references in the answers of non-nq builds.

Good points, queued and pushed, thank you!

On interesting thing is that if you click on the small bubble in the text, you are taken to the corresponding QQ at the end of that chapter. If you click on the square, you are taken to the answer. If you click on the page number in the square in the upper right-hand corner of the QQ question, you get taken back to the original small bubble, all of which is goodness.

Quoted 3 lines

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Quoted 7 lines

Ya, that's as described in the commit log of Patch 2/5:

o Hyperlinks are made in the following way:

- Inline QQ marker -> Chapter-wise Quiz -> Answer in Appendix
- Page number marker in Quiz part -> Inline QQ marker
- Answer in Appendix -> Inline QQ marker

OK, my reading comprehension was clearly substandard. :-/

Quoted 5 lines
Quoted 2 lines

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

It is possible, but the white box at the end of the answer is supposed to be a short-cut for those wanting to resume reading text.

True enough.

Quoted 3 lines

So, appended is a compromise modifying the links of "Quick Quiz" and black box in the answer to go back to chapter-wise quiz section.

Quoted 8 lines
Quoted 1 line

Thoughts?

It does work well, and removes one layer of clicking that otherwise needs to happen. Let's see what people think about it.

We also have the page-number marker that goes back to the text, so we do have the option of making the black and white boxes go to the beginning and end of the quick-quiz box at the end of the chapter.

No, my point in making white box to go back to the end of the quiz in normal builds was to help people reach the text following the quiz.
So linking white box to a quiz at the end of the chapter spoils this purpose. A page-number marker can be far away from the white box when the answer is long.

Quoted 5 lines

But again,
let's see how this patch works for people.

Any objection to my pushing it as is, or should I wait for a second version. (I have queued it, but not yet pushed it out.)

I'm OK with your pushing it as is.

Thanks, Akira

Quoted 12 lines

Thanx, Paul

Quoted 9 lines

Thanks, Akira

Quoted 7 lines

This is probably not a big deal, given that clicking on the small bubble will take them to that list, but I figured that it was worth asking the question.

Thanx, Paul

Quoted 1 line

Thanks, Akira

[...]

#10 lore raw
Quoted 82 lines · Akira Yokosawa
Quoted 65 lines · Paul E. McKenney
Quoted 43 lines · Akira Yokosawa
Quoted 38 lines · Paul E. McKenney
Quoted 26 lines · Akira Yokosawa

Hi Paul,

A change in upstream hyperref package (v7.00j) breaks code in qqz.sty.
Now, \refstepcounter in vertical mode can cause a page break. Our use of \refstepcounter in framed Quick Quiz is in vertical mode and if a page break happens at that point, destination point set by \refstepcounter is discarded by tcolorbox, which results in a missing destination.

This can be fixed by leaving vertical mode in front of \refstepcounter, which is what Patch 1/5 does.

The updated code is compatible with older versions of hyperref as long as our usage patterns are concerned.
Aa a bonus, new link-target positions look nicer (not too close to the "Quick Quiz" labels).

Patches 2/5--4/5 are (in my opinion) improvements to the -nq build. Seeing both Quizzes and Answers in the final section, one would just see the answer without taking time to think about a quiz. So these patches modify the -nq build so that chapter-wise sections have only the quiz parts.
Answers are presented in Appendix E in the same way as the other builds.

Quoted 1 line

Patch 5/5 adds page references in the answers of non-nq builds.

Good points, queued and pushed, thank you!

On interesting thing is that if you click on the small bubble in the text, you are taken to the corresponding QQ at the end of that chapter. If you click on the square, you are taken to the answer. If you click on the page number in the square in the upper right-hand corner of the QQ question, you get taken back to the original small bubble, all of which is goodness.

Quoted 3 lines

However, if you click on the either black square at the end of the question or the white shadowed square at the end of the answer, you get taken back to the small bubble in the text.

Quoted 7 lines

Ya, that's as described in the commit log of Patch 2/5:

o Hyperlinks are made in the following way:

- Inline QQ marker -> Chapter-wise Quiz -> Answer in Appendix
- Page number marker in Quiz part -> Inline QQ marker
- Answer in Appendix -> Inline QQ marker

OK, my reading comprehension was clearly substandard. :-/

Quoted 5 lines
Quoted 2 lines

Is it possible that some of our readers will expect that these two squares will instead take them back to the question at the end of the chapter?

It is possible, but the white box at the end of the answer is supposed to be a short-cut for those wanting to resume reading text.

True enough.

Quoted 3 lines

So, appended is a compromise modifying the links of "Quick Quiz" and black box in the answer to go back to chapter-wise quiz section.

Quoted 8 lines
Quoted 1 line

Thoughts?

It does work well, and removes one layer of clicking that otherwise needs to happen. Let's see what people think about it.

We also have the page-number marker that goes back to the text, so we do have the option of making the black and white boxes go to the beginning and end of the quick-quiz box at the end of the chapter.

No, my point in making white box to go back to the end of the quiz in normal builds was to help people reach the text following the quiz.
So linking white box to a quiz at the end of the chapter spoils this purpose. A page-number marker can be far away from the white box when the answer is long.

Quoted 7 lines
Quoted 5 lines

But again,
let's see how this patch works for people.

Any objection to my pushing it as is, or should I wait for a second version. (I have queued it, but not yet pushed it out.)

I'm OK with your pushing it as is.

Done!

Thanx, Paul

Quoted 15 lines

Thanks, Akira

Quoted 12 lines

Thanx, Paul

Quoted 9 lines

Thanks, Akira

Quoted 7 lines

This is probably not a big deal, given that clicking on the small bubble will take them to that list, but I figured that it was worth asking the question.

Thanx, Paul

Quoted 1 line

Thanks, Akira

[...]