[R] Hmisc latex function with longtable option

Frank E Harrell Jr f.harrell at vanderbilt.edu
Wed Jul 2 18:46:05 CEST 2008

Erik Iverson wrote:
> Hello -
> I'm trying to use Hmisc's latex function to produce a postscript file of 
> a data.frame, using the longtable = TRUE option.  When I run, for example,
> ## sample R code
> dvips(latex(data.frame(a = rnorm(100), b = rnorm(100)),
>             longtable = TRUE), file = "test.ps")
> latex runs successfully and a test.ps file is produced.  However, I see 
> the following in the output that the latex command sends to the R buffer.
> ...
> Package longtable Warning: Column widths have changed
> (longtable)                in table 1 on input line 121.
> Package longtable Warning: Table widths have changed. Rerun LaTeX.
> ...
> And the resulting test.ps file has the column headings not aligned (in 
> my real life example, there are other misalignments).
> To resolve this, I am currently going into the /tmp/Rtmp****/ directory 
> where the .tex files are created by the dvi.latex function, and 
> rerunning latex on the appropriate file****.tex file.
> Is there any thing I'm missing that would make this easier?
> Thanks,
> Erik Iverson
> iverson at biostat.wisc.edu

longtable requires two passes at the LaTeX code to finish the job.  If 
you use

m <- latex(..., file='my.tex')

and \include{my} in a master document, you can run latex twice on the 
master to get the desired result.


> ______________________________________________
> R-help at 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.

Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

More information about the R-help mailing list