title: Bookdown: Cross-reference figure in another file
body: <p>I have taken the plunge and am preparing a manuscript for publication entirely in RStudio using bookdown. In the main text I would like to cross-reference figures in a separate supporting information .Rmd file.</p>
  
  <p>Let's say this is my main text file called <code>main.Rmd</code>:</p>
  
  <pre><code>---
  title: "Main text"
  output:
    bookdown::pdf_book:
      toc: no
  ---
  Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
  </code></pre>
  
  <p>Here is the supporting text called <code>supporting.Rmd</code>, and the figure to refer to, saved in the same folder:</p>
  
  <pre><code>---
  title: "Supporting info"
  output:
    bookdown::pdf_book:
      toc: no
  ---
  
  Here is the supporting text.
  
  ```{r supporting-figure}
  plot(cars)
  ```
  </code></pre>
  
  <p>How can I cross-ref <code>supporting-figure</code> in the main text?</p>
  
  <p>I have checked the section on cross-references in Yihui's <a href="https://bookdown.org/yihui/bookdown/cross-references.html" rel="nofollow noreferrer">bookdown manual</a>, but I cannot see how to extend this to cross-references between files.</p>
  
  <p>I also found this question:
  <a href="https://stackoverflow.com/questions/51345405/cross-reference-figure-in-a-separate-rmarkdown-pdf-file/51357211#comment89810076_51357211">Cross-reference figure in a separate Rmarkdown (PDF) file</a>
   but the accepted answer does not work for me (perhaps because I am using bookdown rather than base Rmarkdown?)</p>