I apologise if this question has already been addressed.

Say I have a set up like this:

I have a main folder in which I have both preamble.tex and a folder sub_1. In sub_1, there is another folder sub_2 - and in sub_2 there is my_file.tex

What must I write in my_file.tex in order to input preamble.tex? A cursory google and tex.stackexchange search of "input" and "different directory" seems only to address the case when, say, the preamble is located in some subdirectory of where the main file is.

Any help is appreciated.

  • 4
    – Daniel
    Commented Jun 24, 2012 at 21:29

1 Answer 1


In the comments, Daniel answered my question.

Moreover, if one wants to input a file n levels above your file (file_name.tex), write \input{ then ../ n times, and then file_name}.

  • Meta-comment: this is not TeX-specific; it's just the way that relative paths are written in UNIX operating systems (in Windows, you turn the slashes around, but as Joseph Wright reminded me, TeX always uses forward slashes even in Windows).
    – Ryan Reich
    Commented Jun 24, 2012 at 22:04
  • I would recommend using \def\Path{../..}, and then use \input{\Path/premable}, in case you ever decide to change the hierarchy. Commented Jun 24, 2012 at 22:55
  • 1
    One should mention that \include will not work for files above the current directory.
    – egreg
    Commented Jun 24, 2012 at 23:00
  • @RyanReich: Meta-meta-comment: Path separation in Windows is good for quite some myths. In fact, the Win32/64 subsystems (at the API level) have always supported both, slashes and backslashes as path separator; the NT kernel under the hood even uses only forward slashes. The support of backslashes (and drive letters, which inside the kernel are just symbolic links, somewhat like UNIX) is a compatibility inheritance from DOS. It's only the shell (cmd.exe) that insists on backslashes and some applications that use archaic algorithms to sanitize file paths.
    – Daniel
    Commented Jun 28, 2012 at 6:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .