[R] Questions on Inserting R graphs in latex!

Liaw, Andy andy_liaw at merck.com
Fri Jan 14 03:48:27 CET 2005


This is not an R problem, but LaTeX.  

Seems like the `slides' document class you're using doesn't recognize the
`figure' environment.  You should check that.

I seem to recall that you need to specify a driver option for graphicx, such
as `epsfig' for some such.  You should check the documentation for that
package.

Andy

> From: Xianggui QU
> 
> Hi,
> I try to insert R graphs into a latex file and I am using a 
> Texniccenter/MikTex combination in my Windows XP. Here are 
> the errors I got. Could someone give me some clues?
>  
> In R, I did
> > plot(sin(1:10), pch="+") 
> > dev.print(device=postscript, 
> "C:\\myFigure.eps",onefile=FALSE, horizontal=FALSE, paper="special") 
>  
> In latex, I did (myFigure.eps is in the same folder as my latex file)
> 
> \documentclass{slides} 
> \usepackage{graphicx} 
> \begin{document} 
> It can be seen in Figure \ref{fig:myFigure}.
> \begin{figure} 
>         \begin{center} 
>                 \includegraphics[scale=0.9]{myFigure} 
>         \end{center} 
>   \caption{test statement} 
>         \label{fig:myFigure} 
> \end{figure} 
> \end{document} 
>  
> I got th following errors while I used Ctrl+F7 to edit.
>  
> ! LaTeX Error: Environment figure undefined.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.5 \begin{figure}
>                   
> Your command was ignored.
> Type  I <command> <return>  to replace it with another command,
> or  <return>  to continue without it.
> 
> ! LaTeX Error: File `myFigure' not found.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.7 ...      \includegraphics[scale=0.9]{myFigure}
>                                                   
> I could not locate the file with any of these extensions:
> .png,.pdf,.jpg,.mps,.tif
> Try typing  <return>  to proceed.
> If that doesn't work, type  X <return>  to quit.
> 
> ! LaTeX Error: \caption outside float.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.9   \caption
>               {test statement}
> You're in trouble here.  Try typing  <return>  to proceed.
> If that doesn't work, type  X <return>  to quit.
> 
> ! LaTeX Error: \begin{document} ended by \end{figure}.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
>                                                   
> l.11 \end{figure}
>                  
> Your command was ignored.
> Type  I <command> <return>  to replace it with another command,
> or  <return>  to continue without it.
>  
>  
> Thank you very much!
> Xianggui.
>  
>  
>  
> 
> __________________________________________________
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list