\documentclass{...} and puts the text between \begin{document} and \end{document}. Save the four lines below as a .tex file, compile it, and you have a one-page PDF.
1. Write the minimal document
hello-world.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
\documentclass{article}picks the layout.articlesuits papers and short reports;reportandbookadd chapters, andbeamermakes slides.\begin{document}and\end{document}enclose everything that is printed. LaTeX ignores anything after\end{document}.- The page number at the bottom comes from the
articleclass.
2. Add a title and sections
Everything between\documentclass and \begin{document} is the preamble: settings and document information, but no printed text. Set the title, author and date there, then print them with \maketitle in the body. \section{...} adds a numbered heading.
title-sections.tex
- Paragraphs: a blank line starts a new paragraph. A single line break in the source is treated like a space.
- Comments:
%hides the rest of the line. To print a percent sign, write\%. - Page size: the
geometryand\pagestyle{empty}lines only make the preview compact. Leave them out to get a normal page with page numbers.
\date{\today} prints the date of the compile. More heading levels and numbering options are on Sections and chapters.
3. Add math and a package
Inline math goes between$...$. The equation environment centers a numbered equation on its own line. Packages add features: \usepackage{amsmath} in the preamble provides \text and other math tools.
first-article.tex
graphicx the same way and see inserting images. Package management explains package options and loading order.
4. Compile and fix errors
Compiling turnsmain.tex into main.pdf. With a local TeX installation, run pdflatex main.tex; pdfLaTeX is the usual default, and Choosing a compiler explains when to use XeLaTeX or LuaLaTeX instead. Run it a second time when the document has a table of contents or cross-references.
If the compile stops, read the first error in the log: the number after l. is the line to look at. The most common beginner errors are text in the preamble (Missing \begin{document}), a missing }, and _ or ^ outside math (Missing $ inserted). Common LaTeX errors explains each message.
A larger project keeps main.tex in a folder with its images and bibliography files; Your first LaTeX project shows that layout.
