Is there a way in Sphinx Myst to link to a footnote in a different document?

231 Views Asked by At

I'm preparing documentation for a project using the Sphinx readthedocs theme and Myst.

What I'd like to be able to do within a Myst file is to link to a footnote in another Myst file. For example, something like:

See {ref}`Footnote %s <example.md/footnote-label>` in the {ref}`examples` page.

It would be nice to have the footnote's number substituted for footnote-label, but I'd settle for some way of putting in a link anchor to a footnote.

I have no problem with including links to section headers, anchors, equations, figures, etc. I also have no problems with footnotes within a given Myst-Markdown file. I'm rendering the documentation in HTML.

If there's a way to do this, it's not in the Myst documentation. I know I could do this by anticipating the name of the rendered HTML file; e.g.,

[this footnote](document-base/example.html#footnote-label) 

but I'd prefer some method by which Sphinx/Markdown would resolve the reference for me.

Edit:

Following Steve's suggestion, I gave it a try. If I had something like this near the top of the document:

I am writing a paragraph that requires a footnote.[^the-footnote]

(my-footnote)=
[^the-footnote]: This is what a footnote looks like.

More stuff...

The link {ref}`my-footnote` would link to just before the "More stuff...", not to the bottom of the page where the footnote was.

2

There are 2 best solutions below

1
On BEST ANSWER

It turns out that this questions was essentially already asked and answered:

Sphinx footnotes across pages or equivalent

I can't do what I'd like to do with footnotes across documents, using either Sphinx or Myst.

2
On

From the documentation of ref:

Labels that aren’t placed before a section title can still be referenced, but you must give the link an explicit title, using this syntax:

:ref:`Link title <label-name>`.

In the file with the footnote, do this:

## Footnotes

(my-footnote)=

[^the-footnote]: This is what a footnote looks like.

In the other file, reference the label:

{ref}`My Title <my-footnote>`.