My real problem is with a 300 pages book that worked fine in the past, but now fail to recognize hundreds of implicit links to hundreds of headers, but consider a new bookdown project named "test" where the contents pages are reduced 3 simple files:
index.Rmd
01-test.Rmd
02-test.Rmd
and the other files are untouched, except adding keep_md: yes
in _output.yml
to see a merged .md file after rendering.
With Build Book
> bookdown::pdf_book
this will produce a test.pdf
but also this test.md
:
---
title: "test"
site: bookdown::bookdown_site
documentclass: book
---
# foo
bla bla [bah] and [foo]
<!--chapter:end:index.Rmd-->
# bah
bla bla [baz]
<!--chapter:end:01-test.Rmd-->
# baz
bla bla [foo]
<!--chapter:end:02-test.Rmd-->
But in the PDF (or when exported to a html book) only the first [foo]
will become a link to the chapter foo, but the other three implicit links are rendered as plain text in the PDF. That is, implicit links work only within a chapter, but not between chapters.
Then I realized that the build pane of Rstudio showed:
/usr/bin/pandoc +RTS -K512m -RTS ./index.split.md ./01-test.split.md
./02-test.split.md --to latex ...
And moreover, rendering test.md
directly (replacing site: bookdown::bookdown_site
by output: pdf_document
to the YAML header and using "preview PDF") all implicit links worked, so it is clear that bookdown is merging the LaTeX output with pandoc instead of pass to pandoc the merged markdown file.
Supposedly, the default rendering approach in bookdown is "Merge and knit". I played with new_session: yes
and new_session: no
in _bookdown.yml
to change the rendering approach, but nothing changed.
I know that using [foo](#foo)
instead of [foo]
will work with whatever rendering approach, but change every link in a huge already book is a pain, and export myself the merged file is annoying, so the question is:
How to force to bookdown to export again a merged markdown instead of merge the LaTeX or HTML output with pandoc?
As the problem seem related with software versions, this is my actual system and related R package versions:
Linux Mint 20
RStudio 1.3.1073
R version 3.6.3 (2020-02-29)
pandoc 2.10.1
bookdown_0.20
markdown_1.1
rmarkdown_2.3
knitr_1.29
rstudioapi_0.9.0
tinytex_0.25
yaml_2.2.1