简体   繁体   English

用于 pandoc pdf 输出的标准 R Markdown 中的两列模式

[英]Two-column mode in standard R Markdown for pandoc pdf output

I'm looking for a solution to the RMarkdown 2-column question.我正在寻找 RMarkdown 2 列问题的解决方案。 The columns.sty works great in Beamer but not in article or document mode. column.sty 在 Beamer 中效果很好,但在文章或文档模式下效果不佳。 What I'm looking for is a way to switch from full width to two column text in which the RMarkdown parameters are recognized (minipage doesn't allow this, apparently) and where I can execute a chunk for a plot or table or pander output, and then back again to full width, w/o creating a new page as with \\twocolumn \\onecolumn.我正在寻找的是一种从全宽切换到两列文本的方法,其中 RMarkdown 参数被识别(显然,minipage 不允许这样做),并且我可以在其中为绘图或表格或 pander 输出执行块,然后再次回到全宽,无需像 \\twocolumn \\onecolumn 一样创建一个新页面。 The classoption: twopage approach doesn't work for me for some reason as suggested here . classoption: twopage 方法由于某些原因对我不起作用, 如此处建议的那样 Am I asking too much?我要求太多了吗? Any help with a fully working example would be great!任何对完整工作示例的帮助都会很棒!

Here's an example of the use of the class option 'twocolumn' in the yaml section.这是在 yaml 部分中使用类选项“twocolumn”的示例。 A two column section starts with \\begin{minipage} and ends with \\end{minipage}.两列部分以 \\begin{minipage} 开始,以 \\end{minipage} 结束。 This will produce a two column section but, as far as I can tell, this also creates a latex-only section because RMarkdown parameters (eg # ... for a heading) create an error on rendering to a pdf (that's what I want).这将产生一个两列部分,但据我所知,这也会创建一个仅乳胶部分,因为 RMarkdown 参数(例如 # ... 用于标题)在渲染到 pdf 时会产生错误(这就是我想要的)。

title: "Two column test"
author: "David Stevens"
date: "10/19/2020"
output:
  pdf_document: default
  html_document: default
classoption: twocolumn
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

### Left column  

\begin{minipage}[t]{0.5\textwidth}
First Column Goodies.\\  
More First Column Goodies.\\  
### Left column\\  
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
 Second Column Goodies.\\
 More Second Column Goodies.\\
\end{minipage}

Produces the error产生错误

output file: Two-Column-Tester.knit.md输出文件:两列测试器.knit.md

! You can't use `macro parameter character #' in horizontal mode.你不能在水平模式下使用`宏参数字符#'。 l.81 # ## Left column l.81###左栏

Error: LaTeX failed to compile Two-Column-Tester.tex.错误:LaTeX 无法编译 Two-Column-Tester.tex。 See https://yihui.org/tinytex/r/#debugging for debugging tips.有关调试提示,请参阅https://yihui.org/tinytex/r/#debugging See Two-Column-Tester.log for more info.有关详细信息,请参阅两列测试器.log。 Execution halted执行停止

The line ### Two column renders fine outside the two-column section but when moved inside the two column section throws an error行### 两列在两列部分外呈现良好,但在两列部分内移动时会引发错误

Would you consider work with existing styles?你会考虑使用现有的风格吗? The rticles packages has a large number of those.文章包中有很多。 I by coincidence I just updated the 'gallery' of styles included in that package which you can browse at this link .巧合的是,我刚刚更新了该包中包含的样式“图库”,您可以在此链接中浏览。 There is also one large aggregated gif with all .还有一个包含所有.

We also created the pinp package are derived version of the 'pnas' style in rticles .我们还创建了PinP包中获得的“美国国家科学院院刊”风格的版本rticles I use that in several packages for the vignette.我在小插图的几个包中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM