admin管理员组文章数量:1123194
I'm trying to generate a PDF table using kableExtra in R Markdown where the output PDF dimensions exactly match the table dimensions (no extra white space, no extra text, no page number, nothing else). Currently, the PDF output is default A4 paper.
Here's a minimal reproducible example:
---
output:
pdf_document:
latex_engine: xelatex
---
```{r include=FALSE}
library(kableExtra)
library(dplyr)
\```
```{r echo=FALSE}
# Create sample data
data <- data.frame(
Category = c("A", "B", "C", "D"),
Value1 = c(100, 200, 300, 400),
Value2 = c(10.5, 20.5, 30.5, 40.5),
Value3 = c("Yes", "No", "Yes", "No")
)
# Create table
data %>%
kbl(booktabs = TRUE,
col.names = c("Category", "Value 1", "Value 2", "Value 3"),
align = "lccc") %>%
kable_styling(latex_options = "HOLD_position") %>%
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 1)) %>%
column_spec(1, width = "3cm") %>%
footnote(
symbol = c("This is a footnote", "Another note"),
threeparttable = TRUE
)
\```
Cropping the post-knit pdf is not a solution for many reasons that would take too much time to explain. The objective is really to have the table format directly during the knitting phase.
本文标签: rHow to crop pdf while knitting rmdStack Overflow
版权声明:本文标题:r - How to crop pdf while knitting rmd - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736554812a1944561.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论