Re: [R] R + LaTeX formula

From: Marc Schwartz <>
Date: Sat, 08 Dec 2007 19:24:49 -0600

On Sun, 2007-12-09 at 01:04 +0000, Jonas Stein wrote:
> Hi,
> what is actually the best method to include R-plots into LaTeX
> documents?
> At the moment i use
> postscript("myplot.eps", width = 12.0, height = 9.0, horizontal =
> onefile = TRUE, paper = "special",encoding = "TeXtext.enc")
> plot(foo,bar)
> But it is a bit unhandy to scale later and its difficult to get nice
> formula in the plots.
> And how should i write formulas on the axis or at specific points?
> Has someone had some effort in exporting plots to pstricks or pictex?
> kind regards and thank you for reading so far,

As per the Details section of ?postscript:

The postscript produced for a single R plot is EPS (Encapsulated PostScript) compatible, and can be included into other documents, e.g., into LaTeX, using \includegraphics{<filename>}. For use in this way you will probably want to set horizontal = FALSE, onefile = FALSE, paper = "special". Note that the bounding box is for the device region: if you find the white space around the plot region excessive, reduce the margins of the figure region via par(mar=).

In your code above, change 'onefile = TRUE' to 'onefile = FALSE'.

For scaling you can use the LaTeX \includegraphics directive along with several height and width arguments, such as:


You might want to review the following document:

For including formulae in R plots, see ?plotmath. You can run example(plotmath) and there are many posts in the r-help archives on this.

Beyond the above, you may want to look into using SWeave, whereby you can create entire documents, with nicely formatted tables and plots directly from R code. More information here:

There are also a couple of articles on R News:

Friedrich Leisch. Sweave, part I: Mixing R and LATEX. R News, 2(3):28-31, December 2002.

Friedrich Leisch. Sweave, part II: Package vignettes. R News, 3(2):21-24, October 2003.

HTH, Marc Schwartz mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 09 Dec 2007 - 01:32:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 09 Dec 2007 - 14:00:18 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.