Xaringan in Rmarkdown: How to remove auto_identifiers in headings

253 views Asked by At

While there seems to be quite a bit of discussion about this (here, here, here), it is not clear how one could remove the section heading auto_identifiers (the "#" that appears after a slide's section header; h1,h2,etc.) from a Xaringan theme in Rmarkdown.

Can this be done within the YAML? (markdown: kramdown seems to have an auto_ids: false addition to the header as shown here)

Can this be done in a custom.css by editing .h1 etc.?

Similar to this post:

If the headers are specified as:

# header1 {#header1id}
## header2
### header3

The resulting HTML:

<h1 id="header1id">header1</h1>
<h2 id="header2">header2</header2>
<h3 id="header3">header3</header3>

But I would prefer:

<h1 id="header1id">header1</h1>
<h2>header2</h2>
<h3>header3</h3>

Obviously, using the html directly works (e.g., <h1>header1</h1>), but it would be great to be able to use the markdown # headers.

For completeness, an example YAML within a Rmarkdown.Rmd Xaringan template:

---
title: "Please Remove the # Anchors"
author: "Begin Er"
date: "Now"
output: 
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts]
    nature: 
      beforeInit: "macros.js"
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
      ratio: "16:9"
---

Thanks!

0

There are 0 answers