bookdown icon indicating copy to clipboard operation
bookdown copied to clipboard

Warn on special characters in label when used for cross referencing

Open cderv opened this issue 4 years ago • 0 comments

There are now numerous issues of users puzzled by why the cross referencing mechanism does not work as expected

https://github.com/rstudio/bookdown/issues/839 https://github.com/rstudio/bookdown/issues/157 https://github.com/rstudio/bookdown/issues/941 https://github.com/rstudio/bookdown/issues/867 https://github.com/rstudio/bookdown/issues/406 https://github.com/rstudio/bookdown/issues/194 https://github.com/rstudio/bookdown/issues/336 https://github.com/rstudio/bookdown/issues/892

This is indeed documented (in https://bookdown.org/yihui/bookdown/figures.html)

If you want to cross-reference figures or tables generated from a code chunk, please make sure the chunk label only contains alphanumeric characters (a-z, A-Z, 0-9), slashes (/), or dashes (-).

but the idea of a warning has also been already proposed several times. This impact only bookdown when labels is used for referencing but maybe we can detect when it is used and do something about this.

Even if we change the cross referencing mechanism using Lua Filters, I think this would still be a limitation (due to LaTeX special chatacter I believe)

Maybe we should consider this warning ?

Either specific to bookdown - or once per session when we detect a special char in labels to warn that this could cause issues.

Opening this issue so that we can keep track on the issue

Originally posted by @cderv in https://github.com/rstudio/bookdown/issues/892#issuecomment-849451745

cderv avatar May 27 '21 08:05 cderv