How to prevent MathJax from processing math equations in specific parts
This article shows how to prevent MathJax from processing math equations in specific parts, supposing that you have created a website with WordPress.
As of this writing (November 2022), WordPress is version 6.1 and MathJax is version 3.2.
How to prevent processing for the entire block
When you add a block in the WordPress visual editor, a block setting panel appears on the right. If the Block Settings panel does not appear, click on the gear icon in the upper right corner of the screen.
Click “Advanced” at the bottom of the block settings panel to open it, and enter mathjax_ignore
in the ADDITIONAL CSS CLASS(ES) field.
The mathjax_ignore
class prevents the mathematical code described in that block from being processed. (See the MathJax official website for details.)
In the case of the above image, the display on the web will not be
but will be displayed as follows.
\[ E=mc^2 \]
Mathematical codes in Code blocks are not exceptionally processed even with ADDITIONAL CSS CLASS(ES) blanked.
📌NOTE |
---|
For MathJax version 2 you should enter tex2jax_ignore in the additional CSS class. (See MathJax official website for details.)
|
How to restart processing
This section describes how to partially process the mathematical codes described in the lower layer blocks when the mathjax_ignore
class is marked to a group of multiple blocks.
For example, suppose you enter mathjax_ignore
as an additional CSS class for the “list block” so that the entire list is not processed.
If you want to process the second “list item” in that list block, enter mathjax_process
as the additional CSS class with that list item selected.
Now, only the second list item in the list block will be processed.
The display on the website is as follows.
How to prevent inline-math from being processed
Here are two ways to prevent processing inline-math equations.
Inline code
The first method we will show you is to use the built-in features of WordPress.
Select the code you do not want processed on the visual editor.
Click “Inline Code” from the menu above.
It is no longer processed into equations on the website.
The display on the Web site will be as follows: the font will be slightly smaller and the background will be gray.
Backslash
If you put a single backslash “" before the delimiter, the code will not be processed.
The code is displayed in the font of the string on the website.