latexr-markdownbeamer

Slide with a picture on the left and text on the right in a Beamer presentation


I am working with Beamer presentation in R (rmd file). My intention is to have slide which will be divide on two parts. First from left side I want to insert some picture while from left I want to have some text, which will explain picture. Below you can see my code :

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

When I execute this code I received this error :

! 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

I checked path of picture and in is correct in my PC, so obviously something different is problem.

So can anybody help me how to solve this problem ?


Solution

  • The problem is that rmarkdown will automatically start a new frame before it processes your code. This means you would nest a frame within a frame which is not allowed. You could avoid the problem by either closing the automatic frame from rmarkdown before you open yours or you could use rmarkdown syntax instead of normal beamer syntax:

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

    enter image description here