Bookdown fail to create PDF when reference inside table generated by knitr::kable

Consider the following minimal working example:

---
title: Minimal Working Example
author:
- Raniere Gaia Costa da Silva
date: "2021-04-19"
site: "bookdown::bookdown_site"
documentclass: article
bibliography: reference.bib
link-citations: yes
---

```{r , echo=FALSE, message=FALSE}
library(tidyverse)
df <- read_csv("./data.csv")
df %>%
  knitr::kable(
    booktabs = TRUE,
    caption = 'Foo'
)
```

# References

Where the content of data.csv is

Reference,Classification
[@liuAdvancesDeepLearning2021],Yes

bookdown::render_book(".", "bookdown::html_document2") will create the HTML document as expected.

For reference, Bookdown will create the intermediate Markdown file:

---
title: Minimal Working Example
author:
- Raniere Gaia Costa da Silva
date: "2021-04-19"
site: "bookdown::bookdown_site"
documentclass: article
bibliography: reference.bib
link-citations: yes
---


Table: (\#tab:unnamed-chunk-1)Foo

|Reference                      |Classification |
|:------------------------------|:--------------|
|[@liuAdvancesDeepLearning2021] |Yes            |

# References


<!--chapter:end:mwe.Rmd-->

bookdown::render_book(".", "bookdown::pdf_book") will fail to create the PDF document with the following error message:

/home/raniere/anaconda3/bin/pandoc +RTS -K512m -RTS _main.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output _main.tex --lua-filter /home/raniere/R/x86_64-pc-linux-gnu-library/4.0/bookdown/rmarkdown/lua/custom-environment.lua --lua-filter /home/raniere/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/raniere/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --table-of-contents --toc-depth 2 --number-sections --highlight-style tango --pdf-engine xelatex --variable graphics --wrap preserve --variable tables=yes --standalone -Mhas-frontmatter=false --filter /home/raniere/anaconda3/bin/pandoc-citeproc 
! Missing number, treated as zero.
<to be read again> 
                   @
l.90 [@liuAdvancesDeepLearning2021]
                                    & Yes\\ 

Error: LaTeX failed to compile _main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See _main.log for more info.
Please delete _main.Rmd after you finish debugging the error.

The LaTeX document created by Bookdown has

\caption{\label{tab:unnamed-chunk-1}Foo}
\centering
\begin{tabular}[t]{ll}
\toprule
Reference & Classification\\
\midrule
[@liuAdvancesDeepLearning2021] & Yes\\
\bottomrule
\end{tabular}
\end{table}

I might be able to use Bookdown's Text Reference to work around this issue but it will increase the complexit of my project that have a couple of dozen references like this one.

Any suggestions?

Files

All files are available at https://portland-my.sharepoint.com/:u:/g/personal/rcostadas2-c_my_cityu_edu_hk/EbBBsNPIXpdPkUROrlRmrxwB9XU68yrly_lohxDCfWCYvA?e=r6Hbr8

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.