[R] R Graphics into Latex
marc_schwartz at me.com
Thu Feb 25 01:01:43 CET 2010
On Feb 24, 2010, at 5:37 PM, Ray Brownrigg wrote:
> On Thu, 25 Feb 2010, Lars Bishop wrote:
>> I'm new in Latex and I'm trying to include an R chart into a Latex
>> This is what I'm doing:
>> 1) In R: save the chart as a a Postcript in a folder C:/xxx/Density.eps
>> 2) In Latex (using TexWorks on windows xp) :
>> In the preambule:
>> --This is the Error Message I'm getting:
>> LaTeX Warning: File `R:/MarsTH/Studies/Misc/LIA QA/R/Density.eps' not found
>> input line 26.
>> ! LaTeX Error: Unknown graphics extension: .eps.
> I've seen that message (recently, but on a Mac) when running pdflatex.
> Are you sure you don't have an option set that specifies using pdflatex rather than latex?
Remove the ".eps" extension in your LaTeX code:
Also, be sure that you have created the EPS file using the correct arguments to postscript() as noted in the help file:
postscript("Density.eps", onefile = FALSE, horizontal = FALSE,
paper = "special", width = XXX, height = XXX)
Your Plotting Code
As Ray noted, be sure that you are using 'latex' and not 'pdflatex' to process the .tex file, as the latter will expect PDF files and not EPS files. Typically, unless you are using special postscript markup in LaTeX (such as PSTricks), you can create PDF plot files in R (using pdf()) and then process the result with pdflatex. It saves some intermediate processing steps using dvips and ps2pdf.
For more information on including EPS figures in LaTeX documents, there is a great document available here:
You want to download epslatex.pdf.
More information about the R-help