Lesson 2 of 4

Document Structure

Learn how to divide your document into chapters, sections, and paragraphs, and how to use the preamble.

In a word processor like Microsoft Word, you have to manually highlight text, make it bold, increase the font size, and add spacing to create a "section header."

LaTeX takes a fundamentally different approach. In LaTeX, you tell the compiler what the text is (e.g., "This is a section"), and LaTeX decides exactly how it should look based on world-class typography rules.

The Preamble

As mentioned in the previous lesson, everything between \documentclass{...} and \begin{document} is called the preamble.

The preamble is the "control room" of your document. Nothing written here will directly appear on the page. Instead, this is where you:

  • Define the page margins
  • Import external packages (like math tools or image support)
  • Set the title, author, and date
\documentclass[12pt, a4paper]{article}
 
% --- PREAMBLE STARTS HERE ---
\usepackage[margin=1in]{geometry}
\title{The Theory of Everything}
\author{Albert Einstein}
\date{November 1915}
% --- PREAMBLE ENDS HERE ---
 
\begin{document}
\maketitle
 
Content starts here...
\end{document}

Notice the \maketitle command inside the document environment. This command tells LaTeX to take the title, author, and date you defined in the preamble and generate a beautifully formatted title block at the top of the page.

Optional Arguments

Notice the square brackets in \documentclass[12pt, a4paper]{article}? In LaTeX, square brackets [...] are used for optional parameters, while curly braces {...} are used for mandatory parameters.

Sections and Paragraphs

To structure the actual content of your document, LaTeX provides a hierarchy of sectioning commands. You don't need to number them yourself—LaTeX handles all the numbering automatically!

\section{Introduction}
This is the first paragraph. LaTeX will automatically format it.
 
This is the second paragraph. Notice that to create a new paragraph in LaTeX, you must leave a completely blank line between the text! Just pressing Enter once will NOT create a new paragraph.
 
\subsection{Historical Background}
This is a subsection inside the Introduction. It will be numbered 1.1 automatically.
 
\subsubsection{Early Discoveries}
You can go even deeper. This will be numbered 1.1.1.
 
\section{Methodology}
This is a brand new section. It will be numbered 2.

Unnumbered Sections

Sometimes you want a section heading (like an "Acknowledgments" or "References" section) but you don't want it to be numbered. You can achieve this by adding an asterisk * to the command:

\section*{Acknowledgments}
I would like to thank my cat for sitting on my keyboard while I wrote this paper.

Abstract

For academic papers and articles, you often need an abstract—a brief summary of the paper right below the title. LaTeX provides a built-in environment for this:

\begin{abstract}
This paper presents a groundbreaking new approach to typing LaTeX documents directly in the browser using LetX, eliminating the need for complex local installations.
\end{abstract}

Knowledge Check

Knowledge Check

How do you tell LaTeX to start a new paragraph?