【问题标题】:Adding table of content with bookdown::html_document2 in Rstudio在 Rstudio 中添加带有 bookdown::html_document2 的目录
【发布时间】:2018-10-03 18:47:33
【问题描述】:

我正在使用 Rstudio 构建bookdown::html_document2,但我似乎无法使用 Rstudio 添加目录。

我发现了这个相关的问题 (Bookdown: TOC with html_document2),但是当他们使用命令行时,我使用 Rstudio 的 Knit 按钮编织我的文档。就我而言,它会产生错误:

Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 4, column 33
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous>
Execution halted

要重现错误,请尝试:

---
title: "main title"
author: "Me"
date: "September 26, 2018"
output: bookdown::html_document2:
  toc=TRUE
---


# title 1

# tt

# rr 

## rrr

在 Rstudio 中点击Knit

知道如何让它工作吗? 谢谢

【问题讨论】:

    标签: r rstudio r-markdown bookdown


    【解决方案1】:

    你需要花更多时间学习the YAML syntax

    ---
    title: "main title"
    author: "Me"
    date: "September 26, 2018"
    output:
      bookdown::html_document2:
        toc: true
    ---
    
    
    # title 1
    
    # tt
    
    # rr 
    
    ## rrr
    

    【讨论】:

    • 请考虑将其转变为不仅仅是“阅读手册”的答案。您可以添加一些上下文,例如“在调用 output 之后,每个新的输出类型都应该在自己的行上。您还需要小心缩进。您可以找到更多 here。这就是您的方式将实现它:...`。
    • @AndyClifton 很好的建议!请随时编辑我的答案(有时我只是匆忙输入答案,我绝对同意你的看法,应该改进这个特定的答案)。非常感谢!
    • 很难找到这个问题的答案。这个答案以及 YAML 语法建议是完美的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多