Every LaTeX document begins with a single line: \documentclass. The document class you pick here decides the overall skeleton and look of the whole document — whether it is a paper, a book, or a set of slides. Then, in the preamble between \documentclass and \begin{document}, you declare the packages you use and the settings that apply document-wide. This page walks through both mechanisms in turn.
\documentclass — the first line
Every document starts with the declaration \documentclass[options]{class}. This command is mandatory and must come first — nothing (except comments) may precede it. The class name in braces {} selects the kind of document, and the options in brackets [] fine-tune things like the font size and paper (the options are optional).
A class governs appearance in general: what typeface and size headings use, how chapters and sections are numbered, how margins, headers, and footers are built. These rules live in a **class file (extension .cls)**. In the body you write only meaning — \section{Introduction} — and it is the class’s job to turn that into a concrete look. So by swapping the class alone, you can recast the same manuscript in a different style.
The standard classes
LaTeX ships with these classes out of the box. **article** is the most-used, general-purpose class — for academic papers and shorter documents. It has no chapters (\chapter); the section (\section) is its top level. **report sits between an article and a book, for longer documents that have chapters, such as technical reports and theses. book is for full-length books: it has chapters, assumes two-sided printing, and can switch between front matter, main matter, and back matter. letter is for letters, and slides** is for slides but is rarely used today.
| Class | Use | Chapters / default layout |
|---|---|---|
article | Papers and general short/medium documents | No chapters; one-sided, one-column by default |
report | Technical reports and theses | Has chapters; one-sided by default, separate title page |
book | Books | Has chapters; two-sided by default, chapters open on the right |
letter | Letters | Dedicated commands like \address, \signature |
In book especially, you divide the document with **\frontmatter / \mainmatter / \backmatter**. The \frontmatter region (preface, table of contents, and so on) is numbered in lowercase roman numerals (i, ii, iii…) and its chapters are unnumbered. \mainmatter resets the page number and switches to arabic numerals (1, 2, 3…), and chapter numbering begins. \backmatter (appendices, index) keeps arabic numbering but drops chapter numbers.
Beyond the standard classes (beamer, KOMA-Script, Japanese)
Beyond the standard classes, CTAN offers many classes for specific purposes. For presentation slides, **beamer** is the standard choice: it sets each frame environment as one slide, with stepwise reveals (overlays) and themes. To replace the standard classes with cleaner default typography, KOMA-Script’s scrartcl / scrreprt / scrbook (corresponding to article / report / book) are widely used and notably more configurable.
For Japanese typesetting, you pick a dedicated class to match your engine. On pLaTeX / upLaTeX, Haruhiko Okumura’s **jsarticle / jsbook (jsclasses) are the standard. On LuaLaTeX, you use their LuaLaTeX counterparts ltjsarticle / ltjsbook (ltjsclasses). The newer jlreq** is built on the “Requirements for Japanese Text Layout (JLReq)”; it runs on pLaTeX, upLaTeX, or LuaLaTeX and auto-detects the engine (use the report / book options to behave like report or book).
Common options
Options go inside the brackets, separated by commas — for example \documentclass[11pt,a4paper,twoside]{article}. The most common ones follow; most are document-wide switches.
| Option | Effect | Default |
|---|---|---|
10pt / 11pt / 12pt | Base body font size | 10pt |
a4paper / letterpaper | Paper size (also a5paper, b5paper, legalpaper, etc.) | letterpaper |
twocolumn | Set the body in two columns | One column (onecolumn) |
twoside / oneside | Two-sided / one-sided layout | oneside (but twoside for book) |
landscape | Use landscape orientation | Portrait |
titlepage / notitlepage | Whether the title gets its own page | titlepage for report/book, notitlepage otherwise |
fleqn | Flush displayed formulas left | Centered |
leqno | Put equation numbers on the left | Right |
draft | Mark overfull boxes with a black bar | final |
Whether chapters in book start on a right-hand (odd) page is set by **openright** (the default for book) versus **openany** (the default for report). Options given here are passed not only to the class but also to packages loaded later (they act as global options).
The preamble — \usepackage and global settings
The lines from just after \documentclass up to just before \begin{document} are the preamble. This is not the body yet — it is where you prepare the whole document. The body (the content that gets printed) begins at \begin{document} and ends at \end{document}.
The workhorse of the preamble is **\usepackage[options]{package}. Where the class sets the underlying look, a package (extension .sty)** adds features usable regardless of document type — for instance amsmath to enhance mathematics, graphicx to include figures, or hyperref to add hyperlinks. One command can load several packages at once (\usepackage{amsmath,amssymb}). A handy rule of thumb: if it shapes the look of a particular kind of document, it’s a class; if it adds a feature independent of the kind, it’s a package.
Besides loading packages, the preamble holds settings and definitions that apply to the whole document: the title metadata \title{...}, \author{...}, \date{...}; your own commands via \newcommand; length changes with \setlength; the page style with \pagestyle, and so on. These must be declared before the body — putting them inside the body may have no effect or raise an error.
Here is a complete example with a typical preamble. It selects a class, loads packages for encoding and language, defines a command and sets margins and title metadata, then enters the body.
\documentclass[11pt,a4paper]{article}
% --- preamble: packages ---
\usepackage[T1]{fontenc}
\usepackage{amsmath} % better mathematics
\usepackage{graphicx} % \includegraphics
\usepackage[margin=25mm]{geometry}
\usepackage{hyperref} % load last
% --- preamble: settings & definitions ---
\newcommand{\R}{\mathbb{R}}
\setlength{\parindent}{0pt}
\title{A Short Note}
\author{Ada Lovelace}
\date{\today}
\begin{document}
\maketitle
Hello, \LaTeX! For all $x \in \R$ we have $x^2 \ge 0$.
\end{document}The order of loading matters too. Packages that tend to interfere can behave differently depending on sequence, and some — like hyperref — are best loaded last. For a Japanese document, the first step is to switch the class itself to something like jsarticle or ltjsarticle: choosing a class that matches your engine matters most of all.