I am writing a paper divided into several sections. I would like to have one master file and then several file which I will only include. I would like to do it properly, since I am sending it to my professor and he has to work with on it too.

Let me show, what I mean. The folder structure is:


The master.tex file:

    % preamble

And for example section_one.tex:

\section{Section 1}
Lorem ipsum

Questions I am working in Sublime Text 2 with Latexing. I would like to

  1. create the project in recommended intelligent way (if such exists)
  2. while working on lets say section_one.tex be able to press Ctrl + b (standard for shortcut for building the project) and build the master.tex file not section_one.tex since it does not contain preamble and throws bunch of errors. Also I don't want to have to switch to the master.text file in ST2 every time I want to build.
  • 2
    I would suggest writing a Makefile (Project/Makefile) and changing the build system to Make instead of LaTeX. Then ⌃ Ctrl + B should work in all subdirectories. – hftf Apr 20 '14 at 20:47
  • Thanks I have followed this question. But when I put the makefile into Project/makefile and build the project from section_one.tex I got an error No targets specified and no makefile found. Do you know how to fix it? Since I really don't want to put the makefile into each folder, that seems messy. – quapka Apr 20 '14 at 21:11
  • @quapka: Generally you put the Makefile into the project's topmost folder, and build *and edit) from there. – DevSolar Apr 21 '14 at 9:27
  • +1 for deciding in advance that you want a well structured document. – Ethan Bolker Jul 29 '16 at 17:45

From the LaTeXing documentation:

One option is to create a Sublime Text project and the other one is just to add the following line at the start of your tex file. The path can be absolute or a relative path to the current tex file.

% -*- root: Project_Example.tex -*-

Now, if you have specified a root file, you'll be able to edit the current .tex file and LaTeXing will build the main file upon compilation.


For a solution that take advantage of sublime text 2 (and 3+?), project.

Go to the menu in:

Project -> Add Folder to Project

and then pick the Project Folder, click OK. Then the menu:

Project -> Save Project As

Save it in the project folder. Go again to the menu at:

Project -> Edit Project

Here you will find that it have added the project folder to the project. You can then add a build system to the project, that are executed when you press Ctrl+b. A in depth on how, can be found here: Build systems - Sublime text 2.

A Project-file example that can do as ask for:

        "path": "<Path to Folder>"
        "name": "Project Build",
        "shell": true,
        "cmd": ["texify.exe","--pdf","$project_path/master.tex"]

This are make for windows, with MiKTeX installed.

[Edit]: Remember to select the Projects Build System as the system build under:

Tools -> Build System -> Project Build

Please note that the string after path, should be the path that sublime have saved and not what I have written there.

General on the Project file see here: Unofficial Sublime Doc

Bonus info: If you want the output to be in folder for it self, you can make a folder called: outputfolder(Or what something else if you like), then add /outputfolder in the Working_dir-string like so:


This will set the execution to be called in that folder, but still build the right tex-file, and place all the output in that folder.


So, with a help from one of my friends I have come to this solution.

The project structure is basically the same as in my question. That is:


But I have added makefile found in this answer, many thanks goes to DevSolar. In this makefile simply rewrite all MyDoc strings which stand for the name of your master file.

Then inside all the subFolders add one really simple makefile:

# all triggers defined targets, in this case only 'upper'
all: upper

# jumps one directory up and calls make
    make -C ../

The comments explain the trick. Basically this makefile calls the makefile in the upper directory. Now only setup your SublimeText2 to build with make. You can simple do so by Tools -> Build System -> Make.

Now the project structure should look like this:


Just make sure to put the correct makefiles to the correct folders. Also you can nest them deeper (depends on your need).

By default settings you should be able now to edit section_one.tex and simple press Ctrl+b and make your project!

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.