sphinx
sphinx copied to clipboard
Using links to other chapters in the tablecaption does not working in PDFs
Describe the bug
When I use a link in the tablecaption to another chapter in the document, the link doesn't work in the PDF. In the *.tex file the caption looks like this: \sphinxcaption{To find the tablecaption see Title}\label{\detokenize{index:id2}}
When I change it to this: \sphinxcaption{To find the tablecaption see \hyperref[\detokenize{index:title}]{\sphinxcrossref{\DUrole{std,std-ref}{Title}}}}\label{\detokenize{index:id2}} the link is working.
How to Reproduce
For index.rst and conf.py see: tablecaption.zip
Environment Information
Platform: win32; (Windows-10-10.0.19045-SP0)
Python version: 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)])
Python implementation: CPython
Sphinx version: 7.2.6
Docutils version: 0.18.1
Jinja2 version: 3.1.2
Pygments version: 2.16.1
Sphinx extensions
No response
Additional context
No response
This originates in latex.py code which deliberately prevents the internal reference in the title caption to be properly treated, see the two if not self.in_title
https://github.com/sphinx-doc/sphinx/blob/e976059fd6ab49b1c2784445d7095c9287897724/sphinx/writers/latex.py#L1738-L1762
I don't know (at this time) the rationale for this exclusion
could be that the in_title flag is too generic. Immediate fix would be to add a in_table_title and allow handling of internal (and external?) uri's then in above displayed code, while checking in_table_title
better would be to understand exactly where the processing of internal (or external?) references needs to be prevented and document why; at this stage I don't know. Will tag this as "help wanted".
I'm not sure I'll have time for that until I resolve #11285 so I'll also add an "expert" tag because it requires someone quite familar with the internal flow.