Support table captions in LaTeX output.

This commit is contained in:
Georg Brandl
2008-11-16 17:35:22 +01:00
parent 69853e544e
commit 7d2f674ff2
3 changed files with 14 additions and 2 deletions
+2
View File
@@ -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
View File
@@ -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
+1
View File
@@ -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}