Ista Zahn wrote: > > Hi Tao, > Just set the appropriate *.just argument, e.g.: > > Dat <- data.frame(x1 = rep("this value consists of a long string of > text", 5), x2 = rep("this value consists of an even longer string of > text", 5)) > > library(Hmisc) > latex(Dat, col.just = rep("p{1in}", 2)) > > You can also set justification for column headings, column group > headings etc. See ?latex for details. > > Best, > Ista > >
As Ista said, you can use the p{}, m{} and b{} LaTeX column specifications to create a table column that enforces a line wrap on it's contents. See: http://en.wikibooks.org/wiki/LaTeX/Tables#The_tabular_environment for full details. However, one problem with using say, p{2in}, is that the text is set *fully justified*. This means that the inter-word spacing in each line is expanded so that the line fully occupies the allotted 2 inches of space. For some tables the results are a typographical travesty. The solution is to prepend a ">{justificationCommand}" to your column specification, such as: >{\centering}p{2in} The justification commands you can use are : \centering -> Centers wrapped text \raggedright -> *left* aligns wrapped text \raggedleft -> *right* aligns wrapped text Remember to double the backslash if you are passing this command as an argument in R. This trick will cause a LaTeX compilation error if used to specify the right-most column in a table, unless the hmisc latex() command produces tables that use "\tabularnewline" to invoke table row breaks instead of "\\". Hope this helps. -Charlie -- View this message in context: http://n4.nabble.com/wrap-long-lines-in-table-using-latex-in-Hmisc-tp1571298p1571496.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.