gpt4 book ai didi

r - 我可以使用子 .Rmd 中的 YAML 数据作为 pagedown 文档的一级标题吗?

转载 作者:行者123 更新时间:2023-12-02 02:44:37 25 4
gpt4 key购买 nike

我想在我的 pagedown 文档中使用子 rmarkdown 文档作为“章节”,并将该子文档中的 YAML 选项(例如 title:)用作第一级部分标题。理想情况下,子 .Rmd 中的所有部分标题都将更改为低一级。

我尽我最大的努力阅读了 bookdown 和 pagedown 以及 rmarkdown 的广泛而精彩的文档,但一直无法弄清楚如何完成这一点。

父路径:

---
title: Parent Title
output: pagedown::html_paged
---

# Parent First level header

Some text.

```{r, child='child.Rmd'}

child 路径:

---
title: Child Title
---

# Introduction

Some child text.

期望的结果:

---
title: Parent Title
output: pagedown::html_paged
---

# Parent First level header

Some text.

# Child Title

## Introduction

Some Child text.

最佳答案

来自 https://bookdown.org/yihui/bookdown/usage.html :

Each R Markdown file must start immediately with the chapter title using the first-level heading, e.g., # Chapter Title.

您可能能够破解代码以按需要工作,但将章节标题添加为一级标题似乎更容易,然后将所有后续章节标题增加一个级别......例如在正则表达式 (^#+) 上查找/替换。

关于r - 我可以使用子 .Rmd 中的 YAML 数据作为 pagedown 文档的一级标题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56246104/

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