Summary

Why and how to modularize a LaTeX project: folder structure, \input vs \include, and centralizing metadata.

Prerequisite: Lessons 01–03 (setup, basics, templates).

Why modularize?

Easier to maintain long documents, reuse content/styles across projects, and isolate errors by compiling specific parts.

project/
β”œβ”€β”€ build/          # output (PDF, logs, aux files)
β”œβ”€β”€ bib/            # bibliography (.bib)
β”œβ”€β”€ img/            # figures and images
β”œβ”€β”€ tex/            # chapters and preamble
β”‚   β”œβ”€β”€ metadata.tex
β”‚   β”œβ”€β”€ preamble.tex
β”‚   β”œβ”€β”€ chap1.tex
β”‚   └── chap2.tex
β”œβ”€β”€ main.tex        # main file
└── Makefile        # (optional) build scripts

\input vs \include

  • \input{file} inserts the content as if it were in the same file.
  • \include{file} creates auxiliary files (.aux) and is great for chapters.
% main.tex
\documentclass{report}
\begin{document}
\include{tex/chap1}
\include{tex/chap2}
\end{document}

Metadata (centralize your work’s info)

% tex/metadata.tex
\def\thetitle{Work Title}
\def\theauthor{Full Name}
\def\advisor{Prof. Dr. So-and-so}
\def\theyear{2026}
% main.tex
\input{tex/metadata}
\title{\thetitle}
\author{\theauthor}
\date{\theyear}