1

I am trying to create an automated report in rmarkdown for business partners and I am a bit stuck on how to alter the table of contents.

Essentially, I would like the table of contents to have a different font family (Gotham Light) from the primary document font (Gotham Book), and I would also like to make it smaller than the default font size.

Is there an easy and quick way to do this in the YAML settings at the top of the R Markdown file?

Here are the YAML settings:

title: "Report Title"
author: "Authors"
date: 'Date'
output: 
  pdf_document:
    latex_engine: xelatex
    toc: true
    toc_depth: 1
header-includes:
  - \usepackage{fontspec}
  - \setmainfont{Gotham Book}
  - \usepackage{booktabs}
  - \usepackage[tocflat]{tocstyle}
  - \usetocstyle{standard}
---
  • Do you want the heading for the TOC also to be in a different font? Making the entries a different font is simple. – Alan Munn Jun 28 '18 at 14:34
  • 1
    No, I would like the TOC heading and entries to be in the same font, but one that is different from the body of the report. Ideally I would also adjust the heading and entry fonts to be slightly different sizes. – Randall Helms Jun 28 '18 at 14:46
  • Can you provide a complete MWE? Just use some built in dataset, make two graphs, put some short text inbetween. I guess rather few people have a standard MWE ready of their own and even fewer will write one just to answer your question. Have you read the rmarkdown and knitr documentation? Do you even use knitr or what's the setup? I hear the developer is quite open for suggestions and new ideas. I don't have a system handy right now, so I'm afraid I can't be of more help than this atm. – thymaro Jun 30 '18 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.