From: Akira Yokosawa <akiyks@gmail.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Akira Yokosawa <akiyks@gmail.com>
Subject: [PATCH 1/5] docs: pdfdocs: Tweak width params of TOC
Date: Tue, 1 Feb 2022 08:59:58 +0900 [thread overview]
Message-ID: <e52b4718-7909-25be-fbc1-76800aa62ae3@gmail.com> (raw)
In-Reply-To: <b5b948b7-8e41-3bd6-1a52-44785c89c965@gmail.com>
Sphinx has its own set of width parameters of Table of Contents (TOC)
for LaTeX defined in its class definition of sphinxmanual.cls.
It also inherits parameters for chapter entries from report.cls of
original LaTeX base.
However, they are optimized assuming small documents with tens of
pages and chapters/sections of less than 10.
To cope with some of kernel-doc documents with more than 1000
pages and several tens of chapters/sections, definitions of those
parameters need to be adjusted.
Unfortunately, those parameters are hard coded in the class
definitions and need low-level LaTeX coding tricks to redefine.
As Sphinx 1.7.9 does not have \sphinxtableofcontentshook,
which defines those parameters in later Sphinx versions,
for compatibility with both pre-1.8 and later Sphinx versions,
empty the hook altogether and redefine \@pnumwidth, \l@chapter,
\l@section, and \@subsection commands originally defined in
report.cls.
Summary of parameter changes:
Width of page number (\@pnumwidth): 1.55em -> 2.7em
Width of chapter number: 1.5em -> 1.8em
Indent of section number: 1.5em -> 1.8em
Width of section number: 2.6em -> 3.2em
Indent of subsection number: 4.1em -> 5em
Width of subsection number: 3.5em -> 4.3em
Notes:
1. Parameters for subsection become relevant only when
":maxdepth: 3" is specified under "toctree::" (e.g., RCU/index.rst).
They can hold subsection numbers up to 5 digits such as "18.7.13"
(in RCU.pdf).
2. Number of chapters in driver-api.pdf is getting closer to 100.
When it reaches 100, another set of tweaks will be necessary.
3. The low-level LaTeX trick is mentioned in "Unofficial LaTeX2e
reference manual" at:
http://latexref.xyz/Table-of-contents-etc_002e.html
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
---
Documentation/conf.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/Documentation/conf.py b/Documentation/conf.py
index f07f2e9b9f2c..e5c13dee2de8 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -409,6 +409,37 @@ latex_elements = {
# Additional stuff for the LaTeX preamble.
'preamble': '''
+ % Custom width parameters for TOC --- Redefine low-level commands
+ % defined in report.cls
+ \\makeatletter
+ %% Redefine \\@pnumwidth (page number width)
+ \\renewcommand*\\@pnumwidth{2.7em}
+ %% Redefine \\l@chapter (chapter list entry)
+ \\renewcommand*\\l@chapter[2]{%
+ \\ifnum \\c@tocdepth >\\m@ne
+ \\addpenalty{-\\@highpenalty}%
+ \\vskip 1.0em \\@plus\\p@
+ \\setlength\\@tempdima{1.8em}%
+ \\begingroup
+ \\parindent \\z@ \\rightskip \\@pnumwidth
+ \\parfillskip -\\@pnumwidth
+ \\leavevmode \\bfseries
+ \\advance\\leftskip\\@tempdima
+ \\hskip -\\leftskip
+ #1\\nobreak\\hfil
+ \\nobreak\\hb@xt@\\@pnumwidth{\\hss #2%
+ \\kern-\\p@\\kern\\p@}\\par
+ \\penalty\\@highpenalty
+ \\endgroup
+ \\fi}
+ %% Redefine \\l@section and \\l@subsection
+ \\renewcommand*\\l@section{\\@dottedtocline{1}{1.8em}{3.2em}}
+ \\renewcommand*\\l@subsection{\\@dottedtocline{2}{5em}{4.3em}}
+ \\makeatother
+ %% Sphinx < 1.8 doesn't have \\sphinxtableofcontentshook
+ \\providecommand{\\sphinxtableofcontentshook}{}
+ %% Undefine it for compatibility with Sphinx 1.7.9
+ \\renewcommand{\\sphinxtableofcontentshook}{} % Empty the hook
% Prevent column squeezing of tabulary.
\\setlength{\\tymin}{20em}
% Use some font with UTF-8 support with XeLaTeX
--
2.17.1
next prev parent reply other threads:[~2022-02-01 0:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-31 23:56 [PATCH 0/5] docs: pdfdocs: Improve LaTeX preamble (TOC, CJK fonts) Akira Yokosawa
2022-01-31 23:59 ` Akira Yokosawa [this message]
2022-02-01 0:02 ` [PATCH 2/5] docs: pdfdocs: Switch default CJK font to KR variants Akira Yokosawa
2022-02-01 0:03 ` [PATCH 3/5] docs: pdfdocs: Enable CJKspace in TOC for Korean titles Akira Yokosawa
2022-02-01 0:04 ` [PATCH 4/5] docs/translations: Skip CJK contents if suitable fonts not found Akira Yokosawa
2022-02-01 0:05 ` [PATCH 5/5] docs: pdfdocs: Move CJK monospace font setting to main conf.py Akira Yokosawa
2022-02-15 23:46 ` [PATCH 0/5] docs: pdfdocs: Improve LaTeX preamble (TOC, CJK fonts) Jonathan Corbet
2022-02-16 13:00 ` Akira Yokosawa
2022-02-17 14:21 ` Akira Yokosawa
2022-02-17 16:34 ` Jonathan Corbet
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=e52b4718-7909-25be-fbc1-76800aa62ae3@gmail.com \
--to=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®