如何:降价 PDF 将表格向左对齐



目标我一直想创建一个 pdf 报告功能,但我无法像我想要的那样重新设计 pdf 的布局。我要解决的问题之一是我无法将表格向左对齐。现在它居中。

系统及其他

  • CentOS 版本 6.9 (最终版)
  • TeX 3.141592 (Web2C 7.5.6)

模板。马币

---
title: "Reporting"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, results='asis', echo=FALSE}
knitr::kable(head(cars), format = "markdown") %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```

build_report。R

# Libraries
require(knitr)
require(markdown)
library(RMySQL)
library(png)
library(kableExtra)
# create .md file
knit("template.Rmd", "template.md")
# create .html file
markdownToHTML("template.md", "template.html", options=c("use_xhml"))
# create .pdf file
command <- paste0("pandoc -V geometry:'left=0.5in,bottom=1in,top=1.5in' -s ", "template.html", " -o ", "output.pdf")
system(command)

输出.pdf输出示例(遗漏不相关信息)1

能够在@Hao的帮助下解决它

1) 从 .Rmd 到 .md 直接到 PDF,省略 markdownToHTML()

2)在模板中包含库(kableExtra)。RMD不在build_report。R

3)使用格式="降价"

模板。马币

---
title: "Reporting"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, results='asis', echo=FALSE}
knitr::kable(head(cars), format = "markdown") %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```

build_report。R

# Libraries
require(knitr)
require(markdown)
library(RMySQL)
library(png)
library(kableExtra)
# create .md file
knit("template.Rmd", "template.md")
# create .pdf file
command <- paste0("pandoc -V geometry:'left=0.5in,bottom=1in,top=1.5in' -s ", "template.md", " -o ", "output.pdf")
system(command)

删除kable中的format = "markdown"library(kableExtra)放在某个地方

最新更新