Adding a table of contents

Reporting with R Markdown

Amy Peterson

Head of Core Curriculum at DataCamp

Table of contents

Markdown file with toc

Knit file with toc

Reporting with R Markdown

TOC depth

Markdown file with TOC depth of 2

Knit file with TOC depth of 2-

Reporting with R Markdown

Number sections

Markdown file with toc, toc_depth, and number_sections

Knit file with toc, toc_depth, and number_sections

Reporting with R Markdown

Number sections

Markdown file with headers with two and three hashes

Knit file with toc, toc_depth, and number_sections

Reporting with R Markdown

TOC float

Markdown file with toc, toc_depth, and toc_float

Creating an HTML file with toc_float

Reporting with R Markdown

TOC float: collapsed

Markdown file with toc, toc_depth, and toc_float with collapsed false

Creating an HTML file with toc_float with collapsed false

Reporting with R Markdown

TOC float: smooth scroll

Markdown file with toc, toc_depth, and toc_float with collapsed false and smooth_scroll false

Creating an HTML file with toc_float with collapsed false and smooth_scroll false

Reporting with R Markdown

Summary

  • toc
  • toc_depth
    • HTML default: 3
    • PDF default: 2
  • number_sections

HTML

  • toc_float
    • collapsed
    • smooth_scroll
Reporting with R Markdown

Let's practice!

Reporting with R Markdown

Preparing Video For Download...