0

after a long search without results I hope you can help me. Here is my problem: I can't load .pdf files with \includegraphics.
The background is that I have one repository to create my frequent used pictures and now I try to work with two of them within another repository. This leads to long relative paths (../../../../../a/b/c/d/file.pdf) and get the error "File ... not found". I create this path with TexStudio -> include graphic and checked it several times manually. TexStudio shows me the right preview when I slide over the path. When I place the file in my working directory or a few folders above \includegraphics works fine.

\documentclass{standalone}  
    \usepackage{import}  
    \usepackage{graphicx}  
\begin{document}  
    \begin{tabular}{cc}  
    \includegraphics[width=0.4\linewidth]{longpath/file1} &  
    \includegraphics[width=0.4\linewidth]{longpath/file2}  
    \end{tabular}   
\end{document}
14
  • 2
  • Thank you so far. I tried to use the graphicx package and \graphicspath, but it didn't work. And I checked the texmf.cnf too. openin_any=a is set.
    – Person_386
    Apr 28, 2019 at 16:09
  • Does your path include spaces?
    – leandriis
    Apr 28, 2019 at 16:22
  • No spaces. See the complete path: ../../../../../../../Vorlagen/Berichte_und_wissArbeiten/Abbildungen/Pumpen_und_Luefter/Dia__Arbeitspunkteinstellung_durch_Bypass_prinzip/Arbeitspunkteinstellung_durch_Bypass_prinzip
    – Person_386
    Apr 29, 2019 at 7:48
  • 1
    As a workaround, you could make a subdirectory /images/ in the directory where you have your main document and fill this with softlinks to the images (this assumes linux or similar OS). That way you don't duplicate the images and can still edit them in their original place. Apr 30, 2019 at 11:44

1 Answer 1

1

Your mwe works with the relative paths you propose but it takes a heck of a lot of fiddling about to do so. Alternatively the second image is auto loaded just by giving its name (no need for folder paths etc)

enter image description here

\documentclass{standalone}  
    \usepackage{import}  
    \usepackage{graphicx}
    \graphicspath{{../../../../../../../Vorlagen/Berichte_und_wissArbeiten/Abbildungen/Pumpen_und_Luefter/Dia__Arbeitspunkteinstellung_durch_Bypass_prinzip/Arbeitspunkteinstellung_durch_Bypass_prinzip/}}
\begin{document}  
    \begin{tabular}{cc}  
    \includegraphics[width=0.4\linewidth]{HelloWorld} &  
    % the above image is loaded using the graphics path above which is over 180 characters from the device root  and would be much shorter if it was entered as its absolute location
    %the following image is automatically loaded from a texmf directory (I dont need to know where it comes from its just there)
    \includegraphics[width=0.4\linewidth]{example-image-A}  
    \end{tabular}   
\end{document}

So how does Latex know where to look for the image Note I could have specified a folder called longpath so that images file1 and file2 are loaded from longpath/ (but that would be pointless they may as well be in /mypngs or /myeps or /mygifs to avoid loading inappropriate types

So in the example above simply entering /mypngs/file1 would look down texmf folders including my texinputs environmental which on this run (I can change it at will) is set to TEXINPUTS=H:\MiKTeX app\texmf-local (note it does work even though there is a space included) in that folder it will find a subfolder called mypngs but it could have been /graphics/ or

\includegraphics[width=0.4\linewidth]{Vorsprung_Duck_Technik/example-image-duck}

You must log in to answer this question.

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