gpt4 book ai didi

r - 仅将 pandoc_args 应用于 rmarkdown 文档的一部分——例如两列

转载 作者:行者123 更新时间:2023-12-04 17:49:23 25 4
gpt4 key购买 nike

有没有一种方法可以使用 rmarkdown 创建一个输出,该输出只有两列用于页面的部分?也就是说,我想要一个标题和一些横跨整个页面的文本,但数字仍以列格式保留。考虑下面的示例,其中列设置为 2,但标题保留在那里。

更新

我使用 \twocolumn 解决方案更接近这里,但随后创建了一个新的空白页面。

---
title: "twocol_test"
author: "test"
output: pdf_document
---

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

## This header should stretch across the whole page
Then this text should also not be in a column. But then the figures below should be organized into two columns:

\twocolumn

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

\onecolumn


```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

更普遍的问题是如何将 pandoc arg 仅应用于 .Rmd 文件的一部分?

最佳答案

我无法完全弄清楚这一点,但发现了一些对我的目的有用的东西,它涉及将参数传递给跨越两列的标题。不完美,但这会起作用:

---
output:
pdf_document:
pandoc_args: [
"-V", "classoption=twocolumn"
]
params:
test:
value: test
set_title: test_title
---

---
title: `r params$set_title`
---

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

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

```{r}
plot(iris$Sepal.Length, iris$Sepal.Width)
```

关于r - 仅将 pandoc_args 应用于 rmarkdown 文档的一部分——例如两列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46227063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com