Skip to content

Commit

Permalink
LaTeX: workaround a memoir class compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbu committed Apr 16, 2022
1 parent a1d9127 commit 2b6e42a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sphinx/texinputs/sphinxpackagefootnote.sty
Expand Up @@ -194,6 +194,9 @@
% -- Sphinx specific:
% currently commented out due to
% https://github.com/sphinx-doc/sphinx/pull/10191#issuecomment-1038807448
% Memo: memoir class detection of successive footnote marks (to separate them
% by commas) is broken by \refstepcounter and also by \label, and some
% mitigation such as in \sphinxfootref would be needed
% \global\let\spx@saved@thefnmark\@thefnmark
% % this is done to access robustly the page number where footnote mark is
% \refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
Expand Down Expand Up @@ -394,16 +397,20 @@
\def\spx@footrefHref {#4}%
}%
\def\sphinx@footmark@getpage #1#2#3\relax{%
\def\spx@footmarkpage{#2}%
\edef\spx@footmarkpage{#2}%
}%
\protected\def\sphinxfootref#1{% #1 always is explicit number in Sphinx
\spx@opt@BeforeFootnote
\refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
% each of \refstepcounter and \label interferes with memoir class detection
% of successive footnote marks, so we move them to inside \@makefnmark
\let\spx@saved@makefnmark\@makefnmark
\ltx@ifundefined{r@\thesphinxscope.footnote.#1}%
{\gdef\@thefnmark{?}}% on first LaTeX run
{\gdef\@thefnmark{?}% on first LaTeX run
\refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
}%
{\sphinx@xdef@thefnmark{#1}% also defines \spx@footrefHref
\def\@makefnmark{% will be used by \H@@footnotemark
\refstepcounter{sphinxfootnotemark}\label{footnotemark.\thesphinxfootnotemark}%
\hyper@linkstart{link}{\spx@footrefHref}%
\spx@saved@makefnmark
\hyper@linkend
Expand Down

0 comments on commit 2b6e42a

Please sign in to comment.