LaTeX Basics: From Zero to Mathematical Typesetting
LaTeX is a professional typesetting system especially suitable for creating documents containing complex mathematical formulas. Unlike WYSIWYG editors like Word, LaTeX uses a markup language to specify document structure and content through code. Whether writing academic papers, books, or simple math notes, mastering LaTeX allows your documents to exhibit professional typesetting quality.
The History and Advantages of LaTeX
LaTeX was developed in 1984 by Leslie Lamport based on Donald Knuth's TeX system. It was initially created to solve complex mathematical formula typesetting problems in scientific literature and has now become a standard tool in academia.
The main advantages of LaTeX:
- Mathematical formula typesetting: LaTeX provides rich commands and environments to easily express complex mathematical concepts
- Automatic typesetting: Automatically handles chapter numbering, references, table of contents generation, etc.
- Separation of content and format: Allows authors to focus on content creation rather than format adjustment
- Cross-platform compatibility: Maintains consistent output effects across different operating systems
- Stability and reliability: Widely used and tested over many years, with good stability
Installation and Environment Configuration
To start using LaTeX, you need to install a LaTeX distribution and an editor. Here are recommended choices for different platforms:
Windows System:
- Install MiKTeX or TeX Live distribution
- Recommended editors: TeXstudio or VS Code with LaTeX Workshop plugin
macOS System:
Linux System:
- Install TeX Live distribution (through package managers like apt, yum, etc.)
- Recommended editors: TeXmaker or VS Code
Online Editor Options:
- Overleaf: No installation required, edit and compile LaTeX documents directly in the browser
- SimpleTex: Provides formula recognition and conversion to LaTeX code, simplifying mathematical formula input
Basic Document Structure and Common Commands
Here's the structure of a simple LaTeX document:
\documentclass{article}
\begin{document}
This is my first LaTeX document!
\end{document}
Document Classes:
article
: For short documents like journal papers, reportsreport
: Suitable for longer documents like thesesbook
: For book typesettingbeamer
: For creating presentation slides
Common Commands:
Title and author:
\title{Document Title} \author{Author Name} \date{\today} \maketitle
Section commands:
\section{First Chapter} \subsection{First Section} \subsubsection{Subsection}
List environments:
\begin{itemize} \item Unordered list item 1 \item Unordered list item 2 \end{itemize} \begin{enumerate} \item Ordered list item 1 \item Ordered list item 2 \end{enumerate}
Image insertion:
\usepackage{graphicx} \begin{figure} \centering \includegraphics[width=0.5\textwidth]{image_name.jpg} \caption{Image description} \label{fig:myfigure} \end{figure}
Math Mode Introduction and Examples
LaTeX provides two math modes: inline mode and display mode.
Inline Math Mode: Formulas embedded within text lines, surrounded by $...$
or \(...\)
.
For example:
Display Math Mode: Formulas occupy their own line, centered, surrounded by $$...$$