I usually load a helping TeX file that contains my customizations, e.g., usual packages, corporate standard colors, and macros for abbreviations. I want my helping file to also load another external file that is in the same folder. I certainly want to avoid giving the explicit path to the second external file every time.


Let's say the helping file is cosmetix.tex, which loads abbreviations.tex. abbreviations.tex is in the same folder as cosmetix.tex and both are in a folder called common:

% cosmetix.tex
% ... some customization
% load abbreviations

My main file is tester.tex:

% tester.tex

% load cosmetix

Dummy text.

This leads to the following error: LaTeX error: File `abbreviations.tex' not found.


How can I use nested \inputs with files in different folders without (i) converting my code to a package and (ii) using absolute paths?


Although this question is pretty generic, it is also a follow up to my previous question: Reproducing an official letterhead. I have reproduced my institute's letterhead, which in turn needs to load the logo. I load the letterhead using the \input mechanism. I know this is not the most elegant way, but until I get time to convert this to a package (or read scrlttr2 documentation to convert my letterhead to an option file), this is a solution that reasonably works for me.

As I mentioned above, I can't use absolute paths because I'm using multiple computers with different operating systems, and therefore, the root of the directory tree is different for each computer.

  • I always use relative paths, so something like ../common/ (with as many ../ needed to get to a common point) assuming that you keep all the files at the same hierarchy depth. Otherwise you could define a \Path which has the full path and use \input{\Path/common/<file>}. – Peter Grill Jun 17 '12 at 1:57
  • @PeterGrill, that's how I do it too---a macro containing relative path and pass it to the helper file. But if the files are in the same folder, shouldn't this make my life easier? – Ali Mehrizi Jun 17 '12 at 3:08
  • You can add the helper files to your local TeX common folder, e.g., ~/texmf/tex/latex/commons. See tex.stackexchange.com/a/1167/9626 by @JosephWright – Ali Mehrizi Jun 17 '12 at 5:22
  • @AliMehrizi, yes, I could, but if I didn't use Dropbox to sync my files across different computers or if Dropbox let me use a second folder to share. – Ali Mehrizi Jun 17 '12 at 5:23
  • @AliMehrizi, hmm, you only marginally mentioned that in your question, but now I see it. How about updating TEXINPUTS on your computers? See, e.g., tex.stackexchange.com/questions/6528/… – Ali Mehrizi Jun 17 '12 at 5:29

Use the package import, which does exactly one thing: to solve this problem. See


Basically the package defines two commands: \import and \subimport. \import needs an absolute path, while subimport needs a relative path. They both look at the current folder and TEXINPUTS first. If you want to avoid checking TEXINPUTS, use the starred version.


For your case, the only line you need to change is to update \input to \subimport (and of course, add \usepackage{import}). That is, you would need to write:


No changes are necessary in cosmetix.tex.

  • does anyone know if import can be nested, i.e., \import{myDir/}{myfile} and in myfile.tex have \import{./figures/}{myFig.tikz}? – daaxix Sep 23 '15 at 18:35
  • @daaxix, yes, it can. – Ali Mehrizi Oct 6 '15 at 19:53
  • I was having this exact problem, and ended up here. I was disappointed that it seems nothing on this page explains why it's happening. While reading I kept tweaking things, and I think I know what's going on. While compiling the main document, it interprets the relative path from the location of the main tex file. If all projects folders have the same relative path to the common folder, you can write cosmetix.tex to input the other file as if it's in a project file. In my case, this won't work, since I have subprojects. I look forward to trying out import. – Travis Bemrose Nov 16 '15 at 4:07
  • could one replicate this with \subfile ? – Benedict K. Jul 15 at 17:40

I personally try to avoid having to remember to change settings just because I switched computers. And since you are using Dropbox, I would recommend you set up your directory structure so that it is portable and does not require special settings:


Don't keep files in the \Projetcs directory, but only in the sub-directories, and always use relative paths:


Alternatively, you could adapt one of the solutions from How to detect and condition based on hostname to define a different root path depending on which machine you are on.

  • in fact my directory structure is already similar to what you mentioned, but with the addition that my root also has a (for example) Proposals folder in which subfolder proposal1 also needs to call something from common. Your solution of giving path as a macro would work if I use \CommonPath in both the main file and the helper file. – Ali Mehrizi Jun 17 '12 at 23:57
  • This can work if you define \CommonPath in each file. So /Projects/paper1/Paper1.tex would define it as ../common and /Projects/Proposals/proposal1/Proposal1.tex would define it as ../../common. It is a bit klunky and repetitive, but there is minimal duplication. – Troy Daniels Jun 16 '14 at 21:41
  • @TroyDaniels: I would have the \newcommand*{\CommonPath}{../commom} in a custom .sty file that all the files include via \usepacakge{}. – Peter Grill Jun 17 '14 at 0:17
  • 1
    @PeterGrill A common file does not work in this case, because his directory structure is such that sometimes CommonPath is ../common and sometimes it is ../../common. – Troy Daniels Jun 18 '14 at 22:09

As discussed in comments on the question, it seems a reasonable solution is to update the TEXINPUTS variable. You will have to update this variable on all of your computers. If you are using Dropbox or any sync software to keep your computers in sync, you should put the common folder in their path.

For WindEdt/Win7, Choose Variables tab from Options | Execution Modes. Under TEXINPUTS variable (or add it if it's not there) enter the absolute path to the folder. The screen shot below shows how when the common folder is called _Common.

enter image description here


Well I think it is, because input just puts the commands of the file in as is. So the whole file tester.tex would look like

% tester.tex

% load cosmetix
% cosmetix.tex
% ... some customization
% load abbreviations

Dummy text.

That will be compiled. Since you are in the folder of tester.tex it cannot load abbreviations.tex. You would need to put \input{common/abbreviations.tex} into cosmetix.tex.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.