Smich7 - 5 months ago 75

LaTeX Question

I'm trying to do a

`xtable`

`knitr`

I tried that :

`<<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})

@

But my result is :

As you can see. My xtable overflow the page because my lines are too long. Can someone help me ?

PS : I can't use

`{tabular}`

Answer

Have a look at the align function:

```
<<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})
@
```

You can use it to change the column alignment like you would for any other LaTeX table. These resources may be helpful to you: