Skip to main content
Home

Built and signed on GitHub Actions

Adds support for TeX (math) syntax to Eleventy projects

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
9 months ago (0.1.2)

eleventy-tex

This plugin provides build-time rendering of LaTeX files. It introduces a transform to scan for and replace any TeX syntax after your files have been built, with the exception of Markdown files; for Markdown, the transform happens before the file is transformed to HTML. This is because things such as $a_1 + a_2$ would first be transformed to $a<em>1 + a</em>2$, which obviously would break the MathML output. You may turn off the TeX processing on a per-page basis by setting ignoreTeX: true in its front matter.

Installation

To install, run any of the following commands:

# For npm:
npx jsr add @vrugtehagel/eleventy-tex
# For yarn:
yarn dlx jsr add @vrugtehagel/eleventy-tex
# For pnpm:
pnpm dlx jsr add @vrugtehagel/eleventy-tex
# For deno:
deno add @vrugtehagel/eleventy-tex

Config

Add the plugin like usual in your Eleventy configuration file (usually .eleventy.js), optionally with an options argument:

import EleventyTeX from "@vrugtehagel/eleventy-tex";

export default function (eleventyConfig) {
  // …
  eleventyConfig.addPlugin(EleventyTeX, {
    extension: "tex",
  });
  // …
}

There are a handful of options available:

  • delimiters: An array of delimiters. By default, there are two inline delimiters, \(…\) and $…$, and two so-called "display" modes, \[…\] and $$…$$. It is possible to overwrite them, or import defaultDelimiters and use [...defaultDelimiters, …] to add them without removing the defaults.
  • katexOptions: These options are passed as-is to KaTeX, which is the package used to render the math. See the KaTeX docs for more information, or check the types defined by this package. Note that these options may be overwritten by individual delimiters.
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@vrugtehagel/eleventy-tex

Import symbol

import * as eleventy_tex from "@vrugtehagel/eleventy-tex";
or

Import directly with a jsr specifier

import * as eleventy_tex from "jsr:@vrugtehagel/eleventy-tex";

Add Package

pnpm i jsr:@vrugtehagel/eleventy-tex
or (using pnpm 10.8 or older)
pnpm dlx jsr add @vrugtehagel/eleventy-tex

Import symbol

import * as eleventy_tex from "@vrugtehagel/eleventy-tex";

Add Package

yarn add jsr:@vrugtehagel/eleventy-tex
or (using Yarn 4.8 or older)
yarn dlx jsr add @vrugtehagel/eleventy-tex

Import symbol

import * as eleventy_tex from "@vrugtehagel/eleventy-tex";

Add Package

npx jsr add @vrugtehagel/eleventy-tex

Import symbol

import * as eleventy_tex from "@vrugtehagel/eleventy-tex";

Add Package

bunx jsr add @vrugtehagel/eleventy-tex

Import symbol

import * as eleventy_tex from "@vrugtehagel/eleventy-tex";