Document Architecture

Document Structure & Sectioning

Learn how to configure document classes, custom page styles, sectioning hierarchies, and multi-file project structures.

Document Structure & Preamble

Document Structure & Preamble

Comprehensive syntax, arguments, options, and copyable snippets for document structure & preamble.

Command Mandatory { }

\documentclass{class}

Declares the document class (article, report, book, letter, beamer, etc.)

💡 Deep Dive Explanation & Options

Document Classes & Options:
Classes: article (papers/essays), report (theses with chapters), book (two-sided books), beamer (slides).
Font Sizes: 10pt, 11pt, 12pt.
Paper Sizes: a4paper, letterpaper.
Layouts: twocolumn, onecolumn, titlepage, draft, final.

Example Code
\documentclass{article}
Command Mandatory { }

\usepackage{package}

Loads a package

Example Code
\usepackage{amsmath}
Command Mandatory { } Optional [ ]

\usepackage[options]{package}

Loads a package with options

Example Code
\usepackage[utf8]{inputenc}
Environment Mandatory { }

\begin{document}

Starts the document body

Example Code
\begin{document}
Command Mandatory { }

\end{document}

Ends the document body

Example Code
\end{document}
Command Mandatory { }

\title{text}

Sets the document title

Example Code
\title{A Study of Light Scattering}
Command Mandatory { }

\author{text}

Sets the document author(s)

Example Code
\author{Deb}
Command Mandatory { }

\date{text}

Sets the document date

Example Code
\date{\today}
Command

\maketitle

Typesets the title block

Example Code
\maketitle
Command Mandatory { } Optional [ ]

\newcommand{\name}[n]{def}

Defines a new command with n arguments

Example Code
\newcommand{\vect}[1]{\mathbf{#1}}
Command Mandatory { } Optional [ ]

\renewcommand{\name}[n]{def}

Redefines an existing command

Example Code
\renewcommand{\arraystretch}{1.5}
Command Mandatory { }

\providecommand{\name}{def}

Defines a command only if not already defined

Example Code
\providecommand{\eps}{\varepsilon}
Command Mandatory { }

\newenvironment{name}{begin}{end}

Defines a new environment

Example Code
\newenvironment{note}{\begin{quote}\itshape}{\end{quote}}
Command Mandatory { }

\renewenvironment{name}{begin}{end}

Redefines an existing environment

Example Code
\renewenvironment{abstract}{\small}{}
Command Mandatory { }

\input{file}

Inserts contents of another file

Example Code
\input{chapter1}
Command Mandatory { }

\include{file}

Includes another file (starts new page)

Example Code
\include{chapter2}
Command Mandatory { }

\includeonly{file1,file2}

Restricts which \include files are processed

Example Code
\includeonly{chapter1,chapter3}
Command

\newpage

Starts a new page

Example Code
\newpage
Command

\clearpage

Flushes floats and starts a new page

Example Code
\clearpage
Command

\cleardoublepage

Clears page, ensures next page is odd-numbered

Example Code
\cleardoublepage
Command

\pagebreak

Suggests a page break

Example Code
\pagebreak
Command

\nopagebreak

Suggests no page break

Example Code
\nopagebreak
Command

\linebreak

Suggests a line break

Example Code
\linebreak
Command

\nolinebreak

Suggests no line break

Example Code
\nolinebreak
Command Mandatory { }

\pagestyle{style}

Sets the page style (plain, empty, headings, fancy)

Example Code
\pagestyle{fancy}
Command Mandatory { }

\thispagestyle{style}

Sets page style for current page only

Example Code
\thispagestyle{empty}
Command Mandatory { }

\pagenumbering{style}

Sets page numbering style (arabic, roman, alph)

Example Code
\pagenumbering{roman}
Document Hierarchy & Sectioning

Document Hierarchy & Sectioning

Comprehensive syntax, arguments, options, and copyable snippets for document hierarchy & sectioning.

Command Mandatory { }

\part{title}

Top-level sectioning (books/reports)

Example Code
\part{Introduction}
Command Mandatory { }

\chapter{title}

Chapter heading (report/book classes)

Example Code
\chapter{Light Scattering Theory}
Command Mandatory { }

\section{title}

Section heading

💡 Deep Dive Explanation & Options

Sectioning Hierarchy: \part (-1) → \chapter (0) → \section (1) → \subsection (2) → \subsubsection (3) → \paragraph (4) → \subparagraph (5). Automatically increments numbering, updates running headers, and registers in the Table of Contents. Use \section[Short Title]{Full Title} for compact TOC entries.

Example Code
\section{Methodology}
Command Mandatory { }

\subsection{title}

Subsection heading

Example Code
\subsection{Sample Preparation}
Command Mandatory { }

\subsubsection{title}

Sub-subsection heading

Example Code
\subsubsection{Calibration}
Command Mandatory { }

\paragraph{title}

Paragraph-level heading

Example Code
\paragraph{Note.}
Command Mandatory { }

\subparagraph{title}

Sub-paragraph-level heading

Example Code
\subparagraph{Remark.}
Command Mandatory { }

\section*{title}

Unnumbered section heading

💡 Deep Dive Explanation & Options

Unnumbered Section: Suppresses section numbering and omits the heading from the Table of Contents by default (ideal for Acknowledgments, Forewords, or References).

Example Code
\section*{Acknowledgments}
Command

\appendix

Switches sectioning to appendix numbering

Example Code
\appendix
Command

\tableofcontents

Generates table of contents

Example Code
\tableofcontents
Command

\listoffigures

Generates list of figures

Example Code
\listoffigures
Command

\listoftables

Generates list of tables

Example Code
\listoftables
Command Mandatory { }

\addcontentsline{file}{unit}{text}

Manually adds an entry to a TOC-like list

Example Code
\addcontentsline{toc}{section}{References}
Command Mandatory { }

\addtocontents{file}{text}

Adds text directly to a TOC-like file

Example Code
\addtocontents{toc}{\protect\newpage}
Headers & Footers (fancyhdr)

Headers & Footers (fancyhdr)

Comprehensive syntax, arguments, options, and copyable snippets for headers & footers (fancyhdr).

Command Mandatory { }

\pagestyle{fancy}

Activates custom fancy headers/footers (fancyhdr package)

Example Code
\pagestyle{fancy}
Command Mandatory { } Optional [ ]

\fancyhead[pos]{text}

Sets header content at a given position (fancyhdr package)

Example Code
\fancyhead[L]{\leftmark}
Command Mandatory { } Optional [ ]

\fancyfoot[pos]{text}

Sets footer content at a given position (fancyhdr package)

Example Code
\fancyfoot[C]{\thepage}
Command Mandatory { }

\renewcommand{\headrulewidth}{length}

Sets the thickness of the header rule line (fancyhdr)

Example Code
\renewcommand{\headrulewidth}{0.4pt}
Command

\leftmark

Prints the current top-level sectioning title in a header (fancyhdr)

Example Code
\fancyhead[L]{\leftmark}
Command

\rightmark

Prints the current lower-level sectioning title in a header (fancyhdr)

Example Code
\fancyhead[R]{\rightmark}