title: How do I get Bookdown to properly knit a PDF with multiple code chunks?
body: <p>I am transitioning to Bookdown from Markdown. Although it seems as though this should be straightforward I am getting an unexpected knit failure once I have added the 3rd (usually) code chunk in a chapter (not index.rmd) file. I have tried using code from the <a href="https://raw.githubusercontent.com/rstudio/tufte/master/inst/rmarkdown/templates/tufte_html/skeleton/skeleton.Rmd" rel="nofollow noreferrer">example code by Allaire and Xie</a> with the same result. The problem does not occur if all the markdown code is in one file i.e. no chapters. Here is the sample code from the index and 1st chapter files. Sorry about the formatting; I'm not sure how to format markdown code in stackoverflow so the 3 back tics consistently show.</p>
  
  <pre><code>---
  classoption: openany # Removes blank pages (Arrgh!!)
  site: "bookdown::bookdown_site"
  output:
    bookdown::tufte_book2: 
      latex_engine: xelatex
  ---
  ```{r setup, include=FALSE}
  library(ggplot2)
  # invalidate cache when the tufte version changes
  knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion("tufte"))
  ```
  </code></pre>
  
  <p>And this is the first chapter code:</p>
  
  <pre><code># Figures
  ## Margin Figures
  
  Images and graphics play an integral role in Tufte's work. To place figures in the margin you can use the **knitr** chunk option `fig.margin = TRUE`. For example:
  
  ```{r fig-margin, fig.margin = TRUE, fig.cap = "MPG vs horsepower, colored by transmission.", fig.width=3.5, fig.height=3.5, cache=TRUE, message=FALSE}
  library(ggplot2)
  mtcars2 &lt;- mtcars
  mtcars2$am &lt;- factor(
    mtcars$am, labels = c('automatic', 'manual')
  )
  ggplot(mtcars2, aes(hp, mpg, color = am)) +
    geom_point() + geom_smooth() +
    theme(legend.position = 'bottom')
  ```
  
  In fact, you can include anything in the margin using the **knitr** engine named `marginfigure`. Unlike R code chunks ```` ```{r} ````, you write a chunk starting with ```` ```{marginfigure} ```` instead, then put the content in the chunk. See an example on the right about the first fundamental theorem of calculus.
  
  ```{marginfigure}
  We know from _the first fundamental theorem of calculus_ that for $x$ in $[a, b]$:
  $$\frac{d}{dx}\left( \int_{a}^{x} f(u)\,du\right)=f(x).$$
  ```
  </code></pre>
  
  <p>It fails here</p>
  
  <pre><code>knitr::kable(
    mtcars[1:6, 1:6], caption = 'A subset of mtcars.'
  )
  </code></pre>
  
  <p>Deleting the code after "It fails here" makes it knit properly for me.</p>
  
  <p><a href="https://www.dropbox.com/sh/f4leteicck5dtgw/AAD7rcJ29vM50jVZ1RcPTVXZa?dl=0" rel="nofollow noreferrer">Dropbox link with scripts, log, and pdf's.</a></p>