Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I set the main file in Textmate 2 in order to make it compile my complete dissertation and not the file I am editing?

share|improve this question
up vote 2 down vote accepted

You need to tell your Latex editor where the main file of your dissertation is placed, in regard to the document you are editing. To define it, add this command to the header of the .tex file that you are editing:

%!TEX root = ../Main.tex

Just edit the path to your main file (in this example "../Main.tex") from the file you are editing. I usually have a file "main.tex" as master document and I link the chapters or sections of the document which are placed in sub-folder.

To try it out, open the menu Bundles -> Latex -> Project Management -> Open Master File With this line in the head the main.tex file will open. Then you can compile it directly from the included .tex file with Bundles -> Latex -> Typeset and View

share|improve this answer
It worked perfect, Gbugnard. Thanks a lot! – grandeabobora May 30 '13 at 16:46
This is robust and nice, but you have to add the header line to all .tex files in the project. With Pontus's solution you only have to add the line once per project. – Nagel Jul 20 at 13:20

To set the master file on a project basis, put

TM_LATEX_MASTER = "/path/to/main.tex"

in a file called .tm_properties in your project root.

As an alternative, have a look at the Subfiles and Standalone packages.

share|improve this answer

Alternatively to the above suggested way, you could set a TextMate Variable that should be called TM_LATEX_MASTER and point it to your main latex document (copy the path into the variable value field next to the variable name).

The place where you can set TextMate's variables is under TextMate's Preferences (cmd+,) and go to the "Variables" section.

share|improve this answer
The problem with this is that you would have to change this variable whenever you want to compile a different LaTeX document. So Pontus's solution might be better for most people. – Nagel Jul 20 at 13:19

Your Answer


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.