Skip to Content
Menu
This question has been flagged
4 Replies
4505 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

Avatar
Discard

where is the view, frontend or backend?

Best Answer

I am trying to add in Odoo ORM page but target page it was not able to display.

Avatar
Discard
Author Best Answer

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>



Avatar
Discard

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.

Hi, I also got the same problem in Odoo15 while loading the page only it will change the formula data..Does anybody find out the solution for this??

Related Posts Replies Views Activity
1
Jun 18
4027
0
Mar 15
3953