How to include image on left side and text on the right side for rmarkdown presentation
Asked Answered
S

3

13

How can this be done in Markdown?

I am using the beamer presentation in Rmarkdown, and I want an image on the left side of a slide and text on the right side of a slide.

Basically, what this does: https://tex.stackexchange.com/questions/165475/figure-next-to-text-in-beamer

But for Markdown not latex.

Sketchbook answered 8/7, 2017 at 21:29 Comment(1)
If someone proposes a solution that works when the output format is .pdf, it would make me a very happy man.Willis
W
13

Use the multicol package:

---
title: "Untitled"
author: "Martin"
date: "7/9/2017"
output: 
  beamer_presentation: 
    keep_tex: yes
header-includes:
  - \usepackage{multicol}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## R Markdow

\begin{multicols}{2}

  \null \vfill
  \includegraphics[width=.3\textwidth]{unnamed.png}
  \vfill \null

\columnbreak

  \null \vfill
  \begin{itemize}
    \item Item 1
    \item Item 2
  \end{itemize}
  \vfill \null
\end{multicols}

enter image description here

Wealthy answered 9/7, 2017 at 11:42 Comment(3)
Do you know how to center the picture and text? Mine appear at the top of the slide so there is black space at the bottomSketchbook
Also is it possible to have the stuff on the right side be an itemized list? I get an execution error when I trySketchbook
Please scroll down people: [this is the correct answer](https://mcmap.net/q/855534/-how-to-include-image-on-left-side-and-text-on-the-right-side-for-rmarkdown-presentation_Selfidentity
W
10

You can do it in Pandoc's way! Refer to the manual for more information.

---
output: beamer_presentation
---

:::: {.columns}
::: {.column width="60%"}
![giraffe](giraffe.jpg)
:::
::: {.column width="40%"}
["Funny giraffe looking at the side"](https://www.flickr.com/photos/8070463@N03/9594476129) by [Tambako the Jaguar](https://www.flickr.com/photos/8070463@N03) is licensed under [CC BY-ND 2.0](https://creativecommons.org/licenses/by-nd/2.0/?ref=ccsearch&atype=rich)
:::
::::

screenshot

Windmill answered 9/10, 2020 at 18:53 Comment(0)
C
3

I would not use the multicol package with beamer, beamer has its own mechanism for columns:

---
output: 
  beamer_presentation:
    theme: "CambridgeUS"
    keep_tex: true

---

# test

\begin{columns}[onlytextwidth,T]
  \begin{column}{.45\linewidth}
    \includegraphics[width=\linewidth]{example-image-duck}
  \end{column}
  \begin{column}{.45\linewidth}
    test
  \end{column}
\end{columns}

enter image description here

Ceremonial answered 29/10, 2019 at 23:3 Comment(1)
@ideus Using hard coded widths is really not a useful suggestion. The columns use relative widths and they will adjust if one changes the aspect ratio or similar. Combining this with hard coded lengths will destroy the layout.Ceremonial

© 2022 - 2024 — McMap. All rights reserved.