When rendering html documents with rmarkdown there are ways to make a two columns layout, e.g. here
Is there an easy way to render a pdf document with two column layout? Is there an example code somewhere?
When rendering html documents with rmarkdown there are ways to make a two columns layout, e.g. here
Is there an easy way to render a pdf document with two column layout? Is there an example code somewhere?
New pandoc version have made this easier since my original answer. According to pandoc's manual, you can now specify classoptions directly in the YAML front matter:
---
classoption:
- twocolumn
---
The new div notation also allows for inserting two column sections anywhere in the document, working for most formats
:::::::::::::: {.columns}
::: {.column width="40%"}
contents...
:::
::: {.column width="60%"}
contents...
:::
::::::::::::::
You can use the article option twocolumn
to format the whole document in two columns. Add this to your yaml front matter:
---
output:
pdf_document:
pandoc_args: [
"-V", "classoption=twocolumn"
]
---
More succinctly:
---
output:
pdf_document:
classoption: twocolumn
---
Regarding switching between one and two columns modes in pdf the following snippets work for me
To two column mode:
```{r, echo=FALSE, results='asis'}
cat("\\twocolumn")
```
To one column mode:
```{r, echo=FALSE, results='asis'}
cat("\\onecolumn")
```
Credit for this answer found here: https://timmurphy.org/2010/06/23/adding-a-two-column-section-to-a-latex-document/
\begin{minipage}[t]{0.5\textwidth}
First Column Goodies.\\
More First Column Goodies.\\
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
Second Column Goodies.\\
More Second Column Goodies.\\
\end{minipage}
Note: VERY important that there is no space between the /end{minipage} and the next \begin{minipage} (not counting comments). Otherwise LaTeX will not render the columns side by side.
In addition to scoa's answer, in order to give the columns more space you can add a value to the header-includes:
, for example:
---
output:
pdf_document:
...
header-includes:
- \setlength{\columnsep}{18pt}
---
© 2022 - 2024 — McMap. All rights reserved.