mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix section and table titles with reference cause latex build error
This commit is contained in:
@@ -1381,9 +1381,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_reference(self, node):
|
||||
for id in node.get('ids'):
|
||||
anchor = not self.in_caption
|
||||
self.body += self.hypertarget(id, anchor=anchor)
|
||||
if not self.in_title:
|
||||
for id in node.get('ids'):
|
||||
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']
|
||||
|
@@ -1,8 +1,20 @@
|
||||
==============
|
||||
test-reference
|
||||
==============
|
||||
|
||||
The section with a reference to [AuthorYear]_
|
||||
=============================================
|
||||
|
||||
.. figure:: rimg.png
|
||||
|
||||
This is the figure caption with a reference to [AuthorYear]_.
|
||||
|
||||
.. list-table:: The table title with a reference to [AuthorYear]_
|
||||
:header-rows: 1
|
||||
|
||||
* - Header1
|
||||
- Header2
|
||||
* - Content
|
||||
- Content
|
||||
|
||||
.. [AuthorYear] Author, Title, Year
|
||||
|
@@ -327,5 +327,7 @@ def test_reference_in_caption(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\caption{This is the figure caption with a reference to \\label{index:id1}'
|
||||
assert ('\\caption{This is the figure caption with a reference to \\label{index:id2}'
|
||||
'{\\hyperref[index:authoryear]{\\emph{{[}AuthorYear{]}}}}.}' in result)
|
||||
assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result
|
||||
assert '\\caption{The table title with a reference to {[}AuthorYear{]}}' in result
|
||||
|
Reference in New Issue
Block a user