在 rmarkdown::beamer_presentation 中使用幻灯片注释时框架内容消失

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

我用 rmarkdown::beamer_presentation 生成一个 LaTex beamer presentation
当我通过向 YAML header 添加 header-includes: \setbeameroption{show notes on second screen} 使用幻灯片注释时, 演示文稿的很多内容都消失了 : LaTex 数学、单词、tables、

请看下面的图片。从第二个屏幕截图可以看出,内容“仍然存在”,只是以某种方式打印成白色(原因不明,请参见下面的简单 MWE)。

带和不带幻灯片注释的帧

带幻灯片注释的框架:显示内容“存在”的屏幕截图(hidden/in 白色)

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}

取消注释 header-includes: \setbeameroption{show notes on second screen} 以包括幻灯片注释 -- table、箭头和 figure/table 下方的超级引用将消失。

这是旧版 xelatex 的问题,换个引擎就可以避免了。

如果你因为某些原因确实需要xelatex,你可以升级到texlive 2021预测试,问题就解决了。

---
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}