# \input and \include for a thesis

I'm writing a thesis but not modular style. I simply write everything in one big document and want to change it. But there is a problem.

For sections must not I start with \begin{document} again? Otherwise, it can't be compiled, but if I do it, for this time my document will have lots of begin command.

What can I do to continue with one document?

• Could you please make a sentence of your title ? What you want is not exactly explicit. What do your mean by modular style and there is a problem ? – BambOo Apr 29 '18 at 19:01

You should input your .tex files in this way:

\documentclass[options]{theclass}

%preamble

\begin{document}
\section{section1name}
\input{sec1} %the file is sec1.tex

\section{section2name}
\input{sec2} %the file is sec2.tex
.
.
.
\end{document}


So latex will paste the text where you call \input{}

include works quite the same but it starts a new page when you call \include{}

That would be the best strategy.

If you want just one file, then write the document in this way:

\documentclass[options]{article}

%preamble

\begin{document}
\section{section1name}

I am writing

\section{section2name}

Same way
.
.
.
\end{document}


As you can see, both cases have just one begin-end document.

If you want to avoid numbered sections use the starred command

\section*{}


The difference between \input and \include is how it's included, there is an old discussion on how to use them.

No, you do \begin{document} things only once. Then you use \include{chapter3} once per chapter. You can basically cut the chapter text from the big document, place it into chapter3.tex and insert the include statement instead in the main document.

Update: Oh, an continuing scrying into your question: you compile the main document, as before. As the start of the compilation regarded, nothing changes for you that multiple included *.tex files are present.

I also recommend latexmk and git for more easy compilation and management of the source, but that's tangential.

• And if OP really wants to compile the subfiles separately, then they'd wan to look into the standalone or subfiles packages. – Teepeemm Apr 29 '18 at 19:28
• Teepeemm: Excellent addendum! There are also solutions around latex-preview and overall wonderful AuCTeX, but emacs is not everyones favourite toy. – Oleg Lobachev Apr 29 '18 at 19:31