Cross referencing and other Bookdown essentials

There are a few things that I continually need to lookup how to do in R’s Bookdown

Cross Referencing

I am constantly forgetting how to cross-reference in bookdown and rmarkdown. Below are some options for cross-referencing in bookdown and rmarkdown documents

Bookdown

Bookdown’s referencing system is extensive. Though it can run into some trouble if sections are explicitly unnumbered using {-}.

<!--  the info in curly brackets provides a tag to link to  -->
## This is a subsection {#my-sub-section}  
... 
Later in the text I can reference \@ref(my-sub-section) 

For all the deals see: https://bookdown.org/yihui/bookdown/cross-references.html

Rmarkdown / markdown

This method works when bookdown is not installed… though it does require some basic html coding

Step 1: declare an anchor point

This will create a point that can be referenced. Note that this can be placed anywhere in the document. Where bookdown above does this for sections this has more flexibility in being anywhere in the document.

<!-- note:   name=   --->
<a name="my-point-to-reference"></a>

Step 2: Call the achor

Here are two options

Markdown
[Link to](#my-point-to-reference)
HTML
<a href="#my-point-to-reference">Link here</a>

Insert an Image – including figure reference

"'{r SomeFigure, fig.caption = "Some caption here"}
knitr::include_graphics("images/knit-logo.png")
"'

To reference the figure later use: \@ref(fig:SomeFigure) – note that this refers the rmarkdown chunk label and is prefixed by fig:

Colin Chisholm RPF
Colin Chisholm RPF
Forest Manager

Interested in forests and ecology