Lesson 1

Your First Document

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 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 what each line does:

  1. \documentclass{article}: This tells the LaTeX compiler that we are writing an article. Other common classes include report, book, and beamer (for presentations).
  2. \begin{document}: This marks the beginning of the content that will actually be printed on the page.
  3. Hello, World!: This is the text that will appear in your PDF.
  4. \end{document}: This tells the compiler that the document is finished. Anything written after this line will be 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 formatting to everything inside it.

Try It Yourself

In LetX, you don't need to compile anything manually. Just type the code, and the preview will update automatically.

Try changing the text "Hello, World!" to your own name.

Knowledge Check

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