docs: pdfdocs: One-half spacing for CJK translations
authorAkira Yokosawa <akiyks@gmail.com>
Mon, 9 Aug 2021 01:23:57 +0000 (10:23 +0900)
committerJonathan Corbet <corbet@lwn.net>
Thu, 12 Aug 2021 15:13:32 +0000 (09:13 -0600)
CJK documents are much easier to read with a wider baseline stretch.
Applying onehalfspacing option of "setspace" package looks reasonable.

Note: \usepackage{setspace} needs to be before that of hyperref in the
preamble.
The 'extrapackages' key (available since Sphinx 2.3) is for this purpose.
For systems with Sphinx < 2.3, dummy commands of \onehalfspacing and
\singlespacing are provided instead.
One-half spacing is not effective in LaTeX sources generated by such
revisions of Sphinx.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Link: https://lore.kernel.org/r/547a1f1c-0bb5-20a7-ea0e-951bfc3c3925@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/conf.py
Documentation/translations/ja_JP/howto.rst
Documentation/translations/ko_KR/howto.rst

index 2ccfe44..f219a7a 100644 (file)
@@ -341,6 +341,9 @@ latex_elements = {
         verbatimhintsturnover=false,
     ''',
 
+    # For CJK One-half spacing, need to be in front of hyperref
+    'extrapackages': r'\usepackage{setspace}',
+
     # Additional stuff for the LaTeX preamble.
     'preamble': '''
        % Prevent column squeezing of tabulary.
@@ -404,9 +407,12 @@ latex_elements['preamble']  += '''
        }
        \\newCJKfontfamily[JPsans]\\jpsans{Noto Sans CJK JP}
        \\newCJKfontfamily[JPmono]\\jpmono{Noto Sans Mono CJK JP}
+       % Dummy commands for Sphinx < 2.3 (no 'extrapackages' support)
+       \\providecommand{\\onehalfspacing}{}
+       \\providecommand{\\singlespacing}{}
        % Define custom macros to on/off CJK
-       \\newcommand{\\kerneldocCJKon}{\\makexeCJKactive}
-       \\newcommand{\\kerneldocCJKoff}{\\makexeCJKinactive}
+       \\newcommand{\\kerneldocCJKon}{\\makexeCJKactive\\onehalfspacing}
+       \\newcommand{\\kerneldocCJKoff}{\\makexeCJKinactive\\singlespacing}
        \\newcommand{\\kerneldocBeginSC}{%
            \\begingroup%
            \\scmain%
@@ -437,6 +443,8 @@ latex_elements['preamble']  += '''
            \\renewcommand{\\CJKttdefault}{JPmono}%
        }
        \\newcommand{\\kerneldocEndJP}{\\endgroup}
+       % Single spacing in literal blocks
+       \\fvset{baselinestretch=1}
        % To customize \\sphinxtableofcontents
        \\usepackage{etoolbox}
        % Inactivate CJK after tableofcontents
index 73ebdab..d667f9d 100644 (file)
@@ -1,3 +1,7 @@
+.. raw:: latex
+
+       \kerneldocCJKoff
+
 NOTE:
 This is a version of Documentation/process/howto.rst translated into Japanese.
 This document is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
@@ -11,6 +15,10 @@ try to update the original English file first.
 
 ----------------------------------
 
+.. raw:: latex
+
+       \kerneldocCJKon
+
 この文書は、
 Documentation/process/howto.rst
 の和訳です。
index a2bdd56..e3cdf0c 100644 (file)
@@ -1,3 +1,7 @@
+.. raw:: latex
+
+       \kerneldocCJKoff
+
 NOTE:
 This is a version of Documentation/process/howto.rst translated into korean
 This document is maintained by Minchan Kim <minchan@kernel.org>
@@ -11,6 +15,10 @@ try to update the original English file first.
 
 ----------------------------------
 
+.. raw:: latex
+
+       \kerneldocCJKon
+
 이 문서는
 Documentation/process/howto.rst
 의 한글 번역입니다.