mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2134 figure caption with reference causes latex build error
This commit is contained in:
parent
7cbd1254a9
commit
32b483d5bc
2
CHANGES
2
CHANGES
@ -4,6 +4,8 @@ Release 1.3.4 (in development)
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #2134 Fix figure caption with reference causes latex build error
|
||||
|
||||
|
||||
Release 1.3.3 (released Dec 2, 2015)
|
||||
====================================
|
||||
|
@ -1382,7 +1382,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_reference(self, node):
|
||||
for id in node.get('ids'):
|
||||
self.body += self.hypertarget(id, anchor=True)
|
||||
anchor = not self.in_caption
|
||||
self.body += self.hypertarget(id, anchor=anchor)
|
||||
uri = node.get('refuri', '')
|
||||
if not uri and node.get('refid'):
|
||||
uri = '%' + self.curfilestack[-1] + '#' + node['refid']
|
||||
|
4
tests/roots/test-references-in-caption/conf.py
Normal file
4
tests/roots/test-references-in-caption/conf.py
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
||||
html_theme = 'classic'
|
8
tests/roots/test-references-in-caption/index.rst
Normal file
8
tests/roots/test-references-in-caption/index.rst
Normal file
@ -0,0 +1,8 @@
|
||||
test-reference
|
||||
==============
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
This is the figure caption with a reference to [AuthorYear]_.
|
||||
|
||||
.. [AuthorYear] Author, Title, Year
|
BIN
tests/roots/test-references-in-caption/rimg.png
Normal file
BIN
tests/roots/test-references-in-caption/rimg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 218 B |
@ -318,3 +318,14 @@ def test_footnote(app, status, warning):
|
||||
assert ('\\end{threeparttable}\n\n'
|
||||
'\\footnotetext[4]{\nfootnotes in table caption\n}'
|
||||
'\\footnotetext[5]{\nfootnotes in table\n}' in result)
|
||||
|
||||
|
||||
@with_app(buildername='latex', testroot='references-in-caption')
|
||||
def test_reference_in_caption(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\caption{This is the figure caption with a reference to \\label{index:id1}'
|
||||
'{\\hyperref[index:authoryear]{\\emph{{[}AuthorYear{]}}}}.}' in result)
|
||||
|
Loading…
Reference in New Issue
Block a user