However, there are scenarios where we may wish to allow duplicate labels. For example, if we have one parent document in which we knit the child document multiple times, it will fail:
If you want to allow duplicate labels in the main document instead of the child document, you have to set this option before knitr::knit()
is called. One possible way to achieve that is to set the option in your file (see the help page ?Rprofile
for more information).
The second label will be silently changed to test-1
. This may avoid overwriting the plot from the chunk with the label , but it also makes the chunk label unpredictable, so you may have difficulties in cross-referencing figures (see Section ), because the cross references are also based on chunk labels.