How to place xtable object to the left side of page

天大地大妈咪最大 提交于 2019-12-31 04:30:31

问题


Question: How to place xtable object to the left side of page or how to disable centering globally.

I'm struggling to figure out how to place xtable object on the left side. I have got a *.Rmd file and all this goes to the relevant r chunk.

require(xtable)
df <- data.frame(x=seq(1,10,1),y=rnorm(10))

Xtab <- xtable(df, digits=0, caption="\\textbf{MINIMAL/IDEAL}",  
               floating=FALSE, latex.environments = c("left"))
print(Xtab, size = "small", include.colnames=FALSE)

I have included the following after reading various sources (print.xtable; xtable manual etc.)

1) floating=FALSE 2) latex.environments = c("left")

I have searched SO and used some of the hints but all failed.


回答1:


It seems to make quite a difference whether you pass a parameter to xtable() or to print(xtable()). The following chunk creates a table according to your data that is aligned at the left of the page in the pdf file.

```{r, results='asis',echo=FALSE}
library(xtable)
df <- data.frame(x=seq(1, 10, 1),y = rnorm(10))
print(xtable(df,digits=0, caption="\\textbf{MINIMAL/IDEAL}"), include.colnames=FALSE, size = "small", comment=FALSE, latex.environments="flushleft")
```

However, as you can see, the caption remains at the center of the page.



来源:https://stackoverflow.com/questions/31896916/how-to-place-xtable-object-to-the-left-side-of-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!