I have the following folder structure

 | 00Main
 |  |
 |  | Main.tex
 | 01Components
 |  | IntroFolder
 |  |  | Introduction.tex
 |  | DataChapterFolder
 |  |  | Data.tex
 |  | TexVariablesFolder
 |  |  | MacrosAndVariables.tex

And so forth.

In the 'Main.tex' file I use subfiles package to include my data and intro.tex files within begin{document}

But I use \inpnut to include my macrosand variable that come before the document stuff.



And this WORKS. Its great.


If I try to compile ONLY the 'Introduction.tex' file (to save time). I get errors asking for my 'MacrosAndVariables.tex' file.

I don't know if I can explain, but when compiling the Introduction, it wants to go up two folder levels (../../). But the 'input' command only goes up one.

If I change \input to be


when I'm compiling in the introduction folder. Then it does WORK.

But then when I go back and compile the 'main' document, I have to remove the extra ../ from the \input.

I guess the relative paths are kind of relative to what you are compiling, and not relative to the file where they are found.

Is there a way to fix this?

I don't know how to give a MWE since its very hard drive structure dependent.

  • why don't you use \subfile for the file too? – Ulrike Fischer Feb 24 '18 at 23:49
  • @UlrikeFischer I don't know, it doesn't work for me when I use \subfile in the preamble. If I replace \input with \subfile it doesn't find the files at all. \subfile works in the \begin{document} area though. So I know the package is loading. Just doesn't work in the preamble. – Nertskull Feb 25 '18 at 0:02
  • Sorry I mixed up \subfile and \subimport (from the import package). – Ulrike Fischer Feb 25 '18 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.