Commits

Georg Brandl  committed e47385c

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

  • Participants
  • Parent commits c0c3d0e

Comments (0)

Files changed (1)

File sphinx/writers/latex.py

         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
         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):
     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}')
         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 ')
         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