出于某种原因,rmarkdown和/或pandoc认为添加
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
序言是个好主意。。。显然不是这样。
您可以通过指定图像的高度而不是比例因子来避免这个问题:
---
title: "TITLE"
author: "JS"
subtitle: SUBTITLE
output:
beamer_presentation:
keep_tex: yes
ioslides_presentation: default
fontsize: 14pt
---
# Example
\begin{figure}
\includegraphics[height=4cm]{example-image-duck}
\end{figure}
---
# Add figure via R code
```{r, message = FALSE, warnings = FALSE, eval = TRUE, echo = TRUE}
plot(rnorm(100))
```