# How can you maintain a documents master mode in Texmaker?

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.comMay 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:

\usepackage{subfiles}


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

\subfile{subdoc}


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

\documentclass[mymaindoc]{subfiles}
\begin{document}

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

\end{document}


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

Comparison

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.

-