I would like to include a footnote within a figure caption in an R markdown report rendered to both PDF and HTML (report is based on bookdown
/thesisdown
/huskydown
).
The ideal would be to use text references:
(ref:foo-footnote) Text in the footnote.
Can span multiple lines, but has to start on the line of the text reference.
(ref:foo-caption) My text with a footnote.^[(ref:foo-footnote)]
What I tried
---
title: "Footnote in Caption"
author: "Test"
output: html_document
#output: pdf_document
---
## Figure with caption which includes a footnote
<!-------------------------------------------------------------------->
<!-- Reference the figure "by number" as usual with \@ref(fig:foo) -->
<!-- Reference the figure "by name" by adding an anchor above the figure: -->
<!-- \hypertarget{fig:foo}{} -->
<!-- which can be referenced by: -->
<!-- [my linked text](#fig:foo) -->
(ref:foo-caption) My caption^[Footnote text.].
(ref:foo-scaption) My short caption
```{r foo, echo=FALSE, out.width='100%', fig.align = "center", fig.cap='(ref:foo-caption)', fig.scap='(ref:foo-scaption)'}
knitr::include_graphics(paste0(fig_path,"foo.png"), auto_pdf = TRUE)
# if auto_pdf = TRUE: includes PDF version of figure if available in same folder
```