How to add footnotes to GitHub-flavoured Markdown?

前端 未结 10 1023
夕颜
夕颜 2021-01-29 17:21

I am just trying to add footnotes in my GitHub Gist, but it doesn\'t work:

Some long sentence. [^footnote]

[^footnote]: Test, [Link](https://google.com).


        
相关标签:
10条回答
  • 2021-01-29 18:00

    This works for me:

    blablabla [<sup>1</sup>](#1) blablabla

    footnotes: reference to blablabla <a class="anchor" id="1"></a>

    0 讨论(0)
  • 2021-01-29 18:04

    Expanding a little bit on the previous answer, you can make the footnote links clickable here as well. First define the footnote at the bottom like this

    <a name="myfootnote1">1</a>: Footnote content goes here
    

    Then reference it at some other place in the document like this

    <sup>[1](#myfootnote1)</sup>
    
    0 讨论(0)
  • 2021-01-29 18:07

    Here's a variation of Eli Holmes' answer that worked for me without using latex:

    Text<span id="a1">[¹](#1)</span>
    
    <span id="1">¹</span> Footnote.[⏎](#a1)<br>
    

    Example

    0 讨论(0)
  • 2021-01-29 18:14

    I used a variant of Mateo's solution. I'm using this in Rmd files written in github flavored markdown (gfm) for a Jekyll powered website but the same Rmd files are being used to produce pdfs in various contexts. The Rmd files are math heavy and the math is displayed with MathJax on the website. So I needed a solution that works with gfm that is processed via Jekyll, works with pandoc->pdflatex, and is compatible with MathJax.

    snippet from Rmd file (which is gfm)

    Here is a paragraph with an footnote <span id="a1">[[1]](#f1)</span>.
    
    Footnotes
    =========
    
    1. <span id="f1"></span> This is a footnote. [$\hookleftarrow$](#a1)
    

    $\hookleftarrow$ is latex, which works for me since I always have MathJax enabled. I use that to make sure it shows up correctly in my pdfs. I put my footnotes in square brackets because superscript is confusing if I am putting a footnote on some inline math.

    Here it is in action: https://eeholmes.github.io/posts/2016-5-18-FI-recursion-1/

    These notes can be put anywhere in the Rmd. I am putting in a list at the end so they are technically endnotes.

    0 讨论(0)
提交回复
热议问题