R-Markdown-kableExtra软件包-format ='latex'不起作用 [英] R-Markdown - kableExtra package - format = 'latex' not working
问题描述
使用kableExtra文档.在RMardown中,我正在运行:
Using the kableExtra documentation. inside RMardown I am running:
```{r}
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kable(dt, format = "rmarkdown")
```
这实际上输出了一个表,但我也在控制台中得到了以下内容:
this actually outputs a table but I also get the following in the console:
Error in kable_rmarkdown(x = c("Mazda RX4", "Mazda RX4 Wag", "Datsun 710", :
could not find function "kable_rmarkdown"
当我切换到:
```{r}
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kable(dt, format = "latex")
```
我没有错误,也没有表格.我需要安装乳胶才能使用此功能吗?
I get no error and no table. Do I need to install latex to use this functionality?
推荐答案
Just to put the comments together for providing a complete answer: The following quote is from the kableExtra vignette:
从kableExtra 0.9.0开始,加载此程序包(库(kableExtra))时,它将根据您当前的环境自动设置全局选项"knitr.table.format".除非您要渲染PDF,否则kableExtra会尝试为您渲染HTML表.您不再需要在每个kable()函数中手动设置全局选项或格式选项.
Starting from kableExtra 0.9.0, when you load this package (library(kableExtra)), it will automatically set up the global option ’knitr.table.format’ based on your current environment. Unless you are rendering a PDF, kableExtra will try to render a HTML table for you. You no longer need to manually set either the global option or the format option in each kable() function.
因此您可以在两个示例(markdown和LaTeX)中编写:
So you can write in both your examples (markdown and LaTeX):
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kable(dt)
根据您的输出格式,您将获得以HTML或LaTeX(PDF)呈现的表格.是的:对于PDF,您将需要安装LaTeX.如今,使用 Xihui Xie的TinyTeX 可以很容易地做到这一点.
Depending on your output format you will get the table rendered in HTML or LaTeX (PDF). And yes: For PDF you will need a LaTeX installation. But this is nowadays quite easy with TinyTeX by Yihui Xie.
这篇关于R-Markdown-kableExtra软件包-format ='latex'不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!