3
|
1 |
%
|
|
2 |
% sphinxmanual.cls for Sphinx (http://sphinx-doc.org/)
|
|
3 |
%
|
|
4 |
|
|
5 |
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
|
6 |
\ProvidesClass{sphinxmanual}[2017/03/26 v1.6 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 |
% Change the title page to look a bit better, and fit in with the fncychap
|
|
34 |
% ``Bjarne'' style a bit better.
|
|
35 |
%
|
|
36 |
\renewcommand{\maketitle}{%
|
|
37 |
\let\spx@tempa\relax
|
|
38 |
\ifHy@pageanchor\def\spx@tempa{\Hy@pageanchortrue}\fi
|
|
39 |
\hypersetup{pageanchor=false}% avoid duplicate destination warnings
|
|
40 |
\begin{titlepage}%
|
|
41 |
\let\footnotesize\small
|
|
42 |
\let\footnoterule\relax
|
|
43 |
\noindent\rule{\textwidth}{1pt}\par
|
|
44 |
\begingroup % for PDF information dictionary
|
|
45 |
\def\endgraf{ }\def\and{\& }%
|
|
46 |
\pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup
|
|
47 |
\hypersetup{pdfauthor={\@author}, pdftitle={\@title}}%
|
|
48 |
\endgroup
|
|
49 |
\begin{flushright}%
|
|
50 |
\sphinxlogo
|
|
51 |
\py@HeaderFamily
|
|
52 |
{\Huge \@title \par}
|
|
53 |
{\itshape\LARGE \py@release\releaseinfo \par}
|
|
54 |
\vfill
|
|
55 |
{\LARGE
|
|
56 |
\begin{tabular}[t]{c}
|
|
57 |
\@author
|
|
58 |
\end{tabular}
|
|
59 |
\par}
|
|
60 |
\vfill\vfill
|
|
61 |
{\large
|
|
62 |
\@date \par
|
|
63 |
\vfill
|
|
64 |
\py@authoraddress \par
|
|
65 |
}%
|
|
66 |
\end{flushright}%\par
|
|
67 |
\@thanks
|
|
68 |
\end{titlepage}%
|
|
69 |
\setcounter{footnote}{0}%
|
|
70 |
\let\thanks\relax\let\maketitle\relax
|
|
71 |
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
|
|
72 |
\if@openright\cleardoublepage\else\clearpage\fi
|
|
73 |
\spx@tempa
|
|
74 |
}
|
|
75 |
|
|
76 |
\newcommand{\sphinxtableofcontents}{%
|
|
77 |
\pagenumbering{roman}%
|
|
78 |
\pagestyle{plain}%
|
|
79 |
\begingroup
|
|
80 |
\parskip \z@skip
|
|
81 |
\tableofcontents
|
|
82 |
\endgroup
|
|
83 |
% before resetting page counter, let's do the right thing.
|
|
84 |
\if@openright\cleardoublepage\else\clearpage\fi
|
|
85 |
\pagenumbering{arabic}%
|
|
86 |
\ifdefined\fancyhf\pagestyle{normal}\fi
|
|
87 |
}
|
|
88 |
|
|
89 |
% This is needed to get the width of the section # area wide enough in the
|
|
90 |
% library reference. Doing it here keeps it the same for all the manuals.
|
|
91 |
%
|
|
92 |
\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.6em}}
|
|
93 |
\renewcommand*\l@subsection{\@dottedtocline{2}{4.1em}{3.5em}}
|
|
94 |
|
|
95 |
% Fix the bibliography environment to add an entry to the Table of
|
|
96 |
% Contents.
|
|
97 |
% For a report document class this environment is a chapter.
|
|
98 |
%
|
|
99 |
\newenvironment{sphinxthebibliography}[1]{%
|
|
100 |
\if@openright\cleardoublepage\else\clearpage\fi
|
|
101 |
% \phantomsection % not needed here since TeXLive 2010's hyperref
|
|
102 |
\begin{thebibliography}{1}%
|
|
103 |
\addcontentsline{toc}{chapter}{\bibname}}{\end{thebibliography}}
|
|
104 |
|
|
105 |
% Same for the indices.
|
|
106 |
% The memoir class already does this, so we don't duplicate it in that case.
|
|
107 |
%
|
|
108 |
\@ifclassloaded{memoir}
|
|
109 |
{\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}
|
|
110 |
{\newenvironment{sphinxtheindex}{%
|
|
111 |
\if@openright\cleardoublepage\else\clearpage\fi
|
|
112 |
\phantomsection % needed as no chapter, section, ... created
|
|
113 |
\begin{theindex}%
|
|
114 |
\addcontentsline{toc}{chapter}{\indexname}}{\end{theindex}}}
|