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 ?

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


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.

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.