Yihui documented figure referencing very well. There is only one thing I need to add: do remember to add a figure caption if you want to reference it.
For example, if we have a chunk label without a figure caption:
We cannot reference it: Figure ??.
This is because without a figure caption, the figure won’t be numbered. Without a number, the figure cannot be referenced.
Simply adding a figure caption solves the problem:
Now we can reference it: Figure 1
Last modified on 2022-10-01