6

My folder structure looks like that:

enter image description here


While putting the chapters into the base file Report.tex works completely fine I get trouble when I try to insert the graphics into the chapters.

For example: How can I put the file Image_1 into Chapter_1.tex? As you can see the target file Image_1 is located in a neighboured directory of Chapter_1.tex.

Some command in Chapter_1.tex like...

\includegraphics[blabla]{../Graphics/Image_1}

... leads to the error "! LaTeX Error: File `../Graphics/Image_1' not found."


Minimum Working Examples (MWE):

For file Report.tex in root directory:

\documentclass{book}

\usepackage{graphicx}
\usepackage{blindtext}

\begin{document}

    \input{Chapters/Chapter_1}

    \input{Chapters/Chapter_2}

    \input{Chapters/Chapter_3}

\end{document}

For file Chapter_1.tex in subdirectory Chapters:

\chapter{First chapter}

\blindtext

\includegraphics{../Graphics/Image_1}

For file Image_1.tex in subdirectory Graphics:

\includegraphics{example-image-golden}

Do you have any ideas how to cross-input files from parallel directories? Thank you very much!

6
  • Well, without an MWE it's hard to give you an accurate answer. I understand that this answer could solve the problem of your graphics. For the chapters, you need to add the path into the \include{} command.
    – Aradnix
    Commented Jan 30, 2018 at 5:23
  • @Aradnix: Thank you very much for your kind reply! I added the belonging MWE. I would love to add the image without further packages if it is possible?
    – Dave
    Commented Jan 30, 2018 at 5:42
  • checking with \graphicspath{{../figure_folder/,../figure_subfolder/,}}, so that it will check all the folder paths
    – MadyYuvi
    Commented Jan 30, 2018 at 10:19
  • 3
    I think within the file that's \input you need to use the path relative to the root file (not the input file), so try \includegraphics{Graphics/Image_1} instead. Commented Jan 30, 2018 at 11:11
  • @NicolaTalbot: You are right, thank you very much! Indeed the path will be taken from the root file what means that subdirectories can be accessed. You can post this as an answer if you want. :-)
    – Dave
    Commented Feb 1, 2018 at 17:17

1 Answer 1

9

Files that are \input need to use a path relative to the root file (the one containing \documentclass) not to the included file, so you need to use

\includegraphics{Graphics/Image_1}

instead of

\includegraphics{../Graphics/Image_1}

It's probably simpler to use \graphicspath in the root file so you don't have to worry about the paths:

\graphicspath{{Graphics/}}

or if you have sub-directories within Graphics:

\graphicspath{{Graphics/}{Graphics/subDir1/}{Graphics/subDir2/}}

then you just need to use

\includegraphics{Image_1}

You must log in to answer this question.

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