【发布时间】:2018-06-06 01:43:08
【问题描述】:
我正在尝试从包含复杂表格的 Bookdown 脚本生成 PDF。该表包括一些带有下标的参数名称。我还想为一些行着色。示例脚本如下所示:
---
title: "Example problem"
author: "Frida Gomam"
site: bookdown::bookdown_site
documentclass: book
output:
#bookdown::gitbook: default
bookdown::pdf_book: default
always_allow_html: yes
---
This is a test example for the problem.
```{r}
library(magrittr)
library(knitr)
library(kableExtra)
df <- data.frame(Parameter = c("NO~x~ emissions", "SO~2~ emissions", "CO~2~ emissions"), "Value mg/Nm^3^" = c(800,900,1000),check.names=F)
knitr::kable(df,escape = F, caption = 'Example table!', booktabs = TRUE, format = "latex") %>% #
row_spec(0, bold = T, color = "white", background = "#045a8d") %>%
row_spec(c(2), bold = T, color = "white", background = "#3690c0")
```
blah blah
我可以使用 kable 格式作为 'format = "html"' 运行脚本,结果看起来很好,包括彩色行和下标。当我将格式更改为 Latex 时,下标在生成的 pdf 中显示不正确。
我尝试将参数 escape = F 添加到 kable,但构建过程失败。
Quitting from lines 14-23 (_main.Rmd)
Error in kable_latex(x = c("$NO_{x}$ emissions", "SO2 emissions", "CO2 emissions", :
unused argument (example = FALSE)
Calls: <Anonymous> ... eval -> %>% -> eval -> eval -> <Anonymous> -> do.call
谁能帮忙解决这个问题?
【问题讨论】: