Smich7 - 1 year ago 226

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

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

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:

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**