Georg Brandl avatar Georg Brandl committed c8faf13

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

Comments (0)

Files changed (3)

 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)
 ============================

sphinx/texinputs/sphinx.sty

                 linkcolor=InnerLinkColor,filecolor=OuterLinkColor,
                 menucolor=OuterLinkColor,urlcolor=OuterLinkColor,
                 citecolor=InnerLinkColor]{hyperref}
-\RequirePackage[figure,table]{hypcap}
+% 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.)
+\RequirePackage{hypcap}
 
 % From docutils.writers.latex2e
 \providecommand{\DUspan}[2]{%

sphinx/writers/latex.py

 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:
             self.body.append(u'\n\\begin{threeparttable}\n'
-                             u'\\caption{%s}\n' % self.table.caption)
+                             u'\\capstart\\caption{%s}\n' % self.table.caption)
         if self.table.longtable:
             self.body.append('\n\\begin{longtable}')
         elif self.table.has_verbatim:
             else:
                 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):
         self.body.append(self.context.pop())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.