2

This is a great answer on how to do a 2-column layout in R-Markdown when rendering PDF.

Basically the answer is 'add the following to the header':

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

But how do I make it three columns or more?

Gorka
  • 1,971
  • 1
  • 13
  • 28
Georgery
  • 7,643
  • 1
  • 19
  • 52

1 Answers1

0

To generate a html file with multiple columns, you could use the CSS grid layout:

---
output: html_document
---

:::: {style="display: grid; grid-template-columns: 20% 50% 20%; grid-column-gap: 5%; "}

::: {}

contents...

:::

::: {}

contents...

:::

::: {}

contents...

:::

::::

If you want to use four (or more) columns:

:::: {style="display: grid; grid-template-columns: pc1% pc2% pc3% pc4%; grid-column-gap: pgap%; "}

Adjust the column size and gap percentages to your needs.

This won't work if you replace html_doument with pdf_document. If you are particularly interested in generating a pdf output, a workaround would be to open the html file with a browser and then printing it to a pdf file.

Gorka
  • 1,971
  • 1
  • 13
  • 28