mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Prevent putting footnotes in captions, which is not supported by latex.
This commit is contained in:
parent
8621526045
commit
fc7aa2e0cb
@ -242,6 +242,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.verbatim = None
|
self.verbatim = None
|
||||||
self.in_title = 0
|
self.in_title = 0
|
||||||
self.in_production_list = 0
|
self.in_production_list = 0
|
||||||
|
self.in_footnote = 0
|
||||||
|
self.in_caption = 0
|
||||||
self.first_document = 1
|
self.first_document = 1
|
||||||
self.this_is_the_title = 1
|
self.this_is_the_title = 1
|
||||||
self.literal_whitespace = 0
|
self.literal_whitespace = 0
|
||||||
@ -594,9 +596,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
raise nodes.SkipNode
|
raise nodes.SkipNode
|
||||||
|
|
||||||
def visit_collected_footnote(self, node):
|
def visit_collected_footnote(self, node):
|
||||||
|
self.in_footnote += 1
|
||||||
self.body.append('\\footnote{')
|
self.body.append('\\footnote{')
|
||||||
def depart_collected_footnote(self, node):
|
def depart_collected_footnote(self, node):
|
||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
|
self.in_footnote -= 1
|
||||||
|
|
||||||
def visit_label(self, node):
|
def visit_label(self, node):
|
||||||
if isinstance(node.parent, nodes.citation):
|
if isinstance(node.parent, nodes.citation):
|
||||||
@ -815,7 +819,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
def visit_paragraph(self, node):
|
def visit_paragraph(self, node):
|
||||||
self.body.append('\n')
|
self.body.append('\n')
|
||||||
def depart_paragraph(self, node):
|
def depart_paragraph(self, node):
|
||||||
self.body.append('\n\n')
|
self.body.append('\n')
|
||||||
|
|
||||||
def visit_centered(self, node):
|
def visit_centered(self, node):
|
||||||
self.body.append('\n\\begin{center}')
|
self.body.append('\n\\begin{center}')
|
||||||
@ -946,9 +950,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.body.append(self.context.pop())
|
self.body.append(self.context.pop())
|
||||||
|
|
||||||
def visit_caption(self, node):
|
def visit_caption(self, node):
|
||||||
|
self.in_caption += 1
|
||||||
self.body.append('\\caption{')
|
self.body.append('\\caption{')
|
||||||
def depart_caption(self, node):
|
def depart_caption(self, node):
|
||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
|
self.in_caption -= 1
|
||||||
|
|
||||||
def visit_legend(self, node):
|
def visit_legend(self, node):
|
||||||
self.body.append('{\\small ')
|
self.body.append('{\\small ')
|
||||||
@ -1221,6 +1227,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
if used:
|
if used:
|
||||||
self.body.append('\\footnotemark[%s]' % num)
|
self.body.append('\\footnotemark[%s]' % num)
|
||||||
else:
|
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)
|
footnode.walkabout(self)
|
||||||
self.footnotestack[-1][num][1] = True
|
self.footnotestack[-1][num][1] = True
|
||||||
raise nodes.SkipChildren
|
raise nodes.SkipChildren
|
||||||
|
Loading…
Reference in New Issue
Block a user