I would like to place two figures next to each other. It should not be combined into one image or plot, because then I cannot do two separate captions.
Right now it is as follows:
I would like to achieve
Here is my code
---
title: "Untitled"
author: ""
date: "`r Sys.Date()`"
output:
officedown::rdocx_document
---
# Heading 1
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
```{r}
#| echo = FALSE,
#| fig.cap = "Plot 1",
#| fig.width = 2,
#| fig.height = 2
library(ggplot2)
ggplot(tibble::tibble(x = 1:10, y = 1:10), aes(x = x, y = y)) +
geom_line()
```
```{r}
#| echo = FALSE,
#| fig.cap = "Plot 2",
#| fig.width = 2,
#| fig.height = 2
library(ggplot2)
ggplot(tibble::tibble(x = 10:1, y = 10:1), aes(x = x, y = y)) +
geom_line()
```
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
I tried the suggestion for html which is not working in officedown, see https://forum.posit.co/t/how-to-stack-two-images-horizontally-in-r-markdown/18941
Very similar solution to this question - the same method appears to work well with ggplots. Use the multicol section tags build into officedown, as documented here. See the top and the bottom of the code block below.
<!---BLOCK_MULTICOL_START--->
```{r}
#| echo = FALSE,
#| fig.cap = "Plot 1",
#| fig.width = 2,
#| fig.height = 2
library(ggplot2)
ggplot(tibble::tibble(x = 1:10, y = 1:10), aes(x = x, y = y)) +
geom_line()
```
```{r}
#| echo = FALSE,
#| fig.cap = "Plot 2",
#| fig.width = 2,
#| fig.height = 2
library(ggplot2)
ggplot(tibble::tibble(x = 10:1, y = 10:1), aes(x = x, y = y)) +
geom_line()
```
<!---BLOCK_MULTICOL_STOP{widths: [3,3], space: 0.2, sep: false}--->
Results in: