[Tex/LaTex] How to set \input global directory to \graphicspath

directoryinputtemplates

tI have Latex template to which I pass parameters using Pandoc. One parameter is $logopath$ where all the graphics are located and I'm able to set graphicspath properly, no problem.

\graphicspath{{$logopath$}} % this works

I decided to break my main template into parts so that I can load only necessary packages and contents from subtemplates and by doing that, I simplify my main template structure. When I use absolute path, input works as expected.

\input{/Users/pasi/Projects/dxss/endusers/a/sub1.tex} % this works

Since these templates are distributed to various systems and locations, it is mandatory to use same information as I have in graphicspath. Main template, subtemplates and graphics files are in the same directory and I can't "hard code" the absolute path. I recognize that this question/answer looks like a 100 % match, but I'm not able to make it work no matter what…

\makeatletter
\def\input@path{{$logopath$}} % this doesn't work
\makeatother

\makeatletter
\def\input@path{{/Users/pasi/Projects/dxss/endusers/a/}} % this works
\makeatother

When I try this:

\input{sub1.tex}

It fails, as all other variations except absolute paths.

UPDATE.

I just realized that my Projects directory is a symbolic link to "Machintosh HD 2/Projects". Somehow \graphicspath seems to accept path with white spaces, but \input@path doesn't. My program that passes $logopath$ variable to Pandoc inserts true path into that variable, not path with a symbolic link. White spaces are escaped.

Bug or feature with \input?

Best Answer

I would have never guessed that this works...

\makeatletter
\def\input@path{{"$logopath$"}} % working solution with possible white spaces in path
\makeatother

This "quoting" also seems to work with paths without white spaces. Big thanks to @David Carlisle for your comments. Glorious win for trial-n-error -method :)

Related Question