# How to define pathname variables? [closed]

How do I define a variable (pathname) that can be recognized by various commands, such as \input{} and \includegraphics{} ?

I tried the following

\newcommand{\patha}[]{./folderA}
\def \pathb {./folderB}
\input{\patha/file1}
\input{\pathb/file2}


It did not work.

I am working with a few collaborators on a book. Each chapter is expected to have its own folder with images in a subfolder.

However, we changed the folder names or path name several times, for various reasons. Each time, we will have to also change the pathname in the tex files. This takes a lot of time.

It will be great if we can define a variable, say chapter1, and assign a pathname to it. In the tex file, we can then use the variable wherever needed. This way, when the folder name or path name is changed, we only need to update the variable. This will save us a lot of time.

Any input would be greatly appreciated!

• \newcommand{\patha}{folderA} should work (the [] in your example is a syntax error) (or \def as you have it also should work) Jan 6 '14 at 1:17
• I was guessing this was to demonstrate 2 things that had been tried?
– cfr
Jan 6 '14 at 1:31
• Have you seen \graphicspath? (Consult the graphicx manual for its usage.)
– yo'
Feb 8 '15 at 12:34
• Even though this question is closed it comes up as the top google result for "latex file path variable" so it would be good to link it to a possible duplicate Jan 8 '19 at 14:51