Skip to content

Getting graphs into LaTeX

5 messages · Andrew Criswell, Ko-Kang Kevin Wang, A.J. Rossini +2 more

#
Hello ALL:

I ran with success the following commands in R getting a file saved
------------------------------------------------------------------------------------
postscript()

postscript('~/data/st202/2003/lecture00/lecture00-graph-01.eps',
           horizontal = FALSE, height = 6, pointsize = 10)

hist(trial.outcome.5, breaks = 5,
     main = '1000 Replications of 5 Trials of a Coin Toss',
     xlab = 'Frequency of a Tail')
------------------------------------------------------------------------------------
But when I try to include it within a LaTeX document, I get the 
following complaint.

LaTeX document (trix.tex):
------------------------------------------------------------------------------------
\documentclass[11pt]{article}
\usepackage[pdftex]{graphicx,color}
\begin{document}
\includegraphics{lecture00-graph-01.eps}
\end{document}
------------------------------------------------------------------------------------
Which I try to compile with the command:  pdflatex trix.tex

But then, I get this error:
------------------------------------------------------------------------------------
! LaTeX Error: Unknown graphics extension: .eps.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.5 \includegraphics{lecture00-graph-01.eps}

?
------------------------------------------------------------------------------------
Any suggestions?

Thanks,
ANDREW
#
Hi,

----- Original Message -----
From: "Andrew Criswell" <arc at arcriswell.com>
To: "r-help" <r-help at stat.math.ethz.ch>
Sent: Friday, August 22, 2003 2:17 AM
Subject: [R] Getting graphs into LaTeX
----------
----------


Have you closed the postscript device?  Normally you need a dev.off() after
you finished the plot.  Try putting dev.off() after your hist().

The other thing is can you actually view "lecture00-graph-01.eps" in the
directory, with a postscript Viewer?

The last point, I think pdflatex (or pdftex) does not accept PS/EPS
formatted picture.  Can you latex trix.tex?  If so, try to save your
histogram as a PDF or PNG file, then pdflatex it again.

Cheers,

Kevin

------------------------------------------------
Ko-Kang Kevin Wang
Master of Science (MSc) Student
Department of Statistics
University of Auckland
New Zealand
www.stat.auckland.ac.nz/~kwan022



********************************************
#
pdflatex needs pdf,jpg, or other formats -- it can't handle eps.

best,
-tony
andrew> Hello ALL:
    andrew> I ran with success the following commands in R getting a file saved
    andrew> ------------------------------------------------------------------------------------
    andrew> postscript()

    andrew> postscript('~/data/st202/2003/lecture00/lecture00-graph-01.eps',
    andrew>            horizontal = FALSE, height = 6, pointsize = 10)

    andrew> hist(trial.outcome.5, breaks = 5,
    andrew>      main = '1000 Replications of 5 Trials of a Coin Toss',
    andrew>      xlab = 'Frequency of a Tail')
    andrew> ------------------------------------------------------------------------------------
    andrew> But when I try to include it within a LaTeX document, I get the
    andrew> following complaint.

    andrew> LaTeX document (trix.tex):
    andrew> ------------------------------------------------------------------------------------
    andrew> \documentclass[11pt]{article}
    andrew> \usepackage[pdftex]{graphicx,color}
    andrew> \begin{document}
    andrew> \includegraphics{lecture00-graph-01.eps}
    andrew> \end{document}
    andrew> ------------------------------------------------------------------------------------
    andrew> Which I try to compile with the command:  pdflatex trix.tex

    andrew> But then, I get this error:
    andrew> ------------------------------------------------------------------------------------
    andrew> ! LaTeX Error: Unknown graphics extension: .eps.

    andrew> See the LaTeX manual or LaTeX Companion for explanation.
    andrew> Type  H <return>  for immediate help.
    andrew>  ...

    andrew> l.5 \includegraphics{lecture00-graph-01.eps}

    andrew> ?
    andrew> ------------------------------------------------------------------------------------
    andrew> Any suggestions?

    andrew> Thanks,
    andrew> ANDREW

    andrew> ______________________________________________
    andrew> R-help at stat.math.ethz.ch mailing list
    andrew> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
#
On Thu, 19 Dec 2002, A.J. Rossini wrote:

            
pdf or png these days I believe.  (There was tiff and jpg support once,
but tiff has definitely gone.)

R does have a pdf() device (and I wonder who wanted to include graphs in
pdftex documents?).  Otherwise eps can be converted to pdf by the script
epstopdf (which calls distiller or gs) which has an executable version on
Windows, epstopdf.exe.
#
On Thu, Aug 21, 2003 at 08:17:05PM +0700, Andrew Criswell wrote:
"pdflatex" wants pdf-pics, not eps. If you want to use both, latex &
pdflaex, save one version with pdf(), one version with postscript
and use \includegraphics{~/xx} without ending. pdflatex & latex
will choose the appropiate file. 
pm