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

@latex2js/macros

v3.0.10

Published

latex2js macros

Readme

@latex2js/macros

A comprehensive collection of LaTeX macro definitions for mathematical notation, providing shortcuts and enhancements for mathematical typesetting in LaTeX2JS.

Installation

npm install @latex2js/macros

Features

  • Transform Pairs: Fourier, Z-transform, and Laplace transform notation
  • Mathematical Symbols: Extended collection of mathematical operators and symbols
  • Set Theory: Comprehensive set theory notation and operators
  • Category Theory: Morphisms, functors, and categorical constructs
  • Theorem Environments: Shortcuts for theorem, lemma, proposition, and proof environments
  • Typography: Enhanced spacing and formatting for mathematical expressions

Usage

Basic Import

import macros from '@latex2js/macros';

// The macros are provided as a template string
console.log(typeof macros); // 'string'

Integration with LaTeX2JS

import { LaTeX2HTML5 } from 'latex2js';
import macros from '@latex2js/macros';

// Initialize with macros
const parser = new LaTeX2HTML5();
parser.addMacros(macros);

Integration with MathJax

import macros from '@latex2js/macros';

// Configure MathJax with the macros
window.MathJax = {
  tex: {
    macros: macros
  }
};

Available Macros

Transform Pairs

Perfect for signal processing and mathematical analysis:

% Fourier Transform
$$\mathscr{F}\{f(t)\} = F(\omega)$$
$$f(t) \FTpair F(\omega)$$

% Z-Transform  
$$\mathscr{Z}\{x[n]\} = X(z)$$
$$x[n] \ZTpair X(z)$$

% Laplace Transform
$$\mathscr{L}\{f(t)\} = F(s)$$
$$f(t) \LTpair F(s)$$

Mathematical Operators

Extended mathematical notation:

% Enhanced operators
$$\E[X]$$           % Expectation
$$\Var(X)$$         % Variance
$$\Cov(X,Y)$$       % Covariance
$$\argmax_x f(x)$$  % Argument maximum
$$\argmin_x f(x)$$  % Argument minimum

Set Theory

Comprehensive set operations:

% Set operations
$$A \intersection B$$   % Intersection
$$A \union B$$         % Union
$$A \setminus B$$      % Set difference
$$\powerset{A}$$       % Power set
$$A \symdiff B$$       % Symmetric difference

Category Theory

Advanced categorical constructs:

% Category theory
$$\Hom(A, B)$$         % Hom-set
$$A \iso B$$           % Isomorphism
$$f \colon A \to B$$   % Morphism notation
$$\End(A)$$            % Endomorphisms
$$\Aut(A)$$            % Automorphisms

Theorem Environments

Shortcuts for mathematical writing:

\begin{thm}[Fundamental Theorem]
Every continuous function on a closed interval is uniformly continuous.
\end{thm}

\begin{lem}
This is a supporting lemma.
\end{lem}

\begin{prop}
This is a proposition.
\end{prop}

\begin{proof}
The proof follows from the definition.
\end{proof}

Typography Enhancements

Improved spacing and formatting:

% Enhanced spacing
$$a \,+\, b$$          % Thin spaces around operators
$$\int_a^b f(x) \dd x$$ % Proper differential notation
$$\vec{v} \cdot \vec{u}$$ % Vector notation

Complete Macro List

The package includes over 140 macro definitions covering:

  • Analysis: Real and complex analysis notation
  • Algebra: Group theory, ring theory, field theory
  • Topology: Topological spaces and continuous maps
  • Probability: Probability theory and statistics
  • Logic: Logical operators and quantifiers
  • Geometry: Geometric constructions and notation
  • Computer Science: Algorithms and complexity theory

Integration Examples

With React Components

import { LaTeX } from 'latex2react';
import macros from '@latex2js/macros';

function MathDocument() {
  const content = `
    \\begin{thm}[Fourier Transform]
    For any function $f \\in L^1(\\mathbb{R})$:
    $$f(t) \\FTpair F(\\omega) = \\int_{-\\infty}^{\\infty} f(t) e^{-i\\omega t} \\dd t$$
    \\end{thm}
  `;
  
  return <LaTeX content={content} macros={macros} />;
}

With Vue Components

<template>
  <latex :content="mathContent" :macros="macros" />
</template>

<script>
import macros from '@latex2js/macros';

export default {
  data() {
    return {
      macros,
      mathContent: `
        $$\\E[X] = \\int_{-\\infty}^{\\infty} x f_X(x) \\dd x$$
      `
    };
  }
};
</script>

With HTML5 Integration

<!DOCTYPE html>
<html>
<head>
  <script src="path/to/latex2html5.bundle.js"></script>
</head>
<body>
  <script type="text/latex">
    \begin{thm}
    The Pythagorean theorem: $a^2 + b^2 = c^2$
    \end{thm}
  </script>
  
  <script>
    // Macros are automatically included in the HTML5 bundle
    LaTeX2HTML5.init();
  </script>
</body>
</html>