[R] R Graphics into Latex‏

Sharpie chuck at sharpsteen.net
Thu Feb 25 02:28:42 CET 2010



Lars Bishop-2 wrote:
> 
> Hi,
> 
> I'm new in Latex and I'm trying to include an R chart into a Latex
> document.
> 
> This is what I'm doing:
> 
> 1) In R: save the chart as a a Postcript in a folder C:/xxx/Density.eps
> 

So, to be clear, your graphic is saved on the C drive.



Lars Bishop-2 wrote:
> 
> 2) In Latex (using TexWorks on windows xp) :
> 
> In the preambule:
> 
> \documentclass[11pt]{article}
> \usepackage{graphicx}
> \begin{document}
> 
> blah..blah
blah
> 
> \begin{figure}
> \centering
> \includegraphics{C:/xxx/Density.eps}
> \label{fig:Density}
> \end{figure}
> 
> --This is the Error Message I'm getting:
> 
> LaTeX Warning: File `R:/MarsTH/Studies/Misc/LIA QA/R/Density.eps' not
> found
> on input line 26.
> 

And LaTeX is looking on the R drive.  Not quite sure how to fix this as you
did specify C:/xxx/Density.eps in your call to \includegraphics{}.  TeX and
LaTeX were developed in UNIX environments where there are no C drives or R
drives that segment the file system-- everything is contained under "/". 
There may be some special way you have to enter Windows paths.




Lars Bishop-2 wrote:
> 
> ! LaTeX Error: Unknown graphics extension: .eps.
> 

You said you were using TeXworks which uses pdflatex as the default
compiler.  pdflatex compiles directly from .tex to .pdf and supports a wide
variety of graphic inputs *EXCEPT* for .eps as the warning message above
indicates.  The older method of compiling LaTeX documents is to use the
latex compiler which produces a .dvi file, then running dvips to produce a
postscript file and then running ps2pdf to produce a pdf file.  The latex
compiler *ONLY* supports .eps as a graphic input.

Personally, I would stick with the pdflatex compiler and switch to using the
pdf() device in R for your graphics output.

Hope this helps!

-Charlie



Lars Bishop-2 wrote:
> 
> See the LaTeX manual or LaTeX Companion for explanation.
> 
> Type H <return> for immediate help.
> 
> I'll appreciate your help.
> Thanks in advance,
> 
> Lars.
> 

-- 
View this message in context: http://n4.nabble.com/R-Graphics-into-Latex-tp1568266p1568391.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list