All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: paulmck@linux.vnet.ibm.com
Cc: perfbook@vger.kernel.org, Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH v2 1/3] qqz: Improve accuracy of cross-links
Date: Sat, 23 Apr 2016 20:44:51 +0900	[thread overview]
Message-ID: <571B6033.80608@gmail.com> (raw)
In-Reply-To: <571B5FBE.6030005@gmail.com>

From da7b4f7e910734102b8a4c54cb1e9b3ad599aa04 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiysw@gmail.com>
Date: Thu, 21 Apr 2016 21:29:57 +0900
Subject: [PATCH v2 1/3] qqz: Improve accuracy of cross-links

In commit 33b93f8258f5 ("qqz: Cross-link questions and answers"),
cross-links of quick quizzes and their answers were implemented.
However it uses the \stepcounter{} command, and direct references
of 'quickquizctr' counter is not output to the .aux file.
The symptom is when you click on a hyperlink in the resulting PDF,
you jump to a random nearby label such as that of Figure, Table,
or Section, etc. which happens just before the \label{} using
'quickquizctr'.

By using \refstepcounter{} instead and using 2 counters
'quickquizctr' and 'quickquizctrC' ('C' stands for 'Chapter'),
each of which is automatically reset at a new chapter and
a new section respectively, and defining \theHNum at the head
of qqz.sty, then redefining it within the \QuickQuizAnsers
command, matching QQ.n.m's and QQA.n.m's are output to the .aux
file correctly.

By applying this change, resulting hyperlinks become to jump to
places almost exactly where you'd expect.

This change may have the effect of increasing the required number
of 'pdflatex' invocations to get a final result. The following
commit will take care of it.

Signed-off-by: Akira Yokosawa <akiysw@gmail.com>
---
 qqz.sty | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/qqz.sty b/qqz.sty
index 7270468..438f515 100644
--- a/qqz.sty
+++ b/qqz.sty
@@ -15,7 +15,9 @@
 %%
 %% Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

-\newcounter{quickquizctr}
+\newcounter{quickquizctr}[chapter]
+\newcounter{quickquizctrC}[section]
+\newcommand*{\theHNum}{\arabic{chapter}.\arabic{quickquizctr}}
 \newcommand{\QuickQuizAnswerChapter}{\textbf{Unknown QuickQAC!!!}}

 \newcommand{\QuickQHeading}[3]{\label{#1.#3}\hyperref[#2.#3]{\textbf{Quick Quiz #3:}}}
@@ -23,9 +25,9 @@
 \newcommand{\QuickQuizChapter}[2]{
 	\chapter{#2}
 	\label{#1}
-	\setcounter{quickquizctr}{0}}
+	}
 \newcommand{\QuickQuiz}[1]{
-	\stepcounter{quickquizctr}
+	\refstepcounter{quickquizctr}
 	\QuickQHeading{QQ}{QQA}{\thechapter.\thequickquizctr}}
 \newcommand{\QuickQuizAnswer}[1]{\rule{7pt}{7pt}}
 \newcommand{\QuickQuizEnd}{}
@@ -37,6 +39,7 @@
 % There is probably a better way to do this, but this does work.

 \newcommand{\QuickQuizAnswers}{
+	\renewcommand*{\theHNum}{\arabic{section}.\arabic{quickquizctrC}}
 	\chapter{Answers to Quick Quizzes}
 	\label{chp:Answers to Quick Quizzes}
 	~ \\
@@ -46,11 +49,10 @@

 \newcommand{\QuickQAC}[2]{
 	\edef\QuickQuizAnswerChapter{\getrefnumber{#1}}
-	\setcounter{quickquizctr}{0}
 	\section{#2}}

 \newcommand{\QuickQ}[1]{
-	\stepcounter{quickquizctr} ~ \\ ~ \\
-	\QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctr} #1 ~ \\ }
+	\refstepcounter{quickquizctrC} ~ \\ ~ \\
+	\QuickQHeading{QQA}{QQ}{\QuickQuizAnswerChapter.\thequickquizctrC} #1 ~ \\ }

 \newcommand{\QuickA}[1]{\rule{7pt}{7pt} \\ ~ \\ \textbf{Answer:} \\ }
-- 
1.9.1


  reply	other threads:[~2016-04-23 11:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-23 11:42 [PATCH v2 0/3] qqz and runlatex improvements Akira Yokosawa
2016-04-23 11:44 ` Akira Yokosawa [this message]
2016-04-23 11:46 ` [PATCH v2 2/3] Improve behavior of build scripts Akira Yokosawa
2016-04-23 11:48 ` [PATCH v2 3/3] Remove *.bbl from repository Akira Yokosawa
2016-04-23 14:56 ` [PATCH v2 0/3] qqz and runlatex improvements Akira Yokosawa
2016-04-23 19:24   ` Paul E. McKenney
2016-04-23 19:20 ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=571B6033.80608@gmail.com \
    --to=akiyks@gmail.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=perfbook@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.