7

Using the default Xaringan CSS, if $math$ is placed in a footnote, it appears to be rendered as inline code, rather than rendering as math. I was not able to find information about this - is this just a natural limitation in Xaringan or remark.js? Or perhaps I am doing something wrong?

See basic example below:

# A Test

- This is a test<sup>1</sup>

.footnote[<sup>1</sup> This includes $\delta+\frac{2}{3}$ math.]

This will render the math between the $$ as if it were between backticks.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
ryansafner
  • 93
  • 3

1 Answers1

7

[UPDATE 17/12/2019] Another way to circumvent this is to replace the maths expression $\delta+\frac{2}{3}$ with \(\delta+\frac{2}{3}\) which bypasses any need for remark.js to convert $ and thus avoiding the bug there.


Yes I noticed this too. I think somehow remark.js is interfering with mathjax but I don't really know. To get around this I use the html code directly instead. So below should work:

# A Test

- This is a test<sup>1</sup>

<span class="footnote"><sup>1</sup> This includes $\delta+\frac{2}{3}$ math.</span>

[UPDATE] The explanation of why this happens can be found here. TL;DR: remark.js removes the brackets necessary for mathjax to detect the maths.

Yihui also provided an alternate hack if the use of .footnote[] is desirable which involves adding the brackets to the inline math code:

.footnote[<sup>1</sup> This includes `\\(\delta+\frac{2}{3}\\)` math.]

Emi
  • 3,514
  • 8
  • 11
  • 2
    Hi Kunoichi Emi, would you help me debug it? :) The JS code to deal with math expressions is here: https://github.com/yihui/xaringan/blob/153684b9a4662903e34c7e8397dca845c2a2be89/inst/rmarkdown/templates/xaringan/resources/default.html#L68-L85 – Yihui Xie Jun 19 '19 at 15:39
  • 2
    You knew how to solve it didn't you Yihui, but you gave me enough hint for me to figure it out myself ;) I have to admit that I had no idea how to solve it but I'm surprised that I actually figured it out after your hint. But my current hack will impact anything code written starting and ending in round brackets - will explain on github issues. – Emi Jun 20 '19 at 04:35
  • 2
    To be honest, I didn't really know what the problem was. I can certainly figure it out by myself, but thought it would be a good exercise for other people (and I have already had too much other work to do). Anyway, thanks again for the investigation: https://github.com/yihui/xaringan/issues/213 – Yihui Xie Jun 20 '19 at 16:23
  • 2
    None of the presented solutions work for me; has something changed? – F. Privé Mar 03 '21 at 06:25
  • The method described by [@YihuiXie](https://stackoverflow.com/users/559676/yihui-xie) in GitHub still works: `.footnote[1 This includes \`\\(\delta+\frac{2}{3}\\)\` math.]` – Crimc Sep 30 '22 at 20:25