Suppress pdflatex warning about missing eps file

I use .eps graphics in my latex documents converted at compile using the epstopdf package and it works great.

When I build the file, epstopdf creates the <filename>-eps-converted-to.pdf file and includes it in the resulting .pdf.

I would now like to now delete the .eps file and just use the converted<filename>-eps-converted-to.pdf file. This actually works, sort of - epstopdf doesn't complain (rightly or wrongly), it just returns

Package epstopdf Info: Output file is already uptodate.


and the resulting .pdf contains the image as desired.

However, I get an annoying LaTeX warning

LaTeX Warning: File test.eps' not found on input line 8.


MWE:

\documentclass{article}

\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{epsfig}

\begin{document}
\includegraphics{test.eps}
\end{document}


Build this with any .eps file and it builds fine. Now delete or rename the .eps file and it still builds fine, but gives the annoying warning above.

My question: is there any way to just disable the warning for missing .eps files?

The reason for this is that I often auto-generate .eps files outside of the latex source directory and would like to just commit the latex source to git with the converted .pdf files (output locally by using the [outdir=./] option with epstopdf) but without the source .eps files - this way I or anyone else can build it stand-alone.

Updated MWE with .eps file outside the source path:

\documentclass{article}
\usepackage{graphicx}
\usepackage[outdir=./]{epstopdf}
\epstopdfsetup{suffix=}
\begin{document}
\includegraphics{../test}
\end{document}

• You shouldn't need epsfig: the recommended solution is to use graphicx instead. And you probably don't need epstopdf although the latter will not hurt anything.
– cfr
Jan 14, 2015 at 22:21
• don't use epsfig and use \includegraphics{test} rather than \includegraphics{test.eps} then all you need to do is check in the generated files as test.pdf and latex will use the eps if it is there and pdflatex will use the pdf it's probably simpler just to convert each of the eps externally rather than getting latex to escape to teh shell to convert them Jan 14, 2015 at 22:40
• @DavidCarlisle, thank you for the comment - that works well if the .eps file is in the source directory. Is there a solution if the file is outside the source dir and [outdir=./] is used with epstopdf? I have added a new MWE to demonstrate. Jan 14, 2015 at 23:36

It doesn't seem that there is a way to prevent the warning showing up directly.

One work-around would be to use the silence package to filter out the warnings from the output.

However, silence doesn't detect these warnings as they're generated using

\@warning{File #1' not found}%


(line 166 of graphics.sty) and silence only picks up warnings generated using \PackageWarning, \ClassWarning, \@latex@warning and \@font@warning (lines 381-431 in v1.5b of silence.sty).

I have contacted the maintainer of silence about this but received no response, so the simplest solution is to place the following code in the preamble:

\usepackage{silence}

\WarningFilter[latex_file_not_found]{latex}{File}

\makeatletter
\let\sl@warning\@warning
\def\@warning#1{%
\def\sl@PackageName{latex}%
\ifsl@NoLine
\sl@NoLinefalse
\else
\sl@StoreMessage{#1}%
\fi
\sl@warning{#1}}

\def\@warning@no@line#1{%
\sl@StoreMessage{#1}%
\sl@NoLinetrue
\@warning{#1\@gobble}}
\makeatother

\ActivateWarningFilters[latex_file_not_found]


This will ignore all \@warnings that start with File.

It is also possible to wrap all \includegraphics with \ActivateWarningFilters[latex_file_not_found] and \DeactivateWarningFilters[latex_file_not_found] to only apply this to graphics imports (I'm not sure where File warnings would otherwise show up).

Alternatively, this can also be automatically included in all \includegraphics calls with the following re-definition (credit to David Carlisle and this answer):

\makeatletter
\let\oldGin@ii\Gin@ii
\def\Gin@ii[#1]#2{%
\ActivateWarningFilters[latex_file_not_found]%
\oldGin@ii[{#1}]{#2}%
\DeactivateWarningFilters[latex_file_not_found]}
\makeatother


Package epstopdf can be reconfigured to remove the additional name suffix from the generated file name. The suffix was added to avoid accidental overwriting of .pdf source files. But if all images are .eps files, then these precaution measure is not necessary. The image file is then included without extension and the graphicx package will find the .pdf file or .eps file depending on the order given by \DeclareGraphicsExtensions (see package grfext for manipulating the sort order).

\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\epstopdfsetup{suffix=}
\begin{document}
\includegraphics{test}
\end{document}

• Thanks for your answer, and this has definitely taught me a few things. However, it doesn't work when the .eps file is outside the source path and I use epstopdf with [outdir=./]`. I have added a new MWE for this case. Is there a solution here? Jan 14, 2015 at 23:29