# latex2html5

> Author interactive math equations and diagrams online using LaTeX and PSTricks

Latest version **4.5.2** (published 2026-08-25) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install latex2html5
pnpm add latex2html5
yarn add latex2html5
bun add latex2html5
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.5.2 |
| Published | 2026-08-25 |
| First published | 2018-03-07 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 214.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 625 |
| Author | Dan Lynch <pyramation@gmail.com> |
| Maintainers | pyramation |

## Links

- npm: https://www.npmjs.com/package/latex2html5
- Repository: https://github.com/Mathapedia/LaTeX2JS
- Issues: https://github.com/Mathapedia/LaTeX2JS/issues
- npm.io page: https://npm.io/package/latex2html5

## Dependencies (5)

- [latex2js](https://npm.io/package/latex2js.md) ^4.5.0
- [mathjaxjs](https://npm.io/package/mathjaxjs.md) ^4.2.0
- [@latex2js/utils](https://npm.io/package/@latex2js/utils.md) ^4.2.0
- [@latex2js/macros](https://npm.io/package/@latex2js/macros.md) ^3.2.0
- [@latex2js/pstricks](https://npm.io/package/@latex2js/pstricks.md) ^4.2.0

## Recent versions

- 4.5.2 (latest) — 2026-08-25
- 4.5.1 — 2026-08-25
- 4.5.0 — 2026-08-25
- 4.4.1 — 2026-08-25
- 4.4.0 — 2026-08-24
- 4.0.8 — 2026-08-24
- 4.0.7 — 2026-08-18
- 4.0.3 — 2026-08-17
- 4.0.1 — 2026-08-17
- 3.1.4 — 2025-07-22
- 3.1.3 — 2025-07-06
- 3.1.2 — 2025-07-06
- 2.1.3 — 2020-06-12
- 2.1.2 — 2020-06-12
- 2.1.0 — 2020-06-12
- … 16 more at https://npm.io/package/latex2html5/versions

## README

# latex2html5

Pure HTML5 implementation for LaTeX rendering with automatic discovery and bundled JavaScript distribution. Perfect for vanilla HTML pages and simple integrations.

## Installation

### NPM Package

```bash
npm install latex2html5
```

## Features

- **Zero Dependencies**: Works with pure HTML - no build tools required
- **Automatic Discovery**: Finds and renders LaTeX content automatically
- **Bundled Distribution**: Single JS file includes everything needed
- **Interactive Graphics**: PSTricks support with sliders and animations
- **Mathematical Notation**: Integrated MathJax rendering
- **Multiple Environments**: Support for various LaTeX environments
- **Easy Integration**: Drop-in solution for any website

## Quick Start

```html
<!DOCTYPE html>
<html>
<head>
  <title>LaTeX2JS Example</title>
  <link rel="stylesheet" href="path/to/latex2js.css">
  <script src="path/to/latex2html5.bundle.js"></script>
</head>
<body>
  <h1>Mathematical Document</h1>
  
  <script type="text/latex">
  Here is some great equation:

  $$x = \frac{{-b \pm \sqrt{b^2-4ac}}}{{2a}}$$

  And now for a great diagram:

  \begin{pspicture}(0,-3)(8,3)
  \rput(0,0){$x(t)$}
  \rput(4,1.5){$f(t)$}
  \rput(4,-1.5){$g(t)$}
  \rput(8.2,0){$y(t)$}
  \rput(1.5,-2){$h(t)$}
  \psframe(1,-2.5)(7,2.5)
  \psframe(3,1)(5,2)
  \psframe(3,-1)(5,-2)
  \rput(4,0){$X_k = \frac{1}{p} \sum \limits_{n=\langle p\rangle}x(n)e^{-ik\omega_0n}$}
  \psline{->}(0.5,0)(1.5,0)
  \psline{->}(1.5,1.5)(3,1.5)
  \psline{->}(1.5,-1.5)(3,-1.5)
  \psline{->}(6.5,1.5)(6.5,0.25)
  \psline{->}(6.5,-1.5)(6.5,-0.25)
  \psline{->}(6.75,0)(7.75,0)
  \psline(1.5,-1.5)(1.5,1.5)
  \psline(5,1.5)(6.5,1.5)
  \psline(5,-1.5)(6.5,-1.5)
  \psline(6,-1.5)(6.5,-1.5)
  \pscircle(6.5,0){0.25}
  \psline(6.25,0)(6.75,0)
  \psline(6.5,0.5)(6.5,-0.5)
  \end{pspicture}
  </script>

  <script type="text/latex">
  \begin{nicebox}[title=Theorem]
  For any continuous function $f$ on $[a,b]$:
  $$\int_a^b f(x) dx = F(b) - F(a)$$
  where $F'(x) = f(x)$.
  \end{nicebox}
  </script>

  <script>
    LaTeX2HTML5.init();
  </script>
</body>
</html>
```

### Method 2: `init` and `render` methods

```javascript
import { init, render } from 'latex2html5';

// Auto-discover and render all LaTeX content
init();

// Or render specific content
const content = `
Here is some great equation:

$$x = \frac{{-b \pm \sqrt{b^2-4ac}}}{{2a}}$$

And now for a great diagram:

\begin{pspicture}(0,-3)(8,3)
\rput(0,0){$x(t)$}
\rput(4,1.5){$f(t)$}
\rput(4,-1.5){$g(t)$}
\rput(8.2,0){$y(t)$}
\rput(1.5,-2){$h(t)$}
\psframe(1,-2.5)(7,2.5)
\psframe(3,1)(5,2)
\psframe(3,-1)(5,-2)
\rput(4,0){$X_k = \frac{1}{p} \sum \limits_{n=\langle p\rangle}x(n)e^{-ik\omega_0n}$}
\psline{->}(0.5,0)(1.5,0)
\psline{->}(1.5,1.5)(3,1.5)
\psline{->}(1.5,-1.5)(3,-1.5)
\psline{->}(6.5,1.5)(6.5,0.25)
\psline{->}(6.5,-1.5)(6.5,-0.25)
\psline{->}(6.75,0)(7.75,0)
\psline(1.5,-1.5)(1.5,1.5)
\psline(5,1.5)(6.5,1.5)
\psline(5,-1.5)(6.5,-1.5)
\psline(6,-1.5)(6.5,-1.5)
\pscircle(6.5,0){0.25}
\psline(6.25,0)(6.75,0)
\psline(6.5,0.5)(6.5,-0.5)
\end{pspicture}
`;

render(content, document.getElementById('target'));
```

## Usage Examples

### Automatic Content Discovery

```html
<!-- LaTeX content is automatically discovered and rendered -->
<script type="text/latex">
Here is some great equation:

$$x = \frac{{-b \pm \sqrt{b^2-4ac}}}{{2a}}$$

And now for a great diagram:

\begin{pspicture}(0,-3)(8,3)
\rput(0,0){$x(t)$}
\rput(4,1.5){$f(t)$}
\rput(4,-1.5){$g(t)$}
\rput(8.2,0){$y(t)$}
\rput(1.5,-2){$h(t)$}
\psframe(1,-2.5)(7,2.5)
\psframe(3,1)(5,2)
\psframe(3,-1)(5,-2)
\rput(4,0){$X_k = \frac{1}{p} \sum \limits_{n=\langle p\rangle}x(n)e^{-ik\omega_0n}$}
\psline{->}(0.5,0)(1.5,0)
\psline{->}(1.5,1.5)(3,1.5)
\psline{->}(1.5,-1.5)(3,-1.5)
\psline{->}(6.5,1.5)(6.5,0.25)
\psline{->}(6.5,-1.5)(6.5,-0.25)
\psline{->}(6.75,0)(7.75,0)
\psline(1.5,-1.5)(1.5,1.5)
\psline(5,1.5)(6.5,1.5)
\psline(5,-1.5)(6.5,-1.5)
\psline(6,-1.5)(6.5,-1.5)
\pscircle(6.5,0){0.25}
\psline(6.25,0)(6.75,0)
\psline(6.5,0.5)(6.5,-0.5)
\end{pspicture}
</script>

<script>
  LaTeX2HTML5.init(); // Renders all LaTeX content
</script>
```

---
_Source: https://npm.io/package/latex2html5 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
