Skip to content

Commit

Permalink
Fix sphinx-doc#777 (part II): Latex output "too deeply nested"
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jfbu committed Oct 25, 2016
1 parent 0ad5420 commit 15b4573
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions sphinx/texinputs/sphinx.sty
Original file line number Diff line number Diff line change
Expand Up @@ -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}
10 changes: 6 additions & 4 deletions sphinx/writers/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 15b4573

Please sign in to comment.