* [PATCH 0/2] Small improvements to qqz.sty
@ 2015-09-17 9:32 Paolo Bonzini
2015-09-17 9:32 ` [PATCH 1/2] qqz: avoid duplicate references Paolo Bonzini
2015-09-17 9:32 ` [PATCH 2/2] qqz: cross-link questions and answers Paolo Bonzini
0 siblings, 2 replies; 5+ messages in thread
From: Paolo Bonzini @ 2015-09-17 9:32 UTC (permalink / raw)
To: perfbook
The first patch avoids cluttering the log with warnings. The
second adds cross-links between quick quizzes and their answers.
Paolo Bonzini (2):
qqz: avoid duplicate references
qqz: cross-link questions and answers
qqz.sty | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--
2.5.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] qqz: avoid duplicate references
2015-09-17 9:32 [PATCH 0/2] Small improvements to qqz.sty Paolo Bonzini
@ 2015-09-17 9:32 ` Paolo Bonzini
2015-09-17 18:34 ` Paul E. McKenney
2015-09-17 9:32 ` [PATCH 2/2] qqz: cross-link questions and answers Paolo Bonzini
1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2015-09-17 9:32 UTC (permalink / raw)
To: perfbook
\refstepcounter makes LaTeX create a label "quickquizctr.NN". However
such labels repeat in every chapter, which causes a complaint that
"destination with the same identifier has been already used" in the
log. Avoid clutter by using \stepcounter instead.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qqz.sty | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qqz.sty b/qqz.sty
index 6a9da91..ca70c56 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -23,7 +23,7 @@
\label{#1}
\setcounter{quickquizctr}{0}}
\newcommand{\QuickQuiz}[1]{
- \refstepcounter{quickquizctr}
+ \stepcounter{quickquizctr}
\textbf{Quick Quiz \thechapter.\thequickquizctr:}}
\newcommand{\QuickQuizAnswer}[1]{\rule{7pt}{7pt}}
\newcommand{\QuickQuizEnd}{}
@@ -48,7 +48,7 @@
\section{#2}}
\newcommand{\QuickQ}[1]{
- \refstepcounter{quickquizctr} ~ \\ ~ \\
+ \stepcounter{quickquizctr} ~ \\ ~ \\
\textbf{Quick Quiz \QuickQuizAnswerChapter.\thequickquizctr:} #1 ~ \\ }
\newcommand{\QuickA}[1]{\rule{7pt}{7pt} \\ ~ \\ \textbf{Answer:} \\ }
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] qqz: cross-link questions and answers
2015-09-17 9:32 [PATCH 0/2] Small improvements to qqz.sty Paolo Bonzini
2015-09-17 9:32 ` [PATCH 1/2] qqz: avoid duplicate references Paolo Bonzini
@ 2015-09-17 9:32 ` Paolo Bonzini
2015-09-17 18:34 ` Paul E. McKenney
1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2015-09-17 9:32 UTC (permalink / raw)
To: perfbook
This is useful even if you _are_ actually solving the quick quizzes.
Some ebook readers in particular support hyperlinks but have very
limited support for PDF search and back/forward.
The implementation is easy; it works by adding QQ.chapter.quiz labels
at the question and QQA.chapter.quiz at the answer. The only
interesting point is using \edef and \getrefnumber to extract the
chapter number for answers, in a way that can be passed to
\hyperref. An alternative would be to just use consecutive numbering
for the QQ and QQA labels, but I find this a little more elegant.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qqz.sty | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/qqz.sty b/qqz.sty
index ca70c56..7270468 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -18,13 +18,15 @@
\newcounter{quickquizctr}
\newcommand{\QuickQuizAnswerChapter}{\textbf{Unknown QuickQAC!!!}}
+\newcommand{\QuickQHeading}[3]{\label{#1.#3}\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}}
+
\newcommand{\QuickQuizChapter}[2]{
\chapter{#2}
\label{#1}
\setcounter{quickquizctr}{0}}
\newcommand{\QuickQuiz}[1]{
\stepcounter{quickquizctr}
- \textbf{Quick Quiz \thechapter.\thequickquizctr:}}
+ \QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}}
\newcommand{\QuickQuizAnswer}[1]{\rule{7pt}{7pt}}
\newcommand{\QuickQuizEnd}{}
@@ -43,12 +45,12 @@
%% Internal interfaces generated by scripts.
\newcommand{\QuickQAC}[2]{
- \renewcommand{\QuickQuizAnswerChapter}{\ref{#1}}
+ \edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
\setcounter{quickquizctr}{0}
\section{#2}}
\newcommand{\QuickQ}[1]{
\stepcounter{quickquizctr} ~ \\ ~ \\
- \textbf{Quick Quiz \QuickQuizAnswerChapter.\thequickquizctr:} #1 ~ \\ }
+ \QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctr} #1 ~ \\ }
\newcommand{\QuickA}[1]{\rule{7pt}{7pt} \\ ~ \\ \textbf{Answer:} \\ }
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] qqz: avoid duplicate references
2015-09-17 9:32 ` [PATCH 1/2] qqz: avoid duplicate references Paolo Bonzini
@ 2015-09-17 18:34 ` Paul E. McKenney
0 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2015-09-17 18:34 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: perfbook
On Thu, Sep 17, 2015 at 11:32:55AM +0200, Paolo Bonzini wrote:
> \refstepcounter makes LaTeX create a label "quickquizctr.NN". However
> such labels repeat in every chapter, which causes a complaint that
> "destination with the same identifier has been already used" in the
> log. Avoid clutter by using \stepcounter instead.
Nice! Queued and pushed.
Thanx, Paul
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> qqz.sty | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qqz.sty b/qqz.sty
> index 6a9da91..ca70c56 100644
> --- a/qqz.sty
> +++ b/qqz.sty
> @@ -23,7 +23,7 @@
> \label{#1}
> \setcounter{quickquizctr}{0}}
> \newcommand{\QuickQuiz}[1]{
> - \refstepcounter{quickquizctr}
> + \stepcounter{quickquizctr}
> \textbf{Quick Quiz \thechapter.\thequickquizctr:}}
> \newcommand{\QuickQuizAnswer}[1]{\rule{7pt}{7pt}}
> \newcommand{\QuickQuizEnd}{}
> @@ -48,7 +48,7 @@
> \section{#2}}
>
> \newcommand{\QuickQ}[1]{
> - \refstepcounter{quickquizctr} ~ \\ ~ \\
> + \stepcounter{quickquizctr} ~ \\ ~ \\
> \textbf{Quick Quiz \QuickQuizAnswerChapter.\thequickquizctr:} #1 ~ \\ }
>
> \newcommand{\QuickA}[1]{\rule{7pt}{7pt} \\ ~ \\ \textbf{Answer:} \\ }
> --
> 2.5.0
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe perfbook" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] qqz: cross-link questions and answers
2015-09-17 9:32 ` [PATCH 2/2] qqz: cross-link questions and answers Paolo Bonzini
@ 2015-09-17 18:34 ` Paul E. McKenney
0 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2015-09-17 18:34 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: perfbook
On Thu, Sep 17, 2015 at 11:32:56AM +0200, Paolo Bonzini wrote:
> This is useful even if you _are_ actually solving the quick quizzes.
> Some ebook readers in particular support hyperlinks but have very
> limited support for PDF search and back/forward.
>
> The implementation is easy; it works by adding QQ.chapter.quiz labels
> at the question and QQA.chapter.quiz at the answer. The only
> interesting point is using \edef and \getrefnumber to extract the
> chapter number for answers, in a way that can be passed to
> \hyperref. An alternative would be to just use consecutive numbering
> for the QQ and QQA labels, but I find this a little more elegant.
Very nice, people have been asking for this for some time.
On their behalf, thank you very much!!! Queued and pushed.
Thanx, Paul
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> qqz.sty | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/qqz.sty b/qqz.sty
> index ca70c56..7270468 100644
> --- a/qqz.sty
> +++ b/qqz.sty
> @@ -18,13 +18,15 @@
> \newcounter{quickquizctr}
> \newcommand{\QuickQuizAnswerChapter}{\textbf{Unknown QuickQAC!!!}}
>
> +\newcommand{\QuickQHeading}[3]{\label{#1.#3}\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}}
> +
> \newcommand{\QuickQuizChapter}[2]{
> \chapter{#2}
> \label{#1}
> \setcounter{quickquizctr}{0}}
> \newcommand{\QuickQuiz}[1]{
> \stepcounter{quickquizctr}
> - \textbf{Quick Quiz \thechapter.\thequickquizctr:}}
> + \QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}}
> \newcommand{\QuickQuizAnswer}[1]{\rule{7pt}{7pt}}
> \newcommand{\QuickQuizEnd}{}
>
> @@ -43,12 +45,12 @@
> %% Internal interfaces generated by scripts.
>
> \newcommand{\QuickQAC}[2]{
> - \renewcommand{\QuickQuizAnswerChapter}{\ref{#1}}
> + \edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
> \setcounter{quickquizctr}{0}
> \section{#2}}
>
> \newcommand{\QuickQ}[1]{
> \stepcounter{quickquizctr} ~ \\ ~ \\
> - \textbf{Quick Quiz \QuickQuizAnswerChapter.\thequickquizctr:} #1 ~ \\ }
> + \QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctr} #1 ~ \\ }
>
> \newcommand{\QuickA}[1]{\rule{7pt}{7pt} \\ ~ \\ \textbf{Answer:} \\ }
> --
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe perfbook" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-17 18:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-17 9:32 [PATCH 0/2] Small improvements to qqz.sty Paolo Bonzini
2015-09-17 9:32 ` [PATCH 1/2] qqz: avoid duplicate references Paolo Bonzini
2015-09-17 18:34 ` Paul E. McKenney
2015-09-17 9:32 ` [PATCH 2/2] qqz: cross-link questions and answers Paolo Bonzini
2015-09-17 18:34 ` 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.