<html><head></head><body bgcolor="#FFFFFF"><div><br><br>Sent from my iPad</div><div><br>On 01/09/2012, at 0:24, Themis Matsoukas <<a href="mailto:tmatsoukas@me.com">tmatsoukas@me.com</a>> wrote:<br></div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font><span> \input{../problem-dbase/problemXYZ/problem.tex}</span><br><span></span><br><span>All of this miraculously works, but what I would like to do now is access from inside problem.tex the name of its enclosing folder and then pass it to \graphicspath, so that instead of hard-coding the name "problemXYZ" in the \graphicspath this would be set automatically in each latex run. I am probably asking for too much of a miracle... </span><br></div></blockquote><div><br></div><div>No, not too much, if you do a bit of work.</div><div><br></div><div>Use TeX's \write18 to run a shell command, such as</div><div> cat `pwd`> pwd.txt </div><div>giving you the name of the directory written inside a simple text file.</div><div><br></div><div>Then use TeX's \openin to create a file stream to input the contents of that file.</div><div>Now with TeX's \read primitive, you can get the contents of this 1-line file stored as the expansion of a macro. (Then use \closein to free-up the file stream cleanly.)</div><div>Finally, if you only want the name, not the full path, then you can define a TeX macro that extracts what occurs after the directory delimiter / . You'll have to run this repeatedly, to extract just the final bit, as TeX's pattern matching occurs on the first instance.</div><div>(or use dirname instead of pwd )</div><div><br></div><div>Consult the TeXbook to learn how to do these non-LaTeX actions.</div><div><br></div><div>Also, you may need to invoke LaTeX with the -shell-escape option, if that is not automatically enabled. Herb can comment on this. </div><div><br></div><div>Maybe there is a package that helps make such tasks easier.</div><div>Dunno, as I always write my own coding from scratch, using the primitives.</div><br><blockquote type="cite"><div><span></span><br><span>Themis</span><br></div></blockquote><br><div>Hope this helps,</div><div><br></div><div> Ross</div></body></html>