TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. 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

I am writing a project with texmaker, and i've separated it into several files, to keep it organized. But I run into the following problem - I have to define every startup that the main document is in master mode. (otherwise autocomplete of \cite{} wouldn't work in the included files).

Anyone got a solution for this ?

share|improve this question

migrated from stackoverflow.com May 16 '12 at 16:35

This question came from our site for professional and enthusiast programmers.

Since version 3.3.3 Texmaker has a "save session" menu item in the File menu (see the first record in the changelog at http://www.xm1math.net/texmaker/log.html).

So, open all the tex files you need, define the "Master document", as usual. Then do "save session".

Next time, open the session file, not the tex files. The master will be automatically "selected".

share|improve this answer

There are two different solutions to your problem.

1. Texmaker sessions

Define the master document, then choose "File" / "Save session" from the menu. In the future, when starting Texmaker, open the saved session instead of your tex file.

2. Package "subfiles"

The subfiles package provides an interesting solution which is independent from Texmaker.

In your main document mymaindoc.tex, you simply use the package:


and you replace all \input and \include statements with:


In your sub document subdoc.tex, you add a small document prefix and suffix, pointing to your main document:


% ... original content of subdoc.tex ...


That's it. Now, you can compile mymaindoc.tex as well as subdoc.tex.


With "master document", compilation from a sub document will rebuild the whole document, while the "subfiles" package will only generate the relevant part of your sub document. So "subfiles" is usually faster at the expense of being somewhat inexact.

share|improve this answer

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.