Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a large document which currently is comprised of a variety of .tex files.

The mainfile.tex looks something like:

%lots of total formatting stuff

\include{Body/chapter1}
\include{Body/chapter2}
%\include{Body/chapter3}
%\include{Body/chapter4}
%etc

However, this means each of the components (ie chapter1, chapter2, etc) are not valid code.

I want to be able to view an individual file and compile while viewing it (ex. chapter1.tex) within TeXmaker. I am fine if this compiles mainfile.tex

As I understand, I need to either combine everything into one file or do either:

  • tell TeXmaker to let me set a "always compile this file even if not viewing it" option somewhere - so things like F1, etc work, and always reference the mainfile.tex

or

  • move all my formatting initialization, etc, to a file which I can include at the front of each individual component (and include some sort of header guard in this? I have no idea if this concept is feasible or even makes sense in LaTeX) so the same overall formatting is ALWAYS included at the beginning of a document regardless as to the order they are included.

I would strongly prefer the second option if possible but I am unsure how to do this.

share|improve this question
    
Do you know about \includeonly{..}? With this you can select which \include-d files get really included. If you put your front (ToC, etc.) and back-matter (appendix etc.) also in own file and \include them you can compile things chapters. See e.g. Keep chapter number of chapters inserted with \include for details. –  Martin Scharrer Jan 18 '13 at 20:53
add comment

2 Answers 2

up vote 16 down vote accepted

Have your main document in the current editing window. Now select Options-Define Current Document as "Master Document". This should what I understand you are asking for. You will now see in the left pane the structure of the document and regardless of what subfile you are editing running a compile will compile your main document.

share|improve this answer
    
Awesome. I have a feeling that's by far the easier of my two options... –  enderland Jan 18 '13 at 20:33
2  
Argh, I've been ages clicking back to the main document to compile the whole thing, this tip is going to save me millions of clicks! THANKS! –  Dan May 20 '13 at 15:08
1  
My life just became so much more efficient. You, sir or madame, are truly wonderful. –  dylanlknowles Jan 17 at 19:01
    
Using texmaker for 4 or 5 years, this problem always bugged me. Today I finally look for a solution and here you are. Props on you sir. –  Al_th Jul 8 at 8:27
add comment

You can just process your main file but add

\includeonly{chapter2}

then only chapter 2 will be processed. Unlike processing it as a completely separate document, the aux files of the other chapters will be read and so the chapter will still be numbered 2 and cross referenced to other chapters will work even if those chapters are omitted on this run.

share|improve this answer
add comment

Your Answer

 
discard

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.