lf_araujo
lf_araujo

Reputation: 2063

Using pandoc-crossref with R bookdown

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?

Upvotes: 2

Views: 1055

Answers (2)

HBat
HBat

Reputation: 5702

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).

Upvotes: 1

Kevin Arseneau
Kevin Arseneau

Reputation: 6264

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.

Upvotes: 3

Related Questions