How to make multi-column Layout in R Markdown when rendering PDF?

こ雲淡風輕ζ 提交于 2021-02-10 06:36:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/61724367/how-to-make-multi-column-layout-in-r-markdown-when-rendering-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!