我试图在xtable
生成的PDF文档的每一行用knitr
做长句。
我试过了:
<<echo=F,results="asis",command=NA>>=
df<-c("This is a very very very very very very very very very very very very very very very very very very very very long line",
"Another very very very very very very very very very very very long line")
df<-as.data.frame(df)
xtab <- xtable(df)
print.xtable(xtab,sanitize.text.function=function(x){x})
@
但我的结果是:
如你所见。我的xtable溢出页面,因为我的行太长了。有人能帮助我吗?
PS:我无法使用{tabular}
,因为我的数据框的长度取决于闪亮的应用用户的输入。
答案 0 :(得分:2)
看看对齐功能:
<<echo=FALSE,results=tex>>=
library(xtable)
df<-c("This is a very very very very very very very very very very very very very very very very very very very very long line",
"Another very very very very very very very very very very very long line")
df<-as.data.frame(df)
xtab <- xtable(df)
align(xtab) <- "|lp{6cm}|"
print.xtable(xtab,sanitize.text.function=function(x){x})
@
您可以像使用任何其他LaTeX表一样更改列对齐方式。这些资源可能对您有所帮助: