GithubHelp home page GithubHelp logo

plugin-mathjax's Introduction

Math integration with GitBook

This plugin uses MathJax to display Math/TeX formula. This is an official plugin. Versions >=0.1.0 require GitBook >=2.0.0.

How to use it?

Add it to your book.json configuration:

{
    "plugins": ["mathjax"]
}

Install your plugins using:

$ gitbook install ./

You can now add TeX formula to your book using the {% math %} block:

When {% math %}a \ne 0{% endmath %}, there are two solutions to {% math %}(ax^2 + bx + c = 0){% endmath %} and they are {% math %}x = {-b \pm \sqrt{b^2-4ac} \over 2a}.{% endmath %}

You can also use the shortcut $$:

When $$a \ne 0$$, there are two solutions to $$(ax^2 + bx + c = 0)$$ and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

Configuration

You can force the use of svg pre-processed by adding to your book.json:

{
    "pluginsConfig": {
        "mathjax":{
            "forceSVG": true
        }
    }
}

plugin-mathjax's People

Contributors

jpreynat avatar samypesse avatar szarnyasg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin-mathjax's Issues

Book building fails due to unresolved merge markers in index.js

$ gitbook build
info: 8 plugins are installed 
info: 7 explicitly listed 
info: loading plugin "mathjax"... ERROR

PluginError: Error with plugin "mathjax": Unexpected token <<

The error is due to the unresolved merge markers in https://github.com/GitbookIO/plugin-mathjax/blob/master/index.js

<<<<<<< HEAD
var Promise = require('q');
var crc     = require('crc');
var mjAPI   = require('mathjax-node/lib/mj-single.js');

var started   = false;
=======
var Q = require('q');
var fs = require('fs');
var path = require('path');
var crc = require('crc');
var exec = require('child_process').exec;
var mjAPI = require('mathjax-node/lib/mj-single.js');

var started = false;
>>>>>>> master

Prod Limit Issue

The first code renders fine, but when I try to change _j to _{j=1}, it fails.

Code:

j as second lower limit

$$\begin{aligned} \Pr(D \mid \textbf{W,S}) & = {\prod\limits_{i=1}^{I} \Pr(S_j \mid D) \Pr(D) ; \prod\limits_j^J \Pr(S_j \mid D) \Pr(D) \over \Pr(\textbf{W,S})} \end{aligned}$$

j=1 as second lower limit

$$\begin{aligned} \Pr(D \mid \textbf{W,S}) & = {\prod\limits_{i=1}^{I} \Pr(S_j \mid D) \Pr(D) ; \prod\limits_{j=1}^J \Pr(S_j \mid D) \Pr(D) \over \Pr(\textbf{W,S})} \end{aligned}$$

Screenshot of Rendering:
http://cl.ly/image/151H1x180c2d

Using the plugin

I'd like to give this plugin a try but I can't figure how to use it once installed. Is it ready for use? Thanks for your work on this.

My ebook doesnt compile when page has MathJax.

It looks like when I added mathjax code to my pages, ebooks pdf mobi epub doesnt compile anymore. Website is ok. Is there any known issues with this case? I can provide more info if needed.

mathjax-node v1 compatibility

Just a heads up. The first beta of mathjax-node v1 is out, including several breaking changes. From a quick look, you mainly need to simplify the require call.

If you want to keep speech-rule-engine support, then you'll need more changes (since we dropped SRE integration in favor of separate modules).

Plugin crashes watcher

Hi,

After I installed this plugin and run it through gitbook serve after a few seconds I get this error:

Error: watch personal-docs/node_modules/mathjax/jax/output/SVG/fonts/STIX-Web/Variants ENOSPC

Any Ideas?

howto show math expression in single line

When I used mathjax in gitbook, all math expression were show on one line with other text. When the math is a \frac or something like, it will be "compact" height like the text around.
How could I show the math expression in a single line so it can be shown in full height?

Error converting .svg into .png

I used mathjax to produce the latex formula,
and I use gitbook serve to produce webpages with correct formulas
however, when I use gitbook pdf to produce a pdf file,
I got

error: error while generating page "chapter1/14-shu-zhi-fang-zhen-shi-li-ff1a-xin-guan-fei-yan-yu-ce.md":

Error: Error converting C:\Users\Administrator\AppData\Local\Temp\tmp-47768poGb4f1fkPK_mathjax_46d8639.svg into C:\Users\Administrator\AppData\Local\Temp\tmp-47768poGb4f1fkPK\c6231af5.png

I check the markdown file, I find only one latex code there,

$$ \begin{array}{c} S[T+1]-S[T]=-r \beta I S / N \\ E[T+1]-E[T]=r \beta I S / N-\alpha E \\ I[T+1]-I[T]=\alpha E-\gamma I \\ R[T+1]-R[T]=\gamma I \end{array} $$

Gitbook fails to build after version 1.1.1

Hey,
Gitbook builds properly with mathjax version 1.1.0
But with mathjax version 1.1.1, I am getting a error
"PluginError: Error with plugin "mathjax": Cannot find module 'MathJax-node/lib/mj-single.js' "

upgrade to 2.6

Hi,

There is a bug in the <2.6 mathjax versions, where there's a trailing | rendered in Chrome at the end of the formulas.
An upgrade to 2.6 would eliminate the issue (and the need to hide it with CSS rules).

Thanks,
Imre

Bug latex math delimiter \[ \] auto escape

Hi,

it seems that latex delimiters \( \) and \[ \] does not work anymore with the last version of the plugin

edit:
At it seems are not escaped anymore \( or \[. Writing \\( \\) and \\[ \\] seems to work.
Could these delimiters be escaped automatically ? (then It would not break asciidoctor latexmath stem compat)

Maths Plugin Improvement Suggestion

Right now, I think Mathematics is displayed like this:

What's happening now

(correct me if I'm wrong...)

  • Only TeX notation is currently supported. (There are other input formats)
  • Only dollar signs are recognised as maths delimiters.
  • Maths is stored as a <script> tag in the HTML file, (which is good, better than leaving it raw, solving issues such as #3, but maybe MathML is better for accessibility and other reasons).
  • TeX notation is stored within the script element.
  • MathJax is required to display the maths.
  • Not all EPUB readers support MathJax, and so some EPUB readers, and engines that don't run JS can't display the mathematics. E.g. GitbookIO/gitbook#295

Suggestion: Would it be great if it was like this?

Suggestion?

  • ASCIIMath, TeX syntax, and MathML are all recognised and parsed (authors can choose which one to use through the plugin options).
  • Various delimiters for mathematics are recognised and supported (chosen by the author through plugin options, maybe author uses a lot of dollar signs? perhaps.)
  • MathML and SVG are generated. Since MathJax is not lightning fast, SVG is shown until all mathematics are typeset completely.
    SVG is also used as a backup for software that don't support MathML nor MathJax. SVG can be disabled through the option.
    Perhaps something like MathJax-Node could help us with generating MathML and SVG?
  • Authors can define custom macros for MathJax through the plugin options. This would make our lives a lot easier and make our markdown source look more beautiful (and readable).
  • Original notation source is preserved in MathML annotation.
  • MathJax is served with the webpage, so that mathematics is rendered consistently. (Authors can also choose the maths font settings and other useful settings as well)

Summary

What do you guys, @SamyPesse and @AaronO, think?


Plugin options that are possibly great to have:

  • choose input notation
  • choose maths delimiters
  • enable/disable SVG being generated
  • custom macros and all those kind of good stuff that are in MathJax configurations.

Update MathJax version

This plugin loads MathJax 2.0 which is over 2.5 years old. The latest version is 2.4 and the point releases are very stable.

[BLOCKING] Mathjax failed to load in Gitbook v2.6.7

This error occured from 2016/12/8 and it has been ONE MONTH. My development team depends on my requirement specification book to work. And this issue affects our work a lot.

Can you help solve it ASAP? Thanks.

Here is the error msg:

Building Site, will upload
info: loading book configuration....OK 
info: load plugin gitbook-plugin-mathjax ....ERROR
info: load plugin gitbook-plugin-mermaid ....OK 
……
Error: Error loading plugins: gitbook-plugin-mathjax. Run 'gitbook install' to install plugins from NPM.

Here is the full message:

Downloading source
Extracting source
GitBook version is 2.6.7 
Tweaking book.json
Installing plugins
info: 4 plugins to install 
info: No version specified, resolve plugin mathjax 
info: install plugin mathjax from npm (gitbook-plugin-mathjax) with version 1.0.2 
make: Entering directory `/tmp/book/node_modules/gitbook-plugin-mathjax/node_modules/MathJax-node/node_modules/jsdom/node_modules/contextify/build'
  CXX(target) Release/obj.target/contextify/src/contextify.o
  SOLINK_MODULE(target) Release/obj.target/contextify.node
  SOLINK_MODULE(target) Release/obj.target/contextify.node: Finished
  COPY Release/contextify.node
make: Leaving directory `/tmp/book/node_modules/gitbook-plugin-mathjax/node_modules/MathJax-node/node_modules/jsdom/node_modules/contextify/build'
[email protected] node_modules/gitbook-plugin-mathjax
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
info: >> plugin mathjax installed with success 
info: No version specified, resolve plugin mermaid 
info: install plugin mermaid from npm (gitbook-plugin-mermaid) with version 0.0.9 
make: Entering directory `/tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/build'
  CXX(target) Release/obj.target/weakref/src/weakref.o
  SOLINK_MODULE(target) Release/obj.target/weakref.node
  SOLINK_MODULE(target) Release/obj.target/weakref.node: Finished
  COPY Release/weakref.node
make: Leaving directory `/tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantom/node_modules/dnode/node_modules/weak/build'
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v1.9.19/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantomjs/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...

Received 12854K total.
Extracting tar contents (via spawned process)
Removing /tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantomjs/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1483354316604/phantomjs-1.9.8-linux-x86_64 -> /tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /tmp/book/node_modules/gitbook-plugin-mermaid/node_modules/phantomjs/lib/phantom/bin/phantomjs
[email protected] node_modules/gitbook-plugin-mermaid
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
info: >> plugin mermaid installed with success 
info: No version specified, resolve plugin comment 
info: install plugin comment from npm (gitbook-plugin-comment) with version 0.2.1 
[email protected] node_modules/gitbook-plugin-comment
info: >> plugin comment installed with success 
info: No version specified, resolve plugin autocover 
info: install plugin autocover from npm (gitbook-plugin-autocover) with version 1.2.1 
info: >> plugin autocover installed with success 

Done, without error
Building Site, will upload
info: loading book configuration....OK 
info: load plugin gitbook-plugin-mathjax ....ERROR
info: load plugin gitbook-plugin-mermaid ....OK 
info: load plugin gitbook-plugin-comment ....OK 
info: load plugin gitbook-plugin-autocover ....OK 
info: load plugin gitbook-plugin-highlight ....OK 
info: load plugin gitbook-plugin-search ....OK 
info: load plugin gitbook-plugin-sharing ....OK 
info: load plugin gitbook-plugin-fontsettings ....OK 

Error: Error loading plugins: gitbook-plugin-mathjax. Run 'gitbook install' to install plugins from NPM.

Troubles with Mac Os

I do not success on installing this plugin on my mac.
My book compile well on gitbook and on an ubuntu.
I have followed this tuto, with nmp installed thanks to brew.

vhuber@host% gitbook install
info: 8 plugins to install
info: No version specified, resolve plugin anchors
info: install plugin anchors from npm (gitbook-plugin-anchors) with version 0.4.0
[email protected] node_modules/gitbook-plugin-anchors
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
info: >> plugin anchors installed with success
info: No version specified, resolve plugin include-highlight
info: install plugin include-highlight from npm (gitbook-plugin-include-highlight) with version 0.1.0
[email protected] node_modules/gitbook-plugin-include-highlight
├── [email protected]
├── [email protected]
└── [email protected]
info: >> plugin include-highlight installed with success
info: No version specified, resolve plugin mathjax
info: install plugin mathjax from npm (gitbook-plugin-mathjax) with version 1.0.0
child_process.js:1162
    throw errnoException(err, 'spawn');
          ^
Error: spawn E2BIG
    at exports._errnoException (util.js:746:11)
    at ChildProcess.spawn (child_process.js:1162:11)
    at exports.spawn (child_process.js:995:9)
    at spawn (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/lib/utils/spawn.js:7:13)
    at runCmd_ (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/lib/utils/lifecycle.js:207:14)
    at runCmd (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/lib/utils/lifecycle.js:172:5)
    at runPackageLifecycle (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/lib/utils/lifecycle.js:134:3)
    at Array.<anonymous> (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
    at LOOP (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
    at chain (/Users/vhuber/.gitbook/versions/2.2.0/node_modules/npm/node_modules/slide/lib/chain.js:20:5)

and my book.json

{
    "gitbook": "2.2.0",
    "plugins": ["anchors","include-highlight","mathjax","ga","richquotes","toc","expandable-chapters","unicodecss"],
    "pluginsConfig": {
        "ga": {
            "token": "UA-65761593-1"
        },
        "richquotes" : {
            "todos" : true,
            "fixme" : true
        }
    },
    "links": {
        "sidebar": {
            "Feel++": "http://www.feelpp.org/",
            "GitHub": "http://www.github.com/feelpp/feelpp"
        }
    }
}

info: load plugin mathjax ....ERROR

I already run gitbook install and the mathjax is in my node_modules.
When I run gitbook serve I got message like:

 Live reload server started on port: 35729
 Press CTRL+C to quit ...

 info: loading book configuration....OK
 info: load plugin mathjax ....ERROR
 info: load plugin gitbook-plugin-highlight ....OK
 info: load plugin gitbook-plugin-livereload ....OK

 Error: Error loading plugins: mathjax. Run "gitbook install" to install plugins from NPM.

I print the error is

{ [Error: Cannot find module 'q'] code: 'MODULE_NOT_FOUND' }

How to fix it.
gitbook version: 2.4.0
OS: MacOS

misunderstand underscore

code:

$\begin{aligned}
\max & c \cdot x
\\\\
s.t. & A_{m_1 \cdot n} \cdot x \le b
\\\\
& Aeq_{m_2 \cdot n} \cdot x = beq
\\\\
& x_i \ge 0
\end{aligned}$

and the result is like this:

<p>$\begin{aligned}
\max &amp; c \cdot x
\\
s.t. &amp; A<em>{m_1 \cdot n} \cdot x \le b
\\
&amp; Aeq</em>{m_2 \cdot n} \cdot x = beq
\\
&amp; x_i \ge 0
\end{aligned}$</p>

when the Aeq line is removed the em tag disappears and everything is normal.

Error with plugin "mathjax":

D:\workspace\blog\interview_books>gitbook build
info: 8 plugins are installed
info: 7 explicitly listed
info: loading plugin "mathjax"... ERROR

PluginError: Error with plugin "mathjax": Cannot find module 'mathjax/unpacked/MathJax'

it is not working in new website

I use the plugin in my gitbook.
Few day ago, i sync to new Gitbook website
I found it work well in legacy Gitbook website, but it is not working in new website

is it support in new website?
Or, i need use a new config, or use other plugin replace it?

ERRORS in Node 4.0+

Since the nodejs merge the iojs, something need to update.
In depedence chains, JSDOM is the big reason to show errors.

Howerver, the current version (0.3.0) of MathJax-node is still with old version (3.1.2),
New changes still work in develop.

There is a unstabled version: https://github.com/morlay/plugin-mathjax
For node 4.0+ user, use mathjax-beta instead, until MathJax-node is ready.

Maybe still a TODO for this plugin :-)

Example/How to use

There should be an example repository for all of the plugins or at least documentation for each one in the plugin repository.

Can't load MathJax.js when the root directory contains chinese characters

When the root diretory is "书籍", and run "gitbook serve", it reports "Can't load MathJax.js from file:///D:/Code/书籍/node_modules/mathjax/unpacked/MathJax.js"

Live reload server started on port: 35729
Press CTRL+C to quit ...

info: 8 plugins are installed
info: loading plugin "mathjax"... OK
info: loading plugin "livereload"... OK
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 4 pages
info: found 3 asset files
warn: "this.generator" property is deprecated, use "this.output.name" instead
warn: "navigation" property is deprecated
warn: "book" property is deprecated, use "this" directly instead
warn: "options" property is deprecated, use config.get(key) instead
Can't load MathJax.js from file:///D:/Code/书籍/node_modules/mathjax/unpacked/MathJax.js

When I change “书籍” to "book", and run "gitbook serve" again, everything is OK.

Live reload server started on port: 35729
Press CTRL+C to quit ...

info: 8 plugins are installed
info: loading plugin "mathjax"... OK
info: loading plugin "livereload"... OK
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 4 pages
info: found 3 asset files
warn: "this.generator" property is deprecated, use "this.output.name" instead
warn: "navigation" property is deprecated
warn: "book" property is deprecated, use "this" directly instead
warn: "options" property is deprecated, use config.get(key) instead
info: >> generation finished with success in 2.0s !

Starting server ...
Serving book on http://localhost:4000

I'm really confused about how to use plugins.

The help doc didn't help very much here.

I added this into my book.json:

{
   plugins: ["katex"]
}

but the build failed, so I changed into this:

{
    "plugins": ["katex"]
}

again it did not work, telling me that

info: load plugin katex ....ERROR
Error: Error loading plugins: katex. Run 'gitbook install' to install plugins from NPM.

So what exactly should I be doing to enable MathJax for my doc?

Thanks again for this great system.

Can't use two formula on single line

First, thanks for the awesome plugin!

When I have a line that contains just a single formula it gets centered with padded with vertical padding as expected. The problem I have is when I want to start and end a line with a formula, something like:

$$formula$$ text $$formula$$

This gets rendered as a single formula, the two inner-most delimiters getting interpreted as part of a larger formula, here's a screenshot:

screen shot 2015-02-08 at 6 31 34 pm

Am I doing something wrong?

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.