Skip to content

Implement LaTeX footnotes using \footnotemark and \footnotetext#32

Merged
jeroen merged 5 commits into
r-lib:mainfrom
yihui:patch-1
Jul 7, 2025
Merged

Implement LaTeX footnotes using \footnotemark and \footnotetext#32
jeroen merged 5 commits into
r-lib:mainfrom
yihui:patch-1

Conversation

@yihui

@yihui yihui commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

This is the best I could achieve with my poor knowledge of C. Ideally, we should render footnotes into \footnote{} in the case of CMARK_NODE_FOOTNOTE_REFERENCE, but I can't figure out how I can get the footnote content from the node there (maybe that's just not possible). I'd very much appreciate help here.

Fixes github/cmark-gfm#314

@jeroen

jeroen commented Oct 14, 2024

Copy link
Copy Markdown
Member

This is the best I could achieve with my poor knowledge of C. Ideally, we should render footnotes into \footnote{} in the case of CMARK_NODE_FOOTNOTE_REFERENCE, but I can't figure out how I can get the footnote content from the node there (maybe that's just not possible). I'd very much appreciate help here.

Could you give some example markdown input with the intended output (to match pandoc or similar), perhaps I can help.

@yihui

yihui commented Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

Sure:

Hello[^1]

[^1]: A footnote.

should generate

Hello\footnote{A footnote.}

Currently I'm generating

Hello\footnotemark[1]

\footnotetext[1]{A footnote.}

which is fine but not ideal.

@jeroen

jeroen commented Jul 7, 2025

Copy link
Copy Markdown
Member

I have lost track of the discussion, sorry :(

It seems indeed upstream cmark-gfm is not actively maintained so we need to do it ourselves.

I can see why it is not ideal but indeed it would be much more complicated to move text content from the footnote reference back to the corresponding footnote mark location. So if you are still interested we can merge this solution.

@jeroen jeroen merged commit 6c29d2c into r-lib:main Jul 7, 2025
17 checks passed
@jeroen

jeroen commented Jul 7, 2025

Copy link
Copy Markdown
Member

commonmark 2.0.0 is now on cran.

@yihui yihui deleted the patch-1 branch October 30, 2025 15:21
yihui added a commit to yihui/litedown that referenced this pull request Oct 30, 2025
…n merged

a latex footnote no longer has to be one paragraph, or must use numeric IDs
@yihui

yihui commented Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

Perfect! Thanks!

In {litedown}, I converted \footnotemark[x] and \footnotetext[x]{*} to \footnote{*}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement footnotes for LaTeX output

2 participants