2

I have been trying to render my thesis with the bibliography added to the TOC. After reading bookdown documentation carefully I have come to the conclusion that I must do the following:

bookdown::render_book(input = "index.Rmd",output_format = "bookdown::pdf_book", toc_bib = TRUE)

However, "unused argument" error is thrown in the console when I try to use it. Now, the documentation says that the third argument of render_book is the dots (i.e. ...) argument and that it gets passed to output_format, so it should work.

I'm confused here, why doesn't it work?

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Adrian
  • 755
  • 9
  • 17
  • Have you tried `list(toc_bib = TRUE)`? – Frans Rodenburg Jul 26 '18 at 05:25
  • Yep. It says: `Error in dirname(output_file) : a character vector argument expected` – Adrian Jul 26 '18 at 17:27
  • Well then, you can turn it into a character vector with quotation marks, like this: `bookdown::render_book(input = "index.Rmd",output_format = "bookdown::pdf_book", "toc_bib = TRUE")`. – Frans Rodenburg Jul 26 '18 at 18:44
  • No, I'm afraid that won't work. `Error: Failed to compile toc_bib = TRUE.tex. See toc_bib = TRUE.log for more info.` It treats it like a new tex file. – Adrian Jul 26 '18 at 19:16
  • Interesting, how about changing the second argument to `output_format = "bookdown::pdf_book(toc_bib = TRUE)"`? – Frans Rodenburg Jul 26 '18 at 22:26
  • Just to comment, I did manage to add the bibliography to TOC by adding `\addcontentsline{toc}{chapter}{Bibliography}` to the markdown document. However this feels like a "hack" and not a proper answer to my question (why is the high level function provided by the bookdown package not working) so I still leave this open. – Adrian Jul 28 '18 at 18:23

2 Answers2

1

The following works for me:

bookdown::render_book("index.Rmd", "bookdown::pdf_book", output_options=list(toc_bib = TRUE))
Emi
  • 3,514
  • 8
  • 11
0

You can also add to the YAML in your thesis.Rmd file

header_includes:
- \usepackage[nottoc,numbib]{tocbibind}