Merge pull request #3032 from jfbu/improvelatexcompatibilities

Fix #3031: incompatibility with LaTeX package ``tocloft``
This commit is contained in:
Jean-François B 2016-10-12 22:40:28 +02:00 committed by GitHub
commit 749a6a0558
5 changed files with 47 additions and 47 deletions

View File

@ -1739,13 +1739,18 @@ These options influence LaTeX output. See further :doc:`latex`.
``'fontenc'`` ``'fontenc'``
"fontenc" package inclusion, default ``'\\usepackage[T1]{fontenc}'``. "fontenc" package inclusion, default ``'\\usepackage[T1]{fontenc}'``.
``'maketitle'`` ``'maketitle'``
"maketitle" call, default ``'\\maketitle'``. Override if you want to "maketitle" call, default ``'\\maketitle'`` (but it has been
redefined by the Sphinx ``manual`` and ``howto`` classes.) Override
if you want to
generate a differently-styled title page. generate a differently-styled title page.
``'releasename'`` ``'releasename'``
value that prefixes ``'release'`` element on title page, default value that prefixes ``'release'`` element on title page, default
``'Release'``. ``'Release'``.
``'tableofcontents'`` ``'tableofcontents'``
"tableofcontents" call, default ``'\\tableofcontents'``. Override if "tableofcontents" call, default ``'\\sphinxtableofcontents'`` (it is a
wrapper of unmodified ``\tableofcontents``, which may itself be
customized by user loaded packages.)
Override if
you want to generate a different table of contents or put content you want to generate a different table of contents or put content
between the title page and the TOC. between the title page and the TOC.
``'transition'`` ``'transition'``

View File

@ -927,16 +927,15 @@
% fix the double index and bibliography on the table of contents % fix the double index and bibliography on the table of contents
% in jsclasses (Japanese standard document classes) % in jsclasses (Japanese standard document classes)
\ifx\@jsc@uplatextrue\undefined\else \ifx\@jsc@uplatextrue\undefined\else
\renewcommand{\theindex}{ \renewenvironment{sphinxtheindex}
\cleardoublepage {\cleardoublepage\phantomsection
\phantomsection \begin{theindex}}
\py@OldTheindex {\end{theindex}}
}
\renewcommand{\thebibliography}[1]{ \renewenvironment{sphinxthebibliography}[1]
\cleardoublepage {\cleardoublepage\phantomsection
\phantomsection \begin{thebibliography}{\detokenize{#1}}}
\py@OldThebibliography{1} {\end{thebibliography}}
}
\fi \fi
% disable \@chappos in Appendix in pTeX % disable \@chappos in Appendix in pTeX
@ -1024,3 +1023,8 @@
% stylesheet for highlighting with pygments % stylesheet for highlighting with pygments
\RequirePackage{sphinxhighlight} \RequirePackage{sphinxhighlight}
% make commands known to non-Sphinx document classes
\providecommand*{\sphinxtableofcontents}{\tableofcontents}
\providecommand*{\sphinxthebibliography}{\thebibliography}
\providecommand*{\sphinxtheindex}{\theindex}

View File

@ -70,11 +70,10 @@
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{} %\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
} }
\let\py@OldTableofcontents=\tableofcontents \newcommand{\sphinxtableofcontents}{
\renewcommand{\tableofcontents}{
\begingroup \begingroup
\parskip = 0mm \parskip = 0mm
\py@OldTableofcontents \tableofcontents
\endgroup \endgroup
\rule{\textwidth}{1pt} \rule{\textwidth}{1pt}
\vspace{12pt} \vspace{12pt}
@ -91,21 +90,18 @@
% Contents. % Contents.
% For an article document class this environment is a section, % For an article document class this environment is a section,
% so no page break before it. % so no page break before it.
\let\py@OldThebibliography=\thebibliography \newenvironment{sphinxthebibliography}[1]{%
\renewcommand{\thebibliography}[1]{
\phantomsection \phantomsection
\py@OldThebibliography{1} \begin{thebibliography}{\detokenize{#1}}%
\addcontentsline{toc}{section}{\bibname} \addcontentsline{toc}{section}{\bibname}}{\end{thebibliography}}
}
% Same for the indices. % Same for the indices.
% The memoir class already does this, so we don't duplicate it in that case. % The memoir class already does this, so we don't duplicate it in that case.
% %
\@ifclassloaded{memoir}{}{ \@ifclassloaded{memoir}
\let\py@OldTheindex=\theindex {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}
\renewcommand{\theindex}{ {\newenvironment{sphinxtheindex}{%
\phantomsection \phantomsection
\py@OldTheindex \begin{theindex}%
\addcontentsline{toc}{section}{\indexname} \addcontentsline{toc}{section}{\indexname}}{\end{theindex}}}
}
}

View File

@ -82,15 +82,14 @@
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{} %\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
} }
\let\py@OldTableofcontents=\tableofcontents \newcommand{\sphinxtableofcontents}{%
\renewcommand{\tableofcontents}{%
% before resetting page counter, let's do the right thing. % before resetting page counter, let's do the right thing.
\if@openright\cleardoublepage\else\clearpage\fi \if@openright\cleardoublepage\else\clearpage\fi
\pagenumbering{roman}% \pagenumbering{roman}%
\pagestyle{plain}% \pagestyle{plain}%
\begingroup \begingroup
\parskip \z@skip \parskip \z@skip
\py@OldTableofcontents \tableofcontents
\endgroup \endgroup
% before resetting page counter, let's do the right thing. % before resetting page counter, let's do the right thing.
\if@openright\cleardoublepage\else\clearpage\fi \if@openright\cleardoublepage\else\clearpage\fi
@ -108,23 +107,19 @@
% Fix the bibliography environment to add an entry to the Table of % Fix the bibliography environment to add an entry to the Table of
% Contents. % Contents.
% For a report document class this environment is a chapter. % For a report document class this environment is a chapter.
\let\py@OldThebibliography=\thebibliography \newenvironment{sphinxthebibliography}[1]{%
\renewcommand{\thebibliography}[1]{
\if@openright\cleardoublepage\else\clearpage\fi \if@openright\cleardoublepage\else\clearpage\fi
\phantomsection \phantomsection
\py@OldThebibliography{1} \begin{thebibliography}{\detokenize{#1}}%
\addcontentsline{toc}{chapter}{\bibname} \addcontentsline{toc}{chapter}{\bibname}}{\end{thebibliography}}
}
% Same for the indices. % Same for the indices.
% The memoir class already does this, so we don't duplicate it in that case. % The memoir class already does this, so we don't duplicate it in that case.
% %
\@ifclassloaded{memoir}{}{ \@ifclassloaded{memoir}
\let\py@OldTheindex=\theindex {\newenvironment{sphinxtheindex}{\begin{theindex}}{\end{theindex}}}
\renewcommand{\theindex}{ {\newenvironment{sphinxtheindex}{%
\if@openright\cleardoublepage\else\clearpage\fi \if@openright\cleardoublepage\else\clearpage\fi
\phantomsection \phantomsection
\py@OldTheindex \begin{theindex}%
\addcontentsline{toc}{chapter}{\indexname} \addcontentsline{toc}{chapter}{\indexname}}{\end{theindex}}}
}
}

View File

@ -291,7 +291,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
'makeindex': '\\makeindex', 'makeindex': '\\makeindex',
'shorthandoff': '', 'shorthandoff': '',
'maketitle': '\\maketitle', 'maketitle': '\\maketitle',
'tableofcontents': '\\tableofcontents', 'tableofcontents': '\\sphinxtableofcontents',
'postamble': '', 'postamble': '',
'printindex': '\\printindex', 'printindex': '\\printindex',
'transition': '\n\n\\bigskip\\hrule{}\\bigskip\n\n', 'transition': '\n\n\\bigskip\\hrule{}\\bigskip\n\n',
@ -588,7 +588,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def generate_indices(self): def generate_indices(self):
def generate(content, collapsed): def generate(content, collapsed):
ret.append('\\begin{theindex}\n') ret.append('\\begin{sphinxtheindex}\n')
ret.append('\\def\\bigletter#1{{\\Large\\sffamily#1}' ret.append('\\def\\bigletter#1{{\\Large\\sffamily#1}'
'\\nopagebreak\\vspace{1mm}}\n') '\\nopagebreak\\vspace{1mm}}\n')
for i, (letter, entries) in enumerate(content): for i, (letter, entries) in enumerate(content):
@ -605,7 +605,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
ret.append('\\sphinxstyleindexextra{%s}' % self.encode(entry[4])) ret.append('\\sphinxstyleindexextra{%s}' % self.encode(entry[4]))
ret.append('\\sphinxstyleindexpageref{%s:%s}\n' % ret.append('\\sphinxstyleindexpageref{%s:%s}\n' %
(entry[2], self.idescape(entry[3]))) (entry[2], self.idescape(entry[3])))
ret.append('\\end{theindex}\n') ret.append('\\end{sphinxtheindex}\n')
ret = [] ret = []
# latex_domain_indices can be False/True or a list of index names # latex_domain_indices can be False/True or a list of index names
@ -653,14 +653,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
for bi in self.bibitems: for bi in self.bibitems:
if len(widest_label) < len(bi[0]): if len(widest_label) < len(bi[0]):
widest_label = bi[0] widest_label = bi[0]
self.body.append(u'\n\\begin{thebibliography}{%s}\n' % widest_label) self.body.append(u'\n\\begin{sphinxthebibliography}{%s}\n' % widest_label)
for bi in self.bibitems: for bi in self.bibitems:
target = self.hypertarget(bi[2] + ':' + bi[3], target = self.hypertarget(bi[2] + ':' + bi[3],
withdoc=False) withdoc=False)
self.body.append(u'\\bibitem[%s]{%s}{%s %s}\n' % self.body.append(u'\\bibitem[%s]{%s}{%s %s}\n' %
(self.encode(bi[0]), self.idescape(bi[0]), (self.encode(bi[0]), self.idescape(bi[0]),
target, bi[1])) target, bi[1]))
self.body.append(u'\\end{thebibliography}\n') self.body.append(u'\\end{sphinxthebibliography}\n')
self.bibitems = [] self.bibitems = []
def visit_start_of_file(self, node): def visit_start_of_file(self, node):