在K-Studio中使用带有booktabs = TRUE选项的kable时出错

时间:2022-03-14 22:37:37

Does anyone have problem with compiling .pdf output using kable with booktabs=TRUE option in R Studio? Without booktabs it works just fine. When I try to improve the table format adding booktabs=TRUE to kable, I get an error "! Illegal unit of measure (pt inserted)." followed by message of pandoc "Error: pandoc document conversion failed with error 43".

有人在R Studio中使用带有booktabs = TRUE选项的kable编译.pdf输出有问题吗?没有booktabs它工作得很好。当我尝试改进表格式时,将booktabs = TRUE添加到kable,我收到错误“!非法测量单位(插入pt)。”然后是pandoc消息“错误:pandoc文档转换失败,错误43”。

My code is:

我的代码是:

kable(table, col.names = c("Groups", "N","% Cum", "%", "N","% Cum.", "%"),
      caption="Some Caption",row.names = FALSE,align="c",
      format ="latex", booktabs=FALSE)  %>%
      add_header_above(c(" ", "Group 1" = 3, "Group 2" = 3)) %>%
      kable_styling(latex_options = c("striped", "hold_position"))

2 个解决方案

#1


0  

You need to add a call to the booktabs package in LATEX. Add this to your preamble

您需要在LATEX中添加对booktabs包的调用。将此添加到您的序言中

---
output: pdf_document
header-includes:
  - \usepackage{booktabs}
---

#2


0  

I had the same problem (error 43). In my case, it was because at least one of my rows began with a bracket [. Once I removed this it compiled the pdf as usual.

我遇到了同样的问题(错误43)。在我的情况下,这是因为我的行中至少有一行以括号开头[。一旦我删除它,它就像往常一样编译pdf。

#1


0  

You need to add a call to the booktabs package in LATEX. Add this to your preamble

您需要在LATEX中添加对booktabs包的调用。将此添加到您的序言中

---
output: pdf_document
header-includes:
  - \usepackage{booktabs}
---

#2


0  

I had the same problem (error 43). In my case, it was because at least one of my rows began with a bracket [. Once I removed this it compiled the pdf as usual.

我遇到了同样的问题(错误43)。在我的情况下,这是因为我的行中至少有一行以括号开头[。一旦我删除它,它就像往常一样编译pdf。