Currently, I have my main LaTeX document set up as follows:

\title{Mytitle} \author{Me} \date{}


While my chapters themselves contain no preamble, no begin/end document etc, just the contents of the chapter itself.

I use Latexian and really enjoy the live preview function in a split screen. I would like to write each individual chapter and use the live preview feature, however, I cannot compile/preview each chapter on its own without its own preamble, begin/end document etc.

Is there a way around this? It feels very clunky to have to switch back and forth between a window containing just my chapter and one containing the entire thesis. Similarly, it feels very clunky to have each chapter contain everything necessary to compile and then manually comment out the extra lines from every single chapter when I wish to compile them all together.

  • Doesn't Latexian allow you to set a master document or main file or similar? Many editors have a concept of a project so that compiling any file in that project can be configured to compile the main/master file. If you use \include rather than \input, you can use \includeonly{}as mentioned below. Alternatively, look at standalone or import for other possibilities.
    – cfr
    Jan 17, 2017 at 3:04
  • @cfr I have never heard of this feature before, but it looks like what I am after. I will have to see whether or not Latexian can do this, thank you.
    – Echan
    Jan 17, 2017 at 5:10
  • @cfr The feature was fairly well hidden, but that completely solved my issue.
    – Echan
    Jan 17, 2017 at 5:37
  • You should put te \chapter{<title>} command within te chapter file.
    – Johannes_B
    Jan 17, 2017 at 7:24
  • look into the subfiles package. Jan 17, 2017 at 9:35

3 Answers 3


Convert your chapters in complete documents (with the same preample that the main document) and then go to CTAN to known about the topic subdoc: in­clude com­plete doc­u­ments in other doc­u­ments. In particular, docmute or standalone packages is what your are looking for. It is a simple as add one of these packages to the preamble of the main document (there are many examples of use of both packages in this site, for example this answer.

I suggest also move rest of the preamble to a preamble.tex file and left in the main document only \input{preamble} and use only this command in the preambles of the child fles, because if you need change some change in the preambles, you only have to do once, avoiding mistakes.

Alternatively, as suggested in the other answer, you can also preview the main document with only a chapter, using \includeonly{...} in the preamble of the main document, but note that this command affect to \include commands, not to \input (see When should I use \input vs. \include?), so in your example, you should change \chapter{...}\input{...} by only \include{...} with \chapter{...} included in the child document.


Another approach is to have a compile01.tex file which contains:

\usepackage{../my_preamble}% all your package loads and custom macros in one file. (You could also \input it)

You'd then have compile02.tex etc. as well. I didn't use this approach for chapters (I wanted to test the bibliography and TOC often enough that it wasn't worth it, instead I preferred to use \includeonly or comment out the \include/\inputlines in my thesis_master.tex ). But I did set up something similar for TikZ pictures to avoid compiling the whole thesis while fine-tuning a figure.

  • Although your suggestion will not produce the same result that \includeonly in main.tex and simplify check partial results, basically translate the hassle of having to compile main.tex to the hassle of of compile through a third file for each chapter, but the main point of the question is see a live preview while editing chapter01.tex, that is not really solved in this way
    – Fran
    Jan 17, 2017 at 14:11
  • @Fran I don't use Latexian so it wasn't obvious to me that this wouldn't generate a live preview until you said so. My thesis files were big enough that for all but the introduction, compilation of a single chapter took a few tens of seconds on a fast machine. With frequent saving it would be almost constantly updating. So I compiled on my own schedule
    – Chris H
    Jan 17, 2017 at 14:26

Plenty of other questions on this same topic. I think the easiest way to do it is to put a line like this in your preamble:


Typeset single chapter from book

Edit: And use \include instead of \input

  • 2
    This really doesn't address the question and adding this to the preamble in the question will just produce an error.
    – cfr
    Jan 17, 2017 at 3:02
  • @cfr not sure I understand your comment. Because you also posted above: "If you use \include rather than \input, you can use \includeonly{}as mentioned below." Why post the same advice as me and downvote my brief response plus link to information? Is it because you thought I should copy more of their answer? Jan 21, 2017 at 4:36
  • @TomAnderson I think the problem is that the code in the question doesn't have any chapters, so more is needed than just adding \includeonly: the source also needs to be set up correctly.
    – Joseph Wright
    Jan 21, 2017 at 8:14
  • 1
    The source in the question doesn't use \include{}. You can't use \includeonly{} with \input{}.
    – cfr
    Jan 21, 2017 at 19:10
  • 1
    By the way, it was not me who down-voted your answer. @JosephWright ??
    – cfr
    Jan 21, 2017 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .