无法使用xtable在pdf页面上居中放置表格?

时间:2019-07-19 14:14:54

标签: r-markdown

我写了下面从R运行的代码。唯一的事情是桌子一直在向左移动,我想将它居中。没有这个参数吗?

这是我在Rmd中的代码:

{r echo = FALSE, results='asis'}
tbl<-Bdata[-c(13,16),]
x<-xtable(tbl, auto = T)
rws <- seq(1, (nrow(tbl)), by = 2)
spc <- seq(4, (nrow(tbl)), by = 4)
addtorow <- list()
addtorow$pos <- as.list(c(0,
                          rws,
                          nrow(x),
                          spc)
                        )
addtorow$command <- as.vector(c("\\toprule \n 
                                &\\multicolumn{4}{c}{OP4} \\\\ \\cmidrule(lr){2-5} \n 
                                &\\multicolumn{2}{c}{30} & \\multicolumn{2}{c}{00} \\\\ \\cmidrule(lr){2-3} \\cmidrule(lr){4-5} \n
                                & TP & EO & TP & EO & \\\\ \\midrule ",
                                rep("\\rowcolor[gray]{0.95}", length(rws)),
                                "\\bottomrule",
                                rep("\\addlinespace[5pt] ", length(spc)))
                              ,mode="character" )

digits(x) <- matrix(c(0,0,0,-2,0,0,0,0,0,0,0,0,0,0,1,0), nrow = nrow(x), ncol = ncol(x)+1)
print(x, add.to.row=addtorow,include.colnames = FALSE, hline.after = NULL, size="\\fontsize{10pt}{12pt}\\selectfont")

这是R中的代码:

rmarkdown::render("z:/projects/DiBut/F1CEVI/DiBut(5)/eval/Tbl_generator  - OPs.Rmd", 
                 output_file = file.path(path, "Bxxx_A-x-x.pdf"),
                 encoding = "native.enc",
                 params = list(
                   dyntitle = "Averages Stationary Operating Points",
                   dynsubtitle = "OP3 - 4",
                   dynfigno = "A 3-3",
                   dynprojectname ="xxx / xxx"
                   ))

result of actual code 谢谢您的帮助!

0 个答案:

没有答案