[OS X TeX] Can latex read the name of the folder that contains my latex file?
lfsequeira at gmail.com
Wed Sep 5 06:20:11 EDT 2012
>> On 01/09/2012, at 0:24, Themis Matsoukas <tmatsoukas at me.com> wrote:
>>> 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...
>> No, not too much, if you do a bit of work.
>> Use TeX's \write18 to run a shell command, such as
>> cat `pwd`> pwd.txt
>> giving you the name of the directory written inside a simple text file.
> I'll have to digest this and give it a try. Thanks.
Actually, the command given above is wrong.
It should be either:
echo `pwd` > pwd.txt
or (much better) just
pwd > pwd.txt
the 'cat' command is used to output the contents of a file to the standard output. Using 'cat' with a directory name instead of a regular file name will yield an error.
More information about the MacOSX-TeX