I am writing my thesis using book class. And I use include function so that I can have separate files for each chapter. One problem with this is that I must click run button in the main file. If I click run button in chapter files, error occurs. I learned that this is not a problem in TeX Studio so long as all the files is open. But I am using TeXWork and TeXMaker. So I always to find the right button to click, which is annoying. Is there an easy fix for this problem, please? Thanks.

2 Answers 2


I'm using TeXMaker to write my thesis, and after trying with include and input, that had the problem you mentioned, I ended up using the subfiles package, in this way:

Main document




\subfile{./Chapter} % Chapter file's name (and position)


Chapter document

\documentclass[./MainDocument.tex]{subfiles} % Main document file's name (and position)


In this way I can compile a single chapter. I saw that not all the properties (such as line spacing or headers/footers) of the main document are passed to the subfile; however, I compile the subfile only to check the content of the chapter, while I check the style and so on when I run the main document.

  • How did you find that out, please? Only curious.
    – LaTeXFan
    Aug 13, 2015 at 6:56
  • @LaTeXfan Actually I don't remember, since it was when I started organizing my thesis files and learning LaTeX at the same time, so I was googling like a thousand problems a day! :-)
    – MarcoG
    Aug 13, 2015 at 6:59

Both Texmaker and TeXworks are able to do this.


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.