Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MathJax source code for version 3 and beyond

License

NotificationsYou must be signed in to change notification settings

mathjax/MathJax-src

Repository files navigation

GitHub release versionGitHub release version (v3)GitHub release version (v2)NPM versionjsdelivr rankjsDelivr hits (npm)npm monthly downloads (full)npm monthly downloads (full)npm total downloadsnpm total downloadstest workflowcodecov

Beautiful math in all browsers

MathJax is an open-source JavaScript display engine for LaTeX, MathML,and AsciiMath notation that works in all modern browsers, withbuilt-in support for assistive technology like screen readers,including automatic speech generation and an expression explorer thatcan be used to investigate typeset mathematics on a more granularlevel than the complete expression. It requires no setup on the partof the user (no plugins to download or software to install), so thepage author can write web documents that include mathematics and beconfident that users will be able to view it naturally and easily.Simply include MathJax and some mathematics in a web page, and MathJaxdoes the rest.

Some of the main features of MathJax include:

  • High-quality display of LaTeX, MathML, and AsciiMath notation in HTML pages

  • Supported in most browsers with no plug-ins, extra fonts, or specialsetup for the reader

  • Easy for authors, flexible for publishers, extensible for developers

  • Supports math accessibility, cut-and-paste interoperability, and otheradvanced functionality

  • Powerful API for integration with other web applications

Seehttp://www.mathjax.org/ for additional details about MathJax,andhttps://docs.mathjax.org for the MathJax documentation.

What's in this Repository

This repository contains the source files for MathJax, which arewritten in TypeScript. These are compiled into JavaScript files andthen combined into component files for use on the web. The componentfiles are available from severalCDN services that hostMathJax,and also from theMathJax ComponentRepository. Node applicationscan use either the component files, or call the MathJax JavaScriptfiles directly.

Installation and Use

Using MathJax in web browsers

If you are loading MathJax from a CDN into a web page, there is noneed to install anything. Simply use ascript tag that loadsMathJax from the CDN. E.g.,

<scriptsrc="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js"defer></script>

See theMathJaxdocumentationand theMathJax Web Demos, and theMathJaxNode Demos for moreinformation.

Using MathJax Components in node applications

To use MathJax components in a node application, install themathjaxpackage:

npm install mathjax@4

Then importmathjax within your application and initialize it:

importMathJaxfrom'mathjax';awaitMathJax.init({ ...});

where{ ... } is the MathJax configuration you want to use. E.g.,

importMathJaxfrom'mathjax';awaitMathJax.init({loader:{load:['input/tex','output/svg']}});constsvg=awaitMathJax.tex2svgPromise('\\frac{1}{x^2-1}',{display:true});console.log(MathJax.startup.adaptor.outerHTML(svg));

Alternatively, in an ES5 node application, you can use

constMathJax=require('mathjax');MathJax.init({ ...}).then(()=>{ ...});

where the first{ ... } is a MathJax configuration, and the second{ ... } is the code to run after MathJax has been loaded. E.g.

constMathJax=require('mathjax');MathJax.init({loader:{load:['input/tex','output/svg']}}).then(()=>{constsvg=MathJax.tex2svg('\\frac{1}{x^2-1}',{display:true});console.log(MathJax.startup.adaptor.outerHTML(svg));}).catch((err)=>console.log(err.message));

Note: the technique in the two examples above is for node-basedapplication only, not for browser applications. This method sets upan alternative DOM implementation, which you don't need in thebrowser, and it depends on node and the local file system in otherways. This setup will not work properly in the browser, even if youwebpack it or use some other bundler.

See thedocumentationand theMathJax NodeRepository for more details.

Using MathJax modules directly in node applications

You can use the MathJax JavaScript files (as opposed to MathJaxcomponents) directly in node applications. This gives you thegreatest flexibility, but requires more coding. To use this approach,install the@mathjax/src package:

npm install @mathjax/src

This will provide the following directories:

node_modules/  @mathjax/src/    ts/                  the MathJax source TypeScript files    js/                  the compiled JavaScript files    components/          the component build tools and control files    bundle/              the packages component files

You can use the components and JavaScript files directly in your nodeapplications (see theMathJax nodedemos for examples).

If you want to work from the GitHub repository directly, then do thefollowing:

git clone https://github.com/mathjax/MathJax-src.git mathjax-srccd mathjax-srcnpm run --silent build-all

in order to compile the JavaScript files from the TypeScript source,and build the component files from the JavaScript files.

Code Contributions

If you are interested in contributing code to MathJax, please see thedocumentation for contributors for details on howto do this, and for the policies for making pull requests. Inparticular, please be careful that you are working from the properbranch in the git repository, or you may be asked to rebase yourchanges when you make a pull request.

MathJax Community

The main MathJax website ishttp://www.mathjax.org, and it includesannouncements and other important information. AMathJax userforum for askingquestions and getting assistance is hosted at Google, and theMathJaxbug tracker is hostedat GitHub.

Before reporting a bug, please check that it has not already beenreported. Also, please use the bug tracker (rather than the helpforum) for reporting bugs, and use the user's forum (rather than thebug tracker) for questions about how to use MathJax.

MathJax Resources


[8]ページ先頭

©2009-2025 Movatter.jp