【发布时间】:2016-04-27 11:28:41
【问题描述】:
我正在尝试将标题与 Rmarkdown 文件中的 pandoc 表居中对齐(输出为 PDF)。表格以页面为中心,我希望标题同样居中。我似乎无法在 pander/pandoc.table 中找到一个选项,它可以让我在 Rstudio/Knitr 中编写的 Rmarkdown 中执行此操作。我目前唯一的解决方案是包含一串 ...nbsp;
我已经检查了 panderOptions,并且通过在 yaml 标头中插入代码,我还关注了 xtable caption alignment left aligned with table or centered (using knitr) 中的 cmets(没有成功)。而且,我已按照此处的建议添加了换行符:Issue with creating PDf file with Pander+Knitr: Error when putting table with caption and plot directly next to each other。
非常欢迎任何建议。
谢谢, 理查德
Rmarkdown 文档:
header-includes:
- \usepackage[
singlelinecheck=false,
justification=centering
]{caption}
output:
pdf_document
---
```{r table2, echo=FALSE, message=FALSE, warnings=FALSE, results='asis'}
library(pander)
panderOptions('keep.line.breaks', TRUE )
table2 <- "HHHH member | Description of future
H11111 | standard model
H22222 | low model
H33333 | decreasing projection"
df2 <- read.delim(textConnection(table2), header=FALSE, sep="|", strip.white=TRUE, stringsAsFactors=FALSE)
names(df2) <- unname(as.list(df2[1,]))
df2 <- df2[-1,] # remove first row
row.names(df2) <- NULL
pandoc.table(df2,
caption= "Table 2. Insert title here\n", style = "multiline", split.cells = c(20, 25))
```
系统: Linux Mint (17.1)/Ubuntu Trusty RStudio:0.98.1103 潘德:0.6.0 针织:1.12.3
【问题讨论】:
-
off-topic:
header=Tandcheck.names=Finread.delim然后你可以省略接下来的 3 行代码。