title: Cannot create index for LaTeX/PDF output
body: <p>I followed the <a href="https://bookdown.org/yihui/bookdown/latex-index.html" rel="nofollow noreferrer">bookdown</a> instruction to create the indexing. Although the code ran without error, it was not showing the index in the pdf output. There is also instruction <a href="https://github.com/rstudio/bookdown/issues/149" rel="nofollow noreferrer">here</a>. I must be doing something silly!</p>
  
  <p>The reproducible code is here:</p>
  
  <pre><code>#####################
  ##### index.Rmd #####
  #####################
  
  --- 
  title: "Linear Models using R"
  author: 
  - J Smith
  - ABC Inc
  site: bookdown::bookdown_site
  bookdown::gitbook:
  fontsize: 12pt
  geometry: margin=0.8in
  bookdown::pdf_book:
      template: null
      keep_tex: yes
      toc: yes
  includes:
    in_header:
      - \usepackage{makeidx}
      - \makeindex  
    after_body:
      - \printindex
  documentclass: book
  classoption: openany
  bibliography: [book.bib, packages.bib]
  biblio-style: apalike
  link-citations: yes
  description: "Linear Models using R"
  ---
  
  
  ####################
  ###### 01.Rmd ######
  ####################
  
  # Model
  
  This is an R Markdown\index{rmarkdown} document\index{document}.
  
  This book\index{book} describes linear\index{linear} model.
  
  In this chapter\index{chapter}, we will discuss polynomial\index{polynomial} model.
  
  
  # Index{-}
  
  ####### Error
  ####### \printindex 
  </code></pre>
  
  <p>Just to add clarity, lines with mulitple '#' are comments or file names. Note if I run simple <code>\printindex</code> at the end of the document (commented above), it shows the following error:</p>
  
  <p><code>! Undefined control sequence. \printindex</code></p>
  
  <p>The <code>sessionInfo()</code> is here:</p>
  
  <pre><code>R version 3.4.1 (2017-06-30)
  Platform: x86_64-pc-linux-gnu (64-bit)
  Running under: CentOS Linux 7 (Core)
  
  Matrix products: default
  BLAS: /cm/shared/apps/R/3.4.1/lib64/R/lib/libRblas.so
  LAPACK: /cm/shared/apps/R/3.4.1/lib64/R/lib/libRlapack.so
  
  locale:
   [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
   [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
   [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
   [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
   [9] LC_ADDRESS=C               LC_TELEPHONE=C            
  [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  loaded via a namespace (and not attached):
   [1] Rcpp_0.12.17     bookdown_0.7.15  digest_0.6.15    withr_2.1.2     
   [5] R6_2.2.2         jsonlite_1.5     git2r_0.18.0     magrittr_1.5    
   [9] evaluate_0.11    httr_1.3.1       stringi_1.2.2    curl_3.1        
  [13] rmarkdown_1.10.8 devtools_1.13.4  htmldeps_0.1.1   tools_3.4.1     
  [17] stringr_1.3.1    xfun_0.3         yaml_2.2.0       compiler_3.4.1  
  [21] memoise_1.1.0    htmltools_0.3.6  knitr_1.20.8    
  </code></pre>