1. Georg Brandl
  2. sphinx


Georg Brandl  committed c8faf13

#501: Fix regression when building LaTeX docs with figures that
don't have captions.

  • Participants
  • Parent commits f6c989e
  • Branches default

Comments (0)

Files changed (3)


View file
 Release 1.0.3 (in development)
+* #501: Fix regression when building LaTeX docs with figures that
+  don't have captions.
 * #510: Fix inheritance diagrams for classes that are not picklable.
+* #502, #503: Fix small layout bugs in agogo and haiku themes.
 Release 1.0.2 (Aug 14, 2010)

File sphinx/texinputs/sphinx.sty

View file
+% Fix anchor placement for figures with captions.
+% (Note: we don't use a package option here; instead, we give an explicit
+% \capstart for figures that actually have a caption.)
 % From docutils.writers.latex2e

File sphinx/writers/latex.py

View file
 from sphinx.errors import SphinxError
 from sphinx.locale import admonitionlabels, versionlabels, _
 from sphinx.util.osutil import ustrftime
+from sphinx.util.pycompat import any
 from sphinx.util.texescape import tex_escape_map, tex_replace_map
 from sphinx.util.smartypants import educateQuotesLatex
         self.body = self._body
         if not self.table.longtable and self.table.caption is not None:
-                             u'\\caption{%s}\n' % self.table.caption)
+                             u'\\capstart\\caption{%s}\n' % self.table.caption)
         if self.table.longtable:
         elif self.table.has_verbatim:
                 self.body.append('{|' + ('L|' * self.table.colcount) + '}\n')
         if self.table.longtable and self.table.caption is not None:
-            self.body.append(u'\\caption{%s} \\\\\n' % self.table.caption)
+            self.body.append(u'\\capstart\\caption{%s} \\\\\n' % self.table.caption)
         if self.table.caption is not None:
             for id in self.next_table_ids:
                 self.body.append(self.hypertarget(id, anchor=False))
                 align = '\\begin{flush%s}' % node.attributes['align']
                 align_end = '\\end{flush%s}' % node.attributes['align']
             self.body.append('\\begin{figure}[htbp]%s\n' % align)
+            if any(isinstance(child, nodes.caption) for child in node):
+                self.body.append('\\capstart\n')
             self.context.append(ids + align_end + '\\end{figure}\n')
     def depart_figure(self, node):