5

I am writing up some coursework using LaTeX, and I wanted to import a diagram, however when I did the image did not appear in the compiled pdf. The image has been exported as a eps file, and also as a pdf, both of which had the same result. (Although the PDF also required me to provide bounding box figures, as latex couldn't fetch them from the file). I am including the graphic like this:

\documentclass[10pt]{article}
\usepackage[dvips]{geometry,color,graphicx}
\geometry{a4paper}
\begin{document}
\begin{figure}[ht!]
    \centering
    \includegraphics[width=300pt]{figure.eps}
    \caption{caption}
    \label{label}
\end{figure}
\end{document}
16
  • 1
    Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question.
    – Werner
    Aug 27, 2013 at 18:20
  • Is figure.eps in the present working directory of the LaTeX file you are compiling?
    – dustin
    Aug 27, 2013 at 18:20
  • Remove the extension (*.eps) and make sure it is in the same directory as the TeX file.
    – Dan
    Aug 27, 2013 at 18:20
  • What options are you passing to the graphicx package? Aug 27, 2013 at 18:21
  • 4
    delete [dvips] and .eps then your example should work with latex (using the eps version) or pdflatex (using the pdf version) If it doesn't work it is presumably a problem with the image, but as a test use \fbox{\includegraphics{figure}} so latex puts a visible box around the space where it thinks the image is, if that box is wrong, suspect the boundingbox in the eps file. Aug 27, 2013 at 18:59

2 Answers 2

12

Delete [dvips] and .eps then your example should work with latex (using the eps version) or pdflatex (using the pdf version) If it doesn't work it is presumably a problem with the image, but as a test use

\fbox{\includegraphics{figure}} 

so latex puts a visible box around the space where it thinks the image is, if that box is wrong, suspect the boundingbox in the eps file.


The dvips driver can include EPS files but not PDF and the pdftex engine used by pdflatex can include PDF files but not EPS. If you use [dvips] explicitly LaTeX will set things up for dvips so it will not work if you process the document with pdflatex. If you omit the option and the file extension, then a default option is taken depending on the engine used ([dvips] if you use latex and [pdftex] if you use pdflatex. In each case a default list of file extensions is defined, so if you do not put an explicit .eps extension in \includegraphics but have both .eps and .pdf available, latex will try figure.eps and pdflatex will try figure.pdf

2
  • As a bonus is it possible if you could explain why that works? Aug 27, 2013 at 19:12
  • @handuel see update Aug 27, 2013 at 19:18
0

You need to install Ghostscript software. Please check the wesite http://www.ghostscript.com/download/gsdnld.html

There are five different files depending on your operating system. For instance, if you are working in windows xp or 7, you will need to install the file for Windows (32 bit). If you are using windows 8 or 10, you will need the file for Windows (64 bit).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .