Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

migrated from stackoverflow.com Aug 27 '13 at 18:18

This question came from our site for professional and enthusiast programmers.

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 '13 at 18:20
    
Is figure.eps in the present working directory of the LaTeX file you are compiling? –  dustin Aug 27 '13 at 18:20
    
Remove the extension (*.eps) and make sure it is in the same directory as the TeX file. –  maj nem ɪz dæn Aug 27 '13 at 18:20
    
What options are you passing to the graphicx package? –  Andrew Swann Aug 27 '13 at 18:21
2  
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. –  David Carlisle Aug 27 '13 at 18:59

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer
    
As a bonus is it possible if you could explain why that works? –  handuel Aug 27 '13 at 19:12
    
@handuel see update –  David Carlisle Aug 27 '13 at 19:18
    
Thanks, that's perfect –  handuel Aug 27 '13 at 19:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.