quarto

How to change the text size in a portion of the body of a pdf document?


Is there a way to change the text size to a section of text when the output is a PDF? In the example below, I would like the hint text to be smaller.

---
title: "Untitled"
format: pdf
---

# Quarto

## Question 1
### Part A

This is a question-

*Hint: This part should be a smaller text.*

This is the answer in regular-sized text.

Solution

  • You can define your own \hint command using LaTeX, e.g.

    include-in-header: 
          text: |
            \newcommand{\hint}[1]{{\tiny \textit Hint: #1}}
    

    makes \hint{...} available, where the enclosed text is italic and tiny. Also possible is \small, \footnotesize and so on, see LaTeX font sizes for examples.

    enter image description here

    ---
    title: "Untitled"
    format: pdf
    include-in-header: 
          text: |
            \newcommand{\hint}[1]{{\tiny \textit Hint: #1}}
    ---
    
    # Quarto
    
    ## Question 1
    ### Part A
    
    This is a question-
    
    \hint{This part should be a smaller text size.}
    
    This is the answer in regular-sized text.