All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -perfbook 0/5] Updates of qqz.sty
@ 2021-04-14 10:47 Akira Yokosawa
  2021-04-14 10:54 ` [PATCH -perfbook 1/5] qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox Akira Yokosawa
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-14 10:47 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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.

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(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH -perfbook 1/5] qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox
  2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
@ 2021-04-14 10:54 ` Akira Yokosawa
  2021-04-14 11:04 ` [PATCH -perfbook 2/5] qqz.sty: Modify -nq build to have chapterwise quiz-only section Akira Yokosawa
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-14 10:54 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

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@gmail.com>
---
 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



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -perfbook 2/5] qqz.sty: Modify -nq build to have chapterwise quiz-only section
  2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
  2021-04-14 10:54 ` [PATCH -perfbook 1/5] qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox Akira Yokosawa
@ 2021-04-14 11:04 ` Akira Yokosawa
  2021-04-14 11:09 ` [PATCH -perfbook 3/5] perfbook-lt.tex: Remove boolean qqzchpend Akira Yokosawa
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-14 11:04 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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).

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 Makefile               |  2 +-
 advsync/rt.tex         | 18 --------
 howto/howto.tex        | 14 ------
 qqz.sty                | 97 ++++++++++++++++++++++++------------------
 utilities/divideqqz.pl | 25 ++++++++++-
 5 files changed, 81 insertions(+), 75 deletions(-)

diff --git a/Makefile b/Makefile
index cd8ee7ff..cec7e878 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/advsync/rt.tex b/advsync/rt.tex
index 2732f9ed..96c22d25 100644
--- a/advsync/rt.tex
+++ b/advsync/rt.tex
@@ -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:
 
diff --git a/howto/howto.tex b/howto/howto.tex
index a4ed4f4c..42e3d626 100644
--- a/howto/howto.tex
+++ b/howto/howto.tex
@@ -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
 %
diff --git a/qqz.sty b/qqz.sty
index 0992c027..9b1d4c35 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -53,14 +53,14 @@
 
 \tcbset{enhanced,colback=black!5,boxrule=0.5pt,top=1pt,bottom=1pt,left=0pt,right=0pt}
 \newcounter{quickquizctr}[chapter]
-\newcounter{quickquizctrE}[chapter]
 \newcounter{quickquizctrC}[section]
+\newcounter{quickquizctrP}[chapter] % for noqqz build page anchor
 \newcommand*{\theHNum}{\arabic{chapter}.\arabic{quickquizctr}}
 \newcommand{\QuickQuizAnswerChapter}{\textbf{Unknown QuickQAC!!!}}
 
 \newcommand{\QuickQHeading}[3]{\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}\label{#1.#3}}
 \newcommand{\QuickQHeadingPage}[3]{\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}\label{#1.#3}%
-	\hfill\raisebox{0.5ex}{\footnotesize\fbox{p.\pageref{#2.#3}}}}
+	\hfill\raisebox{0.5ex}{\footnotesize\fbox{p.\pageref{QQP.#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},}
@@ -75,34 +75,31 @@
 	\vspace{-1pt}\hfill\fbox{#1}\vspace{1pt}}
 \newcommand{\QuickQuiz}[1]{%
 	\vspace{-1pt}%
-	\hfill\fbox{\refstepcounter{quickquizctr}%
-	\QuickQHeadingLight{QQ}{QQA}{\thechapter.\thequickquizctr}}%
+	\hfill\fbox{\refstepcounter{quickquizctrP}%
+	\QuickQHeadingLight{QQP}{QQ}{\thechapter.\thequickquizctrP}}%
 	\vspace{1pt}}
 \newcommand{\QuickQuizB}[1]{%
-	\refstepcounter{quickquizctr}%
-	\QuickQHeadingBegin{QQ}{QQA}{\thechapter.\thequickquizctr}}
+	\refstepcounter{quickquizctrP}%
+	\QuickQHeadingBegin{QQP}{QQ}{\thechapter.\thequickquizctrP}}
 \newcommand{\QuickQuizM}[1]{%
-	\refstepcounter{quickquizctr}%
-	\QuickQHeadingMiddle{QQ}{QQA}{\thechapter.\thequickquizctr}}
+	\refstepcounter{quickquizctrP}%
+	\QuickQHeadingMiddle{QQP}{QQ}{\thechapter.\thequickquizctrP}}
 \newcommand{\QuickQuizE}[1]{%
-	\refstepcounter{quickquizctr}%
-	\QuickQHeadingEnd{QQ}{QQA}{\thechapter.\thequickquizctr}}
+	\refstepcounter{quickquizctrP}%
+	\QuickQHeadingEnd{QQP}{QQ}{\thechapter.\thequickquizctrP}}
 \newcommand{\EQuickQuiz}[1]{%
 	\begin{tcolorbox}[breakable]
-	\leavevmode\refstepcounter{quickquizctr}%
-	\small\QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}%
+	\leavevmode\refstepcounter{quickquizctrP}%
+	\small\QuickQHeading{QQP}{QQA}{\thechapter.\thequickquizctrP}%
 	{#1}
 }
-\newcommand{\QuickQuizAnswer}[1]{%
-	\refstepcounter{quickquizctrE}%
-	\label{QQE.\thechapter.\thequickquizctrE}}
+\newcommand{\QuickQuizAnswer}[1]{\label{QQE.\thechapter.\thequickquizctrP}}
 \newcommand{\QuickQuizAnswerB}[1]{\QuickQuizAnswer{#1}}
 \newcommand{\QuickQuizAnswerM}[1]{\QuickQuizAnswer{#1}}
 \newcommand{\QuickQuizAnswerE}[1]{\QuickQuizAnswer{#1}}
 \newcommand{\EQuickQuizAnswer}[1]{%
-	\refstepcounter{quickquizctrE}%
-	\hyperref[QQA.\thechapter.\thequickquizctr]{\rule{7pt}{7pt}}%
-	\label{QQE.\thechapter.\thequickquizctrE}
+	\hyperref[QQA.\thechapter.\thequickquizctrP]{\rule{7pt}{7pt}}%
+	\phantomsection\label{QQE.\thechapter.\thequickquizctrP}%
 	\end{tcolorbox}
 }
 \newcommand{\QuickQuizEnd}{\goodbreak}
@@ -120,9 +117,8 @@
 	{#1}
 }
 \newcommand{\QuickQuizAnswer}[1]{%
-	\refstepcounter{quickquizctrE}%
 	\hyperref[QQA.\thechapter.\thequickquizctr]{\rule{7pt}{7pt}}%
-	\label{QQE.\thechapter.\thequickquizctrE}
+	\phantomsection\label{QQE.\thechapter.\thequickquizctr}
 	\end{tcolorbox}
 }
 \newcommand{\QuickQuizEnd}{}
@@ -132,9 +128,8 @@
 	\QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}
 	{#1}}
 \newcommand{\QuickQuizAnswer}[1]{%
-	\refstepcounter{quickquizctrE}%
 	\hyperref[QQA.\thechapter.\thequickquizctr]{\rule{7pt}{7pt}}%
-	\label{QQE.\thechapter.\thequickquizctrE}}
+	\phantomsection\label{QQE.\thechapter.\thequickquizctr}}
 \newcommand{\QuickQuizEnd}{\goodbreak}
 }
 \newcommand{\QuickQuizB}[1]{\QuickQuiz{#1}}
@@ -159,6 +154,17 @@
 %	\QuickQuizARef{\QQname}
 % The reference also generates a hyperlink.
 
+\IfNoQqz{
+\newcommand{\QuickQuizLabel}[1]{
+	\edef#1{\thechapter.\thequickquizctrP}
+}
+\newcommand{\QuickQuizRef}[1]{%
+	\hyperref[QQ.#1]{Quick Quiz~#1}%
+}
+\newcommand{\QuickQuizARef}[1]{%
+	\hyperref[QQA.#1]{Quick Quiz~#1}%
+}
+}{
 \newcommand{\QuickQuizLabel}[1]{
 	\edef#1{\thechapter.\thequickquizctr}
 }
@@ -168,17 +174,9 @@
 \newcommand{\QuickQuizARef}[1]{%
 	\hyperref[QQA.#1]{Quick Quiz~#1}%
 }
+}
 
-\IfQqzChpEnd{
-\newcommand{\QuickQuizAnswers}{}
-\newcommand{\QuickQuizAnswersChp}[1]{
-%	\renewcommand*{\theHNum}{\arabic{section}.\arabic{quickquizctrC}}
-%	\label{sec:#1:Answers to Quick Quizzes}
-	\setlength{\parskip}{0.0pt plus 1ex}
-	\input{#1}
-	\setlength{\parskip}{0.0pt plus 1.0pt}% return to default
-}}{
-\newcommand{\QuickQuizAnswers}{
+\newcommand{\QuickQuizAnswers}{%
 	\renewcommand*{\theHNum}{\arabic{section}.\arabic{quickquizctrC}}
 	\chapter{Answers to Quick Quizzes}
 	\label{chp:Answers to Quick Quizzes}
@@ -189,21 +187,27 @@
 	\input{qqz}
 	\setlength{\parskip}{0.0pt plus 1.0pt}% return to default
 }
+\IfNoQqz{
+\newcommand{\QuickQuizAnswersChp}[1]{
+	\setlength{\parskip}{0.0pt plus 1ex}
+	\input{#1}
+	\setlength{\parskip}{0.0pt plus 1.0pt}% return to default
+}}{
 \newcommand{\QuickQuizAnswersChp}[1]{}
 }
 
 %% Internal interfaces generated by scripts.
 
-\IfQqzChpEnd{
-\newcommand{\QuickQAC}[3]{
-	\edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
-	\section{Answers to Quick Quizzes}
-	\label{sec:#3:Answers to Quick Quizzes}}
-}{
 \newcommand{\QuickQAC}[3]{
 	\edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
 	\section{#2}}
-}
+
+\IfNoQqz{
+\newcommand{\QuickQQC}[3]{
+	\edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
+	\section{Quick Quizzes}
+	\label{sec:#3:Quick Quizzes}}
+}{}
 
 \IfQqzBg{
 \newcommand{\QuickQ}[1]{
@@ -217,14 +221,25 @@
 	\end{tcolorbox}
 	\noindent\textbf{Answer:} \\ }
 }{\IfNoQqz{
+\newcommand{\QuickQQ}[1]{
+	\begin{tcolorbox}[breakable]
+	\leavevmode\refstepcounter{quickquizctr}%
+	\QuickQHeadingPage{QQ}{QQA}{\thechapter.\thequickquizctr}\\
+}
+
+\newcommand{\QuickQE}[1]{
+	\hyperref[QQA.\thechapter.\thequickquizctr]{\rule{7pt}{7pt}}%
+	\end{tcolorbox}
+}
+
 \newcommand{\QuickQ}[1]{
 	\begin{tcolorbox}[breakable]
 	\leavevmode\refstepcounter{quickquizctrC}%
-	\QuickQHeadingPage{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
+	\QuickQHeadingPage{QQA}{QQP}{\QuickQuizAnswerChapter.\thequickquizctrC}\\
 }
 
 \newcommand{\QuickA}[1]{%
-	\hyperref[QQ.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
+	\hyperref[QQP.\QuickQuizAnswerChapter.\thequickquizctrC]{\rule{7pt}{7pt}}
 	\end{tcolorbox}
 	\noindent\textbf{Answer:} \\ }
 }{
diff --git a/utilities/divideqqz.pl b/utilities/divideqqz.pl
index 7387f683..7895fb23 100755
--- a/utilities/divideqqz.pl
+++ b/utilities/divideqqz.pl
@@ -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";
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -perfbook 3/5] perfbook-lt.tex: Remove boolean qqzchpend
  2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
  2021-04-14 10:54 ` [PATCH -perfbook 1/5] qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox Akira Yokosawa
  2021-04-14 11:04 ` [PATCH -perfbook 2/5] qqz.sty: Modify -nq build to have chapterwise quiz-only section Akira Yokosawa
@ 2021-04-14 11:09 ` Akira Yokosawa
  2021-04-14 11:11 ` [PATCH -perfbook 4/5] howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full' Akira Yokosawa
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-14 11:09 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, 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.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 Makefile        | 3 +--
 perfbook-lt.tex | 3 ---
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index cec7e878..1d26cfbb 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/perfbook-lt.tex b/perfbook-lt.tex
index 41371abf..d8786baa 100644
--- a/perfbook-lt.tex
+++ b/perfbook-lt.tex
@@ -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}
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -perfbook 4/5] howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full'
  2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
                   ` (2 preceding siblings ...)
  2021-04-14 11:09 ` [PATCH -perfbook 3/5] perfbook-lt.tex: Remove boolean qqzchpend Akira Yokosawa
@ 2021-04-14 11:11 ` Akira Yokosawa
  2021-04-14 11:12 ` [PATCH -perfbook 5/5] qqz.sty: Add page reference to QQA Appendix as the same as -nq build Akira Yokosawa
  2021-04-14 17:31 ` [PATCH -perfbook 0/5] Updates of qqz.sty Paul E. McKenney
  5 siblings, 0 replies; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-14 11:11 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

Now chapter-wise sections contain Quizzes only.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 Makefile        | 2 +-
 howto/howto.tex | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 1d26cfbb..4beb2c17 100644
--- a/Makefile
+++ b/Makefile
@@ -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"
 
diff --git a/howto/howto.tex b/howto/howto.tex
index 42e3d626..74bbed4c 100644
--- a/howto/howto.tex
+++ b/howto/howto.tex
@@ -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
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -perfbook 5/5] qqz.sty: Add page reference to QQA Appendix as the same as -nq build
  2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
                   ` (3 preceding siblings ...)
  2021-04-14 11:11 ` [PATCH -perfbook 4/5] howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full' Akira Yokosawa
@ 2021-04-14 11:12 ` Akira Yokosawa
  2021-04-14 17:31 ` [PATCH -perfbook 0/5] Updates of qqz.sty Paul E. McKenney
  5 siblings, 0 replies; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-14 11:12 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

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

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 qqz.sty | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/qqz.sty b/qqz.sty
index 9b1d4c35..4e1a138a 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -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}}
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH -perfbook 0/5] Updates of qqz.sty
  2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
                   ` (4 preceding siblings ...)
  2021-04-14 11:12 ` [PATCH -perfbook 5/5] qqz.sty: Add page reference to QQA Appendix as the same as -nq build Akira Yokosawa
@ 2021-04-14 17:31 ` Paul E. McKenney
  2021-04-15  3:49   ` Akira Yokosawa
  5 siblings, 1 reply; 11+ messages in thread
From: Paul E. McKenney @ 2021-04-14 17:31 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Wed, Apr 14, 2021 at 07:47:51PM +0900, Akira Yokosawa wrote:
> 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.

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

>         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(-)
> 
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -perfbook 0/5] Updates of qqz.sty
  2021-04-14 17:31 ` [PATCH -perfbook 0/5] Updates of qqz.sty Paul E. McKenney
@ 2021-04-15  3:49   ` Akira Yokosawa
  2021-04-15  5:11     ` Paul E. McKenney
  0 siblings, 1 reply; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-15  3:49 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On Wed, 14 Apr 2021 10:31:23 -0700, Paul E. McKenney wrote:
> On Wed, Apr 14, 2021 at 07:47:51PM +0900, Akira Yokosawa wrote:
>> 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.
> 
> 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.

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

> 
> 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 

> 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
> 
>>         Thanks, Akira
[...]

----8<--------
From: Akira Yokosawa <akiyks@gmail.com>
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.

Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
 qqz.sty | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qqz.sty b/qqz.sty
index 4e1a138a..86b50c79 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -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:} \\ }
 }{
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH -perfbook 0/5] Updates of qqz.sty
  2021-04-15  3:49   ` Akira Yokosawa
@ 2021-04-15  5:11     ` Paul E. McKenney
  2021-04-15  5:47       ` Akira Yokosawa
  0 siblings, 1 reply; 11+ messages in thread
From: Paul E. McKenney @ 2021-04-15  5:11 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Thu, Apr 15, 2021 at 12:49:18PM +0900, Akira Yokosawa wrote:
> On Wed, 14 Apr 2021 10:31:23 -0700, Paul E. McKenney wrote:
> > On Wed, Apr 14, 2021 at 07:47:51PM +0900, Akira Yokosawa wrote:
> >> 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.
> > 
> > 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.
> 
> 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.  :-/

> > 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.

> 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

>        Thanks, Akira 
> 
> > 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
> > 
> >>         Thanks, Akira
> [...]
> 
> ----8<--------
> From: Akira Yokosawa <akiyks@gmail.com>
> 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.
> 
> Suggested-by: Paul E. McKenney <paulmck@kernel.org>
> Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
> ---
>  qqz.sty | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/qqz.sty b/qqz.sty
> index 4e1a138a..86b50c79 100644
> --- a/qqz.sty
> +++ b/qqz.sty
> @@ -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:} \\ }
>  }{
> -- 
> 2.17.1
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -perfbook 0/5] Updates of qqz.sty
  2021-04-15  5:11     ` Paul E. McKenney
@ 2021-04-15  5:47       ` Akira Yokosawa
  2021-04-15 15:30         ` Paul E. McKenney
  0 siblings, 1 reply; 11+ messages in thread
From: Akira Yokosawa @ 2021-04-15  5:47 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: perfbook, Akira Yokosawa

On Wed, 14 Apr 2021 22:11:33 -0700, Paul E. McKenney wrote:
> On Thu, Apr 15, 2021 at 12:49:18PM +0900, Akira Yokosawa wrote:
>> On Wed, 14 Apr 2021 10:31:23 -0700, Paul E. McKenney wrote:
>>> On Wed, Apr 14, 2021 at 07:47:51PM +0900, Akira Yokosawa wrote:
>>>> 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.
>>>
>>> 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.
>>
>> 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.  :-/
> 
>>> 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.
> 
>> 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.

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.

>                                                          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

> 
> 							Thanx, Paul
> 
>>        Thanks, Akira 
>>
>>> 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
>>>
>>>>         Thanks, Akira
[...]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -perfbook 0/5] Updates of qqz.sty
  2021-04-15  5:47       ` Akira Yokosawa
@ 2021-04-15 15:30         ` Paul E. McKenney
  0 siblings, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2021-04-15 15:30 UTC (permalink / raw)
  To: Akira Yokosawa; +Cc: perfbook

On Thu, Apr 15, 2021 at 02:47:45PM +0900, Akira Yokosawa wrote:
> On Wed, 14 Apr 2021 22:11:33 -0700, Paul E. McKenney wrote:
> > On Thu, Apr 15, 2021 at 12:49:18PM +0900, Akira Yokosawa wrote:
> >> On Wed, 14 Apr 2021 10:31:23 -0700, Paul E. McKenney wrote:
> >>> On Wed, Apr 14, 2021 at 07:47:51PM +0900, Akira Yokosawa wrote:
> >>>> 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.
> >>>
> >>> 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.
> >>
> >> 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.  :-/
> > 
> >>> 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.
> > 
> >> 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.
> 
> 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.
> 
> >                                                          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

>         Thanks, Akira
> 
> > 
> > 							Thanx, Paul
> > 
> >>        Thanks, Akira 
> >>
> >>> 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
> >>>
> >>>>         Thanks, Akira
> [...]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-15 15:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 10:47 [PATCH -perfbook 0/5] Updates of qqz.sty Akira Yokosawa
2021-04-14 10:54 ` [PATCH -perfbook 1/5] qqz.sty: Use \refstepcounter after leaving vmode in tcolorbox Akira Yokosawa
2021-04-14 11:04 ` [PATCH -perfbook 2/5] qqz.sty: Modify -nq build to have chapterwise quiz-only section Akira Yokosawa
2021-04-14 11:09 ` [PATCH -perfbook 3/5] perfbook-lt.tex: Remove boolean qqzchpend Akira Yokosawa
2021-04-14 11:11 ` [PATCH -perfbook 4/5] howto, Makefile: Update answer to Quick Quiz 1.3 and 'make help-full' Akira Yokosawa
2021-04-14 11:12 ` [PATCH -perfbook 5/5] qqz.sty: Add page reference to QQA Appendix as the same as -nq build Akira Yokosawa
2021-04-14 17:31 ` [PATCH -perfbook 0/5] Updates of qqz.sty Paul E. McKenney
2021-04-15  3:49   ` Akira Yokosawa
2021-04-15  5:11     ` Paul E. McKenney
2021-04-15  5:47       ` Akira Yokosawa
2021-04-15 15:30         ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.