2

Is it possible to use pandoc-crossref in bookdown?

I tried to change the yaml header to:

output: 
    bookdown::tufte_book2:
        toc: yes
        highlight: tango
        pandoc_args: -F /usr/local/bin/pandoc-crossref

Which should pass the filter to pandoc, but I get the error:

pandoc: Error running filter  pandoc-crossref:
Could not find executable ' pandoc-crossref'.

The above error does not make sense, as I entered the correct path. What kind of env is bookdown using, which is precluding the access to the filter file?

lf_araujo
  • 1,991
  • 2
  • 16
  • 39

2 Answers2

3

Here is an example

---
output: bookdown::html_document2
---

# Section name {#id}

```{r pressure, echo=FALSE, fig.cap='test plot'}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. To cross-reference the figure, use `\@ref(fig:pressure)` to produce Figure \@ref(fig:pressure). All this is found within the section \@ref(id).

Which produces...

enter image description here

See https://bookdown.org/yihui/bookdown/figures.html for the official documentation.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Kevin Arseneau
  • 6,186
  • 1
  • 21
  • 40
1

I had a similar issue while I was trying to put numbers to equations in Word files (SO question). I got the same error Could not find executable 'pandoc-crossref'.

My RStudio installation (on Windows) did not come with pandoc-crossref. Here is what I did:

  1. Downloaded pandoc-crossref from here.
  2. Find the path where RStudio saved the file pandoc.exe:
rmarkdown::find_pandoc()
  1. Put the pandoc-crossref.exe in the folder I got in (2).
HBat
  • 4,873
  • 4
  • 39
  • 56