Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=PuOAlaE1SvdfzsooaG4Xrl9iocHX29Kyq92V7Yscq44=; b=OirRP2lDoDEdXihZycBdNbonilGWQUPGXTJ8LYh+QzcHW38Ek/pQ5S76wWXgV3c8nM GduRfIE9ogVPr7V2X1MwnmAcN1oYBHuu3aXG7WqFpdBYaZzduYW7zgyGXKTTpueXGn1v kKnmkrTPC3Qf4D8AaeVnh0RRgyKr4NvPR4YHbx9KO0fnNyXC9mdj+EqN0fkVoqc4g0Jx H612gTG8luVMsLJ1izeBxRegri0UPXyvRGBAC4bTjfHWsV+tjfxen2eCZ+CW5opcJsNE WC8baSQSH60nvnHvPcT3YnN000msizvRBoaLDGgLvEeBV8ZsL3LMI2TyFyniXcWtEuos 505w== From: Akira Yokosawa Subject: [PATCH 1/2] styleguide: Introduce/Experiment 'cleveref' package Message-ID: <407f9616-f2e9-575d-7441-273d626bb40c@gmail.com> Date: Fri, 27 Sep 2019 07:33:26 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit To: paulmck@kernel.org Cc: "Paul E. McKenney" , perfbook@vger.kernel.org, Akira Yokosawa List-ID: 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 --- 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\}[