Beginner 12 min read

Your First LaTeX Document: Complete Beginner's Guide

Learn how to create your first LaTeX document from scratch with this comprehensive step-by-step guide. Perfect for absolute beginners with no prior LaTeX experience.

What is LaTeX?

LaTeX (pronounced "LAY-tek" or "LAH-tek") is a document preparation system that allows you to create professional-quality documents with precise formatting and typesetting. Unlike word processors like Microsoft Word or Google Docs, LaTeX uses a markup language where you write plain text with commands that tell LaTeX how to format your content.

Think of LaTeX as writing instructions for a professional typesetter. You focus on the content and structure of your document, while LaTeX handles the complex task of making it look beautiful.

LaTeX vs. Word Processing: In a word processor, you format text directly (WYSIWYG - What You See Is What You Get). In LaTeX, you write commands that describe structure, and LaTeX produces the formatted output. This separation of content and presentation is LaTeX's greatest strength.

Why Use LaTeX?

Before diving into creating your first document, it's helpful to understand why LaTeX is worth learning:

Superior Mathematical Typesetting

LaTeX produces publication-quality mathematical formulas and equations. It's the standard in mathematics, physics, computer science, and engineering.

Consistent Formatting

LaTeX automatically handles numbering, cross-references, bibliographies, and table of contents. Your documents maintain consistent formatting throughout.

Professional Output

LaTeX documents have a distinctive, professional appearance with optimal line breaking, hyphenation, and spacing that word processors can't match.

Version Control Friendly

LaTeX files are plain text, making them perfect for version control systems like Git. Track changes, collaborate, and manage revisions easily.

Academic Standard

Most academic journals, conferences, and universities require or prefer LaTeX for theses, dissertations, and research papers.

Free and Open Source

LaTeX is completely free to use on any platform. No subscriptions, no licensing fees, and a massive library of free templates and packages.

Installing LaTeX

Before you can create LaTeX documents, you need to install a LaTeX distribution on your computer. A LaTeX distribution includes the LaTeX compiler and thousands of packages for different document types and formatting needs.

Windows Installation

For Windows users, MiKTeX is the most popular LaTeX distribution:

1

Download MiKTeX

Visit miktex.org/download and download the Windows installer (approximately 200 MB).

2

Run the Installer

Double-click the downloaded file and follow the installation wizard. Choose "Install MiKTeX for all users" if you have administrator privileges.

3

Configure Package Installation

During installation, select "Yes" for "Install missing packages on-the-fly". This automatically downloads packages as you need them.

4

Verify Installation

Open Command Prompt and type pdflatex --version. You should see version information if installation was successful.

macOS Installation

For Mac users, MacTeX is the recommended distribution:

1

Download MacTeX

Visit tug.org/mactex and download MacTeX.pkg (approximately 4 GB - it's a full installation).

2

Install MacTeX

Open the .pkg file and follow the installation instructions. This will take 10-15 minutes depending on your system.

3

Verify Installation

Open Terminal and type pdflatex --version to verify the installation.

Linux Installation

For Linux users, TeX Live is available through your package manager:

Ubuntu/Debian
sudo apt-get update
sudo apt-get install texlive-full
Fedora
sudo dnf install texlive-scheme-full
Arch Linux
sudo pacman -S texlive-most
Installation Size: Full LaTeX distributions are large (3-7 GB) because they include thousands of packages and fonts. If disk space is limited, consider installing a basic version and adding packages as needed, or use an online editor like Overleaf.

Choosing a LaTeX Editor

While you can write LaTeX in any text editor, specialized LaTeX editors make the process much easier with features like syntax highlighting, auto-completion, and built-in compilation.

Recommended LaTeX Editors

Overleaf (Online)

Best for: Beginners, collaboration

Pros: No installation needed, real-time preview, easy collaboration, version history included.

Cons: Requires internet connection, free version has compile timeout limits.

Try Overleaf →

TeXstudio (Desktop)

Best for: Feature-rich desktop experience

Pros: Excellent auto-completion, integrated PDF viewer, extensive customization, completely free.

Cons: Interface can be overwhelming for beginners initially.

Download TeXstudio →

VS Code + LaTeX Workshop

Best for: Developers, multi-format projects

Pros: Powerful modern editor, Git integration, excellent for mixed-format projects.

Cons: Requires extension setup, learning curve if new to VS Code.

Get VS Code →

TeXworks (Lightweight)

Best for: Simple, distraction-free writing

Pros: Lightweight, comes with MiKTeX/MacTeX, simple interface, fast startup.

Cons: Fewer features than other editors, basic auto-completion.

Included with MiKTeX and MacTeX installations

Recommendation for Beginners: Start with Overleaf if you want to try LaTeX immediately without installation, or TeXstudio if you prefer working offline with a feature-rich environment. Both are excellent choices for learning LaTeX.

Basic Document Structure

Every LaTeX document follows a standard structure with two main parts: the preamble and the document environment.

The Essential Components

Preamble

\documentclass{...} - Document type

\usepackage{...} - Additional packages

\title{...} - Document metadata

Document Body

\begin{document}

Your actual content goes here

\end{document}

Document Classes

The first line of every LaTeX document specifies the document class, which determines the overall format and available commands:

Document Class Purpose Common Use Cases
article Short documents without chapters Research papers, journal articles, short reports
report Longer documents with chapters Thesis, long reports, project documentation
book Books and manuscripts Books, textbooks, manuals
letter Correspondence Formal letters, business correspondence
beamer Presentations Slides, academic presentations
For Your First Document: Use the article class. It's the most straightforward and suitable for learning LaTeX basics.

Your First Document: Hello World

Let's create your first LaTeX document! We'll start with the classic "Hello World" example and then gradually add more elements.

Minimal LaTeX Document

Here's the absolute minimum code needed for a LaTeX document:

hello.tex
\documentclass{article}

\begin{document}

Hello World! This is my first LaTeX document.

\end{document}

Line-by-Line Explanation:

  • \documentclass{article} - Declares this as an article-type document
  • \begin{document} - Marks the start of your document content
  • Hello World! ... - Your actual content
  • \end{document} - Marks the end of your document (anything after this is ignored)

Adding Title and Author Information

Let's enhance our document with a title, author, and date:

hello_enhanced.tex
\documentclass{article}

% Preamble: Document metadata
\title{My First LaTeX Document}
\author{Your Name}
\date{\today}

\begin{document}

% Create the title
\maketitle

% Introduction section
\section{Introduction}

Hello World! This is my first LaTeX document. I'm learning how to use LaTeX to create professional-looking documents.

% A second section
\section{Why I'm Learning LaTeX}

LaTeX helps me create documents with consistent formatting and beautiful typography. It's especially useful for academic writing and technical documentation.

\end{document}
Output Preview:
My First LaTeX Document
Your Name
January 15, 2024
1 Introduction

Hello World! This is my first LaTeX document. I'm learning how to use LaTeX to create professional-looking documents.

2 Why I'm Learning LaTeX

LaTeX helps me create documents with consistent formatting and beautiful typography. It's especially useful for academic writing and technical documentation.

Comments in LaTeX: Lines starting with % are comments. They're ignored by LaTeX and are useful for adding notes to your code.

Compiling Your Document

After writing your LaTeX code, you need to compile it to generate the final PDF output. The compilation process is different depending on your editor.

Compiling in Different Editors

Overleaf

  1. Create a new project and paste your LaTeX code
  2. Click the "Recompile" button (or press Ctrl+S to auto-compile)
  3. View the PDF in the right panel
  4. Download the PDF using the download icon

Overleaf compiles automatically as you type by default.

TeXstudio

  1. Create a new file: File → New
  2. Paste your code and save as hello.tex
  3. Click the green arrow (Build & View) or press F5
  4. View the PDF in the integrated viewer

Default shortcut: F5 (Build & View), F6 (Compile only), F7 (View PDF)

VS Code

  1. Install the LaTeX Workshop extension
  2. Create a new file and save as hello.tex
  3. Press Ctrl+Alt+B (or Cmd+Option+B on Mac) to build
  4. Click the PDF icon to view the output

LaTeX Workshop can auto-build on save (configurable in settings).

Command Line

  1. Open terminal/command prompt
  2. Navigate to the folder containing your hello.tex file
  3. Run: pdflatex hello.tex
  4. Open the generated hello.pdf file

You may need to run pdflatex twice for proper cross-references and table of contents.

Compilation Files: LaTeX creates several auxiliary files during compilation (.aux, .log, .out, etc.). These are normal and needed for the compilation process. Most editors hide them by default. Only the .pdf file is your final output.

Adding Common Elements

Now that you can create and compile basic documents, let's add some common elements you'll use frequently.

Text Formatting

Text Formatting Examples
% Bold text
This is \textbf{bold text}.

% Italic text
This is \textit{italic text}.

% Underlined text
This is \underline{underlined text}.

% Different sizes
{\tiny Tiny text} {\small Small text} Normal text 
{\large Large text} {\Large Larger text} {\LARGE Even larger}

% Emphasis (usually italic)
This is \emph{emphasized}.

Lists

Creating Lists
% Bulleted list
\begin{itemize}
    \item First item
    \item Second item
    \item Third item
\end{itemize}

% Numbered list
\begin{enumerate}
    \item First step
    \item Second step
    \item Third step
\end{enumerate}

% Description list
\begin{description}
    \item[LaTeX] A document preparation system
    \item[PDF] Portable Document Format
    \item[Editor] Software for writing code
\end{description}

Paragraphs and Line Breaks

Paragraphs and Spacing
This is the first paragraph. LaTeX automatically handles
line breaking and justification. You don't need to worry
about line lengths.

This is a new paragraph. Leave a blank line to start 
a new paragraph.

You can force a line break\\
without starting a new paragraph.

% Horizontal line
\hrulefill

% Page break
\newpage

Special Characters

Some characters have special meaning in LaTeX and need to be escaped with a backslash:

Character LaTeX Code Purpose
# \# Parameter/macro argument
$ \$ Math mode delimiter
% \% Comment character
& \& Table column separator
_ \_ Subscript in math mode
{ \{ Grouping
} \} Grouping
\ \textbackslash Command prefix

Adding a Table

Simple Table Example
\begin{table}[h]
\centering
\begin{tabular}{|l|c|r|}
\hline
Left & Center & Right \\
\hline
Item 1 & 100 & \$50 \\
Item 2 & 200 & \$75 \\
Item 3 & 150 & \$60 \\
\hline
\end{tabular}
\caption{My first table}
\label{tab:example}
\end{table}

Common Beginner Mistakes

Here are the most common errors beginners make and how to avoid them:

Forgetting to Escape Special Characters
Wrong: The price is $50 & includes 20% discount
Correct: The price is \$50 \& includes 20\% discount
Missing \end{document}

Always close your document environment. Without \end{document}, LaTeX will give an error.

Using Single Quotes Incorrectly
Wrong: "Hello World" or 'Hello'
Correct: ``Hello World'' or `Hello'

Use backticks for opening quotes and apostrophes for closing quotes.

Not Loading Required Packages

If you use commands like \includegraphics without loading \usepackage{graphicx}, you'll get an undefined control sequence error.

Multiple Spaces and Blank Lines

LaTeX treats multiple spaces as a single space and multiple blank lines as one paragraph break. This is intentional—LaTeX controls spacing for optimal typography.

Compiling Only Once

For documents with cross-references, table of contents, or bibliographies, you often need to compile 2-3 times for everything to appear correctly.

Debugging Tip: When you get an error, LaTeX tells you the line number where it occurred. Read the error message carefully—it usually tells you exactly what's wrong. Most editors highlight the problematic line.

Next Steps in Your LaTeX Journey

Congratulations! You've created your first LaTeX document. Here's what to learn next:

Mathematical Equations

Learn how to write beautiful mathematical formulas, the feature LaTeX is most famous for.

Learn Math in LaTeX →

Font Sizes and Styles

Master font customization to make your documents look exactly how you want.

Font Size Guide →

Resume Templates

Apply your LaTeX skills to create a professional resume using our templates.

Browse Resume Templates →

Symbols and Special Characters

Discover the vast library of mathematical and special symbols available in LaTeX.

Symbol Reference →

Recommended Learning Path

  1. Text Formatting: Master basic text styling, lists, and document structure
  2. Mathematics: Learn inline and display math, fractions, and common symbols
  3. Figures and Tables: Add images and create professional tables
  4. Cross-References: Link sections, figures, and tables within your document
  5. Bibliography: Manage citations and references with BibTeX
  6. Custom Commands: Create your own shortcuts for frequently used formatting

Practice Makes Perfect

The best way to learn LaTeX is by using it. Try creating different types of documents:

  • Write a short essay or article
  • Create a resume using one of our LaTeX resume templates
  • Make a simple presentation with Beamer
  • Document a project or assignment

Frequently Asked Questions

Do I need to install LaTeX to use it, or can I use it online?

You can use LaTeX both ways. Overleaf is the most popular online LaTeX editor that requires no installation—just create a free account and start writing. However, installing LaTeX locally (MiKTeX for Windows, MacTeX for Mac, TeX Live for Linux) gives you offline access, faster compilation, and full control over packages and configurations.

Why does my LaTeX document compilation fail?

Common causes include: (1) missing packages—install them through your LaTeX distribution's package manager, (2) syntax errors like unmatched braces {} or missing backslashes, (3) special characters not escaped (use \$ instead of $), or (4) undefined references requiring multiple compilations. Check the .log file for specific error messages with line numbers.

How do I convert my Word document to LaTeX?

Use conversion tools like Pandoc (command-line tool) or Word-to-LaTeX (dedicated converter) for automated conversion. However, these rarely produce perfect results—expect to manually clean up formatting, fix tables, and adjust structure. For important documents, it's often faster to recreate them in LaTeX from scratch, especially if they contain complex formatting.

What's the difference between pdflatex, xelatex, and lualatex?

pdflatex is the standard, fastest compiler suitable for most documents. xelatex and lualatex are modern alternatives with better Unicode and font support, making them ideal for non-Latin scripts or custom fonts. For beginners, stick with pdflatex unless you specifically need Unicode or system fonts. Most templates and packages work with all three.

Can I collaborate with others on a LaTeX document?

Yes! Overleaf offers real-time collaboration similar to Google Docs with built-in version control. For local files, use Git for version control—LaTeX's plain text format is perfect for tracking changes. GitHub and GitLab both support LaTeX rendering. You can also use Dropbox or similar services, though they lack proper merge conflict resolution.

How long does it take to learn LaTeX?

You can create basic documents within hours. To become comfortable with common features (formatting, math, tables, figures) typically takes 1-2 weeks of regular use. Advanced features (custom commands, package creation, complex layouts) can take months to master. The learning curve is steeper than Word, but the payoff in document quality and efficiency is substantial for technical writing.

Is LaTeX free to use for commercial purposes?

Yes, LaTeX and most LaTeX packages are completely free and open source under permissive licenses. You can use LaTeX for any purpose—academic, commercial, personal—without licensing fees. This includes creating and selling documents, books, or templates. However, some premium templates from third-party sites may have their own licensing terms.

What should I do if I can't find a specific symbol in LaTeX?

Use Detexify (detexify.kirelabs.org) where you draw the symbol and it suggests LaTeX commands. The Comprehensive LaTeX Symbol List PDF contains over 14,000 symbols. For Unicode symbols, use XeLaTeX or LuaLaTeX with the unicode-math package. Our LaTeX symbols reference covers the most commonly used mathematical and text symbols.

Ready to Create Professional Documents?

Start with our professionally designed LaTeX resume templates

Browse Resume Templates