Here's the preamble:


... And here's the call to \includegraphics:


The error on the log:

! Package pdftex.def Error: File `n6d.png' not found.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.

l.39 ...aph & \includegraphics[scale=0.5]{n6d.png}
                                               & \includegraphics[scale=...

Typing "H" just puts it into draft mode.

The file 'n6d.png' is located in the same folder as the .tex file. I've tried putting just 'n6d' as the filename, but still have the same problem. Here's the command I'm calling to compile the PDF:

"C:\texlive\2012\bin\win32\pdflatex.exe" -output-directory "D:\Documents\School\Math3\Worksheets\3" "D:\Documents\School\Math3\Worksheets\3\wksht3_sols.tex"

There are other files in the .tex file that are having the same issue. Any ideas?

  • 3
    There are many Questions about input paths. For instance this one might be interesting for further reading tex.stackexchange.com/questions/89247/input-file-folder/…
    – bloodworks
    Jan 27, 2013 at 23:15
  • 7
    \includegraphics{ image.png } failed for me. \includegraphics{image.png} then succeded. I ran into trailing / leading whitepace problem. I need ten reputation without association to answer so -> unfortunately for everyone I put my answer in a comment.
    – D A
    Jun 16, 2016 at 18:03
  • Can't post an answer due to reputation limitations. Another subtle cause may be an empty file - for me, pdflatex was giving this error when i've tried to include existing file, which had zero size due to transmission error.
    – Etki
    May 23, 2022 at 22:16

6 Answers 6


I was having this problem too but have figured it out -- I know this is an old thread, but since the question might come up in searches for people with current problems (it came up in mine), I'll say how I fixed it.

If using MiKTeX, even if your figure file is in the same directory as the TeX file you're working with, you have to refresh the file name database every time you add files into this folder. So do this:

  1. open MiKTeX Settings / Options;
  2. Roots tab: check that the folder with the files in it is one of the Root paths;
  3. General tab: Maintenance: Refresh

This solves it for me.

  • 34
    Threads are never old on stackexchange if you have good information to share. This is not the typical stupid forum managed by typical stupid people ;-)
    – HAL9000
    Feb 20, 2014 at 9:45
  • 2
    I'm having this problem, but I use TeXLive, and refreshing the FNDB didn't help me. Very frustrating since everything was working smoothly until today.
    – ಠ_ಠ
    May 5, 2017 at 0:45

Its not important that the image file is in the same directory of the tex file. It should be in the working directory where you launch the pdflatex command.

For example, if you run:

cd ~/bar
pdflatex foo/baz

the PDF file should be in the ~/bar directory rather than the ~/bar/foo directory.

Use the command \graphicspath to set a different path.

added: this is what happens when you run pdflatex from a command line. If you are using an integrated editor, you should dig into the options to see how the editor chooses the working directory into which to run the pdflatex command. I think that usually the working directory will be choosen as to be the directory containing the main source file.

  • 8
    What do you mean by "working directory where you launch the 'pdflatex' command?" Apr 6, 2013 at 21:51
  • 1
    @alanH for example when compiling on a continuous integration server, the command is executed in a directory you-don't-know-where that just happens to be the working directory for the server at that time. On your own system this is probably just the directory your tex file is in.
    – PHPirate
    Oct 31, 2017 at 19:56
  • 3
    The pdflatex command is running in the same directory but still not found. I'm on macos Sep 5, 2018 at 4:05

You can set the path of your figures by adding

\graphicspath{{./Figures/}} %Where the figures folder is located

To your preamble. Of course, {./Figures/} is actually the path where the figures' folder is located.

Also, you may want to try not using wksht3_sols.tex as your file name (due to the _). Change it to something like wksht3sols.tex

Try doing these two things to see how it works.

  • Thanks.. If any one got this problem after an upgrade to Mac Yosemite, then the use of two curly brackets in \graphicspath will solve it.
    – Mostafa
    Nov 25, 2014 at 17:07
  • 3
    This was my issue; I had underscores in the file name. That seems kind of obnoxious. Do we know what the reason for that is? Nov 16, 2017 at 14:00
  • I had underscores but they weren't the problem. I tried myfile.eps and /myfile.eps, but not ./myfile.eps. You either need to include the current directory (dot) in the beginning of the \includegraphics path or set the \graphicspath first. :facepalm:
    – Sinjai
    Oct 23, 2020 at 4:15

I also had this problem. The source of the error was (for me), that the file for the image I wanted to include was registering as having no file-extension (even though it really IS a .png file, and opens like one)! But it listed in the terminal as having no file-extension (for some strange reason).

I just renamed it to file.png instead of file, and of course everything worked fine from there!

So maybe check if your image file actually does "exist" before you stress about which directory LaTeX is checking and so on.

  • 5
    Please don't add "thanks" as answers. Invest some time in the site and you will gain sufficient privileges to upvote answers you like, which is the Stack Exchange way of saying thank you. May 26, 2014 at 12:45

It worked for me after I add these lines


I ran to the same problem today but the cause was different from any of the answers listed here: I was using the package underscore and including pictures containing an underscore in the filename.

Minimum (non)working Example




Compiling with

pdflatex MWE.tex


LaTeX Warning: File `picture_1.png' not found on input line 9.

! Package pdftex.def Error: File `picture\unhbox \voidb@x \penalty \@M \hskip \
z@skip \T1\textunderscore \discretionary {-}{}{}\penalty \@M \hskip \z@skip 1.png' not found.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.

l.9   \includegraphics[height=4cm]{picture_1.png}


Rename picture_1.png to picture-1.png.

Side note

Interestingly, removing the line


leads to a different error message

! Missing number, treated as zero.
<to be read again> 
l.8   \includegraphics[height=4cm]{picture_1.png}

(I am not the first to notice it) and only after pressing Enter complains about picture_1.png not found.

  • The underscore with the usual category code is not the problem. But package underscore makes the underscore active and adds hyphenation support in text mode that breaks its use in file names. The documentation of underscore describes workarounds in section "Deficiencies". Thus option strings (\usepackage[strings]{underscore}) works as \string for _ in \includegraphics[...]{picture\string_1.png}. Aug 5, 2018 at 0:03
  • 2
    For me xelatex always included files with _ but lualatex could not.
    – Dilawar
    Jan 30, 2020 at 6:37

You must log in to answer this question.

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