TransWikia.com

Compiling the main document from a chapter file

TeX - LaTeX Asked by Questions about math on July 8, 2021

I have a main document calling on several different chapter files. What I would like to do is have split-screen open with one chapter tex file on one side and a compiled pdf on the other side that I can update as I go using the keyboard shortcuts from my chapter tex file instead of having to exit, go find my main file and compile it from there, and then come back to my chapter file.

I’ve seen plenty of answers instructing how to compile the main document to show only a single chapter by using include instead of input. But that doesn’t solve the issue of compiling the chapter file while working on it. Those answers still require going back to the main document to compile.

As a bad hack right now, I’ve input my preamble file into my chapter file and written begin{document} stuff etc while I’m working on it so that I can just get it to compile temporarily. The issue is that I have to % out the begin{document} and preamble stuff if I ever want to compile my main document and I’m certain there has to be a better way to do it.

Please help!

One Answer

I have a separate onechapter.tex that has the same preamble and then includes whatever chapter I'm currently working on. That solves the problem with your bad hack that you have a file that doesn't compile.

To avoid switching from the chapter's source to onechapter.tex, you could begin the chapter with
% !TEX root = onechapter.tex
See When and why should I use % !TEX TS-program and % !TEX encoding?

Correct answer by Teepeemm on July 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP