gsalzer / subfiles

class and package for multi-file projects in LaTeX
LaTeX Project Public License v1.3c
25 stars 1 forks source link

Problems with searching images by relative paths #3

Closed maxnick closed 3 years ago

maxnick commented 4 years ago

Today I upgraded the subfiles package to the latest 1.6 version and immediately ran into a problem with compilation of my project, which makes extensive use of the subfiles package. It can't properly resolve \graphicspath anymore so latex can't find image files during the separate subfile compilation. The structure of the project is as follows:

/project
    /Images
    /src
        /subfiles
            /subfile1.tex
            /subfile2.tex
            /...
    /main.tex
    /preamble.tex

The main.tex file has the following structure:

\input{preamble}
\graphicspath{{Images/}{../../Images/}}
\begin{document}
    <content>
\end{document}

The subfiles:

\documentclass[../../main.tex]{subfiles}
\begin{document}
    \includegraphics{picture}
    <content>
\end{document}

The idea is to use just the same file name without a path inside \includegraphics macro in both the whole project and a separate subfiel compilations. Previously, I used to use version 1.2, and all worked smoothly, with just a small addition to the beginning of each subfile:

\makeatletter
\def\input@path{{../../}}
\makeatother

But now it doesn't work neither with this addition nor without. So how to fix this problem and use the same file name of the picture inside the \includegraphics macro in compilation of the subfile and the entire project and automatically handle the difference of the path to the image folder?

gsalzer commented 4 years ago

Thanks for the report, this is indeed a bug. After importing the preamble from the main file, the import command resets the \graphicspath to the value it had before the import, so the new value gets lost. I will think about how to fix it.

ashirwad commented 4 years ago

@gsalzer, any updates on the progress?

Thordar1337 commented 4 years ago

You can hotfix this issue by yourself to work on by setting \graphicspath{{Images/}{../../Images/}} also in the subfile after importing the main-config:

\documentclass[../../main.tex]{subfiles}
\graphicspath{{Images/}{../../Images/}}
\begin{document}
    \includegraphics{picture}
    <content>
\end{document}
christo-auer commented 3 years ago

Having exactly this issues with the mactex 2020 release. It seems, this bug is still open? Is it a "wontfix" or still pending?

gsalzer commented 3 years ago

Still pending. I will fix the issues within the next month, together with the adaption for the new LaTeX version

christo-auer commented 3 years ago

Great and thanks for this awesome package!

gsalzer commented 3 years ago

@maxnick @ashirwad @christo-auer The issue is resolved in the new version 2.0 of the package, which is available from github and, shortly, from CTAN. See also issue3-graphicspath in the tests directory. Please let me know if you encounter any further problem; in this case, open a new issue with sample code.

JPelda commented 3 years ago

Dear gsalzer, the problem still seems to exists if using subfiles: I have the following structure of my document:

preamble.tex main.tex ---Chapter1/main.tex ---Chapter2/main.tex

Now I like to \graphicspath{{somefolder}} with absolute pathname. It does not work (as it did before updating from 2019 to 2020) unless I include in every subfile like Chapter1/main.tex...Chaptern/main.tex before the \begin{document}-statement the line: \graphicspath{{somefolder}}

\documentclass[../../main.tex]{subfiles} \graphicspath{{somefolder}}

\begin{document} \end{document}

Would be nice to have one global \graphicspath{{somefolder}} in the preamble that is valid for any other subfile.

Best Regards, Jo