Is it possible to insert codes (e.g. `r Sys.Date()`) above bookdown gitbook table of content?

125 Views Asked by At

I'd like to include the title, author, and date (which I already specified in the YAML metadata) above the table of content of a bookdown::gitbook document. I want to do this because I'd like to have those three components always visible even when I scroll down. I know that we may add items before the TOC using the HTML tag <li>. However, I use `r Sys.Date()` to get the date in the YAML metadata, and when I use the same thing to insert above the TOC, it shows the literal code and not the date as I wanted. Moreover, the title & author of my document also use R markdown parameters like `r params$title` and `r params$author` (with params values that are passed by an Rscript that calls the render function), and they are also rendered as the literal code. So, I wonder if it is even possible to include code chunks above the TOC. If not, any ideas how I can get what I wanted to do?

This is more or less the YAML metadata that I have now:

---
title: `r params$title`
author: '[`r params$author`](mailto:`r params$author`@domain.com)'
date: "Generated on `r Sys.Date()`"
output:
  bookdown::gitbook:
    config:
      toc:
        before: |
          <li>`r params$title`<br/>`r params$author`<br/>Generated on `r Sys.Date()`</li>
...

Thanks in advance!

0

There are 0 best solutions below