title: Table of Contents not being updated in Rmarkdown pdf creation
body: <p>The TOC of my pdf created from Knit.pdf in Rstudio for some reason is not being updated. It is being created but with some past information (stopped in pag 68 and I´m already on page 99). </p>
  
  <p>Could be something related to cached info? </p>
  
  <p>Below the YAML preamble I´m using and also checked the "include table of contents" options under Knitr Edit R markdown configuration. By the YAML below, also tried to use toc:true below pdf_document and did not work. </p>
  
  <pre><code>title: "My book"
  author: "MyName"
  date: "Mydate"
  documentclass: book
  fontsize: 10pt
  classoption: 
          b5paper
  header-includes:
     - \usepackage{tcolorbox}
     - \usepackage{longtable}
     - \usepackage{sidenotes}
     - \renewcommand{\contentsname}{MyContent}
     - \renewcommand{\chaptername}{MyChapter}
   geometry:
    - tmargin=2cm
    - bmargin=2cm
    - lmargin=2cm
    - rmargin=2cm
  toc: yes
  output: 
    pdf_document:
       fig_caption: yes
       highlight: zenburn
       latex_engine: xelatex
       number_sections: yes
       pandoc_args: --chapters
       toc: yes
       toc_depth: 3
  </code></pre>