1

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?

Pasi
  • 123
  • using absolute paths within the document is usually discouraged as it makes them non portable, it isn't clear what kind of parameter $logopath$ is (an environment variable or something pandoc inserts into the tex file or ...) nor do you say what value it has) but if you add /Users/pasi/Projects/dxss// to your TEXINPUTS enviornment variable or web2c config file settings, then \input and \includegraphics should find any file in any directory below that if just used as \input{sub1} or \includegraphics{mypic2} etc – David Carlisle Jan 05 '15 at 12:51
  • $logopath$ is just an shell escaped string that includes the directory name where graphics are located. – Pasi Jan 05 '15 at 12:55
  • But how is it communicated to tex? via setting an environment or by inserting something into the tex document? and does it include a trailing / as required for graphicspath – David Carlisle Jan 05 '15 at 13:01
  • I pass $logopath$ to tex as Pandoc --variable and yes, it includes / plus as said, graphicspath works just fine. – Pasi Jan 05 '15 at 13:06
  • if graphicspath works I can't see why the input@path definition you give wouldn't work as it is the same thing, that is you are defining input@path to be {{/Users/pasi/Projects/dxss/endusers/a/}} ? – David Carlisle Jan 05 '15 at 13:10
  • That is exactly the problem. It works, when I add absolute path to input@path - if I add $graphicspath$, \graphicspath, graphicspath{{$logopath}}, $logopath$ or any (hopeless) variant, it doesn't. – Pasi Jan 05 '15 at 13:13
  • what does "not work" mean, what is in the actual latex file that is passed to latex after pandoc has done its variable substitutions, and what error do you get? – David Carlisle Jan 05 '15 at 13:15
  • Don't work means that it can't find the file. – Pasi Jan 05 '15 at 13:17
  • 1
    you say \def\input@path{/Users/pasi/Projects/dxss/endusers/a/} % this works works but that should not work, the syntax should be \def\input@path{{/Users/pasi/Projects/dxss/endusers/a/}} % this works with two {{ and if that form works then \def\input@path{{$logopath$}} should be identical input to tex after pandoc has replaced $logopath$ by /Users/pasi/Projects/dxss/endusers/a/ – David Carlisle Jan 05 '15 at 13:25
  • My bad, mistake with copy-paste - I copied a non-working example - edited the original respectively. – Pasi Jan 05 '15 at 13:38
  • if pandoc replaces $logopath$ by /Users/pasi/Projects/dxss/endusers/a/ then the input to latex is the same so both should work. If if does not do the replacement then why not? (and that is presumably a pandoc question rather than a tex one, I don't have pandoc to test) – David Carlisle Jan 05 '15 at 13:40
  • I guess I may have found the root cause. I just realized that my Projects-directory is a symbolic link to "Macintosh HD 2/Projects". Somehow graphicspath works as expected, but input doesn't. Possibly the spaces in string cause this problem, even though they're escaped... – Pasi Jan 05 '15 at 13:41

1 Answers1

2

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 :)

Pasi
  • 123