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

I tried the following

\def \pathb {./folderB}

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!

closed as unclear what you're asking by Johannes_B, Joseph Wright Feb 8 '15 at 12:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    \newcommand{\patha}{folderA} should work (the [] in your example is a syntax error) (or \def as you have it also should work) – David Carlisle Jan 6 '14 at 1:17
  • 2
    That is strange, in my computer it works when you correct the syntax error of extra [] from the first definition. Why do you use \newcommand and then \def to define two path variables? Why not either \newcommand or \def for both? Just curious. – Masroor Jan 6 '14 at 1:21
  • 1
    I was guessing this was to demonstrate 2 things that had been tried? – cfr Jan 6 '14 at 1:31
  • @DavidCarlisle Wann write up an answer? – Johannes_B Feb 8 '15 at 12:21
  • @Johannes_B not really, the version \def\pathb in the question is the answer, so unless James is still stuck, I'd just close as unclear what you are asking. (I could vote but it would close straight away, rather leave for community voting) – David Carlisle Feb 8 '15 at 12:29

Browse other questions tagged or ask your own question.