summaryrefslogtreecommitdiffstats
path: root/sphinx/texinputs/sphinxlatexstyleheadings.sty
blob: b5e9c8543653a3c7194b8f4879ef43646bc79c2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
%% TITLES
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexstyleheadings.sty}[2023/02/11 headings]

\RequirePackage[nobottomtitles*]{titlesec}
\@ifpackagelater{titlesec}{2016/03/15}%
 {\@ifpackagelater{titlesec}{2016/03/21}%
  {}%
  {\newif\ifsphinx@ttlpatch@ok
   \IfFileExists{etoolbox.sty}{%
     \RequirePackage{etoolbox}%
     \patchcmd{\ttlh@hang}{\parindent\z@}{\parindent\z@\leavevmode}%
                                {\sphinx@ttlpatch@oktrue}{}%
     \ifsphinx@ttlpatch@ok
     \patchcmd{\ttlh@hang}{\noindent}{}{}{\sphinx@ttlpatch@okfalse}%
     \fi
   }{}%
   \ifsphinx@ttlpatch@ok
     \typeout{^^J Package Sphinx Info: ^^J
              **** titlesec 2.10.1 successfully patched for bugfix ****^^J}%
   \else
     \AtEndDocument{\PackageWarningNoLine{sphinx}{^^J%
******** titlesec 2.10.1 has a bug, (section numbers disappear) ......|^^J%
******** and Sphinx could not patch it, perhaps because your local ...|^^J%
******** copy is already fixed without a changed release date. .......|^^J%
******** If not, you must update titlesec! ...........................|}}%
     \sphinxbuildwarning{badtitlesec}%
   \fi
  }%
 }{}

% Augment the sectioning commands used to get our own font family in place,
% and reset some internal data items (\titleformat from titlesec package)
\titleformat{\section}{\Large\py@HeaderFamily}%
            {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}
\titleformat{\subsection}{\large\py@HeaderFamily}%
            {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}
% \normalsize added as work-around to a lualatex-ja upstream problem
% https://osdn.net/projects/luatex-ja/ticket/47321
\titleformat{\subsubsection}{\normalsize\py@HeaderFamily}%
            {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}
% By default paragraphs (and subsubsections) will not be numbered because
% sphinxmanual.cls and sphinxhowto.cls set secnumdepth to 2
\titleformat{\paragraph}{\normalsize\py@HeaderFamily}%
            {\py@TitleColor\theparagraph}{0.5em}{\py@TitleColor}
\titleformat{\subparagraph}{\normalsize\py@HeaderFamily}%
            {\py@TitleColor\thesubparagraph}{0.5em}{\py@TitleColor}


% Since Sphinx 1.5, users should use HeaderFamily key to 'sphinxsetup' rather
% than defining their own \py@HeaderFamily command (which is still possible).
% Memo: \py@HeaderFamily is also used by \maketitle as defined in
% sphinxmanual.cls/sphinxhowto.cls
\newcommand{\py@HeaderFamily}{\spx@opt@HeaderFamily}

% This sets up the fancy chapter headings that make the documents look
% at least a little better than the usual LaTeX output.
\@ifpackagewith{fncychap}{Bjarne}{
  \ChNameVar {\raggedleft\normalsize \py@HeaderFamily}
  \ChNumVar  {\raggedleft\Large      \py@HeaderFamily}
  \ChTitleVar{\raggedleft\Large      \py@HeaderFamily}
  % This creates (numbered) chapter heads without the leading \vspace*{}:
  \def\@makechapterhead#1{%
    {\parindent \z@ \raggedright \normalfont
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \DOCH
        \fi
      \fi
      \interlinepenalty\@M
      \if@mainmatter
        \DOTI{#1}%
      \else%
        \DOTIS{#1}%
      \fi
    }}
}{}% <-- "false" clause of \@ifpackagewith

% fix fncychap's bug which uses prematurely the \textwidth value
\@ifpackagewith{fncychap}{Bjornstrup}
 {\AtBeginDocument{\mylen\textwidth\advance\mylen-2\myhi}}%
 {}% <-- "false" clause of \@ifpackagewith


\endinput