wiki:MathJaxPlugin

MathJax Plugin


This plugin provides seamless Latex support for WikidPad. Latex equations are beautifully rendered using the MathJax engine.


Installation

  • This plugin requires WikidPad version 2.2beta03 or higher. Recent versions of the plugin require even newer versions of WikidPad - check the changelog below.
  • Download a copy of MathJax into a directory of your choice. More detailed information and download links are provided here.
  • Switch to a Javascript-capable HTML renderer in Options -> HTML preview/export. The WebKit preview renderer is recommended (and the plugin hasn't been tested with anything else).
  • Extract the plugin files (attached below) into the user_extensions subdirectory of your WikidPad directory (create this folder if it does not already exist).
  • After restarting WikidPad, the WikidPad Options dialog should now have a MathJax entry under Plugin options. Go to this page and enter the full path of your MathJax directory.


How to use

Latex rendering in the previewer is enabled by turning on the plugin (Enable MathJax) on the Options page.

You can now use Latex directly within wiki pages. A large amount of Latex is supported (for more details see the MathJax webpage). A simple example is given below.

The option Use $...$ for inline equations means that expressions between $...$ are interpreted as inline mathematics, as is standard for Latex. You may not want to use this option if you use the $ character frequently elsewhere in your Wiki.

Special characters

Latex requires the backslash character \ for its commands, while WikidPad uses the same character as its escape character. Similarly, Latex formulas will often use _ and * , which are the special characters for italic and bold text in WikidPad. There are two ways to get around these conflicts, depending on whether one wishes to stay closer to the orginial WikidPad syntax or whether on prefers to optimize things for Latex.

The first option is to escape these characters when they arise in Latex formulas, so WikidPad does not process them. You can escape single characters by prefixing them with a backslash \ , or escape entire passages with angled brackets << ... >> . For example, Latex commands like \sin would be entered as
sin.

The second, more elegant option is to switch the Wiki language in the WikidPad options dialog to "MathJax". This is a per-wiki setting. This alternative parser modifies the WikidPad syntax as follows:

  • The escape character is now @
  • Italics are encoded by __youritalictext__ (rather than _youritalictext_)
  • Bold is encoded by yourboldtext (rather than *yourboldtext*)

These changes ensure you can enter most Latex formulas as usual.

Tips and Tricks

  • Because WikidPad renders pages as HTML, indentations and line breaks can sometimes cause problems in multiline Latex expressions. Usually, removing the indentation fixes this issue.
  • In rare instances, WikidPad may interpret some part of a formula in ways which prevent the Latex from rendering properly. In this case, try escaping the sequence as described above.
  • The Webkit renderer allows zooming by holding down CTRL and using the mouse scrollwheel.


An Example

A well-known formula: $$\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$

A set of equations:
\begin{align}
\dot{x} &= \sigma(y-x) \\
\dot{y} &= \rho x - y - xz \\
\dot{z} &= -\beta z + xy
\end{align}

The Cauchy-Schwarz inequality:
\[
\left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
\]

Here are a couple of different ways $$\sqrt{3x-1}+(1+x)^2$$ to have equations \(\sqrt{3x-1}+(1+x)^2\) inline in a normal paragraph $\sqrt{3x-1}+(1+x)^2$ of text.


Changelog

1.0 Initial release

1.1 Change MathJax parser to better avoid conflicts: escape character is now @ instead of |, italic and bold is encoded by __ and

1.1.22b04 Reflect parser changes in WikidPad 2.2.b04_2

1.1.22b05 Reflect parser changes in WikidPad 2.2.b05_2

1.2 Use OverlayParser for the MathJax parser, which should make it unnecessary to update the plugin every time the WikidPad parser changes.

1.3 Drop MathML, change MathJax configuration for compatibility with MathJax 1.1 and HTML5

1.4 Printing now works! Requires WikidPad 2.3.b04 (or higher), and MathJax 2.0 (or higher).

Last modified 6 years ago Last modified on May 19, 2012 11:02:51 PM

Attachments (7)

Download all attachments as: .zip