在 Beamer 演示文稿中左侧显示图片、右侧显示文本的幻灯片

问题描述 投票:0回答:1

我正在使用 R 中的 Beamer 演示文稿(rmd 文件)。我的目的是让幻灯片分为两部分。首先,从左侧我想要插入一些图片,而从左侧我想要一些文本,这将解释图片。下面你可以看到我的代码:

---
title: "Herding"
author:
  - Loana
institute:
  - Supervised by
  - University
date: Academic year 2017-2018
output:
  beamer_presentation:
    incremental: false
    theme: "Frankfurt"
    colortheme: "beaver"
    toc: true
    slide_level: 3
    keep_tex: true
classoption: aspectratio=169
header-includes:
  - \AtBeginSubsection{}
---


\begin{frame}{Your New Slide Title}

\begin{columns}
\begin{column}{0.5\textwidth}
% Left side: Insert your image here
\includegraphics[width=\textwidth]{my_image.png}
\end{column}

\begin{column}{0.5\textwidth}
% Right side: Insert your text here
\begin{itemize}
\item Point 1
\item Point 2
\item Point 3
\end{itemize}
\end{column}
\end{columns}

\end{frame}

当我执行此代码时,我收到此错误:

! Extra }, or forgotten \endgroup.
\endframe ->\egroup 
                    \begingroup \def \@currenvir {frame}
l.126 \end{frame}

Error: LaTeX failed to compile template.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See template.log for more info.
Execution halted

我检查了图片的路径,并且在我的电脑中是正确的,所以显然有问题。

那么有人可以帮我解决这个问题吗?

r beamer
1个回答
0
投票

问题是 rmarkdown 在处理你的代码之前会自动启动一个新框架。这意味着您将在不允许的框架内嵌套框架。您可以通过在打开 rmarkdown 之前关闭自动框架来避免此问题,或者可以使用 rmarkdown 语法而不是正常的 beamer 语法:

---
title: "Herding"
author:
  - Loana
institute:
  - Supervised by
  - University
date: Academic year 2017-2018
output:
  beamer_presentation:
    incremental: false
    theme: "Frankfurt"
    colortheme: "beaver"
    toc: true
    slide_level: 3
    keep_tex: true
classoption: aspectratio=169
header-includes:
  - \AtBeginSubsection{}
---

## Your New Slide Title

\begin{columns}
\begin{column}{0.5\textwidth}
% Left side: Insert your image here
\includegraphics[width=\textwidth]{example-image-duck}
\end{column}

\begin{column}{0.5\textwidth}
% Right side: Insert your text here
\begin{itemize}
\item Point 1
\item Point 2
\item Point 3
\end{itemize}
\end{column}
\end{columns}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.