4

I have a report (pdf output) where I want to add bibliography, list of figures and list of tables to the appendix. And I want those three elements to appear in the table of content.

I add the bibliography by adding bibliography: bibliography.bib to my yaml header. The list of figures and the list of tables I add with LaTex directly.

My appendix therefore looks like:

# Literature {-}

\listoffigures

\listoftables

This nearly works: bibliography, list of figures and list of tables are rendered correctly.

The only problem is, the table of content does only show an entry Literature. The list of figures and list of tables does not appear.

How can I fix this?


I tried with lof: yes and lot: yes in various places of the yaml header (idea from here as well as with toc_appendix: yes (from the same source)

What am I missing?


My complete header looks like:

---
title: something
header-includes: \usepackage{graphicx} \usepackage{float} \usepackage{xcolor} \usepackage{framed} \usepackage{longtable} \definecolor{shadecolor}{RGB}{240,240,240} \pagenumbering{roman} \usepackage{caption} \captionsetup{font=footnotesize}
output:
  bookdown::pdf_book:
    fig_caption: yes
    highlight: kate
    number_sections: yes
    toc: yes
date: | 
    |  
    | `r format(Sys.time(), '%B %d, %Y')`
documentclass: report
geometry: margin=1in
fontfamily: mathpazo
fontsize: 11pt
bibliography: bibliography.bib
preamble: |
  % Any extra latex you need in the preamble
---
symbolrush
  • 7,123
  • 1
  • 39
  • 67
  • Using `--- output: bookdown::pdf_document2 toc: yes lof: yes lot: yes ---` with each parameter in its own line works fine for me. – Martin Schmelzer Jun 18 '19 at 05:51
  • @MartinSchmelzer: Thx for your reply. That was my first try as well. Weirdly I get an error: `Error in base_format(toc = toc, number_sections = number_sections, fig_caption = fig_caption, : unused arguments (lof = TRUE, lot = TRUE)`. Do you have any idea what might be the problem? – symbolrush Jun 18 '19 at 05:56
  • @MartinSchmelzer: I added my header for completeness. I tried inserting `lof: yes` and `lot: yes` just underneath `toc: yes` without success. I also changed `pdf_book` to `pdf_document2` without success. – symbolrush Jun 18 '19 at 06:18
  • @MartinSchmelzer Strange, I can reproduce the error. Looks like a bug? – Christoph Jun 18 '19 at 11:42
  • The problem ist the document class. If you delete this line, it works. If you need to use the report document class, add `\usepackage[nottoc]{tocbibind}` to your includes. – Martin Schmelzer Jun 18 '19 at 16:02
  • @MartinSchmelzer: Thx again. I still get the same error when I delete the document class line.. any other ideas? – symbolrush Jun 19 '19 at 05:14
  • No. I just tried it again on another machine and I only added the tex package `tocbibind` and I got LoT, LoF and then my section References added to the ToC. – Martin Schmelzer Jun 19 '19 at 07:07
  • @MartinSchmelzer: Thank you so much, I got it to work now! :) I had to add `usepackage{tocbibind}` to the yaml header. Somehow I still have to include the two sections with `\listoffigures` and `\listoftables` in my appendix. (`lof: yes` and `lot: yes` still throw the same error). But that's fine for me. Happy it works. – symbolrush Jun 19 '19 at 07:19

1 Answers1

6

The problem lies with the document class report. I guess that it does not handle the list of tables or list of figures like the article class does.

A simple solution is to add \usepackage[nottoc]{tocbibind} to your document. The package does exactly what you want - it adds both appendix sections to your table of contents. You still have to manually add them at the end of your document using \listoffigures and \listoftables.

Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98