Latex KaTex MathJax

LaTeX, KaTeX, and MathJax solve different parts of the same problem: representing and rendering mathematical notation with precision.

What is Latex?

LaTeX (pronounced “lah-tech” or “lay-tech”) is a document preparation system used for typesetting high-quality documents, especially those with complex mathematical notation.

Key points:

  • Not a word processor — you write plain text with markup commands, then compile it to PDF
  • Built on TeX, a typesetting engine created by Donald Knuth in the 1970s
  • LaTeX itself was created by Leslie Lamport in the 1980s as a higher-level layer on top of TeX

What it’s used for:

  • Academic papers, theses, and dissertations
  • Mathematical and scientific documents
  • Books and technical reports
  • Presentations (via Beamer)

How it works:

\documentclass{article}
\begin{document}

Hello, world! Here is an equation:
$$E = mc^2$$

\end{document}

Examples

You write .tex files like this, then compile them (e.g., with pdflatex) to produce a PDF.

Why people use it:

  • Superior math typesetting (industry standard in academia)
  • Consistent, professional formatting
  • Automatic numbering of sections, figures, references
  • BibTeX integration for bibliography management

LaTeX → PostScript → PDF

LaTeX is a document preparation system (a markup language + typesetting engine). It doesn’t directly produce output — it describes what a document should look like. The toolchain works like this:

Traditional pipeline

.tex  →  latex  →  .dvi  →  dvips  →  .ps  →  ps2pdf  →  .pdf
  • .dvi (Device Independent) is an intermediate binary format
  • dvips converts DVI to PostScript
  • ps2pdf (part of Ghostscript) converts PostScript to PDF

Modern pipeline (most common today)

.tex  →  pdflatex / xelatex / lualatex  →  .pdf

Modern engines skip the intermediate steps and produce PDF directly.


What is PostScript?

PostScript (by Adobe, 1984) is a Turing-complete page description language. It describes pages as programs that a printer or renderer executes. LaTeX historically targeted PostScript because it was the dominant format for professional printing.

What is PDF?

PDF (Portable Document Format, also by Adobe, 1993) was derived from PostScript but:

  • Is not a programming language — it’s a static, structured document format
  • Has a cross-reference table for random access (PostScript is sequential)
  • Supports interactive features (hyperlinks, forms, annotations)
  • Is more efficient to render and display on screen

Summary

LaTeX PostScript PDF
Type Markup + typesetting Page description language Document format
Executable? Yes (TeX engine) Yes (interpreter) No (static)
Primary use Authoring Printing Distribution/display
Relationship Compiles to → Ancestor of PDF Target output

LaTeX treats PostScript and PDF as output targets, not as part of its own language. The connection is purely through the compilation toolchain.

What is KaTex?

KaTeX is a fast, lightweight JavaScript library for rendering mathematical notation on the web.

Key points:

  • Developed by Khan Academy
  • Renders LaTeX math syntax to HTML/CSS (no canvas or SVG required)
  • Much faster than alternatives like MathJax
  • Works client-side and server-side (Node.js)
  • Self-contained — no external dependencies at render time

Example usage:

katex.render("c = \\pm\\sqrt{a^2 + b^2}", element);

Common use cases:

  • Displaying math equations in documentation, blogs, or educational platforms
  • Inline math: $E = mc^2$
  • Block/display math: $$\int_0^\infty e^{-x^2} dx$$

It supports a large subset of LaTeX math commands but not all of them — full LaTeX document rendering is outside its scope.

What is MathJax?

MathJax is a JavaScript library that renders mathematical notation in web browsers.

Key points:

  • Displays LaTeX, MathML, and AsciiMath in HTML pages
  • Works without plugins — runs entirely in the browser
  • Produces high-quality, accessible math output (SVG or HTML+CSS)
  • Widely used in academic/educational sites, documentation, and forums (e.g., Wikipedia, Stack Exchange)

Example usage:

<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

<p>The quadratic formula: \( x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \)</p>

The \( ... \) delimiters mark inline math, and \[ ... \] marks display (block) math. MathJax processes these at page load and replaces them with rendered equations.

my DevOps Odyssey

“Σα βγεις στον πηγαιμό για την Ιθάκη, να εύχεσαι να ‘ναι μακρύς ο δρόμος, γεμάτος περιπέτειες, γεμάτος γνώσεις.” - Kavafis’ Ithaka.