Search code examples
rlatexr-markdownmarkdownbeamer

Content of frames disappears when using slide notes in a rmarkdown::beamer_presentation


I generate a LaTex beamer presentation with rmarkdown::beamer_presentation.
When I use slide notes by adding header-includes: \setbeameroption{show notes on second screen} to the YAML header, a lot of content of the presentation disappears: LaTex math, words, tables,

Please see the images below. As can be seen from the second screenshot, the content is "still there", it's just printed in white somehow (for no straightforward reason, see the simple MWE below).

Frames with & Without Slide Notes

MWE_noSlideNotes-withSlideNotes

Frames with Slide Notes: Screenshot to show content "is there" (hidden/in white)

withSlideNotes and highlight

MWE

---
title: "Slide notes in an rmarkdown::beamer_presentation"
output:
  bookdown::pdf_book:
    base_format: rmarkdown::beamer_presentation
    latex_engine: xelatex
    toc: false
    slide_level: 2
header-includes:
  - \usepackage{hyperref}
  - \setbeameroption{show notes on second screen}
---

## table
<!-- ======================================================== -->
\label{FRAME-table-cars}

```{r table, cars, echo = FALSE}
library(kableExtra)
knitr::kable(head(mtcars[, 1:3]), caption = "Table caption")
```
<!-- LaTex label: -->
\captionof{table}{foo}
\label{foo}

\begin{center}
\begin{tiny} 
($\Rightarrow$ See also: \hyperlink{FRAME-plot-pressure}{pressure plot} \hyperlink{FRAME-other-1}{other 1})\linebreak
($\Rightarrow$ and further: \hyperlink{FRAME-other-2}{other 2} \hyperlink{FRAME-other-3}{other 3})
\end{tiny} 
\end{center}

\note{
\textbf{Note frame 1}\\
1 XXXXXXXXXXXXXXXXXXXXXXXXXXX\\
2 XXXXXXXXXXXXXXXXXXXXXXXXXXXA\\
3 XXXXXXXXXXXXXXXXXXXXXXXXXXXAB\\
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXABC\\
}

## Plot
<!-- ======================================================== -->
\label{FRAME-plot-pressure}

```{r plot, echo=FALSE, out.width='66%'}
plot(pressure)
```
<!-- LaTex label: -->
\captionof{figure}{bar}
\label{bar}

\begin{center}
\begin{tiny} 
($\Rightarrow$ See also: \hyperlink{FRAME-table-cars}{table cars} \hyperlink{FRAME-other-1}{other 1})\linebreak
($\Rightarrow$ and further: \hyperlink{FRAME-other-2}{other 2} \hyperlink{FRAME-other-3}{other 3})
\end{tiny} 
\end{center}

\note{
\textbf{Note frame 2}\\
1 XXXXXXXXXXXXXXXXXXXXXXXXXXX\\
2 XXXXXXXXXXXXXXXXXXXXXXXXXXXA\\
3 XXXXXXXXXXXXXXXXXXXXXXXXXXXAB\\
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXABC\\
}

## Other frame 1
<!-- ======================================================== -->
\label{FRAME-other-1}

## Other frame 2
<!-- ======================================================== -->
\label{FRAME-other-2}

## Other frame 3
<!-- ======================================================== -->
\label{FRAME-other-3}

Uncomment header-includes: \setbeameroption{show notes on second screen} to include the slide notes -- whereby the table, the arrows, and the hyperrefs below the figure/table will disappear.


Solution

  • That's a problem with old xelatex versions, just use another engine to avoid the problem.

    If you really need xelatex for some reason, you can upgrade to the texlive 2021 pretest, there the problem is solved.

    ---
    title: "Slide notes in an rmarkdown::beamer_presentation"
    output:
      bookdown::pdf_book:
        base_format: rmarkdown::beamer_presentation
        latex_engine: lualatex
        toc: false
        slide_level: 2
    header-includes:
      - \setbeameroption{show notes on second screen}
    ---
    
    ## table
    <!-- ======================================================== -->
    \label{FRAME-table-cars}
    
    ```{r table, cars, echo = FALSE}
    library(kableExtra)
    knitr::kable(head(mtcars[, 1:3]), caption = "Table caption")
    ```
    <!-- LaTex label: -->
    \captionof{table}{foo}
    \label{foo}
    
    \begin{center}
    \begin{tiny} 
    ($\Rightarrow$ See also: \hyperlink{FRAME-plot-pressure}{pressure plot} \hyperlink{FRAME-other-1}{other 1})\linebreak
    ($\Rightarrow$ and further: \hyperlink{FRAME-other-2}{other 2} \hyperlink{FRAME-other-3}{other 3})
    \end{tiny} 
    \end{center}
    
    \note{
    \textbf{Note frame 1}\\
    1 XXXXXXXXXXXXXXXXXXXXXXXXXXX\\
    2 XXXXXXXXXXXXXXXXXXXXXXXXXXXA\\
    3 XXXXXXXXXXXXXXXXXXXXXXXXXXXAB\\
    4 XXXXXXXXXXXXXXXXXXXXXXXXXXXABC\\
    }
    
    ## Plot
    <!-- ======================================================== -->
    \label{FRAME-plot-pressure}
    
    ```{r plot, echo=FALSE, out.width='66%'}
    plot(pressure)
    ```
    <!-- LaTex label: -->
    \captionof{figure}{bar}
    \label{bar}
    
    \begin{center}
    \begin{tiny} 
    ($\Rightarrow$ See also: \hyperlink{FRAME-table-cars}{table cars} \hyperlink{FRAME-other-1}{other 1})\linebreak
    ($\Rightarrow$ and further: \hyperlink{FRAME-other-2}{other 2} \hyperlink{FRAME-other-3}{other 3})
    \end{tiny} 
    \end{center}
    
    \note{
    \textbf{Note frame 2}\\
    1 XXXXXXXXXXXXXXXXXXXXXXXXXXX\\
    2 XXXXXXXXXXXXXXXXXXXXXXXXXXXA\\
    3 XXXXXXXXXXXXXXXXXXXXXXXXXXXAB\\
    4 XXXXXXXXXXXXXXXXXXXXXXXXXXXABC\\
    }
    
    ## Other frame 1
    <!-- ======================================================== -->
    \label{FRAME-other-1}
    
    ## Other frame 2
    <!-- ======================================================== -->
    \label{FRAME-other-2}
    
    ## Other frame 3
    <!-- ======================================================== -->
    \label{FRAME-other-3}
    

    enter image description here