I am making a Beamer presentation and I use pauses between contents of a single slide. I can't figure out how to show a footnote only after a pause.
Here's an example:
---
title: ""
author: ""
date: ""
output:
beamer_presentation
bibliography: test.bib
---
* one argument
\pause
* another argument^[This citation should appear only with point 2: @fargues2006]
# references
with test.bib
:
@article{fargues2006,
title = {The {{Demographic Benefit}} of {{International Migration}}: {{Hypothesis}} and {{Application}} to {{Middle Eastern}} and {{North African Contexts}}},
author = {Fargues, Philippe},
date = {2006},
journaltitle = {World Bank Policy Research Paper},
url = {http://documents.worldbank.org/curated/en/508301468280735279/pdf/wps4050.pdf},
number = {4050}
}
In this example, the footnote should not appear when only the first point is shown, but instead when the second point is shown.
I tried to apply this answer from TeX StackExchange but without success.
How can I do that?
Edit: following @samcarter_is_at_topanswers.xyz's answer, I precise that I would prefer a solution that does not require to switch from markdown to LaTeX in the document depending on whether a slide has both pauses and footnotes. However, I'm okay with using a .tex
file or adding pandoc arguments in YAML (because I think the solution has to be this way, but I may be wrong).
Edit #2: I would like to put references in these footnotes with @citationkey
Also asked on RStudio Community
Edit: update- to include @citationkey
:
The issue is with how pandoc is translating the ^[] into \footnote
in the output tex file.
This in the markdown:
another argument ^[This citation should appear only with point 2: @fargues2006]
Compiles into this in latex:
another argument\footnote<.->{This citation should appear only
with point 2: Fargues (2006)}
In order to get the footnotes to show up only the slides your point appears on you really need this latex translation:
another argument\footnote\only<+->{This citation should appear only with point 2: Fargues (2006)}
In only<+->
, the +
is a special symbol to mean the current overlay.
To get this to work, you can redefine the \footnote
command so when pandoc translates it it actually calls: \only<+->\footnote
.
NOTE:
The the full command is \only<+->\footnote<.->
which could cause the itemized slides to duplicate because there is two pointers to where the footnotes should appear (\only<+->
and <.->
) and since pandoc is auto-inserting one, I am not sure of a way to get rid of that.
This duplication could also be the result of using *
and \pause
and pandoc translating that to each item appearing in its own itemize
environment- which also has setting options for where the footnotes need to appear and again is also a pandoc thing.
I haven't done enough digging to know which of these is the true culprit for the duplicates..But either way, latex should apply the first pointer formatting for the \footnotes
command and the "most local" setting within an environment (i.e. it will take the footnotes over the itemize).. so each duplicate slide so you'll get the proper formatting at least with this method, but you will have to remove duplicates. If someone knows a way to prevent this- I would be interested to hear about it.
To use: Include this at the beginning of your markdown:
\let\oldfootnote\footnote
\renewcommand{\footnote}{\only<+->\oldfootnote}
Your full markdown:
---
title: ""
author: ""
date: ""
output:
beamer_presentation:
keep_tex: true
bibliography: test.bib
header-includes:
- \let\oldfootnote\footnote
- \renewcommand{\footnote}{\only<+->\oldfootnote}
---
* one argument
\pause
* another argument ^[This citation should appear only with point 2: @fargues2006]
\pause
* and another argument ^[This citation should appear only with point 3]
The output: