I am writing a report with Knitr and am trying to use bookdown to automatically number figures and refer to them.
Here is my header :
---
title: "My title"
author: "Me"
email: "My email"
output:
bookdown::html_document2:
number_sections: true
toc : true
fig_caption : TRUE
---
```{r setup, include=FALSE}
library(bookdown)
knitr::opts_chunk$set(echo = TRUE)
setwd(dir=dirname(rstudioapi::getActiveDocumentContext()$path))
```
And my first figure :
```{r fig1,echo=F, eval=T, fig.align = 'center', fig.cap="My first figure"}
knitr::include_graphics(here::here("images", "Formule 3.png"))
```
When I knit it, I can see my figure but under it, I can see:
(#fig:fig1)My first figure
I expected:
Figure 1 : My first figure
When I remove fig1 in the code chunk, I get an automatic number, but I do not know how to refer to it, because I do not have any reference.
Could anybody explain me what I am doing wrong?
Thank you in advance.
Best regards,
Jean-Luc.