Odoo Help

0

MathJax

By
Fernando Sarabia
on 2/12/18, 8:12 PM 185 views

Hi

I am creating some forms that include some math formulas (greek characters, etc).  I was thinking about displaying them using the javascript library MathJax (https://www.mathjax.org/).

I have tried to add the library to my template quite unsuccessfully:

My code is shown below:

<template id="assets_backend" name="my_template" inherit_id="web.assets_backend">

<xpath expr="." position="inside">

<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="/makuku_app/static/src/js/MathJax.min.js"></script>

</xpath>

</template>

The first "script tag shows the link to my files, and the second is configuration required by the libary.

Any insights would be greatly appreciated.

-F

where is the view, frontend or backend?

Hilar AK
on 2/13/18, 2:32 AM
0
Fernando Sarabia
On 2/13/18, 10:58 AM

Hilar, 

Thank you for your interest in helping me out.

The view is backend...  MathJax, after the page loads, looks for latex expressions between "$" signs (for example: $\sigma$) and converts to the graphic symbol of the greek letter in svg.  I was able to make it work with the following code (see below).  It works but only once.  As soon as I load a new view, mathjax does no longer work.  The following line is supposed to re-execute MathJax everytime the page is reloaded.  MathJax.Hub.Queue(["Typeset",MathJax.Hub]);  but it does not work for some reason.

Thanks again,

Fernando


<template id="editor_head" inherit_id="web.layout" name="My Func">

<xpath expr="//head" position="after">

<!-- jquery -->

<script type="text/x-mathjax-config">

MathJax.Hub.Queue(["Typeset",MathJax.Hub]);

MathJax.Hub.Config({

jax: ["input/TeX", "output/CommonHTML"],

tex2jax: {

inlineMath: [ ['$','$'], ["\\(","\\)"] ],

displayMath: [ ['$$','$$'], ["\\[","\\]"] ],

processEscapes: false

},

});

</script>

<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_SVG'></script>

<!-- plotly -->

</xpath>

</template>



I am sure this code will works when the view is editor_head template, and your problem is its not loading on other views? try to make it in a separate js file and include in web.assets_backend.

Hilar AK
on 2/14/18, 12:14 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 2/12/18, 8:12 PM
Seen: 185 times
Last updated: 4/10/18, 5:41 PM