Search code examples
latexr-markdownknitrpandocbeamer

figure temporisation in Rmarkdown beamer


Trying Rmarkdown for the first time, I can't find anywhere how to do some basic beamer operations. I'd like for example to make a figure appear after some text in a slide, or replace a figure by another one, still inside a frame. How could I do this:

\only<1>{![](figureA.pdf)}
\only<2>{![](figureB.pdf)}

Can someone please give me the basics of slide temporisation with Rmarkdown?


Solution

  • Beamer has redefined various macros, including \includegraphics, to accept overlay arguments. You can use them in rmarkdown like this:

    ---
    output: 
      beamer_presentation:
        theme: "CambridgeUS"
        keep_tex: true
    
    ---
    
    # test
    
    text
    
    \includegraphics<+>[width=.5\textwidth]{example-image-a}
    \includegraphics<+>[width=.5\textwidth]{example-image-b}