我有以下tint
PDF文档:
---
title: "Title"
subtitle: "Subtitle"
author: "Author"
date: "`r Sys.Date()`"
output: tint::tintPdf
---
```{r echo = FALSE, message = FALSE}
# Load library
library(dplyr)
# Create data frame
df <- data.frame(A = runif(10),
B = runif(10),
C = runif(10),
D = runif(10),
E = runif(10),
F = runif(10),
G = runif(10),
H = runif(10))
# Print as a table
knitr::kable(df, booktabs = TRUE, format = "latex",
caption = "This is a caption in the margin.")
```
这将产生带有下表的PDF:
桌子很宽,溢出了标题。为避免这种情况,我可以在full_width = TRUE
的{{1}}函数中使用kable_styling
将其指定为全宽表格。
kableExtra
这会出现以下错误:
! LaTeX错误:未定义环境禁忌。
错误:无法编译Test.tex。有关更多信息,请参见Test.log。 执行停止
对于---
title: "Title"
subtitle: "Subtitle"
author: "Author"
date: "`r Sys.Date()`"
output: tint::tintPdf
---
```{r echo = FALSE, message = FALSE}
# Load library
library(dplyr)
# Create data frame
df <- data.frame(A = runif(10),
B = runif(10),
C = runif(10),
D = runif(10),
E = runif(10),
F = runif(10),
G = runif(10),
H = runif(10))
# Print as a table
knitr::kable(df, booktabs = TRUE, format = "latex",
caption = "This is a caption in the margin.") %>%
kableExtra::kable_styling(full_width = TRUE)
```
软件包(或缺少软件包)似乎很沮丧。因此,我在YAML中添加了此程序包,如下所示:
tabu
这会运行,但是会产生以下内容:
现在,表的内容重叠。哼哼即使在块选项中包含---
title: "Title"
subtitle: "Subtitle"
author: "Author"
date: "`r Sys.Date()`"
output: tint::tintPdf
header-includes:
- \usepackage{tabu}
---
,我也没有运气。
在这种情况下如何生成全宽表?
答案 0 :(得分:0)
这是一种解决方法。通过在longtable = TRUE
中指定kable
,标题将凸显到顶部。另外,在YAML中:tables: yes
。与直觉相反,将kable_styling
与full_width = TRUE
一起使用会将表压缩到主体的整个宽度,而不是主体+边距。
---
title: "Title"
subtitle: "Subtitle"
author: "Author"
date: "`r Sys.Date()`"
output: tint::tintPdf
tables: yes
---
```{r echo = FALSE, message = FALSE}
# Load library
library(dplyr)
# Create data frame
df <- data.frame(A = runif(10),
B = runif(10),
C = runif(10),
D = runif(10),
E = runif(10),
F = runif(10),
G = runif(10),
H = runif(10))
# Print as a table
knitr::kable(df, booktabs = TRUE, format = "latex", longtable = TRUE,
caption = "This is a caption in the margin.")
```