Your first document

Start from the smallest document that compiles, then add a title and headings until you have a small report. Along the way you will pick up LaTeX’s basic rules.

The smallest document

Every LaTeX document has three parts. \documentclass{...} at the top chooses the kind of document; everything before \begin{document} is the preamble (where settings go); and everything between \begin{document} and \end{document} is the body. These few lines are a complete, working example.

document.tex
\documentclass{article}
\begin{document}
This is my first document.
\end{document}

article is the standard class for shorter documents; there are also report, book, and — for Japanese — jlreq (see “TeX/LaTeX and Japanese” to write in Japanese).

The basic rules

Every command starts with a **backslash \. Required arguments go in braces { }, optional ones in brackets [ ]** (e.g. \documentclass[12pt]{article}). Anything from % to the end of the line is a comment and is not printed.

In the body, line breaks in the source are ignored, and a blank line starts a new paragraph — LaTeX decides the final line breaks. Note that & % $ # _ { } have special meanings; to print them literally, escape them as \&, \%, and so on.

Compile it to a PDF

Run the file through a TeX engine to get a PDF. In an editor or on Overleaf you just press “compile”; on the command line:

terminal
pdflatex document.tex     # → document.pdf
# or, simpler — runs the right number of passes automatically:
latexmk -pdf document.tex

Documents with a table of contents or cross-references need two passes (latexmk figures out the count for you). For the full pipeline, see “From source to PDF.”

Add a title and headings — make it a report

Put \title, \author, and \date in the preamble, then call \maketitle at the top of the body to print the title. Headings made with \section and \subsection are numbered automatically, and \tableofcontents builds the contents list for you.

report.tex
\documentclass{article}
\title{My First Report}
\author{Taro Yamada}
\date{\today}
\begin{document}
\maketitle
\tableofcontents

\section{Introduction}
This is the introduction.

\section{Method}
\subsection{Setup}
Details go here.
\end{document}

To leave a heading unnumbered, add an asterisk: \section*{...}. \today is replaced by the date you compile on.

Add features with packages

Missing features come from packages — just add \usepackage{...} to the preamble. For images, graphicx; for serious math, amsmath; for margins, geometry. A vast collection lives on CTAN.

document.tex
\documentclass{article}
\usepackage{graphicx}   % images
\usepackage{amsmath}    % better math
\begin{document}
% your content
\end{document}