# Problem adding more than two figure paths using \graphicspath in LaTeX

My main .tex document is located in a "Parent" folder. The "Parent" folder contains several "Chapter" folders: 0_Chapter, 1_Chapter, 2_Chapter, etc. Each "Chapter" folder contains a .tex document (chapter0.tex, chapter1.tex, chapter2.tex), as well as a figure folder (figures0, figures1, figures2, etc), which are included in the main.tex document upon compilation.

As an example, the path for the figures in Chapter 0 is indicated in the chapter0.tex file using \graphicspath{{0_Chapter/figures0/}}, and for Chapter 1, chapter1.tex contains the line \graphicspath{{1_Chapter/figures1/}}.

When I compile the main.tex file, the figures are nicely added to the document. So far, so good.

However, as soon as I do the same for the next Chapter, I get the error message image.png not found.

I tried as well to add a single figure path by adding \graphicspath{{0_Chapter/figures0/}{1_Chapter/figures1/}{2_Chapter/figures2/}} in the main.tex file, however, it only works when including figures from the first two figure directories, and gives an error message for the third one. The only thing that allows calling the figures from the figures2 folder is by adding the directory directly in \includegraphics...:

\begin{figure}[H]
\includegraphics[width=1\textwidth]{2_Chapter/figures2/image.png}
\end{figure}


I really cannot figure out what the problem is... I tried several methods (some of the links below), but none of them worked... How to add graphics in LaTeX; How to use \graphicspath? ; Multiple graphics directory; \graphicspath and \include;

Does anyone know what the problem might be? Thanks a lot in advance!

EDIT: My files contain the following:

main.tex

 \documentclass[a4paper,11pt,twoside]{report}
\usepackage{graphicx}
\graphicspath{{0_Chapter/figures0/}{figures0/}{1_Chapter/figures1/}{figures1/}{2_Chapter/figures2/}{figures2/}}

\begin{document}
\include{0_Chapter/chapter0.tex}
\include{1_Chapter/chapter1.tex}
\include{2_Chapter/chapter2.tex}
\end{document


chapter0.tex

\chapter{Chapter 0}
Text....
\begin{figure}[H]
\includegraphics[width=1\textwidth]{image0.png}
\end{figure}


chapter1.tex

\chapter{Chapter 1}
Text....
\begin{figure}[H]
\includegraphics[width=1\textwidth]{image1.png}
\end{figure}


chapter2.tex

\chapter{Chapter 2}
Text....
\begin{figure}[H]
\includegraphics[width=1\textwidth]{image2.png}
\end{figure}


Actually, everything works nicely, until I try to include figures in chapter2.tex... (text, sectioning, etc from chapter2.tex is included in the main document... only the figures can't be added)

• (1) welcome, (2) In main.tex C1/figures1 makes sense, but inside C1 you need figures1. Have you tried \graphicspath{{0_Chapter/figures0/}{figures0/}{1_Chapter/figures1/}{figures1/}{2_Chapter/figures2/}{figures2/}}? – daleif Jan 5 '17 at 13:45
• yes i tried using \graphicspath{{0_Chapter/figures0/}{figures0/}{1_Chapter/fig‌​ures1/}{figures1/}{2‌​_Chapter/figures2/}{‌​figures2/}}, however, i get the same error message... – ikoz Jan 5 '17 at 13:57
• I personally don't see the need to splatter my document and graphics files all over your filesystem. Your problem is one reason why. I suggest strongly to have one image-directory and store all your image files there. Of course, in that case you have to name all your image files uniquely. BTW: you should avoid adding the file name extension to \includegraphics. It makes your document less portable. – Jan Jan 5 '17 at 14:32
• I agree that having all the figures in one folder and one tex file is much easier... however, as I have loads of figures and long chapters/sections/subsections/subsusections/paragraphs for the thesis, I found it easier to split my chapters in different tex files and merge them at the end... – ikoz Jan 5 '17 at 14:37
• In this case you are not compiling the chapters on their own. What exactly did you mean by that. Are you sure the folder names are 100% correct in the graphics path list? – daleif Jan 5 '17 at 14:43

Too long for a comment. You probably need to tell us more about your setup. This works fine for me.

File structure

ls  -R
.:
C1/  C2/  main.tex

./C1:
figures1/  T1.tex

./C1/figures1:
test1.png

./C2:
figures2/  T2.tex

./C2/figures2:
test2.png


main.tex:

\documentclass[a4paper]{memoir}
\usepackage{graphicx}
% ignore preamble of included documents
\usepackage{docmute}
\graphicspath{{C1/figures1/}{figures1/}{C2/figures2/}{figures2/}}
\begin{document}

main

\input{C1/T1}

\input{C2/T2}
\end{document}


T1.tex:

\documentclass[a4paper]{memoir}
\usepackage{graphicx}
\graphicspath{{C1/figures1/}{figures1/}{C2/figures2/}{figures2/}}
\begin{document}

\chapter{1}

test1

\includegraphics{test1}
\end{document}


T2.tex:

\documentclass[a4paper]{memoir}
\usepackage{graphicx}
\graphicspath{{C1/figures1/}{figures1/}{C2/figures2/}{figures2/}}
\begin{document}

\chapter{2}

test2

\includegraphics{test2}
\end{document}


So what exactly is different in your setup from my setup.

Note I'm using exactly the same \graphicspath in all files.

• daleif, maybe, the OP has figure-files with identical names in all chapter-directories? Exactly: C1/figures1/test.png and C2/figures2/test.png. This would result in being C1/figures1/test.png included in every chapter. (Having no more information from the OP, I could only guess?) – Jan Jan 5 '17 at 14:28
• @Jan but then the compilation should resolve because it found something. The OP mentions image not found – daleif Jan 5 '17 at 14:41
• You are right. Nevertheless, I doubt that creating that lot of directories is a good idea. – Jan Jan 5 '17 at 15:08