npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@react-pdf/math

v1.0.2

Published

Render LaTeX math expressions in react-pdf documents

Readme

@react-pdf/math

Render LaTeX math expressions in react-pdf documents.

Uses MathJax to convert LaTeX into SVG paths, then maps them to react-pdf's built-in SVG primitives. No fonts or external assets needed — all glyphs are rendered as vector paths directly in the PDF.

Installation

npm install @react-pdf/math
# or
yarn add @react-pdf/math

Peer dependencies:

npm install @react-pdf/renderer react

Usage

import React from 'react';
import { Document, Page } from '@react-pdf/renderer';
import { Math } from '@react-pdf/math';

const MyDocument = () => (
  <Document>
    <Page size="A4" style={{ padding: 40 }}>
      <Math>{"x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}"}</Math>
    </Page>
  </Document>
);

API

<Math>

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | string | — | LaTeX math expression to render | | inline | boolean | false | Inline mode (compact) vs display mode (centered, larger) | | width | number \| string | — | Width of the SVG element | | height | number \| string | — | Height of the SVG element | | color | string | "black" | Color for the math expression | | debug | boolean | false | Adds a visible border around the SVG element for debugging layout |

Display vs Inline mode

Display mode (default) renders the expression as a block, centered with larger operators — ideal for standalone equations:

<Math>{"\\int_0^\\infty e^{-x^2} dx = \\sqrt{\\pi}"}</Math>

Inline mode (inline) renders compact expressions suitable for embedding within text:

<View style={{ flexDirection: 'row', alignItems: 'center' }}>
  <Text>The equation </Text>
  <Math inline>{"E = mc^2"}</Math>
  <Text> is famous.</Text>
</View>

Examples

Fractions and roots

<Math>{"\\frac{\\sqrt{3}}{2}"}</Math>

Summations and integrals

<Math>{"\\sum_{n=1}^{\\infty} \\frac{1}{n^2} = \\frac{\\pi^2}{6}"}</Math>
<Math>{"\\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}"}</Math>

Matrices

<Math>{"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}"}</Math>

Greek letters and operators

<Math>{"\\nabla \\times \\vec{E} = -\\frac{\\partial \\vec{B}}{\\partial t}"}</Math>

Limits

<Math>{"\\lim_{x \\to 0} \\frac{\\sin x}{x} = 1"}</Math>

How it works

  1. LaTeX → SVG: MathJax converts the LaTeX expression into SVG markup with fontCache: 'none', ensuring all glyphs are inlined as <path> elements (no <use>/<defs> references).
  2. SVG → react-pdf: A lightweight parser converts the SVG string into a tree, then recursively maps each SVG element (path, rect, g, etc.) to the corresponding react-pdf SVG component.

Supported LaTeX features

All standard LaTeX math features supported by MathJax are available, including:

  • Arithmetic operators, fractions, roots
  • Greek and Hebrew letters
  • Summations, products, integrals
  • Limits
  • Matrices and arrays
  • Binomial coefficients
  • Trigonometric functions
  • Accents and decorations
  • Spacing commands

License

MIT