mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Support table captions in LaTeX output.
This commit is contained in:
@@ -159,6 +159,8 @@ New features added
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* Support table captions in LaTeX output.
|
||||
|
||||
* Work around a bug in Jinja that caused "<generator ...>" to be
|
||||
emitted in HTML output.
|
||||
|
||||
|
||||
+11
-2
@@ -102,6 +102,7 @@ class Table(object):
|
||||
self.colspec = None
|
||||
self.had_head = False
|
||||
self.has_verbatim = False
|
||||
self.caption = None
|
||||
|
||||
|
||||
class Desc(object):
|
||||
@@ -357,9 +358,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
elif isinstance(parent, nodes.Admonition):
|
||||
self.body.append('{')
|
||||
self.context.append('}\n')
|
||||
elif isinstance(parent, nodes.table):
|
||||
self.table.caption = self.encode(node.astext())
|
||||
raise nodes.SkipNode
|
||||
else:
|
||||
self.builder.warn('encountered title node not in section, topic, admonition'
|
||||
' or sidebar')
|
||||
self.builder.warn('encountered title node not in section, topic, '
|
||||
'table, admonition or sidebar')
|
||||
self.body.append('\\textbf{')
|
||||
self.context.append('}\n')
|
||||
self.in_title = 1
|
||||
@@ -544,6 +548,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.body = self.tablebody
|
||||
def depart_table(self, node):
|
||||
self.body = self._body
|
||||
if self.table.caption is not None:
|
||||
self.body.append('\n\\begin{threeparttable}\n'
|
||||
'\\caption{%s}\n' % self.table.caption)
|
||||
if self.table.has_verbatim:
|
||||
self.body.append('\n\\begin{tabular}')
|
||||
else:
|
||||
@@ -562,6 +569,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.body.append('\\end{tabular}\n\n')
|
||||
else:
|
||||
self.body.append('\\end{tabulary}\n\n')
|
||||
if self.table.caption is not None:
|
||||
self.body.append('\\end{threeparttable}\n\n')
|
||||
self.table = None
|
||||
self.tablebody = None
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
\RequirePackage{framed}
|
||||
\RequirePackage{color}
|
||||
\RequirePackage{fancyvrb}
|
||||
\RequirePackage{threeparttable}
|
||||
|
||||
% Redefine these colors to your liking in the preamble.
|
||||
\definecolor{TitleColor}{rgb}{0.126,0.263,0.361}
|
||||
|
||||
Reference in New Issue
Block a user