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.
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.
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.
Before diving into creating your first document, it's helpful to understand why LaTeX is worth learning:
LaTeX produces publication-quality mathematical formulas and equations. It's the standard in mathematics, physics, computer science, and engineering.
LaTeX automatically handles numbering, cross-references, bibliographies, and table of contents. Your documents maintain consistent formatting throughout.
LaTeX documents have a distinctive, professional appearance with optimal line breaking, hyphenation, and spacing that word processors can't match.
LaTeX files are plain text, making them perfect for version control systems like Git. Track changes, collaborate, and manage revisions easily.
Most academic journals, conferences, and universities require or prefer LaTeX for theses, dissertations, and research papers.
LaTeX is completely free to use on any platform. No subscriptions, no licensing fees, and a massive library of free templates and packages.
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.
For Windows users, MiKTeX is the most popular LaTeX distribution:
Visit miktex.org/download and download the Windows installer (approximately 200 MB).
Double-click the downloaded file and follow the installation wizard. Choose "Install MiKTeX for all users" if you have administrator privileges.
During installation, select "Yes" for "Install missing packages on-the-fly". This automatically downloads packages as you need them.
Open Command Prompt and type pdflatex --version. You should see version information if installation was successful.
For Mac users, MacTeX is the recommended distribution:
Visit tug.org/mactex and download MacTeX.pkg (approximately 4 GB - it's a full installation).
Open the .pkg file and follow the installation instructions. This will take 10-15 minutes depending on your system.
Open Terminal and type pdflatex --version to verify the installation.
For Linux users, TeX Live is available through your package manager:
sudo apt-get update
sudo apt-get install texlive-full
sudo dnf install texlive-scheme-full
sudo pacman -S texlive-most
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.
Pros: No installation needed, real-time preview, easy collaboration, version history included.
Cons: Requires internet connection, free version has compile timeout limits.
Pros: Excellent auto-completion, integrated PDF viewer, extensive customization, completely free.
Cons: Interface can be overwhelming for beginners initially.
Pros: Powerful modern editor, Git integration, excellent for mixed-format projects.
Cons: Requires extension setup, learning curve if new to VS Code.
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
Every LaTeX document follows a standard structure with two main parts: the preamble and the document environment.
\documentclass{...} - Document type
\usepackage{...} - Additional packages
\title{...} - Document metadata
\begin{document}
Your actual content goes here
\end{document}
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 |
article class. It's the most straightforward and suitable for learning LaTeX basics.
Let's create your first LaTeX document! We'll start with the classic "Hello World" example and then gradually add more elements.
Here's the absolute minimum code needed for a LaTeX document:
\documentclass{article}
\begin{document}
Hello World! This is my first LaTeX document.
\end{document}
\documentclass{article} - Declares this as an article-type document\begin{document} - Marks the start of your document contentHello World! ... - Your actual content\end{document} - Marks the end of your document (anything after this is ignored)Let's enhance our document with a title, author, and date:
\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}
Hello World! This is my first LaTeX document. I'm learning how to use LaTeX to create professional-looking documents.
LaTeX helps me create documents with consistent formatting and beautiful typography. It's especially useful for academic writing and technical documentation.
% are comments. They're ignored by LaTeX and are useful for adding notes to your code.
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.
Overleaf compiles automatically as you type by default.
hello.texDefault shortcut: F5 (Build & View), F6 (Compile only), F7 (View PDF)
hello.texLaTeX Workshop can auto-build on save (configurable in settings).
hello.tex filepdflatex hello.texhello.pdf fileYou may need to run pdflatex twice for proper cross-references and table of contents.
Now that you can create and compile basic documents, let's add some common elements you'll use frequently.
% 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}.
% 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}
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
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 |
\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}
Here are the most common errors beginners make and how to avoid them:
The price is $50 & includes 20% discount
The price is \$50 \& includes 20\% discount
Always close your document environment. Without \end{document}, LaTeX will give an error.
"Hello World" or 'Hello'
``Hello World'' or `Hello'
Use backticks for opening quotes and apostrophes for closing quotes.
If you use commands like \includegraphics without loading \usepackage{graphicx}, you'll get an undefined control sequence error.
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.
For documents with cross-references, table of contents, or bibliographies, you often need to compile 2-3 times for everything to appear correctly.
Congratulations! You've created your first LaTeX document. Here's what to learn next:
Learn how to write beautiful mathematical formulas, the feature LaTeX is most famous for.
Learn Math in LaTeX →Master font customization to make your documents look exactly how you want.
Font Size Guide →Apply your LaTeX skills to create a professional resume using our templates.
Browse Resume Templates →Discover the vast library of mathematical and special symbols available in LaTeX.
Symbol Reference →The best way to learn LaTeX is by using it. Try creating different types of documents:
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.
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.
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.
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.
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.
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.
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.
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.
Start with our professionally designed LaTeX resume templates
Browse Resume Templates