Traditionally there are two main ways to customize R Markdown output formats: one is to use the options of an existing output format, e.g., set toc: true for html_document; the other is to define a new output format function based on rmarkdown::output_format(), which usually requires you to develop an R package because that’s the best place to host the function.

The first way can be limited—you can only customize the things that are given to you. The second way gives you …