From 01d06f9ffe0cd2388156fb53287496f45165519c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 13 Feb 2022 20:19:41 +0900 Subject: [PATCH] Fix #10175: LaTeX: named footnote ref is linked to an incorrect footnote A named footnote reference will be converted to a hyperlink to an incorrect footnote if the name is also used in the different document. --- CHANGES | 2 ++ sphinx/writers/latex.py | 1 + tests/test_build_latex.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 6d21d43f0c..29b8c32e8d 100644 --- a/CHANGES +++ b/CHANGES @@ -32,6 +32,8 @@ Bugs fixed unhashable object * #9529: LaTeX: named auto numbered footnote (ex. ``[#named]``) that is referred multiple times was rendered to a question mark +* #10175: LaTeX: named footnote reference is linked to an incorrect footnote if + the name is also used in the different document * #10181: napoleon: attributes are displayed like class attributes for google style docstrings when :confval:`napoleon_use_ivar` is enabled * #10122: sphinx-build: make.bat does not check the installation of sphinx-build diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index a2905e807c..289669549c 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -571,6 +571,7 @@ def depart_document(self, node: Element) -> None: def visit_start_of_file(self, node: Element) -> None: self.curfilestack.append(node['docname']) + self.body.append(CR + r'\sphinxstepscope' + CR) def depart_start_of_file(self, node: Element) -> None: self.curfilestack.pop() diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index d156d15894..b0ae854230 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -1197,6 +1197,7 @@ def test_latex_table_tabulars(app, status, warning): tables = {} for chap in re.split(r'\\(?:section|chapter){', result)[1:]: sectname, content = chap.split('}', 1) + content = re.sub(r'\\sphinxstepscope', '', content) # filter a separator tables[sectname] = content.strip() def get_expected(name): @@ -1266,6 +1267,7 @@ def test_latex_table_longtable(app, status, warning): tables = {} for chap in re.split(r'\\(?:section|chapter){', result)[1:]: sectname, content = chap.split('}', 1) + content = re.sub(r'\\sphinxstepscope', '', content) # filter a separator tables[sectname] = content.strip() def get_expected(name):