Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9529: LaTeX: named footnotes are converted to "?" #10169

Merged
merged 3 commits into from Feb 11, 2022

Conversation

tk0miya
Copy link
Member

@tk0miya tk0miya commented Feb 6, 2022

Feature or Bugfix

  • Bugfix

Purpose

@tk0miya tk0miya added this to the 4.5.0 milestone Feb 6, 2022
@tk0miya tk0miya requested a review from jfbu February 6, 2022 06:07
Named auto numbered footnote (ex. ``[#named]``) that is referred
multiple times was rendered to a question mark.

This calls `\sphinxstepexplicit` for every footnote node that is
referred multiple times.
Copy link
Contributor

@jfbu jfbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed you are right that what was needed was to know which footnotes are multiply referred too, so LGTM!

small nits: The macro \sphinxstepexplicit is now a bit misnamed, let's however stick with its current name. But at some point a comment in texinputs/sphinx.sty may need update like this:

index 4d42199a7..6c9f1606e 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -300,9 +300,9 @@
 % Support scopes for footnote numbering
 \newcounter{sphinxscope}
 \newcommand{\sphinxstepscope}{\stepcounter{sphinxscope}}
-% Explicitly numbered footnotes may be referred to, and for this to be
-% clickable we need to have only one target. So we will step this at each
-% explicit footnote and let \thesphinxscope take it into account
+% Some footnotes are multiply referred-to.  For unique hypertarget in pdf,
+% we need an additional counter.  It is called "sphinxexplicit" for legacy
+% reasons as "explicitly" numbered footnotes may be multiply referred-to.
 \newcounter{sphinxexplicit}
 \newcommand{\sphinxstepexplicit}{\stepcounter{sphinxexplicit}}
 % Some babel/polyglossia languages fiddle with \@arabic, so let's be extra

This extra patch may be postponed to later occaion.

edited: what follows was based on some confused memory, the situation described below with multiple sources may still lead to wrong hyperlinks even with this PR (related #10175).

I have noticed that this PR gives correct hyperlinks even in situation where named footnotes originate in multiple documents, and so may use for example both 1 as footnote mark, which in pdf single document output may be confusing if on same page, but at least with this PR the hyperlink is ok. For example

========== ===
Test [#a]_
========== ===
   1       One
========== ===

.. [#a] Footnote one.

in document doc1.rst and

========== ===
Test [#a]_
========== ===
   1       Two
========== ===

.. [#a] Footnote two.

in doc2.rst, both in toctree of index.rst. In future there is potential using the sphinxscope apparatus in sphinx.sty to create in PDF a disambiguating footnote mark, but at any rate already hyperlink will point to correct footnote, even if on same page in PDF.

@tk0miya
Copy link
Member Author

tk0miya commented Feb 11, 2022

Thank you for reviewing. Updated the comment now.

Let's discuss the problem with multiple sources in #10175.

Thanks as always!

@tk0miya tk0miya merged commit a32d609 into sphinx-doc:4.x Feb 11, 2022
@tk0miya tk0miya deleted the 9529_named_footnotes_in_latex branch February 11, 2022 04:19
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants