summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--doc/markup/misc.rst13
-rw-r--r--sphinx/writers/latex.py30
3 files changed, 35 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 8bd8d42f..08c3fd2c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
Release 1.0.6 (in development)
==============================
+* #565: In the LaTeX builder, not only literal blocks require different
+ table handling, but also quite a few other list-like block elements.
+
* #515: Fix tracebacks in the viewcode extension for Python objects
that do not have a valid signature.
diff --git a/doc/markup/misc.rst b/doc/markup/misc.rst
index 6173589b..35d23b0d 100644
--- a/doc/markup/misc.rst
+++ b/doc/markup/misc.rst
@@ -124,9 +124,10 @@ following directive exists:
.. warning::
- Tables that contain literal blocks cannot be set with ``tabulary``. They are
- therefore set with the standard LaTeX ``tabular`` environment. Also, the
- verbatim environment used for literal blocks only works in ``p{width}``
- columns, which means that by default, Sphinx generates such column specs for
- such tables. Use the :rst:dir:`tabularcolumns` directive to get finer control
- over such tables.
+ Tables that contain block-level elements such as object descriptions, literal
+ blocks, blockquotes or any kind of lists cannot be set with ``tabulary``.
+ They are therefore set with the standard LaTeX ``tabular`` environment.
+ Also, the verbatim environment used for literal blocks only works in
+ ``p{width}`` columns, which means that by default, Sphinx generates such
+ column specs for such tables. Use the :rst:dir:`tabularcolumns` directive to
+ get finer control over such tables.
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 38f44994..2d10d1ee 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -113,7 +113,7 @@ class Table(object):
self.colspec = None
self.rowcount = 0
self.had_head = False
- self.has_verbatim = False
+ self.has_problematic = False
self.caption = None
self.longtable = False
@@ -482,6 +482,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_desc(self, node):
self.body.append('\n\n\\begin{fulllineitems}\n')
+ if self.table:
+ self.table.has_problematic = True
def depart_desc(self, node):
self.body.append('\n\\end{fulllineitems}\n\n')
@@ -615,14 +617,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
u'\\capstart\\caption{%s}\n' % self.table.caption)
if self.table.longtable:
self.body.append('\n\\begin{longtable}')
- elif self.table.has_verbatim:
+ elif self.table.has_problematic:
self.body.append('\n\\begin{tabular}')
else:
self.body.append('\n\\begin{tabulary}{\\linewidth}')
if self.table.colspec:
self.body.append(self.table.colspec)
else:
- if self.table.has_verbatim:
+ if self.table.has_problematic:
colwidth = 0.95 / self.table.colcount
colspec = ('p{%.3f\\linewidth}|' % colwidth) * \
self.table.colcount
@@ -657,7 +659,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.extend(self.tablebody)
if self.table.longtable:
self.body.append('\\end{longtable}\n\n')
- elif self.table.has_verbatim:
+ elif self.table.has_problematic:
self.body.append('\\end{tabular}\n\n')
else:
self.body.append('\\end{tabulary}\n\n')
@@ -725,6 +727,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_bullet_list(self, node):
if not self.compact_list:
self.body.append('\\begin{itemize}\n' )
+ if self.table:
+ self.table.has_problematic = True
def depart_bullet_list(self, node):
if not self.compact_list:
self.body.append('\\end{itemize}\n' )
@@ -733,6 +737,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('\\begin{enumerate}\n' )
if 'start' in node:
self.body.append('\\setcounter{enumi}{%d}\n' % (node['start'] - 1))
+ if self.table:
+ self.table.has_problematic = True
def depart_enumerated_list(self, node):
self.body.append('\\end{enumerate}\n' )
@@ -745,6 +751,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_definition_list(self, node):
self.body.append('\\begin{description}\n')
+ if self.table:
+ self.table.has_problematic = True
def depart_definition_list(self, node):
self.body.append('\\end{description}\n')
@@ -774,6 +782,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_field_list(self, node):
self.body.append('\\begin{quote}\\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')
@@ -795,6 +805,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_centered(self, node):
self.body.append('\n\\begin{center}')
+ if self.table:
+ self.table.has_problematic = True
def depart_centered(self, node):
self.body.append('\n\\end{center}')
@@ -804,6 +816,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.compact_list += 1
self.body.append('\\begin{itemize}\\setlength{\\itemsep}{0pt}'
'\\setlength{\\parskip}{0pt}\n')
+ if self.table:
+ self.table.has_problematic = True
def depart_hlist(self, node):
self.compact_list -= 1
self.body.append('\\end{itemize}\n')
@@ -1220,7 +1234,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self.table:
hlcode = hlcode.replace('\\begin{Verbatim}',
'\\begin{OriginalVerbatim}')
- self.table.has_verbatim = True
+ self.table.has_problematic = True
# get consistent trailer
hlcode = hlcode.rstrip()[:-14] # strip \end{Verbatim}
hlcode = hlcode.rstrip() + '\n'
@@ -1241,6 +1255,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
'\\begin{DUlineblock}{\\DUlineblockindent}\n')
else:
self.body.append('\n\\begin{DUlineblock}{0em}\n')
+ if self.table:
+ self.table.has_problematic = True
def depart_line_block(self, node):
self.body.append('\\end{DUlineblock}\n')
@@ -1256,6 +1272,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
done = 1
if not done:
self.body.append('\\begin{quote}\n')
+ if self.table:
+ self.table.has_problematic = True
def depart_block_quote(self, node):
done = 0
if len(node.children) == 1:
@@ -1292,6 +1310,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_option_list(self, node):
self.body.append('\\begin{optionlist}{3cm}\n')
+ if self.table:
+ self.table.has_problematic = True
def depart_option_list(self, node):
self.body.append('\\end{optionlist}\n')