如何:标记PDF将表格向左对齐

如何:标记PDF将表格向左对齐,pdf,markdown,pandoc,tex,Pdf,Markdown,Pandoc,Tex,目标 我一直想创建一个pdf报告功能,但我无法重新设计pdf的布局,因为我想。我要解决的问题之一是,我无法将表格向左对齐。现在它集中在中间。 系统和其他 CentOS 6.9版(最终版) TeX 3.141592(Web2C 7.5.6) 模板.Rmd --- title: "Reporting" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ```{r

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

系统和其他

  • CentOS 6.9版(最终版)
  • TeX 3.141592(Web2C 7.5.6)
模板.Rmd

---
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")
```
---
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")
```
构建报告.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)
# 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)
#库
需要(knitr)
要求(降价)
图书馆(RMySQL)
图书馆(png)
图书馆(kableExtra)
#创建.md文件
针织(“template.Rmd”、“template.md”)
#创建.html文件
markdownToHTML(“template.md”,“template.html”,options=c(“use_xhtml”))
#创建.pdf文件

命令在
kable
中删除
format=“markdown”
,并将
library(kableExtra)
放在某个地方

可以在@Hao的帮助下解决它

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

2) 将库(kableExtra)包含在模板.Rmd中,而不是构建报告.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)
# 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)
3) 使用format=“markdown”

模板.Rmd

---
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")
```
---
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")
```
构建报告.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)
# 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)
#库
需要(knitr)
要求(降价)
图书馆(RMySQL)
图书馆(png)
图书馆(kableExtra)
#创建.md文件
针织(“template.Rmd”、“template.md”)
#创建.pdf文件

命令库包含在build_report.R中。我忘了在这个例子中添加这个部分。我现在已经添加了它。我已经删除了
format=“markdown”
,但表仍然要居中。@安德烈,我真的不明白你想做什么。在rmd文件中,您将格式设置为pdf_文档,而在r文件中,您似乎尝试先呈现md,然后将其转换为html?这是正确的。我很抱歉,因为我对此不太熟悉。我是基于一个教程的。我基本上想要生成一个pdf报告,所以建议的方法是:Rmd>md>html>pdf@Andrie您可以直接从rmarkdown生成pdf文档。如果您使用的是rstudio,只需单击顶部的“渲染”按钮即可。如果在terminal中使用它,只需在rmarkdown中使用render函数