2

I was having trouble with one of my bookdown projects where the chapter/section cross-references were no longer working in the html output.

The problem is the html links work but they are displayed as ?? -- lacking section number. This is only a problem in the html version of the book. The pdf version compiles properly.

In searching for a solution I tried creating a new bookdown project using the default demo install and it has the same error as highlighted in this image:

broken cross-reference in bookdown.

As noted -- this error is occurring in the default install of bookdown... excerpt from the 01-intro.Rmd (i.e. in Rstudio: File >> New Project >> New Directory >> Book project using bookdown).

# Introduction {#intro}

You can label chapter and section titles using `{#label}` 
after them, e.g., we can reference Chapter \@ref(intro). 
If you do not manually label them, there will be automatic labels anyway,
e.g., Chapter \@ref(methods).

Figures and tables with captions will be placed in `figure`
and `table` environments, respectively.

Here is my sessionInfo()

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  bookdown_0.16   htmltools_0.4.0 tools_3.6.1    
 [5] yaml_2.2.0      Rcpp_1.0.3      rmarkdown_2.0   knitr_1.26     
 [9] xfun_0.11       digest_0.6.23   rlang_0.4.2     evaluate_0.14
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Colin C
  • 76
  • 8

2 Answers2

1

Found a workaround

This is a known issue that the Rstudio group is working on.
https://github.com/rstudio/bookdown/issues/787

I was able to work around this problem by using the version of pandoc that is installed with Rstudio (currently 2.7.2). In windows I did this by removing pandoc from the PATH and then restarting my Rstudio session.

Colin C
  • 76
  • 8
  • This issue is essentially the same as https://github.com/rstudio/bookdown/issues/832, which I just fixed on Github. Thanks! (And yes, downgrading Pandoc or using RStudio's bundled Pandoc is also a possible fix.) – Yihui Xie Jan 10 '20 at 21:10
0

Just leaving this here in case anyone else gets stuck like me: the labels cannot start with a number, so e.g. {#1.1} won't work, but {#s1.1} works with the fix referenced by Yihui's fix in the comment above.

maja zaloznik
  • 660
  • 9
  • 24