6

I'm writing a document organized in many parts, so I use the subfiles packages.

Each subdocuments has a directory for it's images :

./img/
./img/1-Intro/test.png
./img/2-Analysis/

So my code ressemble to that :

% main.tex
\documentclass{report}
  ...
  \usepackage{graphicx}
    \graphicspath{
      {./img/}
      {./img/1-Intro/}
      {./img/2-Analysis/}      
    }
  \usepackage{subfiles}
  \begin{document}
    \subfile{subfile1.tex}
  \end{document} 

And my subfile :

\documentclass[main]{subfiles}
  \begin{document}
    ...
    \includegraphics{test}
    ...    
  \end{document} 

When I compile the main file it works as excepted but when I compile the subfile the image is not found.

So I tried to copy the \graphicspath both into the main and subfiles but in this case the subfile find the image but not the main.

Does any of you guys know how to fix it ? Thanks in advance :)

2
  • Copy the graphicspath{...} code from the main.tex into the subfile.tex, it would work!
    – C. Davide
    Mar 4, 2021 at 23:51
  • did you fixed this issue?
    – Dolphin
    Oct 25, 2023 at 6:31

1 Answer 1

3

Apply the command \subfix to the path in your subfiles, like \graphicspath{{\subfix{./img/}}}. That should fix the issue.

3
  • 1
    Thanks for your quick answer, but the behaviour is still the same :( Mar 4, 2021 at 10:04
  • 1
    Is your installation up-to-date? I can compile your mwe without problem.
    – schoekling
    Mar 4, 2021 at 13:25
  • this did not work for me.
    – Dolphin
    Oct 25, 2023 at 6:25

You must log in to answer this question.

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