Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make 2 column layout in R markdown when rendering pdf?

Tags:

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?

like image 479
rdatasculptor Avatar asked Jan 15 '16 10:01

rdatasculptor


2 Answers

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...  ::: :::::::::::::: 

Original answer

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"     ] --- 
like image 192
scoa Avatar answered Sep 21 '22 00:09

scoa


More succinctly:

--- output:   pdf_document: classoption: twocolumn --- 
like image 29
RTS Avatar answered Sep 20 '22 00:09

RTS