Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Set different width for columns in a two-columns layout R markdown pdf document

$
0
0

I have to generate a pdf from a R markdown document, and the layout should be divided in two different columns. I managed to split the layout in two columns through the multicol package following these instructions. My problem is that now I don't know ho to specify different widths for the two columns, because each of them automatically occupy he 50% of the available space. Below some reproducible code:

---
output:
  pdf_document:
    latex_engine: xelatex
header-includes:
  - \usepackage{multicol}
  - \newcommand{\btwocol}{\begin{multicols}{2}}
  - \newcommand{\etwocol}{\end{multicols}}
classoption:
  - landscape
  - a4paper
---

```{r setup, include=FALSE}
library(ggplot2)

knitr::opts_chunk$set(echo = TRUE)
```

\btwocol

```{r}
mtcars[1:10, 1:10]
```

\columnbreak

```{r}
ggplot(data = mtcars,
       aes(x = mpg,
           y = cyl))
```

\etwocol

Moreover, it seems that with this solution the elements inside the two columns must have the same height, otherwise some blank space is left before one of the outputs.

Thanks!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>