From 15b457358aa1fa2c5db8034e9bbe55e76e17f40c Mon Sep 17 00:00:00 2001 From: jfbu Date: Sun, 5 Jun 2016 21:58:45 +0200 Subject: [PATCH] Fix #777 (part II): Latex output "too deeply nested" Patch use of quote environment by LaTeX writer to prevent increase of ``\@listdepth``. This is experimental and probably not good (Jun 5, 2016). Rebased on master at 0ad5420 (Oct 25, 2016). --- sphinx/texinputs/sphinx.sty | 4 ++++ sphinx/writers/latex.py | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 86a30e70086..63d7bc4387f 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -1001,3 +1001,7 @@ \providecommand*{\sphinxtableofcontents}{\tableofcontents} \providecommand*{\sphinxthebibliography}{\thebibliography} \providecommand*{\sphinxtheindex}{\theindex} + +% will be used to accompany quote environment and help avoid "too deeply nested" +\newcommand*\SphinxDecreaseListDepth {\global\advance\@listdepth\m@ne} +\newcommand*\SphinxIncreaseListDepth {\global\advance\@listdepth\@ne} diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index b667c0c9a33..18b2d8c52cf 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1304,12 +1304,14 @@ def depart_definition(self, node): self.body.append('\n') def visit_field_list(self, node): - self.body.append('\\begin{quote}\\begin{description}\n') + self.body.append('\\begin{quote}\\SphinxDecreaseListDepth' + '\\begin{description}\n') if self.table: self.table.has_problematic = True def depart_field_list(self, node): - self.body.append('\\end{description}\\end{quote}\n') + self.body.append('\\end{description}\\end{quote}' + '\\SphinxIncreaseListDepth\n') def visit_field(self, node): pass @@ -1960,7 +1962,7 @@ def visit_block_quote(self, node): isinstance(child, nodes.enumerated_list): done = 1 if not done: - self.body.append('\\begin{quote}\n') + self.body.append('\\begin{quote}\\SphinxDecreaseListDepth\n') if self.table: self.table.has_problematic = True @@ -1972,7 +1974,7 @@ def depart_block_quote(self, node): isinstance(child, nodes.enumerated_list): done = 1 if not done: - self.body.append('\\end{quote}\n') + self.body.append('\\end{quote}\\SphinxIncreaseListDepth\n') # option node handling copied from docutils' latex writer