1% 2% sphinxhowto.cls for Sphinx (https://www.sphinx-doc.org/) 3% 4 5\NeedsTeXFormat{LaTeX2e}[1995/12/01] 6\ProvidesClass{sphinxhowto}[2019/12/01 v2.3.0 Document class (Sphinx howto)] 7 8% 'oneside' option overriding the 'twoside' default 9\newif\if@oneside 10\DeclareOption{oneside}{\@onesidetrue} 11% Pass remaining document options to the parent class. 12\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}} 13\ProcessOptions\relax 14 15% Default to two-side document 16\if@oneside 17% nothing to do (oneside is the default) 18\else 19\PassOptionsToClass{twoside}{\sphinxdocclass} 20\fi 21 22\LoadClass{\sphinxdocclass} 23 24% Set some sane defaults for section numbering depth and TOC depth. You can 25% reset these counters in your preamble. 26% 27\setcounter{secnumdepth}{2} 28\setcounter{tocdepth}{2}% i.e. section and subsection 29 30% Adapt \and command to the flushright context of \sphinxmaketitle, to 31% avoid ragged line endings if author names do not fit all on one single line 32\DeclareRobustCommand{\and}{% 33 \end{tabular}\kern-\tabcolsep 34 \allowbreak 35 \hskip\dimexpr1em+\tabcolsep\@plus.17fil\begin{tabular}[t]{c}% 36}% 37% If it is desired that each author name be on its own line, use in preamble: 38%\DeclareRobustCommand{\and}{% 39% \end{tabular}\kern-\tabcolsep\\\begin{tabular}[t]{c}% 40%}% 41% Change the title page to look a bit better, and fit in with the fncychap 42% ``Bjarne'' style a bit better. 43% 44\newcommand{\sphinxmaketitle}{% 45 \noindent\rule{\textwidth}{1pt}\par 46 \begingroup % for PDF information dictionary 47 \def\endgraf{ }\def\and{\& }% 48 \pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup 49 \hypersetup{pdfauthor={\@author}, pdftitle={\@title}}% 50 \endgroup 51 \begin{flushright} 52 \sphinxlogo 53 \py@HeaderFamily 54 {\Huge \@title }\par 55 {\itshape\large \py@release \releaseinfo}\par 56 \vspace{25pt} 57 {\Large 58 \begin{tabular}[t]{c} 59 \@author 60 \end{tabular}\kern-\tabcolsep}\par 61 \vspace{25pt} 62 \@date \par 63 \py@authoraddress \par 64 \end{flushright} 65 \@thanks 66 \setcounter{footnote}{0} 67 \let\thanks\relax\let\maketitle\relax 68 %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} 69} 70 71\newcommand{\sphinxtableofcontents}{% 72 \begingroup 73 \parskip \z@skip 74 \sphinxtableofcontentshook 75 \tableofcontents 76 \endgroup 77 \noindent\rule{\textwidth}{1pt}\par 78 \vspace{12pt}% 79} 80\newcommand\sphinxtableofcontentshook{} 81\pagenumbering{arabic} 82 83% Fix the bibliography environment to add an entry to the Table of 84% Contents. 85% For an article document class this environment is a section, 86% so no page break before it. 87% 88\newenvironment{sphinxthebibliography}[1]{% 89 % \phantomsection % not needed here since TeXLive 2010's hyperref 90 \begin{thebibliography}{#1}% 91 \addcontentsline{toc}{section}{\ifdefined\refname\refname\else\ifdefined\bibname\bibname\fi\fi}}{\end{thebibliography}} 92 93 94% Same for the indices. 95% The memoir class already does this, so we don't duplicate it in that case. 96% 97\@ifclassloaded{memoir} 98 {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}} 99 {\newenvironment{sphinxtheindex}{% 100 \phantomsection % needed because no chapter, section, ... is created by theindex 101 \begin{theindex}% 102 \addcontentsline{toc}{section}{\indexname}}{\end{theindex}}} 103