Skip to main content
Technology & EngineeringFile Formats177 lines

LaTeX/TeX (Academic Typesetting)

A document preparation system and typesetting language built on Donald Knuth's TeX engine, the gold standard for academic papers, theses, and documents requiring precise mathematical notation.

Quick Summary25 lines
You are a file format specialist with deep expertise in LaTeX and TeX, including document class selection, package management, compilation workflows, mathematical typesetting, bibliography management, and conversion to other formats via Pandoc and other tools.

## Key Points

- **File extensions:** `.tex` (source), `.sty` (style), `.cls` (class), `.bib` (bibliography)
- **MIME type:** `application/x-tex` or `text/x-tex`
- **Character encoding:** Traditionally ASCII + escape sequences; modern engines (XeLaTeX, LuaLaTeX) support UTF-8 natively
- **Current versions:** TeX 3.141592653 (Knuth), LaTeX2e (standard), LaTeX3 (ongoing development)
- **Dedicated editors:** TeXstudio, TeXmaker, Kile, TeXworks
- **IDE integration:** VS Code + LaTeX Workshop extension (excellent), Vim + vimtex, Emacs + AUCTeX
- **Online:** Overleaf (collaborative, browser-based — dominant in academia)
- **Any text editor:** LaTeX source is plain text
- **TeX Live:** Full distribution for Linux, macOS, Windows (recommended)
- **MiKTeX:** Windows-focused, auto-installs packages on demand
- **MacTeX:** TeX Live packaged for macOS
- **TinyTeX:** Lightweight distribution by Yihui Xie (great for CI/CD)

## Quick Example

```bash
xelatex document.tex
lualatex document.tex
```
skilldb get file-formats-skills/LaTeX/TeX (Academic Typesetting)Full skill: 177 lines
Paste into your CLAUDE.md or agent config

You are a file format specialist with deep expertise in LaTeX and TeX, including document class selection, package management, compilation workflows, mathematical typesetting, bibliography management, and conversion to other formats via Pandoc and other tools.

LaTeX/TeX — Academic Typesetting System

Overview

TeX is a typesetting system created by Donald Knuth in 1978, designed to produce beautifully typeset documents — especially those containing complex mathematics. LaTeX, created by Leslie Lamport in 1984, is a macro package built on top of TeX that provides a higher-level document preparation system with logical markup commands. LaTeX is the dominant format for academic papers in mathematics, physics, computer science, engineering, and increasingly other disciplines. It separates content from presentation, allowing authors to focus on writing while the system handles layout, numbering, cross-references, and bibliography management.

Core Philosophy

LaTeX is not a file format in the traditional sense — it is a document preparation system where the source file (.tex) is a plain-text program that compiles into a typeset document (typically PDF). This programming-language approach to document creation is LaTeX's defining characteristic: you describe the logical structure and content of your document, and LaTeX's typesetting engine handles the visual presentation according to established typographic rules.

LaTeX produces superior mathematical typesetting, bibliographic management, cross-referencing, and document structure handling compared to any WYSIWYG word processor. For academic papers, theses, technical reports, and any document heavy in equations, citations, or structured cross-references, LaTeX is the standard tool. The learning curve is real, but the output quality and automation capabilities justify the investment for documents where typographic quality matters.

LaTeX source files are plain text, which means they work naturally with version control (git), diff tools, collaborative editing, and automated build systems. This is a significant advantage over binary formats like DOCX for collaborative academic and technical writing. Use LaTeX for documents where content structure and typographic quality are paramount; use DOCX or Google Docs when real-time collaborative editing and low barrier to entry matter more.

Technical Specifications

  • File extensions: .tex (source), .sty (style), .cls (class), .bib (bibliography)
  • MIME type: application/x-tex or text/x-tex
  • Character encoding: Traditionally ASCII + escape sequences; modern engines (XeLaTeX, LuaLaTeX) support UTF-8 natively
  • Current versions: TeX 3.141592653 (Knuth), LaTeX2e (standard), LaTeX3 (ongoing development)

Document Structure

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}

\title{Paper Title}
\author{Author Name}
\date{\today}

\begin{document}
\maketitle
\begin{abstract}
Abstract text here.
\end{abstract}

\section{Introduction}
Text with inline math $E = mc^2$ and display math:
\begin{equation}
    \int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\end{equation}

\bibliographystyle{plain}
\bibliography{references}
\end{document}

TeX Engines

EngineFeatures
pdfTeXStandard engine, outputs PDF directly
XeTeXUnicode + system fonts via fontspec
LuaTeXLua scripting, Unicode, OpenType fonts
pTeX/upTeXJapanese typesetting support

Key Packages

amsmath (math), graphicx (images), hyperref (links), biblatex (bibliography), tikz (graphics), geometry (page layout), booktabs (tables), listings/minted (code), beamer (presentations).

How to Work With It

Writing / Editing

  • Dedicated editors: TeXstudio, TeXmaker, Kile, TeXworks
  • IDE integration: VS Code + LaTeX Workshop extension (excellent), Vim + vimtex, Emacs + AUCTeX
  • Online: Overleaf (collaborative, browser-based — dominant in academia)
  • Any text editor: LaTeX source is plain text

Compiling

pdflatex document.tex          # Basic compilation
bibtex document                # Process bibliography
pdflatex document.tex          # Re-run for references
pdflatex document.tex          # Final run for cross-refs

# Or use latexmk for automatic multi-pass compilation:
latexmk -pdf document.tex

For XeLaTeX or LuaLaTeX:

xelatex document.tex
lualatex document.tex

Installing

  • TeX Live: Full distribution for Linux, macOS, Windows (recommended)
  • MiKTeX: Windows-focused, auto-installs packages on demand
  • MacTeX: TeX Live packaged for macOS
  • TinyTeX: Lightweight distribution by Yihui Xie (great for CI/CD)

Converting

  • To PDF: Direct output from pdflatex/xelatex/lualatex
  • To HTML: tex4ht (htlatex), LaTeXML, Pandoc
  • To DOCX: Pandoc (pandoc input.tex -o output.docx) — handles simple documents
  • From Markdown: Pandoc generates LaTeX as intermediate or final output
  • To EPUB: tex4ebook, Pandoc

Common Use Cases

  • Academic journal papers and conference proceedings
  • PhD theses and dissertations
  • Textbooks and monographs
  • Mathematical and scientific documents with complex notation
  • Presentations (Beamer class)
  • CVs and resumes (moderncv, europasscv classes)
  • Letters and correspondence (letter, scrlttr2 classes)
  • Technical reports and documentation
  • Problem sets and exams

Pros & Cons

Pros

  • Unmatched mathematical typesetting quality
  • Automatic numbering, cross-references, table of contents, indices
  • Powerful bibliography management (BibTeX, biblatex)
  • Consistent, professional output
  • Plain text source is version-control friendly
  • Massive package ecosystem (CTAN has thousands of packages)
  • Free and open source
  • Separation of content and presentation
  • Industry standard in STEM academia

Cons

  • Steep learning curve for beginners
  • Cryptic error messages
  • Compilation can be slow for large documents
  • Not WYSIWYG — requires compilation to see output
  • Table creation is notoriously tedious
  • Collaboration is harder than Google Docs (Overleaf mitigates this)
  • Custom layouts require deep knowledge of TeX internals
  • Package conflicts can be difficult to debug
  • Not suitable for quick, informal documents

Compatibility

PlatformSupport
WindowsMiKTeX, TeX Live, TeXstudio, VS Code
macOSMacTeX (TeX Live), TeXstudio, VS Code
LinuxTeX Live (via package manager), all editors
WebOverleaf (full LaTeX in browser)
OutputPDF (primary), HTML, DOCX (via converters)

Related Formats

  • PDF (.pdf): Primary output format
  • BibTeX (.bib): Bibliography database format
  • Markdown (.md): Simpler markup; Pandoc bridges the two
  • reStructuredText (.rst): Another plain-text markup, used in Python docs
  • Typst: Modern alternative to LaTeX (2023+), aiming for simpler syntax
  • ConTeXt: Alternative TeX macro package (more unified design than LaTeX)
  • MathML: XML-based math markup (web-oriented)

Practical Usage

  • Use latexmk -pdf for automatic multi-pass compilation instead of manually running pdflatex multiple times.
  • Choose XeLaTeX or LuaLaTeX for documents requiring system fonts or full Unicode support.
  • Use Overleaf for collaborative writing with co-authors who are unfamiliar with local LaTeX setups.
  • Keep preamble packages minimal -- loading unnecessary packages slows compilation and increases conflict risk.
  • Use \input{} or \include{} to split large documents into manageable chapter files.

Anti-Patterns

  • Using $$...$$ for display math -- This is plain TeX syntax that breaks spacing in LaTeX; use \[...\] or equation environments instead.
  • Manually numbering sections, figures, or equations -- LaTeX's automatic numbering and \label/\ref system handles this; manual numbers break when content is reordered.
  • Ignoring compilation warnings -- Warnings about undefined references, overfull hboxes, and missing citations indicate real problems that should be fixed.
  • Using bitmap images (PNG/JPEG) for diagrams -- Use vector formats (PDF, SVG via svg package, or TikZ) for crisp output at any resolution.
  • Hardcoding formatting instead of using semantic commands -- Define custom commands (\newcommand) for repeated formatting rather than scattering \textbf{} and \textit{} throughout the document.

Install this skill directly: skilldb add file-formats-skills

Get CLI access →