mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#471: Fix LaTeX references to figures.
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,6 +1,8 @@
|
||||
Release 1.0.2 (in development)
|
||||
==============================
|
||||
|
||||
* #471: Fix LaTeX references to figures.
|
||||
|
||||
* #482: When doing a non-exact search, match only the given type
|
||||
of object.
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
else:
|
||||
self.top_sectionlevel = 1
|
||||
self.next_section_ids = set()
|
||||
self.next_figure_ids = set()
|
||||
# flags
|
||||
self.verbatim = None
|
||||
self.in_title = 0
|
||||
@@ -887,11 +888,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
pass
|
||||
|
||||
def visit_figure(self, node):
|
||||
ids = ''
|
||||
for id in self.next_figure_ids:
|
||||
ids += self.hypertarget(id, anchor=False)
|
||||
self.next_figure_ids.clear()
|
||||
if node.has_key('width') and node.get('align', '') in ('left', 'right'):
|
||||
self.body.append('\\begin{wrapfigure}{%s}{%s}\n\\centering' %
|
||||
(node['align'] == 'right' and 'r' or 'l',
|
||||
node['width']))
|
||||
self.context.append('\\end{wrapfigure}\n')
|
||||
self.context.append(ids + '\\end{wrapfigure}\n')
|
||||
else:
|
||||
if (not node.attributes.has_key('align') or
|
||||
node.attributes['align'] == 'center'):
|
||||
@@ -903,7 +908,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
align = '\\begin{flush%s}' % node.attributes['align']
|
||||
align_end = '\\end{flush%s}' % node.attributes['align']
|
||||
self.body.append('\\begin{figure}[htbp]%s\n' % align)
|
||||
self.context.append('%s\\end{figure}\n' % align_end)
|
||||
self.context.append(ids + align_end + '\\end{figure}\n')
|
||||
def depart_figure(self, node):
|
||||
self.body.append(self.context.pop())
|
||||
|
||||
@@ -983,6 +988,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
self.next_section_ids.add(node['refid'])
|
||||
self.next_section_ids.update(node['ids'])
|
||||
return
|
||||
elif isinstance(next, nodes.figure):
|
||||
if node.get('refid'):
|
||||
self.next_figure_ids.add(node['refid'])
|
||||
self.next_figure_ids.update(node['ids'])
|
||||
return
|
||||
except IndexError:
|
||||
pass
|
||||
if 'refuri' in node:
|
||||
|
||||
Reference in New Issue
Block a user