Lesson 1 of 4

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:

  1. \documentclass{article}: This tells the LaTeX compiler what kind of document we are writing. The article class is perfect for essays, short reports, and general writing. Other common classes include report (for longer documents with chapters), book, and beamer (for presentations).
  2. \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.
  3. Hello, World!: This is the plain text that will appear in your PDF.
  4. \end{document}: This tells the compiler that the document is finished. Any text written after this line will be completely ignored.
Commands vs Environments

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.

Knowledge Check

Which command MUST be at the very top of every single LaTeX document you write?