Your First Document
The absolute basics. Learn how to set up and compile your very first LaTeX file.
Let's create the simplest possible LaTeX document. A LaTeX document is essentially a plain text file ending in .tex that contains text mixed with formatting commands.
The Minimal LaTeX Document
Every LaTeX document must contain two key ingredients: a document class declaration, and a document environment.
Here is the absolute bare minimum required to create a PDF:
\documentclass{article}
\begin{document}
Hello, World!
\end{document}Breaking It Down
Let's look at exactly what each line is doing:
\documentclass{article}: This tells the LaTeX compiler what kind of document we are writing. Thearticleclass is perfect for essays, short reports, and general writing. Other common classes includereport(for longer documents with chapters),book, andbeamer(for presentations).\begin{document}: This marks the exact point where your actual content begins. Everything before this line is called the preamble (where you put settings). Everything after this line will actually be printed on the PDF page.Hello, World!: This is the plain text that will appear in your PDF.\end{document}: This tells the compiler that the document is finished. Any text written after this line will be completely ignored.
In LaTeX, a command usually starts with a backslash \ and affects its arguments, like \textbf{bold text}.
An environment starts with \begin{name} and ends with \end{name}, and applies a specific set of rules to everything inside it.
Try It Yourself
If you were using LaTeX offline on your computer, you would have to run a compiler like pdflatex in your terminal to generate the PDF.
But in LetX, you don't need to install or configure anything. Just type the code, and our cloud compiler will generate the PDF instantly in the split-screen preview.
Try opening a new project in LetX and changing the text "Hello, World!" to your own name. See how fast the PDF updates!
Knowledge Check
Before moving on to the next lesson, let's verify your understanding of the bare minimum LaTeX structure.