Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将标题添加到R降价目录_R_R Markdown - Fatal编程技术网

如何将标题添加到R降价目录

如何将标题添加到R降价目录,r,r-markdown,R,R Markdown,是否可以为R标记文档生成的TOC添加标题 具体来说,我现在有这样的东西: --- title: "The Rebel Base Locations" author: "Darth Vader" date: "A long time ago in a galaxy far far away" output: html_document: css: custom.css toc: true toc_depth: 3 number_sections: true -

是否可以为R标记文档生成的TOC添加标题

具体来说,我现在有这样的东西:

---
title: "The Rebel Base Locations"
author: "Darth Vader"
date: "A long time ago in a galaxy far far away"
output: 
  html_document:
    css: custom.css
    toc: true
    toc_depth: 3
    number_sections: true
---

我想要的是TOC有一个名为“Contents”的标题。我可以使用一些css将其向左推。

您可以在html模板的目录前添加一个新字段。下面,请执行以下操作:

  • 将html模板复制到.rmd文件中,并将
    $toc$
    字段更改为如下内容:

  • 这应该在TOC之前添加标题。您可以进行其他修改,例如从
    h1
    更改为另一个标记和/或使用CSS上的字段类。如果您在不使用默认模板时遇到问题(mathjax不起作用),您可以更改默认样式,以后不将
    totcitle
    添加到其他rmd文件应该不会有问题。

    @Mox,这几乎可以起作用,但我收到一条警告:“mathjax在不使用rmarkdown“default”模板时不使用包含的self_。”--问题是我需要MathJax!如果您需要MathJax,我认为最好的选择是编辑原始模板。这个小的添加应该不是问题。当toc_浮动时可能:真的?怎样
    $if(toc)$
    <div id="$idprefix$TOC">
    <h1 class="toctitle">$toctitle$</h1>
    $toc$
    </div>
    $endif$
    
    toctitle: "Contents"
    output: 
      html_document:
        template: toctitle.html
        css: custom.css
        toc: true
        toc_depth: 3
        number_sections: true