From 28f46cae0be54bd6a9f7ee3637d9b33d3e503130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Sun, 25 Aug 2024 12:09:42 +0200 Subject: [PATCH] LaTeX: allow hyperlinks from inside titles --- sphinx/texinputs/sphinxlatexstyletext.sty | 5 +++-- sphinx/writers/latex.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sphinx/texinputs/sphinxlatexstyletext.sty b/sphinx/texinputs/sphinxlatexstyletext.sty index d083cd96a83..3f29e1d1813 100644 --- a/sphinx/texinputs/sphinxlatexstyletext.sty +++ b/sphinx/texinputs/sphinxlatexstyletext.sty @@ -56,8 +56,9 @@ \newenvironment{sphinxlegend}{\par\small}{\par} % reduce hyperref "Token not allowed in a PDF string" warnings on PDF builds \AtBeginDocument{\pdfstringdefDisableCommands{% -% all "protected" macros possibly ending up in section titles should be here -% TODO: examine if \sphinxhref, \sphinxurl, \sphinnolinkurl should be handled + \def\sphinxurl {\url}% + \def\sphinxnolinkurl {\nolinkurl}% + \let\sphinxhref \@secondoftwo \let\sphinxstyleemphasis \@firstofone \let\sphinxstyleliteralemphasis \@firstofone \let\sphinxstylestrong \@firstofone diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 00e8db942a2..413c437c3e6 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1811,7 +1811,8 @@ def visit_reference(self, node: Element) -> None: uri = node.get('refuri', '') if not uri and node.get('refid'): uri = '%' + self.curfilestack[-1] + '#' + node['refid'] - if self.in_title or not uri: + if not uri: + print(node) self.context.append('') elif uri.startswith('#'): # references to labels in the same document