A LaTeX document is not a blank page: it is a small program that you compile to produce a PDF. Good news: the minimal structure fits in four lines. Let us discover it, then compile it together.
Compile Click Compile and watch the PDF appear. You have just compiled your first LaTeX document.
The three parts to remember
\documentclass{article}: the document type (here, an article). It is always the first line.\begin{document}…\end{document}: between these two lines lies everything that will be visible in the PDF.- Whatever comes before
\begin{document}is called the preamble: this is where you set the page layout and load extensions (more on that later).
Modify Your turn: replace the sentence with one of your own, then recompile to see the change.
Show the solution
\documentclass{article}
\begin{document}
I am learning LaTeX with sarmate.net, and it compiles!
\end{document}When it does not compile
LaTeX is strict: if a piece is missing, it stops. The most common beginner's mistake is failing to close the document.
Fix This document does not compile: the line that closes the document is missing. Add it, then compile.
Show the solution
\documentclass{article}
\begin{document}
Here, the end of the document is missing.
\end{document} Key point: every document begins with
\documentclass, and everything that is displayed lives between \begin{document} and \end{document}.