GithubHelp home page GithubHelp logo

bhanditz / gitbook-plugin-mathjax-commonhtml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lwchkg/gitbook-plugin-mathjax-commonhtml

0.0 2.0 0.0 19 KB

MathJax integration into GitBook using MathJax's CommonHTML output processor, which is processed in the server side.

License: GNU General Public License v3.0

JavaScript 100.00%

gitbook-plugin-mathjax-commonhtml's Introduction

MathJax CommonHTML server-side rendering for GitBook

This plugin uses MathJax in the server side using CommonHTML output.

Installation

Add the plugin into book.json or book.js, e.g.

{
    plugins: ["mathjax-commonhtml"]
}

Configuration

This plugin scales the TeX font in MathJax automatically in the default set up. If you do not modify GitBook font settings (not something that a beginner can do), then you do not need to configure this plugin.

However, if you are using custom fonts in your book, or disables the fontsettings plugin, then default setting will not work.

In this case, you can disable automatic scaling by adding the following to book.json or book.js.

{
    "pluginsConfig": {
        "mathjax-commonhtml": {
            "defaultScaling": false
        }
    }
}

You can manually scale MathJax TeX fonts by adding the following CSS:

body .mjx-chtml, .page .section .mjx-chtml { font-size: 116%; }

body .mjx-chtml is used for web site, and .page .section .mjx-chtml is used for ebook.

You should set the font size to match the x-height of your current font. To know the percentage you need, check this CodePen

Usage

The usage of this plugin is the same as the official MathJax and KaTeX plugins.

The following are the instructions copied from KaTeX plugin:

Inline math: $$\int_{-\infty}^\infty g(x) dx$$


Block math:

$$
\int_{-\infty}^\infty g(x) dx
$$

Or using the templating syntax:

{% math %}\int_{-\infty}^\infty g(x) dx{% endblock %}

Why use this plugin instead of the official plugins?

This plugin has the TeX support of MathJax and the speed of KaTeX.

Comparing with MathJax: mathjax-commonhtml generates the math server-side, while the official MathJax plugin generates the math client-side. It means that the web pages load much faster with this plugin.

Comparing with KaTeX: KaTeX supports only a limited set of TeX syntax, and spacing of equation environments are suboptimal. This plugin, which is based on MathJax, does not have this limitation.

Known problems

Currently gitbook PDF and ebook generation does not work. The problem appears to be Calibre (the ebook generator) intercepting MathJax generated tags. If you are interested in creating PDF files for printing, I recommend my sister project “gitbook-pdfgen” though, which works nice with this plugin.

Report bugs / Contributions

gitbook-plugin-mathjax-commonhtml's People

Contributors

lwchkg avatar chicubed avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.