You can add a new field right before the table of contents in the html template. Follow these instructions to do the following:
- Copy the html template to your .rmd file and change the
$toc$ field to the following:
$if(toc)$ <div id="$idprefix$TOC"> <h1 class="toctitle">$toctitle$</h1> $toc$ </div> $endif$
- Then add the
toctitle and template fields to your RMarkdown file. For instance:
toctitle: "Contents" output: html_document: template: toctitle.html css: custom.css toc: true toc_depth: 3 number_sections: true
This should add a title before your TOC. You can make other changes, for example. change from h1 to another tag and / or use the field class in CSS. If you have problems that you are not using the default template (mathjax will not work), you can change the default style and not add totctitle to another rmd file later should not be a problem.
source share