How make 2 column layout in R markdown when render

2019-02-06 12:09发布

问题:

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?

回答1:

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"
    ]
---


回答2:

More succinctly:

---
output:
  pdf_document:
classoption: twocolumn
---


回答3:

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