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}
  • 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 '19 at 16:09
  • Does your path include spaces? – leandriis Apr 28 '19 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 '19 at 07: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. – Henk Metselaar Apr 30 '19 at 11:44
  • Just for diagnosing the problem: can you test with a path without _ ? –  Apr 30 '19 at 12:28
  • long relative directories can all too easily be near to the maximum permitted lengths and then a long filename not behave correctly as it gets modified (especially eps2pdf conversions etc) The constant advice is do NOT use variable build directories try to use fixed environmentals such as TEXINPUTS or absolute \graphicspath{{../..//}{absolute}{relative}{etc.}} –  Apr 30 '19 at 12:29
  • @HenkMetselaar does this workaround work with windows 10? And can you give me a hint how to do it? – Person_386 Apr 30 '19 at 14:49
  • @jackfrost the '' works with a shorter path. To eliminate all '' isn't an option. – Person_386 Apr 30 '19 at 14:51
  • @KJO to use \graphicspath with an absolute path does not fit to my background. I am a member of a working group, and we want all to modify and compile the document. A \graphicspath outside the document could be a solution... Can you tell me what TEXINPUTS is? – Person_386 Apr 30 '19 at 14:58
  • @Person_386 I'd like to know if the _ are the problem. If yes, this can be solved. But to find out you would need to test with a path without them –  Apr 30 '19 at 15:00
  • Put one image in ../../../../../../../Vorlagen/BerichteundwissArbeiten/Abbildungen/PumpenundLuefter/DiaArbeitspunkteinstellungdurchBypassprinzip/ArbeitspunkteinstellungdurchBypassprinzip and report back if this image works –  Apr 30 '19 at 15:03
  • Escape the underscores with \_. But I ran into a problem where it blocked ../ for security reasons. – Tvde1 Apr 30 '19 at 15:05
  • As long as all other rules are adhered to unscore is only a problem in paths when using packages that adapt underscore the most likely culprit is using a served drive or one with spaces/odd utf-8 chars or all too common both –  Apr 30 '19 at 20:21

1 Answers1

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}