6

What is the usual way of making chapters when working with large .tex files?

Do you put \chapter{Chapter 1} inside the main .tex file, or in the included files?

What is the norm, and are there any differences or advantages of doing it one way or another?

\documentclass[a4paper,12pt,twoside,openright]{book}
\begin{document}

\chapter{Chapter 1}
\input{Chapter1}

\end{document}

Or do you put \chapter{Chapter 1} inside the Chapter1.tex separate file?

4
  • 2
    I usually put it inside the file, and use \include (see tex.stackexchange.com/questions/246/… for the difference from \input). Commented Sep 6, 2013 at 18:07
  • 2
    like @TorbjørnT, i put the \chapter line inside the chapterx.tex file and use \include. but i often put a commented-out copy of that \chapter line in the driver file, to help me remember what i'm doing, and if i have to make any special adjustments to that chapter, like add an \addtocontents line, i also put that in the chapterx.tex file and a comment in the driver file. comments are good things. Commented Sep 6, 2013 at 18:15
  • I am aware of \include vs \input thing, but I was wondering if there is a big difference on putting chapter in or out of the included file. The only valid difference I found is with \appendix, where I'll get different result on defining it outside the inputted file...
    – dingo_d
    Commented Sep 6, 2013 at 18:15
  • Thanks on the advices, especially about commenting, it's really a good practice to do :)
    – dingo_d
    Commented Sep 6, 2013 at 18:18

1 Answer 1

3

If you are writing a book or a thesis, which usually has more than one chapter it is a -- in my opinion -- very good strategy to write an central dokument, including document class, praeambel (perhaps an own file), \begin{document}, the chapters, each in one file (names like preface.tex, ìntroduction.tex, conclusion.tex. Do not use chapter1.tex or 3.tex etc. because it could happen you have to change the order of your chapters). Make the central document understandable at once.

Each chapter file includes the hole chapter including chapter heading!

If you use \include{introduction} you can not forget to start a new chapter on a new (or right) side, because \include does it for you.

So the central document should be:

\documentclass[options]{documentclass}
\input{praeambel.tex}

\begin{document}

\frontmatter % if book or scrbook
\include{preface} % starts on new page!
\tableofcontents

\mainmatter % if book or scrbook
\include{introduction}
% ...

\end{document}

and the file intrduction.tex contains:

\chapter{Introduction}%
\label{sec:introduction} 

the chapter text ...

and so on.

Just keep things together which belong together and devide (build logical units) were it is possible.

2
  • Great answer :) I'll keep this in mind :) Oh and chapter stuff was just an example, I'm making my sections like you said, with specific names :)
    – dingo_d
    Commented Sep 6, 2013 at 20:21
  • 1
    Additionally, if your want to use an "Inverse Search"-Feature (i.e. you double-click the PDF to get to the LaTeX-Source of what you clicked), it makes sense to put the \chapter in the included file. At least I prefer to get to the included file, if I click on the headings.
    – Vincent
    Commented Sep 6, 2013 at 22:19

You must log in to answer this question.

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