渲染pdf时如何在R markdown中制作2列布局? [英] How make 2 column layout in R markdown when rendering pdf?

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

问题描述

当使用 rmarkdown 呈现 html 文档时,有一些方法可以制作两列布局,例如这里

When rendering html documents with rmarkdown there are ways to make a two columns layout, e.g. here

是否有一种简单的方法可以呈现具有两列布局的 pdf 文档?某处有示例代码吗?

Is there an easy way to render a pdf document with two column layout? Is there an example code somewhere?

推荐答案

自从我最初的回答以来,新的 pandoc 版本使这变得更容易.根据 pandoc 的手册,您现在可以直接在 YAML 前端指定类选项:

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

新的 div 表示法还允许在文档的任何位置插入两个列部分,适用于大多数格式

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

:::
::::::::::::::

原答案

您可以使用文章选项 twocolumn 将整个文档格式化为两列.将此添加到您的 yaml 前端:

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

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

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