Adding Index for Latex/pdf output

I would like to add an "Index" page after the last page of the book. Followed the example from stackoverlfow, but I'm still not able to see the Index after the last page of the book. Here are my YAML, include_header.tex and after_hoxy.tex configuration.

title: |
!(fig/wellness_fiveO.png)
Title goes here
author: "AG"
date: "4/12/2021"
site: bookdown::bookdown_site
fontsize: 12pt
geometry: margin=0.8in
output:
bookdown::pdf_book:
template: null
keep_tex: yes
toc: yes
includes:
after_body: after_body.tex
in_header: include_header.tex
documentclass: book

include_header.tex

\usepackage{makeidx}
\makeindex

after_body.tex

\printindex

This is documented in bookdown book:

It works fine if you try it on the demo book:

bookdown::pdf_book:
  includes:
    in_header: preamble.tex
    after_body: after_body.tex
  keep_tex: yes

Hint: check the indentation in your YAML just in case.

Why do you deactivate the template ?

1 Like

Thanks for responding. Looked at the documentation you've suggested, and thought I followed the instructions. I pasted both the .tex files I used, is anything else missing? I added another file preamble.tex and edited into index.Rmd YAML. Still not able to generate the Index?

The indentation got messed up when pasted it here, but it looks like this.

output:  
  bookdown::pdf_book:
    toc: yes
    includes:
      in_header:  preamble.tex
      after_body: after_body.tex
    keep_tex: yes

Is setting the template a requirement? I saw other example where it was set to null. What should it be, if null is NOT ok.

Thanks again,

The default template should be ok unless you want to use a specific one.

It works for me when I try with GitHub - rstudio/bookdown-demo: A minimal book example using bookdown : do you manage to make it work with the demo ?

I don't know if you have anything specific with your project that would prevent it to work correctly.

It is a vanilla demo book. Nothing complicated. I was testing pdf_book and index tables. pdf_book compiles fine without the index at the end.

I am suspecting .tex files are not digested properly, somehow ( I have very limited Latex know how).

Question I have is this: if I have the YAML set right, can you take a look at the two .tex files and let me know if they are ok as they are, or what else is missing? I just copied the example from the book URL you sent, and stack overflow from @emitanaka posted answer as stated here.

Thanks again,

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.