You are viewing the PKP Support Forum | PKP Home Wiki

## OJS Plugin: MathJax

The Plugin Gallery is a venue for users of PKP software to share their plugins.

Moderators: jmacgreg, michael, John

Forum rules
If you post a plugin here, please include information on which versions of which applications it is compatible with. Attach a tarball of the plugin (e.g. tar cvzf myPlugin-0.1.tar.gz plugins/generic/myPlugin). Thanks for contributing!

### OJS Plugin: MathJax

This plugin installs and enables the MathJax javascript engine for your journal. From the MathJax documentation:

MathJax is an open-source JavaScript display engine for LaTeX and MathML that works in all modern browsers. It was designed with the goal of consolidating the recent advances in web technologies into a single, definitive, math-on-the-web platform supporting the major browsers and operating systems.

You can see the results of installing/enabling this plugin in the screenshot below. I just copy&pasted the demonstration HTML, which included raw LaTeX, from here, and pasted into an HTML galley.

The MathJax library itself is fairly large, so this plugin weighs in at ~17MB. You can download it from here: mathjax 1.0.0.zip.

Author: James MacGregor
Software: OJS, probably also OCS
Versions: 2.3+
Multilingual: only English included

Cheers,
James
Attachments
screenshot
mathjax.png (164.9 KiB) Viewed 7379 times
jmacgreg

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

### Re: OJS Plugin: MathJax

This plugin is wonderful. Thank you very much. But now there are two problems
1. It does not work while the Citation Markup Assistant being enabled and the issue published.
2. The configure metod for mathjax 1.1 is quit different. So the plugin doesn't work for mathjax 1.1

Hope someone can have solutions.

Best Wishes

Posts: 63
Joined: Wed Nov 05, 2008 8:16 am

### Re: OJS Plugin: MathJax

Thanks for the notes! I'll try and see if I can find a fix for both issues in the near future, time depending. If you don't see anything in the next week, please feel free to remind me here.

Cheers,
James
jmacgreg

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

### Re: OJS Plugin: MathJax

Thanks for the notes! I'll try and see if I can find a fix for both issues in the near future, time depending. If you don't see anything in the next week, please feel free to remind me here.

Cheers,
James

Dear James,
Do you get any progress on mathjax plugin for MathJax verion 1.1 ?
Thank you very much.

Posts: 63
Joined: Wed Nov 05, 2008 8:16 am

### Re: OJS Plugin: MathJax

Not yet, unfortunately -- time's been tight these days. I'll see if I can get to it this weekend, though.

Cheers,
James
jmacgreg

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

### Re: OJS Plugin: MathJax

Hi, my name is Hylke Koers and I work on MathJax. I saw this thread and just wanted to comment that MathJax 1.1 comes with a CDN service, which makes it very easy to integrate into an existing website or platform. In most cases, adding a single line of code into the HTML header is all you need to start including MathML or LaTeX in your documents. More information and installation instructions can be found at http://www.mathjax.org/2011/03/15/news/ ... 1-release/

I hope this is useful, and please feel free to contact us through the contact form on mathjax.org if you have questions.
hkoers

Posts: 1
Joined: Mon May 02, 2011 4:51 am

### Re: OJS Plugin: MathJax

Hi Hylke,

That's great news! I'll definitely be looking into this. If this is the case, we can most likely add the plugin to the OJS codebase so it's available to users by default, since we wouldn't need to ship the entire MathJax library.

Thanks for letting us know,
James
jmacgreg

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

### Re: OJS Plugin: MathJax

Dear All
any progress on MathJax 1.1 ?
Try to modified the plugin with new configuration
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\$$","\$$"] ],
displayMath: [ ['$$','$$'], ["\$","\$"] ],
processEscapes: true
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
but it failed.
The tex2jax options doesn't work.
Thank you very much. I think this plugin is very import for mathematical journals.

Posts: 63
Joined: Wed Nov 05, 2008 8:16 am

### Re: OJS Plugin: MathJax

Hi folks,

I've modified the original mathjax plugin to now use the mathjax CDN service -- so all you need to do is install/upgrade to the plugin provided in this post, and not worry about uploading the entire mathjax library. Lightshadow, would you mind testing this? If it works well for you, I'll include it in the core OJS codebase.

(NB: this file should work with OJS 2.3+. Not tested on OCS or OJS 2.2.x.)

Cheers,
James
Attachments
mathjax.tar.gz
Mathjax plugin version 1.1
jmacgreg

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

### Re: OJS Plugin: MathJax

jmacgreg wrote:Hi folks,

I've modified the original mathjax plugin to now use the mathjax CDN service -- so all you need to do is install/upgrade to the plugin provided in this post, and not worry about uploading the entire mathjax library. Lightshadow, would you mind testing this? If it works well for you, I'll include it in the core OJS codebase.

(NB: this file should work with OJS 2.3+. Not tested on OCS or OJS 2.2.x.)

Cheers,
James

Dear James,
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?co
nfig=TeX-AMS-MML_HTMLorMML">
</script>
<!-- / MathJax plugin -->';
This seems convinent for users, but in fact, it does not. My reasons are
1. It is not consistant with MathJax 1.0 and our custom.
(1) In mathjax 1.0, we use $,,,$ or $$....$$ as math delimiters, but use $$...$$ and $....$ as math delimiters in MathJax 1.1. That means we have to modify our metadata of every old article. By the way, mathematicans seem prefer $..$ and $$....$$ rather than $$...$$ and $....$ .
(2) The way to solve the conflicts is add somelines like
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\$$","\$$"] ],
displayMath: [ ['$$','$$'], ["\$","\$"] ],
processEscapes: true
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
but it doens't seem to work on OJS ( it works on wordpress, moodle....)
2. The plugins did not load at host's mainpage and the reference page.

I have try many possibilities, but I did find a correct solution. You will be appreciated very much if you can find the solution.
My Best Wishes

Posts: 63
Joined: Wed Nov 05, 2008 8:16 am

### Re: OJS Plugin: MathJax

Dear James
Let me state more details.
I try to add some lines to the old MathJaxPlugin.inc.php as following
=========================================
$mathjaxconfig=' <!-- MathJax Config --> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [ ["$","$"], ["\$$","\$$"] ], displayMath: [ ["$$","$$"], ["\$","\$"] ], processEscapes: true } }); </script> <!-- / MathJax plugin Config -->';$mathjaxScript = ' <!-- MathJax plugin -->
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- / MathJax plugin -->';

$templateManager->assign('additionalHeadData',$additionalHeadData."\n" .$mathjaxconfig."\n".$mathjaxScript);
===================

According to the document of MathJax V1.1
This will enable us to use both "$..$" and " $$..$$" as math delimiters, but actually it make " $$..$$" and "$...$" fail to work.
one more problem is that "\" is automatically deleted in the Reference part. ( article/view/articleNO. )

Posts: 63
Joined: Wed Nov 05, 2008 8:16 am

### Re: OJS Plugin: MathJax

Any chance you could email me an example article galley to test this with? Please send one or two to jmacgreg at gmail dot com (and include "mathjax" in the subject line so I know what it's about).

Cheers,
James
jmacgreg

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

### Re: OJS Plugin: MathJax

What I found was that one extra level of backslashing was needed in the source code in my OJS 2.3.5 setup. MathJaxPlugin.inc.php becomes

Code: Select all
$mathjaxconfig=' <!-- MathJax Config --> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [ ["$","$"], ["\\\$$","\\\$$"] ], displayMath: [ ["$$","$$"], ["\\\$","\\\$"] ], processEscapes: true } }); </script> <!-- / MathJax plugin Config -->'; However, I don't think it is a good idea for the plugin to default to using '$' as inlineMath delimiters. Granted that most mathematicians use "\$" rather than "\(" when writing .tex files, Lamport says they're wrong. And it is fairly likely that a dollar sign will occur elsewhere in your HTML code outside of an intentional pair delimiting a LaTeX expression, with a dysfunctional web page as the result. I would prefer to see the plugin distributed with a comment suggesting how it can be modified to change the configuration, but with a default that simply uses the standard mathjax-preferred http://cdn.mathjax.org/mathjax/latest/M ... _HTMLorMML configuration.

If James wanted to be really fancy he could of course offer a configuration page as part of the plugin that would allow setting the delimiters on a per-journal basis.
jqj

Posts: 15
Joined: Wed Dec 23, 2009 2:05 pm

### Re: OJS Plugin: MathJax

I am using OJS 2.3+ (how do I check exactly?). The plugin version I have was borrowed from another journal, and it worked last year. Now does not display LaTeX in abstracts, etc, any more. I see that MathJax is now up to version 2.4.

Will this plugin be updated? Does it need to be? Is there another solution?

Any help will be appreciated.
mcwilson

Posts: 9
Joined: Wed Dec 19, 2012 3:52 pm

### Re: OJS Plugin: MathJax

I've installed this plugin by untarring it into plugins/generic and enabled it through the plugin interface.

Now, it seems to work on only a couple of pages, and these are the "plugin management" page (manager/plugins) and the generic plugins page (manager/plugins/generic). Here, "work" means that the link the mathjax CDN script shows up in the page source. For other pages, there is no evidence of anything happening. (I really need MathJax support only on the abstracts page.)

I've tried clearing the cached pages and cached templates using the management interface, but that doesn't change anything.

Note: I did not run "php tools/upgrade.php upgrade" as per the instructions in the README file. Is this really necessary? (I'll have to get an admin to do this if it is.)
morin

Posts: 11
Joined: Mon Jun 22, 2009 4:41 pm

Next