1% 2% sphinxmanual.cls for Sphinx (https://www.sphinx-doc.org/) 3% 4 5\NeedsTeXFormat{LaTeX2e}[1995/12/01] 6\ProvidesClass{sphinxmanual}[2019/12/01 v2.3.0 Document class (Sphinx manual)] 7 8% chapters starting at odd pages (overridden by 'openany' document option) 9\PassOptionsToClass{openright}{\sphinxdocclass} 10 11% 'oneside' option overriding the 'twoside' default 12\newif\if@oneside 13\DeclareOption{oneside}{\@onesidetrue} 14% Pass remaining document options to the parent class. 15\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}} 16\ProcessOptions\relax 17 18% Defaults two-side document 19\if@oneside 20% nothing to do (oneside is the default) 21\else 22\PassOptionsToClass{twoside}{\sphinxdocclass} 23\fi 24 25\LoadClass{\sphinxdocclass} 26 27% Set some sane defaults for section numbering depth and TOC depth. You can 28% reset these counters in your preamble. 29% 30\setcounter{secnumdepth}{2} 31\setcounter{tocdepth}{1} 32 33% Adapt \and command to the flushright context of \sphinxmaketitle, to 34% avoid ragged line endings if author names do not fit all on one single line 35\DeclareRobustCommand{\and}{% 36 \end{tabular}\kern-\tabcolsep 37 \allowbreak 38 \hskip\dimexpr1em+\tabcolsep\@plus.17fil\begin{tabular}[t]{c}% 39}% 40% If it is desired that each author name be on its own line, use in preamble: 41%\DeclareRobustCommand{\and}{% 42% \end{tabular}\kern-\tabcolsep\\\begin{tabular}[t]{c}% 43%}% 44% Change the title page to look a bit better, and fit in with the fncychap 45% ``Bjarne'' style a bit better. 46% 47\newcommand{\sphinxmaketitle}{% 48 \let\sphinxrestorepageanchorsetting\relax 49 \ifHy@pageanchor\def\sphinxrestorepageanchorsetting{\Hy@pageanchortrue}\fi 50 \hypersetup{pageanchor=false}% avoid duplicate destination warnings 51 \begin{titlepage}% 52 \let\footnotesize\small 53 \let\footnoterule\relax 54 \noindent\rule{\textwidth}{1pt}\par 55 \begingroup % for PDF information dictionary 56 \def\endgraf{ }\def\and{\& }% 57 \pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup 58 \hypersetup{pdfauthor={\@author}, pdftitle={\@title}}% 59 \endgroup 60 \begin{flushright}% 61 \sphinxlogo 62 \py@HeaderFamily 63 {\Huge \@title \par} 64 {\itshape\LARGE \py@release\releaseinfo \par} 65 \vfill 66 {\LARGE 67 \begin{tabular}[t]{c} 68 \@author 69 \end{tabular}\kern-\tabcolsep 70 \par} 71 \vfill\vfill 72 {\large 73 \@date \par 74 \vfill 75 \py@authoraddress \par 76 }% 77 \end{flushright}%\par 78 \@thanks 79 \end{titlepage}% 80 \setcounter{footnote}{0}% 81 \let\thanks\relax\let\maketitle\relax 82 %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} 83 \clearpage 84 \ifdefined\sphinxbackoftitlepage\sphinxbackoftitlepage\fi 85 \if@openright\cleardoublepage\else\clearpage\fi 86 \sphinxrestorepageanchorsetting 87} 88 89\newcommand{\sphinxtableofcontents}{% 90 \pagenumbering{roman}% 91 \begingroup 92 \parskip \z@skip 93 \sphinxtableofcontentshook 94 \tableofcontents 95 \endgroup 96 % before resetting page counter, let's do the right thing. 97 \if@openright\cleardoublepage\else\clearpage\fi 98 \pagenumbering{arabic}% 99} 100 101% This is needed to get the width of the section # area wide enough in the 102% library reference. Doing it here keeps it the same for all the manuals. 103% 104\newcommand{\sphinxtableofcontentshook}{% 105 \renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}}% 106 \renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}}% 107} 108 109% Fix the bibliography environment to add an entry to the Table of 110% Contents. 111% For a report document class this environment is a chapter. 112% 113\newenvironment{sphinxthebibliography}[1]{% 114 \if@openright\cleardoublepage\else\clearpage\fi 115 % \phantomsection % not needed here since TeXLive 2010's hyperref 116 \begin{thebibliography}{#1}% 117 \addcontentsline{toc}{chapter}{\bibname}}{\end{thebibliography}} 118 119% Same for the indices. 120% The memoir class already does this, so we don't duplicate it in that case. 121% 122\@ifclassloaded{memoir} 123 {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}} 124 {\newenvironment{sphinxtheindex}{% 125 \if@openright\cleardoublepage\else\clearpage\fi 126 \phantomsection % needed as no chapter, section, ... created 127 \begin{theindex}% 128 \addcontentsline{toc}{chapter}{\indexname}}{\end{theindex}}} 129