I'm trying to include citations from a .bib file into a kable table in Rmarkdown, using bookdown. The citations work if I specify format = "markdown" in the kable using kableExtra::kbl(). But feeding this to additional kable_styling formatting options no longer works and results in warnings:
---
title: "Citation in landscape table"
site: bookdown::bookdown_site
output:
bookdown::pdf_book:
bibliography: [ref.bib]
biblio-style: apalike
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library('kableExtra')
```
```{r}
tmp <- data.frame('line' = c(1:3), 'ref' = c("no ref", "@R-base", "no ref"))
kbl(tmp, format = "markdown", longtable = TRUE, booktabs = TRUE, escape = FALSE) %>%
kable_styling(latex_options =c("striped", "hold_position", "repeat_header", "scale_down")) %>%
column_spec(2, width = "20em") %>%
landscape()
```
This leads to warning messages in the pdf produced:
## Warning in kableExtra::kable_styling(., latex_options = c("striped",
## "hold_position", : Please specify format in kable. kableExtra can customize
## either HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ for
## details.
## Warning in column_spec(., 2, width = "20em"): Please specify format in
## kable. kableExtra can customize either HTML or LaTeX outputs. See https://
## haozhu233.github.io/kableExtra/ for details.
## Warning in kableExtra::landscape(.): Please specify format in kable. kableExtra
## can customize either HTML or LaTeX outputs. See https://haozhu233.github.io/
## kableExtra/ for details
If I exclude the format = "markdown" option the warnings disappear and I get the correct table in landscape format, but the citation doesn't work anymore.
How do I get both the landscape table with the options as specified with kable_styling() and working citations in the table?
The content of ref.bib is:
@Manual{R-base,
title = {R: A Language and Environment for Statistical
Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2019},
url = {https://www.R-project.org},
}
