Prevent putting footnotes in captions, which is not supported by latex.

This commit is contained in:
Georg Brandl 2011-01-06 18:24:35 +01:00
parent 8621526045
commit fc7aa2e0cb

View File

@ -242,6 +242,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.verbatim = None
self.in_title = 0
self.in_production_list = 0
self.in_footnote = 0
self.in_caption = 0
self.first_document = 1
self.this_is_the_title = 1
self.literal_whitespace = 0
@ -594,9 +596,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
raise nodes.SkipNode
def visit_collected_footnote(self, node):
self.in_footnote += 1
self.body.append('\\footnote{')
def depart_collected_footnote(self, node):
self.body.append('}')
self.in_footnote -= 1
def visit_label(self, node):
if isinstance(node.parent, nodes.citation):
@ -815,7 +819,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_paragraph(self, node):
self.body.append('\n')
def depart_paragraph(self, node):
self.body.append('\n\n')
self.body.append('\n')
def visit_centered(self, node):
self.body.append('\n\\begin{center}')
@ -946,9 +950,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(self.context.pop())
def visit_caption(self, node):
self.in_caption += 1
self.body.append('\\caption{')
def depart_caption(self, node):
self.body.append('}')
self.in_caption -= 1
def visit_legend(self, node):
self.body.append('{\\small ')
@ -1221,6 +1227,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
if used:
self.body.append('\\footnotemark[%s]' % num)
else:
if self.in_caption:
raise UnsupportedError('%s:%s: footnotes in float captions '
'are not supported by LaTeX' %
(self.curfilestack[-1], node.line))
footnode.walkabout(self)
self.footnotestack[-1][num][1] = True
raise nodes.SkipChildren