渲染PDF时如何在R Markdown中制作多列布局? [英] How to make multi-column Layout in R Markdown when rendering PDF?

查看:74
本文介绍了渲染PDF时如何在R Markdown中制作多列布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个关于如何在渲染 PDF 时在 R-Markdown 中进行 2-column 布局的好答案.

基本上答案是将以下内容添加到标题中":

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

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

但是我如何使它三列或更多?

推荐答案

要生成多列的 html 文件,可以使用 CSS 网格布局:

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.

如果您将 html_doument 替换为 pdf_document,这将不起作用.如果您对生成 pdf 输出特别感兴趣,一种解决方法是使用浏览器打开 html 文件,然后将其打印为 pdf 文件.

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.

这篇关于渲染PDF时如何在R Markdown中制作多列布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆