与Rmarkdown一起使用booktabs(Using booktabs with Rmarkdown)

编程入门 行业动态 更新时间:2024-10-15 00:24:06
Rmarkdown一起使用booktabs(Using booktabs with Rmarkdown)

使用RStudio时,Booktabs和xtable会发生Rmarkdown失败。 Tufte模板工作正常,但使用标准的.Rmd文件失败并显示错误消息:

! Undefined control sequence. l.133 \toprule pandoc.exe: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43

一个可重现的例子:

--- title: "Testing booktabs" author: "r.bot" date: "11 June 2015" output: pdf_document --- ```{r, results='asis'} library(xtable) options(xtable.comment = FALSE) options(xtable.booktabs = TRUE) xtable(head(mtcars[,1:6]), caption = "First rows of mtcars") ```

R版本3.1.2(2014-10-31)平台:x86_64-w64-mingw32 / x64(64位)安装最新版本的Pandoc。

Booktabs and xtable fail with Rmarkdown using RStudio. The Tufte template works fine, but using a standard .Rmd file fails with the error message:

! Undefined control sequence. l.133 \toprule pandoc.exe: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43

A reproducible example:

--- title: "Testing booktabs" author: "r.bot" date: "11 June 2015" output: pdf_document --- ```{r, results='asis'} library(xtable) options(xtable.comment = FALSE) options(xtable.booktabs = TRUE) xtable(head(mtcars[,1:6]), caption = "First rows of mtcars") ```

R version 3.1.2 (2014-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Latest version of Pandoc installed.

最满意答案

尝试包括一个文件header.tex ,其中您依赖于booktabs包。 有关详细信息,请参阅rmarkdown 的乳胶选项 。

编辑:虽然包含头文件很方便,并允许更广泛的变化,但在这里,我们通过顶层选项tables: true 。 所以上面例子的最小变化是

--- title: "Testing booktabs" author: "r.bot" date: "June 11, 2015" output: pdf_document tables: true ---

之后,样本xtable输出将与booktabs xtable出现。

Try including a file header.tex in which you depend on the booktabs package. See the latex options for rmarkdown for details.

Edit: While the inclusion of headers is convenient and allows for wider ranging changes, here we get by with the top-level options tables: true. So the minimal change for the example above is

--- title: "Testing booktabs" author: "r.bot" date: "June 11, 2015" output: pdf_document tables: true ---

after which the sample xtable output appears with booktabs.

更多推荐

本文发布于:2023-08-07 18:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465379.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Rmarkdown   booktabs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!