162306a36Sopenharmony_ci% -*- coding: utf-8 -*- 262306a36Sopenharmony_ci% SPDX-License-Identifier: GPL-2.0 362306a36Sopenharmony_ci% 462306a36Sopenharmony_ci% LaTeX preamble for "make latexdocs" or "make pdfdocs" including: 562306a36Sopenharmony_ci% - TOC width settings 662306a36Sopenharmony_ci% - Setting of tabulary (\tymin) 762306a36Sopenharmony_ci% - Headheight setting for fancyhdr 862306a36Sopenharmony_ci% - Fontfamily settings for CJK (Chinese, Japanese, and Korean) translations 962306a36Sopenharmony_ci% 1062306a36Sopenharmony_ci% Note on the suffix of .sty: 1162306a36Sopenharmony_ci% This is not implemented as a LaTeX style file, but as a file containing 1262306a36Sopenharmony_ci% plain LaTeX code to be included into preamble. 1362306a36Sopenharmony_ci% ".sty" is chosen because ".tex" would cause the build scripts to confuse 1462306a36Sopenharmony_ci% this file with a LaTeX main file. 1562306a36Sopenharmony_ci% 1662306a36Sopenharmony_ci% Copyright (C) 2022 Akira Yokosawa 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci% Custom width parameters for TOC 1962306a36Sopenharmony_ci% - Redefine low-level commands defined in report.cls. 2062306a36Sopenharmony_ci% - Indent of 2 chars is preserved for ease of comparison. 2162306a36Sopenharmony_ci% Summary of changes from default params: 2262306a36Sopenharmony_ci% Width of page number (\@pnumwidth): 1.55em -> 2.7em 2362306a36Sopenharmony_ci% Width of chapter number: 1.5em -> 2.4em 2462306a36Sopenharmony_ci% Indent of section number: 1.5em -> 2.4em 2562306a36Sopenharmony_ci% Width of section number: 2.6em -> 3.2em 2662306a36Sopenharmony_ci% Indent of subsection number: 4.1em -> 5.6em 2762306a36Sopenharmony_ci% Width of subsection number: 3.5em -> 4.3em 2862306a36Sopenharmony_ci% 2962306a36Sopenharmony_ci% These params can have 4 digit page counts, 3 digit chapter counts, 3062306a36Sopenharmony_ci% section counts of 4 digits + 1 period (e.g., 18.10), and subsection counts 3162306a36Sopenharmony_ci% of 5 digits + 2 periods (e.g., 18.7.13). 3262306a36Sopenharmony_ci\makeatletter 3362306a36Sopenharmony_ci%% Redefine \@pnumwidth (page number width) 3462306a36Sopenharmony_ci\renewcommand*\@pnumwidth{2.7em} 3562306a36Sopenharmony_ci%% Redefine \l@chapter (chapter list entry) 3662306a36Sopenharmony_ci\renewcommand*\l@chapter[2]{% 3762306a36Sopenharmony_ci \ifnum \c@tocdepth >\m@ne 3862306a36Sopenharmony_ci \addpenalty{-\@highpenalty}% 3962306a36Sopenharmony_ci \vskip 1.0em \@plus\p@ 4062306a36Sopenharmony_ci \setlength\@tempdima{2.4em}% 4162306a36Sopenharmony_ci \begingroup 4262306a36Sopenharmony_ci \parindent \z@ \rightskip \@pnumwidth 4362306a36Sopenharmony_ci \parfillskip -\@pnumwidth 4462306a36Sopenharmony_ci \leavevmode \bfseries 4562306a36Sopenharmony_ci \advance\leftskip\@tempdima 4662306a36Sopenharmony_ci \hskip -\leftskip 4762306a36Sopenharmony_ci #1\nobreak\hfil 4862306a36Sopenharmony_ci \nobreak\hb@xt@\@pnumwidth{\hss #2% 4962306a36Sopenharmony_ci \kern-\p@\kern\p@}\par 5062306a36Sopenharmony_ci \penalty\@highpenalty 5162306a36Sopenharmony_ci \endgroup 5262306a36Sopenharmony_ci \fi} 5362306a36Sopenharmony_ci%% Redefine \l@section and \l@subsection 5462306a36Sopenharmony_ci\renewcommand*\l@section{\@dottedtocline{1}{2.4em}{3.2em}} 5562306a36Sopenharmony_ci\renewcommand*\l@subsection{\@dottedtocline{2}{5.6em}{4.3em}} 5662306a36Sopenharmony_ci\makeatother 5762306a36Sopenharmony_ci%% Sphinx < 1.8 doesn't have \sphinxtableofcontentshook 5862306a36Sopenharmony_ci\providecommand{\sphinxtableofcontentshook}{} 5962306a36Sopenharmony_ci%% Undefine it for compatibility with Sphinx 1.7.9 6062306a36Sopenharmony_ci\renewcommand{\sphinxtableofcontentshook}{} % Empty the hook 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci% Prevent column squeezing of tabulary. \tymin is set by Sphinx as: 6362306a36Sopenharmony_ci% \setlength{\tymin}{3\fontcharwd\font`0 } 6462306a36Sopenharmony_ci% , which is too short. 6562306a36Sopenharmony_ci\setlength{\tymin}{20em} 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci% Adjust \headheight for fancyhdr 6862306a36Sopenharmony_ci\addtolength{\headheight}{1.6pt} 6962306a36Sopenharmony_ci\addtolength{\topmargin}{-1.6pt} 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci% Translations have Asian (CJK) characters which are only displayed if 7262306a36Sopenharmony_ci% xeCJK is used 7362306a36Sopenharmony_ci\usepackage{ifthen} 7462306a36Sopenharmony_ci\newboolean{enablecjk} 7562306a36Sopenharmony_ci\setboolean{enablecjk}{false} 7662306a36Sopenharmony_ci\IfFontExistsTF{Noto Sans CJK SC}{ 7762306a36Sopenharmony_ci \IfFileExists{xeCJK.sty}{ 7862306a36Sopenharmony_ci \setboolean{enablecjk}{true} 7962306a36Sopenharmony_ci }{} 8062306a36Sopenharmony_ci}{} 8162306a36Sopenharmony_ci\ifthenelse{\boolean{enablecjk}}{ 8262306a36Sopenharmony_ci % Load xeCJK when both the Noto Sans CJK font and xeCJK.sty are available. 8362306a36Sopenharmony_ci \usepackage{xeCJK} 8462306a36Sopenharmony_ci % Noto CJK fonts don't provide slant shape. [AutoFakeSlant] permits 8562306a36Sopenharmony_ci % its emulation. 8662306a36Sopenharmony_ci % Select KR variant at the beginning of each document so that quotation 8762306a36Sopenharmony_ci % and apostorph symbols of half-width is used in TOC of Latin documents. 8862306a36Sopenharmony_ci \IfFontExistsTF{Noto Serif CJK KR}{ 8962306a36Sopenharmony_ci \setCJKmainfont{Noto Serif CJK KR}[AutoFakeSlant] 9062306a36Sopenharmony_ci }{ 9162306a36Sopenharmony_ci \setCJKmainfont{Noto Sans CJK KR}[AutoFakeSlant] 9262306a36Sopenharmony_ci } 9362306a36Sopenharmony_ci \setCJKsansfont{Noto Sans CJK KR}[AutoFakeSlant] 9462306a36Sopenharmony_ci \setCJKmonofont{Noto Sans Mono CJK KR}[AutoFakeSlant] 9562306a36Sopenharmony_ci % Teach xeCJK of half-width symbols 9662306a36Sopenharmony_ci \xeCJKDeclareCharClass{HalfLeft}{`“,`‘} 9762306a36Sopenharmony_ci \xeCJKDeclareCharClass{HalfRight}{`”,`’} 9862306a36Sopenharmony_ci % CJK Language-specific font choices 9962306a36Sopenharmony_ci %% for Simplified Chinese 10062306a36Sopenharmony_ci \IfFontExistsTF{Noto Serif CJK SC}{ 10162306a36Sopenharmony_ci \newCJKfontfamily[SCmain]\scmain{Noto Serif CJK SC}[AutoFakeSlant] 10262306a36Sopenharmony_ci \newCJKfontfamily[SCserif]\scserif{Noto Serif CJK SC}[AutoFakeSlant] 10362306a36Sopenharmony_ci }{ 10462306a36Sopenharmony_ci \newCJKfontfamily[SCmain]\scmain{Noto Sans CJK SC}[AutoFakeSlant] 10562306a36Sopenharmony_ci \newCJKfontfamily[SCserif]\scserif{Noto Sans CJK SC}[AutoFakeSlant] 10662306a36Sopenharmony_ci } 10762306a36Sopenharmony_ci \newCJKfontfamily[SCsans]\scsans{Noto Sans CJK SC}[AutoFakeSlant] 10862306a36Sopenharmony_ci \newCJKfontfamily[SCmono]\scmono{Noto Sans Mono CJK SC}[AutoFakeSlant] 10962306a36Sopenharmony_ci %% for Traditional Chinese 11062306a36Sopenharmony_ci \IfFontExistsTF{Noto Serif CJK TC}{ 11162306a36Sopenharmony_ci \newCJKfontfamily[TCmain]\tcmain{Noto Serif CJK TC}[AutoFakeSlant] 11262306a36Sopenharmony_ci \newCJKfontfamily[TCserif]\tcserif{Noto Serif CJK TC}[AutoFakeSlant] 11362306a36Sopenharmony_ci }{ 11462306a36Sopenharmony_ci \newCJKfontfamily[TCmain]\tcmain{Noto Sans CJK TC}[AutoFakeSlant] 11562306a36Sopenharmony_ci \newCJKfontfamily[TCserif]\tcserif{Noto Sans CJK TC}[AutoFakeSlant] 11662306a36Sopenharmony_ci } 11762306a36Sopenharmony_ci \newCJKfontfamily[TCsans]\tcsans{Noto Sans CJK TC}[AutoFakeSlant] 11862306a36Sopenharmony_ci \newCJKfontfamily[TCmono]\tcmono{Noto Sans Mono CJK TC}[AutoFakeSlant] 11962306a36Sopenharmony_ci %% for Korean 12062306a36Sopenharmony_ci \IfFontExistsTF{Noto Serif CJK KR}{ 12162306a36Sopenharmony_ci \newCJKfontfamily[KRmain]\krmain{Noto Serif CJK KR}[AutoFakeSlant] 12262306a36Sopenharmony_ci \newCJKfontfamily[KRserif]\krserif{Noto Serif CJK KR}[AutoFakeSlant] 12362306a36Sopenharmony_ci }{ 12462306a36Sopenharmony_ci \newCJKfontfamily[KRmain]\krmain{Noto Sans CJK KR}[AutoFakeSlant] 12562306a36Sopenharmony_ci \newCJKfontfamily[KRserif]\krserif{Noto Sans CJK KR}[AutoFakeSlant] 12662306a36Sopenharmony_ci } 12762306a36Sopenharmony_ci \newCJKfontfamily[KRsans]\krsans{Noto Sans CJK KR}[AutoFakeSlant] 12862306a36Sopenharmony_ci \newCJKfontfamily[KRmono]\krmono{Noto Sans Mono CJK KR}[AutoFakeSlant] 12962306a36Sopenharmony_ci %% for Japanese 13062306a36Sopenharmony_ci \IfFontExistsTF{Noto Serif CJK JP}{ 13162306a36Sopenharmony_ci \newCJKfontfamily[JPmain]\jpmain{Noto Serif CJK JP}[AutoFakeSlant] 13262306a36Sopenharmony_ci \newCJKfontfamily[JPserif]\jpserif{Noto Serif CJK JP}[AutoFakeSlant] 13362306a36Sopenharmony_ci }{ 13462306a36Sopenharmony_ci \newCJKfontfamily[JPmain]\jpmain{Noto Sans CJK JP}[AutoFakeSlant] 13562306a36Sopenharmony_ci \newCJKfontfamily[JPserif]\jpserif{Noto Sans CJK JP}[AutoFakeSlant] 13662306a36Sopenharmony_ci } 13762306a36Sopenharmony_ci \newCJKfontfamily[JPsans]\jpsans{Noto Sans CJK JP}[AutoFakeSlant] 13862306a36Sopenharmony_ci \newCJKfontfamily[JPmono]\jpmono{Noto Sans Mono CJK JP}[AutoFakeSlant] 13962306a36Sopenharmony_ci % Dummy commands for Sphinx < 2.3 (no 'extrapackages' support) 14062306a36Sopenharmony_ci \providecommand{\onehalfspacing}{} 14162306a36Sopenharmony_ci \providecommand{\singlespacing}{} 14262306a36Sopenharmony_ci % Define custom macros to on/off CJK 14362306a36Sopenharmony_ci %% One and half spacing for CJK contents 14462306a36Sopenharmony_ci \newcommand{\kerneldocCJKon}{\makexeCJKactive\onehalfspacing} 14562306a36Sopenharmony_ci \newcommand{\kerneldocCJKoff}{\makexeCJKinactive\singlespacing} 14662306a36Sopenharmony_ci % Define custom macros for switching CJK font setting 14762306a36Sopenharmony_ci %% for Simplified Chinese 14862306a36Sopenharmony_ci \newcommand{\kerneldocBeginSC}{% 14962306a36Sopenharmony_ci \begingroup% 15062306a36Sopenharmony_ci \scmain% 15162306a36Sopenharmony_ci \xeCJKDeclareCharClass{FullLeft}{`“,`‘}% Full-width in SC 15262306a36Sopenharmony_ci \xeCJKDeclareCharClass{FullRight}{`”,`’}% Full-width in SC 15362306a36Sopenharmony_ci \renewcommand{\CJKrmdefault}{SCserif}% 15462306a36Sopenharmony_ci \renewcommand{\CJKsfdefault}{SCsans}% 15562306a36Sopenharmony_ci \renewcommand{\CJKttdefault}{SCmono}% 15662306a36Sopenharmony_ci \xeCJKsetup{CJKspace = false}% gobble white spaces by ' ' 15762306a36Sopenharmony_ci % For CJK ascii-art alignment 15862306a36Sopenharmony_ci \setmonofont{Noto Sans Mono CJK SC}[AutoFakeSlant]% 15962306a36Sopenharmony_ci } 16062306a36Sopenharmony_ci \newcommand{\kerneldocEndSC}{\endgroup} 16162306a36Sopenharmony_ci %% for Traditional Chinese 16262306a36Sopenharmony_ci \newcommand{\kerneldocBeginTC}{% 16362306a36Sopenharmony_ci \begingroup% 16462306a36Sopenharmony_ci \tcmain% 16562306a36Sopenharmony_ci \xeCJKDeclareCharClass{FullLeft}{`“,`‘}% Full-width in TC 16662306a36Sopenharmony_ci \xeCJKDeclareCharClass{FullRight}{`”,`’}% Full-width in TC 16762306a36Sopenharmony_ci \renewcommand{\CJKrmdefault}{TCserif}% 16862306a36Sopenharmony_ci \renewcommand{\CJKsfdefault}{TCsans}% 16962306a36Sopenharmony_ci \renewcommand{\CJKttdefault}{TCmono}% 17062306a36Sopenharmony_ci \xeCJKsetup{CJKspace = false}% gobble white spaces by ' ' 17162306a36Sopenharmony_ci % For CJK ascii-art alignment 17262306a36Sopenharmony_ci \setmonofont{Noto Sans Mono CJK TC}[AutoFakeSlant]% 17362306a36Sopenharmony_ci } 17462306a36Sopenharmony_ci \newcommand{\kerneldocEndTC}{\endgroup} 17562306a36Sopenharmony_ci %% for Korean 17662306a36Sopenharmony_ci \newcommand{\kerneldocBeginKR}{% 17762306a36Sopenharmony_ci \begingroup% 17862306a36Sopenharmony_ci \krmain% 17962306a36Sopenharmony_ci \renewcommand{\CJKrmdefault}{KRserif}% 18062306a36Sopenharmony_ci \renewcommand{\CJKsfdefault}{KRsans}% 18162306a36Sopenharmony_ci \renewcommand{\CJKttdefault}{KRmono}% 18262306a36Sopenharmony_ci % \xeCJKsetup{CJKspace = true} % true by default 18362306a36Sopenharmony_ci % For CJK ascii-art alignment (still misaligned for Hangul) 18462306a36Sopenharmony_ci \setmonofont{Noto Sans Mono CJK KR}[AutoFakeSlant]% 18562306a36Sopenharmony_ci } 18662306a36Sopenharmony_ci \newcommand{\kerneldocEndKR}{\endgroup} 18762306a36Sopenharmony_ci %% for Japanese 18862306a36Sopenharmony_ci \newcommand{\kerneldocBeginJP}{% 18962306a36Sopenharmony_ci \begingroup% 19062306a36Sopenharmony_ci \jpmain% 19162306a36Sopenharmony_ci \renewcommand{\CJKrmdefault}{JPserif}% 19262306a36Sopenharmony_ci \renewcommand{\CJKsfdefault}{JPsans}% 19362306a36Sopenharmony_ci \renewcommand{\CJKttdefault}{JPmono}% 19462306a36Sopenharmony_ci \xeCJKsetup{CJKspace = false}% gobble white space by ' ' 19562306a36Sopenharmony_ci % For CJK ascii-art alignment 19662306a36Sopenharmony_ci \setmonofont{Noto Sans Mono CJK JP}[AutoFakeSlant]% 19762306a36Sopenharmony_ci } 19862306a36Sopenharmony_ci \newcommand{\kerneldocEndJP}{\endgroup} 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci % Single spacing in literal blocks 20162306a36Sopenharmony_ci \fvset{baselinestretch=1} 20262306a36Sopenharmony_ci % To customize \sphinxtableofcontents 20362306a36Sopenharmony_ci \usepackage{etoolbox} 20462306a36Sopenharmony_ci % Inactivate CJK after tableofcontents 20562306a36Sopenharmony_ci \apptocmd{\sphinxtableofcontents}{\kerneldocCJKoff}{}{} 20662306a36Sopenharmony_ci \xeCJKsetup{CJKspace = true}% For inter-phrase space of Korean TOC 20762306a36Sopenharmony_ci}{ % Don't enable CJK 20862306a36Sopenharmony_ci % Custom macros to on/off CJK and switch CJK fonts (Dummy) 20962306a36Sopenharmony_ci \newcommand{\kerneldocCJKon}{} 21062306a36Sopenharmony_ci \newcommand{\kerneldocCJKoff}{} 21162306a36Sopenharmony_ci %% By defining \kerneldocBegin(SC|TC|KR|JP) as commands with an argument 21262306a36Sopenharmony_ci %% and ignore the argument (#1) in their definitions, whole contents of 21362306a36Sopenharmony_ci %% CJK chapters can be ignored. 21462306a36Sopenharmony_ci \newcommand{\kerneldocBeginSC}[1]{% 21562306a36Sopenharmony_ci %% Put a note on missing CJK fonts or the xecjk package in place of 21662306a36Sopenharmony_ci %% zh_CN translation. 21762306a36Sopenharmony_ci \begin{sphinxadmonition}{note}{Note on missing fonts and a package:} 21862306a36Sopenharmony_ci Translations of Simplified Chinese (zh\_CN), Traditional Chinese 21962306a36Sopenharmony_ci (zh\_TW), Korean (ko\_KR), and Japanese (ja\_JP) were skipped 22062306a36Sopenharmony_ci due to the lack of suitable font families and/or the texlive-xecjk 22162306a36Sopenharmony_ci package. 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci If you want them, please install ``Noto Sans CJK'' font families 22462306a36Sopenharmony_ci along with the texlive-xecjk package by following instructions from 22562306a36Sopenharmony_ci \sphinxcode{./scripts/sphinx-pre-install}. 22662306a36Sopenharmony_ci Having optional ``Noto Serif CJK'' font families will improve 22762306a36Sopenharmony_ci the looks of those translations. 22862306a36Sopenharmony_ci \end{sphinxadmonition}} 22962306a36Sopenharmony_ci \newcommand{\kerneldocEndSC}{} 23062306a36Sopenharmony_ci \newcommand{\kerneldocBeginTC}[1]{} 23162306a36Sopenharmony_ci \newcommand{\kerneldocEndTC}{} 23262306a36Sopenharmony_ci \newcommand{\kerneldocBeginKR}[1]{} 23362306a36Sopenharmony_ci \newcommand{\kerneldocEndKR}{} 23462306a36Sopenharmony_ci \newcommand{\kerneldocBeginJP}[1]{} 23562306a36Sopenharmony_ci \newcommand{\kerneldocEndJP}{} 23662306a36Sopenharmony_ci} 237