13

When I run Andrew Robert's import.tex in MikTeX I get an error message saying that the image file is not found:

! LaTeX Error: File `chick' not found.

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

l.21   \includegraphics{chick}

?

I have put the image file (in this case chick.eps) in the same folder as import.tex.

Speravir
  • 19,491
Sverre
  • 20,729
  • 4
    You are probably use pdflatex instead of latex. The former is actually recommended but doesn't support EPS graphics but only JPG, PNG and PDF. – Martin Scharrer Nov 07 '11 at 00:09
  • Also, it appears that the file downloaded form the web site is called chick1, or chick2, etc and not chick so check the name. I got the error after downloading the file and hence noticed the different name then the file is importing. – Peter Grill Nov 07 '11 at 00:18
  • Thanks Martin. The problem was indeed that I am using pdflatex (that's default in miktex's texworks). I followed the instructions here to convert the eps to a pdf during the compilation. – Sverre Nov 07 '11 at 00:38
  • Also, the pdflatex in TeX Live 2010 and 2011 can automatically convert EPS graphics to their PDF equivalent. – Mike Renfro Nov 07 '11 at 01:00
  • @MikeRenfro: But only with -shell-escape activated? – Martin Scharrer Nov 07 '11 at 08:17
  • 1
    @MartinScharrer: No. TeX Live has a list of save programm calls. So the default shell_escape = p at texmf.cnf together with repstopdf (the restricted/save variant of epstopdf) at the shell_escape_commands (that is default too) is enough. – Schweinebacke Nov 07 '11 at 10:18
  • @Schweinebacke: Thanks, now I remember that. – Martin Scharrer Nov 07 '11 at 10:29
  • @Sverre I think we need to see your log file to establish, for example, what version of the various support packages you are using. – Joseph Wright Nov 08 '11 at 17:54
  • If this is solved, could you post the solution in the form of an answer and mark it so? :) – mpr Nov 13 '11 at 06:48
  • @MartinScharrer: Since your comment solved the problem, I think you should post this as an answer, and perhaps elude to @ Schweinebacke's addition of TeX Live's auto-conversion capability. I don't know anything about it, since I use the appropriate graphics for the compiler anyway. – Werner Nov 18 '11 at 00:43

6 Answers6

22

You are probably use pdflatex instead of latex. The former is actually recommended but doesn't support EPS graphics but only JPG, PNG and PDF. You should convert the EPS to PDF using e.g. epstopdf. Newer versions of pdflatex from TeX Live should do this conversion automatically by running a restricted version (for safety reasons) called repstopdf.

Martin Scharrer
  • 262,582
  • 1
    You should never use convert to convert EPS to PDF. First of all, this would convert the EPS to a bitmap (embedded to a PDF). In case of JPGs embedded to EPS, they would be decompressed and the PDF would become very large. So please use repstopdf to convert EPS into PDF. This is, what TeX Live since 2010 would do on-the-fly and out of the box, if the defaults shell_escpape = p and the entry repstopdf for variable shell_escape_commands at the default texmf.cnf are not changed. – Schweinebacke Nov 18 '11 at 08:18
  • 1
    @Schweinebacke: Sorry, too early in the morning. I didn't had a coffee yet. I meant epstopdf but wrote convert. I use the latter very often for all raster images. – Martin Scharrer Nov 18 '11 at 08:24
  • Don't be angry but I've written a more detailed answer … – Schweinebacke Nov 18 '11 at 08:58
  • In fact, I suspect it's the lack of bounding box information in the pdf which causes pdflatex to complain that the file is missing even if it is actually there. – Andre Holzner Nov 22 '15 at 16:04
  • @AndreHolzner: No, if you write \includegraphics{chick} then the file is searched with all supported file extensions. Now, pdflatex is not supporting EPS files, so doesn't find chick.eps. If there would be a chick.pdf in the same directory it would use that one. – Martin Scharrer Nov 23 '15 at 12:27
8

Using MiKTeX you have to use the recommended graphics format depending on the engine you are using.

So, if you are using latex—mostly at a queue latex→dvips→pstopdf—you can only use EPS, PCX, BMP, MSP, PICT or PNTG, all of them with different file extensions and sometimes with additional endings. EPS is the most recommended file format with latex→dvips, because the dimensions of EPS may be detected by graphics/graphicx itself. For the other file formats you need additional bb-files with the dimensions or to use option boundingbox.

If you are using pdflatex with direct PDF output, you can only use PDF, JPEG, PNG and MPS. (Note: MPS is a subtype of EPS generated by MetaPost and needs parts of ConTeXt to be installed.)

With TeX Live since 2010, support for on-the-fly conversion of EPS to PDF has been added. This should be activated out if the box. The conversion consists in three parts:

  1. A graphics.cfg file, that supports file extensions .ps and .eps even, if pdflatex with direct pdf output is used.
  2. LaTeX package epstopdf, that uses shell escapes to convert eps to pdf on the fly using repstopdf.
  3. A texmf.cnf with settings shell_escpape = p and shell_escape_commands = repstopdf.

Because of this, you may use EPS with pdflatex and direct PDF output, if you are using TeX Live since 2010.

With MiKTeX you may use on-the-fly conversion, too. In this case you have to load LaTeX package epstopdf on your own (see the manual for more information) and you have to set command line option --enable-write18 at call of pdflatex. If you call pdflatex from within a LaTeX editor, have a look at the editor or the profile settings and the editor manual to find out, where you may add this command line option.

You may test the on-the-fly conversion using:

\begin{filecontents*}{\jobname.eps}
%!
%%BoundingBox:100 100 172 172
100 100 moveto
72 72 rlineto
72 neg 0 rlineto
72 72 neg rlineto
stroke
100 100 moveto
/Times-Roman findfont
72 scalefont
setfont
(A) show
showpage
\end{filecontents*}
\documentclass{article}
\usepackage{graphicx}
\usepackage{ifpdf}

\begin{document}
\ifpdf
  You are using pdf\LaTeX. If you see the picture, on-the-fly conversion does work!
\else
  You need to use pdflatex to test the on-the-fly conversion! You may see the
  original eps file without conversion now:
\fi

\includegraphics{\jobname.eps}
\end{document}

Instead of using on-the-fly conversion you may simply convert every EPS to PDF using epstopdf. In this case you may remove extra white space around the picture using pdfcrop.

Note, that sometimes the conversion to PDF results in PDFs with bad Bounding Box. In this case, you should search for %%PageBoundingBox at the PS file and copy the four dimensions at this line to the line %%BoundingBox at the begin or end of the file (replacing the values you'd find there). On-the-fly conversion will be use these new values at next run of pdflatex. If you are using manual conversion, don't forget to do it again.

To convert PDF to EPS the usage of pdftops --eps is recommended. This is a command line utility from xpdf. Note, that this is available not only for Linux, but for Windows too. Alternative you may use pdf2ps, a ghostscript command line utility. But the results may be not a good as the results of pdftops.

Schweinebacke
  • 26,336
1

I had problem not being able to read the eps file using TeXworks. I fixed the problem by including the following line in the tex file:

\usepackage{epstopdf}

I then called the file using:

\includegraphics[scale=0.9]{SecularGmst.eps}
Heiko Oberdiek
  • 271,626
0

For what its worth, I tried all the above methods and none worked. Eventually, I found that TeXstudio was calling repstopdf and not epstopdf. repstopdf was symlinked to epstopdf under /usr/texbin. I removed the repstopdf symlink and recreated it to point to the same file that epstopdf was symlinked to after which it worked.

cd /usr/texbin
rm repstopdf
ln -s ../../texmf-dist/scripts/epstopdf/epstopdf.pl repstopdf

I am running TeXstudio v2.6.6 on Mountain Lion/Mac.

Torbjørn T.
  • 206,688
  • I'm also having the same problem with TeXstudio (v2.7.0 on OSX Mavericks 10.9.2). I tried it in Latexian and there was no problem, so it's definitely a TeXstudio issue. Your solution didn't work for me, unfortunately... – GTF Apr 03 '14 at 15:58
  • Ok, problem solved within TeXstudio's preferences. It has its own internal $PATH variable, which was set to an old (and no longer installed) TeXLive. Changing this to the current version fixed the problem. – GTF Apr 03 '14 at 16:00
0

The filecontents first line should be "%!PS" instead of "%!" to avoid "Invalid binary DOS header" from epstopdf.cpp available at ftp://163.143.1.21/pub/tex/miktex-svn/miktex-latest/Programs/MiKTeX/epstopdf/epstopdf.cpp

My setup is C:\Pub\Tex>pdflatex -version

MiKTeX-pdfTeX 2.9.4225 (1.40.12) (MiKTeX 2.9)

J. Gélinas

  • 1
    This does not answer the question. Instead, it appears as if you are providing the answer to another problem you are having. If so, please open a new question about your problem. – Sverre Sep 12 '15 at 14:37
0

Change pdflatex to xelatex, it solves the problem for me.

panc
  • 143
  • 1
  • 5