sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.56k stars 2.12k forks source link

Multiple labels inside math directives #12379

Open tuncbkose opened 5 months ago

tuncbkose commented 5 months ago

Is your feature request related to a problem? Please describe. I'd like to label and refer to individual lines inside math directives.

Describe the solution you'd like Something like a :labels: option discussed here could work.

Describe alternatives you've considered I've tried thinking of sufficiently good workarounds, but nothing will work as well as a proper solution in Sphinx. I'm working on a document where both the HTML and LaTeX outputs matter and I couldn't devise a band-aid solution that works for both. But if one cares only about one of them, for example HTML, one could probably label/tag manually with LaTeX, and refer to them with {math}`\eqref{...}`.

tuncbkose commented 5 months ago

I was looking around to find the relevant part of the code, which seems to be patches.py.

The current behavior is due to the reference targeting the entire math_block. In order to label individual lines, I imagine one needs to break the math_block into pieces.

ThoreWietzke commented 4 months ago

+1 I currently convert a latex manual to sphinx, so an online documentation as well as a pdf can be generated. In this document I have a rather big equation with multiple lines which all are referenced inside the text.