Return-Path: Received: from mail.kernel.org ([198.145.29.99]:60240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbfI0AeS (ORCPT ); Thu, 26 Sep 2019 20:34:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569544456; bh=EXy78+tJCU9whrfGfYU2MdU5Hv9cq8ORHg4F2by+IUY=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=JJDFb7xzxU5jKpRHH7LXL3+7nPZQd6NLlFy8rr69IujZZbr/V5FebXHA06GOkTGfr 4WuIFOjxgFW30uXVESMWmgF9XRf6PR3ZnhG0x9sK4Pf9bT6sis2/SepYGu5OPQPKYF QODZxueTdTtJCwIWTJAEIW4gXb8TpQEyPKQcW3dY= Date: Thu, 26 Sep 2019 17:34:15 -0700 From: "Paul E. McKenney" Subject: Re: [PATCH 1/2] styleguide: Introduce/Experiment 'cleveref' package Message-ID: <20190927003415.GQ2689@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <407f9616-f2e9-575d-7441-273d626bb40c@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <407f9616-f2e9-575d-7441-273d626bb40c@gmail.com> Sender: perfbook-owner@vger.kernel.org List-ID: To: Akira Yokosawa Cc: perfbook@vger.kernel.org On Fri, Sep 27, 2019 at 07:33:26AM +0900, Akira Yokosawa wrote: > >From 162ed1c2a59b2442287184ecfab5676c75b5e7bf Mon Sep 17 00:00:00 2001 > From: Akira Yokosawa > Date: Sun, 22 Sep 2019 15:30:59 +0900 > Subject: [PATCH 1/2] styleguide: Introduce/Experiment 'cleveref' package > > We can automate label naming by employing "cleveref" package [1] > and get rid of explicit names such as "Section~", "Figure~", > "Table~", etc. in front of \ref{} macros. > > [1]: https://ctan.org/pkg/cleveref > > Using cleveref frees us from keeping label names and label types > consistent. This commit attempts to demonstrate it in Style Guide. > > Note: Cross-references to line numbers are not changed here. > > Signed-off-by: Akira Yokosawa Queued and pushed both, thank you! Thanx, Paul > --- > appendix/styleguide/styleguide.tex | 103 ++++++++++++++--------------- > perfbook.tex | 3 + > 2 files changed, 54 insertions(+), 52 deletions(-) > > diff --git a/appendix/styleguide/styleguide.tex b/appendix/styleguide/styleguide.tex > index e5ca7aaa..4384dc95 100644 > --- a/appendix/styleguide/styleguide.tex > +++ b/appendix/styleguide/styleguide.tex > @@ -10,11 +10,11 @@ This appendix is a collection of style guides which is intended > as a reference to improve consistency in perfbook. It also contains > several suggestions and their experimental examples. > > -Section~\ref{sec:app:styleguide:Paul's Conventions} describes basic > +\cref{sec:app:styleguide:Paul's Conventions} describes basic > punctuation and spelling rules. > -Section~\ref{sec:app:styleguide:NIST Style Guide} explains rules > +\cref{sec:app:styleguide:NIST Style Guide} explains rules > related to unit symbols. > -Section~\ref{sec:app:styleguide:LaTeX Conventions} summarizes > +\cref{sec:app:styleguide:LaTeX Conventions} summarizes > \LaTeX-specific conventions. > > \section{Paul's Conventions} > @@ -258,7 +258,7 @@ It would also help us overcome different conventions. > We can select a specific digit-grouping style as > a default in preamble, or specify an option to each \verb|\num{}| > command as is shown in > -Table~\ref{tab:app:styleguide:Digit-Grouping Style}. > +\cref{tab:app:styleguide:Digit-Grouping Style}. > > \newcommand{\NumDigitGrpA}{12 345} > \newcommand{\NumDigitGrpB}{12.345} > @@ -290,7 +290,7 @@ Table~\ref{tab:app:styleguide:Digit-Grouping Style}. > \end{table} > > As are evident in > -Table~\ref{tab:app:styleguide:Digit-Grouping Style}, > +\cref{tab:app:styleguide:Digit-Grouping Style}, > periods and commas used as other than decimal markers are confusing > and should be avoided, especially in documents expecting global > audiences. > @@ -341,7 +341,7 @@ to embed line labels as comments. > > We used to use the \qco{verbbox} environment provided > by the \qco{verbatimbox} package. > -Section~\ref{sec:app:styleguide:Code Snippet (Obsolete)} describes how > +\cref{sec:app:styleguide:Code Snippet (Obsolete)} describes how > \co{verbbox} can automatically generate line numbers, > but those line numbers cannot be referenced within the \LaTeX\ sources. > > @@ -384,9 +384,9 @@ They are defined in the preamble as shown below: > \input{appendix/styleguide/samplecodesnippetfcv.tex} > > The \LaTeX\ source of a sample code snippet is shown in > -Listing~\ref{lst:app:styleguide:LaTeX Source of Sample Code Snippet (Current)} > +\cref{lst:app:styleguide:LaTeX Source of Sample Code Snippet (Current)} > and is typeset as shown in > -Listing~\ref{lst:app:styleguide:Sample Code Snippet}. > +\cref{lst:app:styleguide:Sample Code Snippet}. > > Labels to lines are specified in \qco{$lnlbl[]} command. The characters > specified by \qco{commandchars} option to \co{VarbatimL} environment are > @@ -395,7 +395,7 @@ for \qco{$lnlbl[]}. Those characters should be selected so that they > don't appear elsewhere in the code snippet. > > Labels \qco{printf} and \qco{return} in > -Listing~\ref{lst:app:styleguide:Sample Code Snippet} > +\cref{lst:app:styleguide:Sample Code Snippet} > can be referred to as shown below: > > \begin{VerbatimU} > @@ -440,9 +440,9 @@ shown below: > \begin{lineref}[ln:app:styleguide:LaTeX Source of Sample Code Snippet (Current)] > The main part of \LaTeX\ source shown on > Lines~\lnref{beg:linelabel}-\lnref{end:linelabel} in > -Listing~\ref{lst:app:styleguide:LaTeX Source of Sample Code Snippet (Current)} > +\cref{lst:app:styleguide:LaTeX Source of Sample Code Snippet (Current)} > can be extracted from a code sample of > -Listing~\ref{lst:app:styleguide:Source of Code Sample} by a perl script > +\cref{lst:app:styleguide:Source of Code Sample} by a perl script > \path{utilities/fcvextract.pl}. All the relevant rules of extraction > are described as recipes in the top level \path{Makefile} and > a script to generate dependencies (\path{utilities/gen_snippet_d.pl}). > @@ -456,7 +456,7 @@ a script to generate dependencies (\path{utilities/gen_snippet_d.pl}). > \label{lst:app:styleguide:Source of Code Sample} > \end{listing*} > > -As you can see, Listing ~\ref{lst:app:styleguide:Source of Code Sample} > +As you can see, \cref{lst:app:styleguide:Source of Code Sample} > has meta commands in comments of C (C++ style). Those meta commands > are interpreted by \path{utilities/fcvextract.pl}, which distinguishes > the type of comment style by the suffix of code sample's file name. > @@ -485,7 +485,7 @@ The \qco{labelbase} option is mandatory and the string given to it > will be passed to the > ``\co{\\begin\{linelabel\}[