Math plugin
This plugin is only available as a paid add-on to a TinyMCE subscription. |
This feature is only available for TinyMCE 7.1 and later. |
The Math plugin provides a way for users to insert complex formulas.
Interactive example
-
TinyMCE
-
HTML
-
JS
-
Edit on CodePen
<textarea id="math_demo">
<h2>Computation of Definite Integrals.</h2>
<p>In computing definite integrals it is important to observe that when the integral is known to exist the limit can be calculated on any properly chosen subset of the <tiny-math-inline formula="S_\delta"></tiny-math-inline>'s. So we have that if <tiny-math-inline formula="S_{\delta_1}"></tiny-math-inline>, <tiny-math-inline formula="S_{\delta_2}"></tiny-math-inline>, ... is any sequence of sums such that <tiny-math-inline formula="\displaystyle\mathop{L}_{n\doteq\infty}\delta_n=0"></tiny-math-inline>, then</p>
<tiny-math-block formula="\mathop{L}_{n\doteq\infty} S_{\delta_n} = \int_a^b f(x)dx."></tiny-math-block>
<p>One case of this kind occurs when <tiny-math-inline formula="\xi_k"></tiny-math-inline> is taken as an end-point of the interval <tiny-math-inline formula="{x_{k-1}}{x_k}"></tiny-math-inline> and all the <tiny-math-inline formula="\Delta_kx"></tiny-math-inline>'s are equal. Then we have</p>
<tiny-math-block formula="\displaystyle \int_a^b f(x)dx = \mathop{L}_{n\doteq\infty} \sum_{k=1}^n f(a+k\Delta x)\Delta x, \text{ where } \Delta x=\frac{b-a}{n}."></tiny-math-block>
<p>A simple example of this principle is the proof of the following theorem.</p>
<p><em>Exerpt from <a href="https://www.gutenberg.org/ebooks/18741">Introduction to Infinitesimal Analysis; Functions of One Real Variable by Veblen et al.</a></em></p>
</textarea>
tinymce.init({
selector: "textarea#math_demo",
plugins: [
"math", "advlist", "anchor", "autolink", "charmap", "code", "codesample", "fullscreen",
"help", "image", "insertdatetime", "link", "lists", "media",
"preview", "searchreplace", "table", "visualblocks",
],
toolbar: "math | codesample | undo redo | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
});
Basic setup
To set up the Math plugin user interface in the editor:
-
add
math
to the plugins option in the editor configuration;
For example:
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'math',
toolbar: 'math',
});
How to Use
To work with math elements, follow these steps:
-
Enable Math Plugin
-
Open the TinyMCE editor with the Math plugin enabled.
-
-
Insert or Edit Math Elements
-
Click the Math plugin icon in the toolbar.
-
This opens the Math dialog.
-
Select preferred language
-
Enter Math formula in the textarea.
-
Choose preferred text wrap
-
-
Preview and Save
-
Check Math formula output in preview.
-
Review the final Math equation in the preview section.
-
Click the save button in the Math dialog.
-
The Math equation is inserted into the editor, wrapped accordingly based on the chosen text wrap.
-
Formula Tag Wrapping
-
The Math dialog wraps the inserted formula with a specific tag.
-
The choice of tag depends on the selected text wrap option in the dialog:
-
For block (Text above and below) text wrap, the tag used is
<tiny-math-block>
. -
For inline (Inline with text) text wrap, the tag used is
<tiny-math-inline>
.
-
Visit https://katex.org/docs/supported for a comprehensive list of supported symbols and functions when inserting mathematical equations after selecting "Language (LaTeX)". |
Toolbar buttons
The Math plugin provides the following toolbar buttons:
Toolbar button identifier | Description |
---|---|
|
Opens the math modal dialog. |
These toolbar buttons can be added to the editor using:
-
The
toolbar
configuration option. -
The
quickbars_insert_toolbar
configuration option.
Menu items
The Math plugin provides the following menu items:
Menu item identifier | Default Menu Location | Description |
---|---|---|
|
Insert |
Opens the math modal dialog. |
These menu items can be added to the editor using:
-
The
menu
configuration option. -
The
contextmenu
configuration option.