TransWikia.com

Problem with includegraphics - file not found!

TeX - LaTeX Asked by Felix Schleef on April 20, 2021

I am trying to include a graph in a tex document.
I do realize that there have already been several questions asked about this topic, but I think by now I have tried all suggested solutions but none seem to work. This is the minimal example:

documentclass[12pt]{report}
usepackage{graphicx}
graphicspath{{C:/Users/felix/Desktop/Bachelorarbeit/TeX/BA_text2/images}}
usepackage[a4paper]{geometry}

begin{document}
begin{figure}
includegraphics[scale=1]{gap_v3_v4_AT.png}
end{figure}
end{document}

Information about my setup:

I am using Texmaker and MiKTeX 2.9.

Things I have tried:

  • Absolute and relative paths,
  • not initialising a figure environment,
  • including the directory where the graph is in the MiKTeX Options-> root directory (was suggested in one of the answers to a similar question)

There is definetly a .png file with the same exact name in the folder set by graphicspath.

I would be really grateful for any ideas!

3 Answers

graphicspath does not really setup directories. graphics (or graphicx) only adds the given strings before the file name of the mandatory argument of a includegraphics, tries to open the file and if is successful uses this concatenated file name to include the file. So

graphicspath{{C:/Users/felix/Desktop/Bachelorarbeit/TeX/BA_text2/images}}
includegraphics[scale=1]{gap_v3_v4_AT.png}

would try to load C:/Users/felix/Desktop/Bachelorarbeit/TeX/BA_text2/imagesgap_v3_v4_AT.png (note the missing slash before gap_v3_v4_AT.png). If C:/Users/felix/Desktop/Bachelorarbeit/TeX/BA_text2/images is the name of a directory, you should append a slash at the end:

documentclass[12pt]{report}
usepackage{graphicx}
graphicspath{{C:/Users/felix/Desktop/Bachelorarbeit/TeX/BA_text2/images/}}
usepackage[a4paper]{geometry}

begin{document}
includegraphics[scale=1]{gap_v3_v4_AT.png}
end{document}

In this example graphicx will try to load C:/Users/felix/Desktop/Bachelorarbeit/TeX/BA_text2/images/gap_v3_v4_AT.png.

BTW: includegraphics does not need a figure environment. figure environments makes sense only, if LaTeX should move the figure if it could not be printed in place. Mostly figure without caption makes no sense.

Correct answer by Schweinebacke on April 20, 2021

  1. You can try to finish your graphicspath statement with a double slash (//)
  2. Check the path that you registered in graphicspath. Many times the file doesn't compile because of a small typo. Try to copy and paste the path from the properties of the file.

Answered by Andre on April 20, 2021

I just found that I had a small letter i in Images, instead of capitalized. Corrected this, and it worked fine. Be careful, Linux is case sensitive with file names.

Answered by wdb07124 on April 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP