rpdflatexknitrquarto

List of Tables and List of Figures in Table of Contents using Quarto book in pdf format


I would like to get List of Tables (lot) and List of Figures (lof) in Table of Contents (toc) a book in the Quarto PDF format. I have the following YAML code in my _quarto.yml file. I'm curious about the approach to achieve this.

project:
  type: book

execute:
  echo: false
  warning: false
  
book:
  title: "Title"
  author: "Author"
  chapters:
    - index.qmd
    - Ch01.qmd
    - Ch02.qmd
    - references.qmd

bibliography: references.bib

format:
  pdf:
    documentclass: scrreprt
    toc: true
    toc-depth: 3
    lof: true
    lot: true

Solution

  • Use the latex package tocbibind. From the package documentation,

    The tocbibind package enables the titles of the Table of Contents, the List of Figures, the List of Tables, the Bibliography and the Index all to be added to the Table of Contents. By default, all of these document elements, if they exist, will be incorporated into the Table of Contents.

    So it will include the title Table of Contents too, which probably you do not want. To disable the inclusion of Table of Contents, use nottoc as classoption.

    project:
      type: book
    
    execute:
      echo: false
      warning: false
      
    book:
      title: "Title"
      author: "Author"
      chapters:
        - index.qmd
        - Ch01.qmd
        - Ch02.qmd
        - references.qmd
    
    bibliography: references.bib
    
    format:
      pdf:
        documentclass: scrreprt
        classoption: nottoc
        toc: true
        toc-depth: 3
        lof: true
        lot: true
        include-in-header: 
          text: |
            \usepackage{tocbibind}
    
    

    And the ToC looks like this now,

    ToC