LaTeX & TeX: The Complete Guide to Scientific Document Format
If you have ever read an academic paper in mathematics, physics, computer science, or engineering and marveled at how perfectly the equations were typeset — the precise spacing, the beautiful fraction bars, the subscripts and superscripts aligned just right — you were almost certainly looking at a document produced with LaTeX. Since the early 1980s, LaTeX has been the gold standard for scientific and technical document preparation, and its .tex source files are one of the most important text-based document formats in academia and research.
What Are TeX and LaTeX?
TeX is a typesetting system created by Donald Knuth, who began work on it in 1978 after being dissatisfied with the typesetting of the second volume of his The Art of Computer Programming series. Knuth wanted typographic perfection — letterpress-quality output from a computer. TeX, completed in 1982 (version 3, frozen in 1989), is the underlying engine that renders text and mathematics to print.
LaTeX (pronounced "lah-tech" or "lay-tech") is a macro package built on top of TeX, created by Leslie Lamport in the early 1980s. LaTeX provides a higher-level document structure: \begin{document}, \section{}, \cite{}, \includegraphics{} — human-friendly commands that compile down to TeX primitives.
When people say "LaTeX", they usually mean LaTeX 2ε (the 1994 version, still current), though development continues in the LaTeX3 project.
Why LaTeX for Scientific Documents?
LaTeX dominates academic publishing because:
- Mathematical typesetting: LaTeX's equation rendering is unmatched. The American Mathematical Society's amsmath package is the gold standard for mathematical notation
- Separation of content and style: you write semantic markup (
\section{Introduction},\emph{italic}) and the document class handles layout — changing journal styles means changing one line - Bibliographies: BibTeX and BibLaTeX manage references, automatically formatting citations to any journal style
- Cross-references:
\label{fig:results}and\ref{fig:results}create automatically-updated figure and equation numbers - Consistency: LaTeX enforces typographic consistency automatically — no manual spacing, no accidental font changes
- Free and open: TeX and LaTeX are free software; every major OS has a full TeX distribution
The .tex File Format
A LaTeX source file (.tex extension) is a plain text file containing both content and markup commands. Commands begin with backslash:
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath} % AMS math extensions
\usepackage{graphicx} % Include images
\usepackage{hyperref} % PDF hyperlinks
\usepackage[style=ieee]{biblatex} % IEEE citation style
\addbibresource{references.bib}
\title{On the Convergence of Stochastic Gradient Descent}
\author{Jane Doe \\ University of Example}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
We prove that stochastic gradient descent converges to a local minimum
under mild smoothness conditions.
\end{abstract}
\section{Introduction}
Let $f: \mathbb{R}^n \to \mathbb{R}$ be a differentiable function.
The gradient descent update rule is:
\begin{equation}
\theta_{t+1} = \theta_t - \eta \nabla f(\theta_t)
\label{eq:gd}
\end{equation}
where $\eta > 0$ is the learning rate. As shown in \eqref{eq:gd}...
\section{Experiments}
Results are presented in Table~\ref{tab:results}.
\begin{table}[h]
\centering
\caption{Convergence rates}
\label{tab:results}
\begin{tabular}{lcc}
\hline
Method & Iterations & Error \\
\hline
SGD & 1000 & 0.01 \\
Adam & 500 & 0.008 \\
\hline
\end{tabular}
\end{table}
\printbibliography
\end{document}
Compiling LaTeX to PDF
LaTeX source must be compiled to produce output. The compilation chain:
-
pdflatex: most common, produces PDF directly. Run 2-3 times to resolve cross-references:
pdflatex main.tex biber main # process bibliography (or bibtex main.aux) pdflatex main.tex pdflatex main.tex -
lualatex: modern engine with native Unicode support and Lua scripting (use for non-Latin scripts)
-
xelatex: another modern engine with Unicode + system font access (great for multilingual documents)
-
latexmk: automates the multi-run compilation:
latexmk -pdf main.tex
TeX Distributions
| Distribution | Platform | Notes |
|---|---|---|
| TeX Live | Linux/macOS/Windows | The most complete distribution; yearly updates |
| MiKTeX | Windows (also macOS/Linux) | On-demand package installation |
| MacTeX | macOS | TeX Live + macOS-specific tools |
| TinyTeX | All | Minimal distribution for R users (install via R/Python) |
LaTeX Editors
Overleaf (overleaf.com): the dominant cloud LaTeX editor — real-time collaborative editing, no local installation needed, used by millions of researchers. The de facto standard for academic collaboration.
TeXstudio: free desktop editor with integrated PDF preview, spell check, code completion
VS Code + LaTeX Workshop extension: popular among programmers; excellent syntax highlighting and PDF sync
TeXmaker: free cross-platform editor with integrated PDF preview
LyX: WYSIWYG-ish LaTeX editor — hides raw LaTeX behind a graphical interface
Converting LaTeX to Other Formats
LaTeX → PDF
pdflatex main.tex — the native output
LaTeX → HTML
make4ht main.tex or htlatex (part of TeX4ht) converts LaTeX to HTML. The results are functional but rarely beautiful. For math, MathJax in the HTML can re-render LaTeX equations natively.
LaTeX → Word (.docx)
Pandoc: pandoc main.tex -o main.docx — converts LaTeX to Word with reasonable fidelity for text-heavy documents. Mathematical equations convert to Word's OMML equation format.
LaTeX → Markdown
pandoc main.tex -o main.md — works for text; equations become LaTeX math mode which most Markdown renderers support.
Word → LaTeX
Pandoc does this too: pandoc input.docx -o output.tex — useful for collaborative documents where collaborators use Word.
Mathematical Equation Rendering
LaTeX's equation syntax is the lingua franca of mathematical communication online. GitHub, Jupyter notebooks, Khan Academy, Wikipedia, and many chat tools all support LaTeX math:
% Inline math
The formula $e^{i\pi} + 1 = 0$ is Euler's identity.
% Display math
\begin{equation}
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
\end{equation}
% Matrix
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
% Fraction
\frac{\partial f}{\partial x} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}
Understanding LaTeX math mode is valuable even for non-LaTeX users because this same syntax appears in Jupyter notebooks ($\LaTeX$), GitHub issue comments, Discord bots, and scientific APIs.
LaTeX is more than a file format — it is a philosophy of document preparation that prioritizes semantic meaning, typographic quality, and long-term reproducibility over immediate WYSIWYG convenience. For scientific communication, these priorities align perfectly with what researchers need: documents that remain beautiful, correct, and renderable for decades.
Related conversions
Document conversions that follow this topic naturally: