Search code examples
pdflatexr-markdownquarto

How can I add multiple lines in the title of a PDF output in Quarto using RStudio?


I am trying to create a PDF file using Quarto in R. In the title, I want three lines: School Name, Exam (i.e., Annual or Mid-term) and Subject (i.e., Mathematics, Statistics, etc.). All these three elements will be in different lines. So, I tried using the following code.

title: `r paste0("School Name", "\\linebreak ","Annual Exam","\\linebreak ","Mathematics")`

But this is giving me an error when I render the document. So, instead of one backtick, I also tried using three backticks. But still, I could not render the document. Can you help me how I can do this?


Solution

  • Try as the following,

    ---
    title: |
      School Name \
      Annual Exam \
      Mathematics
    format: pdf
    ---
    
    ## Quarto
    
    Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
    
    

    The following also works,

    ---
    title: |
       | School Name 
       | Annual Exam 
       | Mathematics
    format: pdf
    ---
    
    ## Quarto
    
    Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
    
    

    multiline title