我能想到的在 Tufte Handouts 中使用全宽表格的唯一方法是使用 ( awesome )kableExtra
包。该软件包为您提供了更多格式和编辑选项,我建议您在此处查看这些指南:指南 1和指南 2。
这是我使用的代码:
---
title: "Tufte Handout"
output:
tufte::tufte_handout:
includes:
in_header: testheader.tex
latex_engine: xelatex
---
```{r setup, include=FALSE}
library(tufte)
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'),
kable.force.latex = TRUE)
options(htmltools.dir.version = FALSE)
```
## Full width table
This is a test. This is a test. This is a test. This is a test. This is a
test. This is a test. This is a test. This is a test.
```{r, resize.width=100, echo=FALSE}
library(knitr)
library(magrittr)
library(kableExtra)
knitr::kable(mtcars[1:6, 1:6], format = "latex", booktabs=T,
table.envir='table*') %>%
kable_styling(latex_options = c("hold_position"), full_width=T)
```
kableExtra 的 Tex 标头 (testheader.tex):
\usepackage{xcolor}
\usepackage{background}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
有几件事对于让它工作很重要,这就是我在这里强调它的原因。即:kable.force.latex = TRUE
和table.envir='table*'
。显然,您可能不需要在代码和 tex 标头中找到的所有内容,因此请随时进行相应调整。
输出如下所示: