[OS X TeX] Can latex read the name of the folder that contains my latex file?

Michael Sharpe msharpe at ucsd.edu
Fri Aug 31 18:50:11 CEST 2012


On Aug 31, 2012, at 7:24 AM, Themis Matsoukas wrote:

> On Aug 31, 2012, at 9:53 AM, Chris Goedde <cgg.lists at gmail.com> wrote:
> 
>> I can't answer, because I don't quite understand what you're asking. The layout of files/folders is not clear to me; a specific example would help. (I think you're talking about a latex file accessing the name of its enclosing folder, but the actual string you seem to want to change points to a different folder).
>> 
>> Is the latex file in question also named problemXYZ? In that case, you can probably use \jobname to cobble together the string you want.
>> 
>> Chris
>> 
> 
> I should have been more clear.  The tree structure is like this:
> 
>      /problem-dbase/problemXYZ/problem.tex
> 
> The latex source of the problem is in problem.tex and contains the line \graphicspath{{../problem-dbase/problemXYZ/}}. The enclosing folder is problemXYZ. All problems in the database are named problem.tex and are identified by the name of the enclosing folder. The root file resides in a folder at the same level as problem-dbase and calls this problem with the command
> 
>      \input{../problem-dbase/problemXYZ/problem.tex}
> 
> 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... 
> 
> Themis

Have you tried something like 

(in master file)
\def\xxx{problemXYZ}
\input{../problem-dbase/\xxx /problem.tex}

and use \xxx in problem.tex to create the graphicspath?

Another possibility might be the \subimport command from the import package.

Michael




More information about the macostex-archives mailing list