Search code examples
rpdffooterquarto

Add author and data in footer in Quarto to Pdf with .tex


From a Header and footer in quarto qmd to pdf I learned it is best to use scrlayer-scrpage when wanting a footer:

---
title: "Untitled"
author: "Me"
date: "this day"
format: 
  pdf:
    include-in-header: 
      text: |
        \usepackage{scrlayer-scrpage}
        \rohead{Header text}
        \lofoot{Footer text}  
---

How could I add the author and the date to the footer (left-aligned)? And what would I add to have the pagenummber at footer in bottom-right? Thanks!

I am looking for some code that extracts the author and the date from the YAML, my final code will be living in a template.tex file.


Solution

  • Try the following,

    ---
    title: "Untitled"
    author: "Me"
    date: today
    format: 
      pdf:
        include-in-header: 
          text: |
            \usepackage{scrlayer-scrpage}
            \usepackage{titling}
            \clearpairofpagestyles
            \lefoot*{\theauthor\hspace{2mm}\thedate}  
            \lofoot*{\theauthor\hspace{2mm}\thedate}
            \refoot*{\pagemark}
            \rofoot*{\pagemark}
    ---
    
    
    ```{r}
    #| echo: false
    #| results: asis
    cat(stringi::stri_rand_lipsum(20), sep = "\n\n")
    ```
    

    To understand how \lefoot, \lofoot, \refoot, \rofoot works, please read through the KOMA-Script manual, from p.265 to p.268.