Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
3  
\input{../../preamble} –  Daniel Jun 24 '12 at 21:29
    
Daniel, thank you. –  JSeaton Jun 24 '12 at 21:54
add comment

1 Answer

up vote 4 down vote accepted

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}.

share|improve this answer
    
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 Jun 24 '12 at 22:04
    
I would recommend using \def\Path{../..}, and then use \input{\Path/premable}, in case you ever decide to change the hierarchy. –  Peter Grill Jun 24 '12 at 22:55
1  
One should mention that \include will not work for files above the current directory. –  egreg Jun 24 '12 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 Jun 28 '12 at 6:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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