2

To write a large document, if I understand correctly, the structure is as follows:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage[french]{babel}
\usepackage[left=1.5cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}
%%and other package

%document principal \begin{document} \include{ch1} \include{ch2} \include{ch3} \end{document}

My questions concern the packages and the sectionning that I must use: if for a chapter, I need a particular package, should I put them in the ch1.tex file or in the main file?

I searched for information about best practices for writing a book but couldn't find anything that matched my search)

Nicolas
  • 1,023
  • 2
    Files you add with \include don't have their own preamble, so all packages need to go in the main file. – Marijn Jan 19 '23 at 16:40
  • 4
    Also \usepackage[utf8]{inputenc} is no longer needed since a few years, utf8 is the default input encoding. – Marijn Jan 19 '23 at 16:42
  • @Marijn So my files that I include don't start with \begin{document}? – Nicolas Jan 19 '23 at 16:44
  • Yes, that is correct - they are not documents, they are chapters. – Marijn Jan 19 '23 at 16:44
  • @Marijn do you know a site that gives advice / best practices for writing chaptered documents? – Nicolas Jan 19 '23 at 16:52
  • TeX.SE :) but joking aside, there is not much to know. Use the document structure as you have now, keep the directory structure as flat as possible to avoid issues with relative paths, use \includeonly if you want to speed up intermediate compilations, and then just start writing... – Marijn Jan 19 '23 at 16:58

1 Answers1

1

The packages should be in the preamble. As your files start after begin{document}, you will receive an error message if you include a package in one of these files.

I use external files in the preamble for packages, but these packages will be available for all files after the preamble. I also use external files for parts of the text after the preamble, but these files do not include packages.

You might prefer to use include{file} to \clearpage before chapters, as explained in this answer, or for another reason, but I find clearer to use \input{file.tex}.

Andre
  • 969