
The best Latex editor ▋
LaTeX Tutorial — Lesson 2
Learn about the document structure in LaTeX
Lesson 2: Document Structure in LaTeX
Now that you’ve written your first LaTeX document, it’s time to bring order to your content.
LaTeX excels at structuring documents. With built-in tools for sections, subsections, paragraphs, lists, and even automated tables of contents, you can quickly organize ideas — whether you’re writing an article, report, or thesis.
Sectioning Commands
LaTeX lets you create hierarchical structure using section commands: latex Copy Edit
When compiled, these commands produce numbered headings:
\section{...}
→ 1. Section Name\subsection{...}
→ 1.1 Subsection Name\subsubsection{...}
→ 1.1.1 Sub-subsection Name
LaTeX automatically numbers and formats these headings — you don’t need to manage it manually.
Notes:
In the
article
document class (which we’re using),\section
is the top-level heading.Other classes like
report
andbook
introduce a higher level:\chapter{...}
. We’ll stick toarticle
for now, which is ideal for shorter documents.
Paragraphs and Line Breaks
To create a new paragraph in LaTeX, just leave a blank line in your source code:
By default, LaTeX will indent the first line of each paragraph. If you just hit Enter once, LaTeX treats it as part of the same paragraph.
To break a line without starting a new paragraph, use the \\
command:
This keeps both lines in the same paragraph but places them on separate lines — useful for addresses, poetry, etc.
Creating a Table of Contents
LaTeX can generate a Table of Contents (ToC) automatically based on your sections:
Place this command where you want the ToC to appear — usually right after the title or abstract.
The first compile may not show the full ToC because LaTeX collects structure data during compilation. Just compile again, and it will be updated with page numbers and headings.
Example: A Structured Document with ToC
When compiled, this document produces a table of contents followed by neatly numbered sections.
Bullet Points and Numbered Lists
LaTeX makes it easy to create lists — either bulleted or numbered:
Bullet List (itemize
)
Numbered List (enumerate
)
LaTeX handles the bullets and numbering automatically.
Nesting Lists
You can nest lists inside each other for sub-items:
LaTeX will switch bullet styles (e.g., dashes or open circles) to visually distinguish nested levels.
Stick with the default formatting for now. You can customize bullets and numbering styles later using packages.
Comments and Organization
Use the percent sign %
to add comments in your source code. These are ignored during compilation:
Comments are great for leaving notes to yourself or disabling content temporarily.
Splitting Documents (Advanced)
For large documents, LaTeX allows you to break up content across multiple files:
But for now, it’s easiest to keep everything in one file as you learn.
Recap
In this lesson, you learned how to:
Structure content with
\section
,\subsection
, and\subsubsection
Start new paragraphs and insert line breaks
Generate a Table of Contents automatically
Create bulleted and numbered lists
Use comments to keep your source organized
Try building on your document from Lesson 1 by adding a few sections and a list. Watch how LaTeX handles formatting — effortlessly.
What’s Next?
In Lesson 3, we’ll explore one of LaTeX’s biggest strengths: writing math and building tables. These tools are essential for academic writing, reports, and any structured document.
Ready to dive into equations and grids? Let’s go!