the example from https://bookdown.org/yihui/rmarkdown-cookbook/cross-ref.html does not work for me. I simply get references like "Figure @ref(fig:cars-plot)." appearing in the pdf or html document, i.e the raw markdown appears rather "Figure 1" The code is below and the versions of installed packages are below that. It seems to be an emacs problem. People have tried the attached code in Rstudio and the references come out correctly.
---
title: Cross-referencing figures, tables, and equations
author: Generated by bookdown
output:
bookdown::html_document2: default
bookdown::pdf_document2: default
---
See Figure \@ref(fig:cars-plot).
par(mar = c(4, 4, .2, .1))
plot(cars) # a scatterplot
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
[5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
[7] LC_PAPER=en_AU.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0 magrittr_2.0.1 fastmap_1.1.0 tools_4.1.0
[5] htmltools_0.5.2 yaml_2.2.2 tinytex_0.36 stringi_1.7.6
[9] rmarkdown_2.11 highr_0.9 knitr_1.37 stringr_1.4.0
[13] xfun_0.29 digest_0.6.29 rlang_0.4.12 evaluate_0.14
``
and the pandoc command is
/usr/bin/pandoc +RTS -K512m -RTS test4.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test4.tex --lua-filter /home/dun280/local/lib/R/x86_64-pc-linux-gnu/4.0/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/dun280/local/lib/R/x86_64-pc-linux-gnu/4.0/site-library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in'
rmarkdown::render('test.Rmd', output_format = 'pdf_document', output_file = 'test.pdf', knit_root_dir=getwd())
rather thanrmarkdown::render('test.Rmd', output_format = 'bookdown::pdf_document2', output_file = 'test.pdf', knit_root_dir=getwd())
– user7543513 Jul 25 '22 at 07:17