title: Rmarkdown Cross-referencing figures don't work
body: <p>So. 
  I want to insert some image files into an Rmarkdown document, auto-generate labels and be able to reference those images from elsewhere in the text. I'm using bookdown, so I start off with </p>
  
  <pre><code>---
  output: 
    html_document:
      toc: true
      number_sections: true
      fig_caption: true
  ---
  ```{r setup, include=FALSE}
  knitr::opts_chunk$set(echo = FALSE)
  library(bookdown)
  ```
  </code></pre>
  
  <p>According to the bookdown <a href="https://bookdown.org/yihui/bookdown/figures.html#fnref6" rel="nofollow noreferrer">manual</a> if I have the following code chunk:</p>
  
  <pre><code>```{r knnPlot, echo=FALSE, fig.cap="Knn Plot"}
      knitr::include_graphics("knn-cs3-gs2.png")
  ```
  </code></pre>
  
  <p>then I should have a label fig:knnPlot automatically generated, because using fig.cap apparently puts R in a figure environment and automatically prepend "fig" to the label. It then tells me I should be able to reference the figure using \@ref(label), or rather, in this case, \@ref(fig:knnPlot)</p>
  
  <p>When I do this however, the text "\@ref(fig:knnPlot)" is output, rather than an actual cross reference. There's no figure label, no numbering. How is this meant to work?</p>
  
  <p>I can't get the hard coding method suggested <a href="https://stackoverflow.com/questions/38861041/knitr-rmarkdown-latex-how-to-cross-reference-figures-and-tables">here</a> to work. Nor can I get the only other option I can find to work, it tells me to install pandoc-crossreference, which leads me down an absurd rabbit hole of installing haskell of all things along with endless dependencies and obscure pointless error messages which lead to spectacularly unhelpful developer forums filled with 6 pages of error logs. </p>