[Tex/LaTex] Problem with \includegraphics – file not found!

floatsgraphicsgraphsmiktextexmaker

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!

Best Answer

\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.

Related Question