HTML page with 4000+ Tex Equations

333 views
Skip to first unread message

dominic...@gmail.com

unread,
Nov 16, 2019, 10:45:23 AM11/16/19
to MathJax Users

I have a static HTML page with 4000+ latex equation (inline and display) and rendering takes about 2 to 3 minutes. To repllicate my problem I copied the content of MathJax sample.html file and created about 4000 equations (attached huge.html). 

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
//skipStartupTypeset: true, //Working
    extensions: ["tex2jax.js"],
MAXBUFFER:8*1024,
    jax: ["input/TeX","output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
},
"HTML-CSS": {
availableFonts: [],
linebreaks: { automatic:true ,width: "52% container" },
EqnChunk: 20,
EqnChunkFactor: 1.5,
EqnChunkDelay: 200          
}
  });
</script>

<script type="text/javascript" class="oxe_script_src" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML"></script>


I have gone through few posts in this group as well as Stackoverflow. I am not sure about my usage of EqnChunk/EqnChunkFactor/EqnChunkDelay here in my sample (https://docs.mathjax.org/en/v2.7-latest/options/output-processors/HTML-CSS.html) and I dont see any difference.


Kindly point me to the best practice in loading equtions that are visible or allow users to contine reading and do the math typeset at the background.

best
Dominic
huge.html

Davide Cervone

unread,
Nov 16, 2019, 8:25:51 PM11/16/19
to mathja...@googlegroups.com
Well, first of all, you are using the slowest output processor that MathJax has, so you might want to switch to CommonHTML or SVG output, which are considerably faster (a factor of 5 or more).  Then you may want to turn off the fast-preview, as that will slow things down during the TeX processing phase.  It also sets the equation chunking to alternative values that makes it generate all the equations at once, which is not optimal for very large numbers of equations.  So you could either disable fast-preview, or set its chunking parameters to process the equations in smaller chunks so that screen interaction can occur more easily while the processing is being done.

To disable the fast preview, use:

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    //skipStartupTypeset: true,  //Working
    MAXBUFFER:8*1024,
    'fast-preview': {
      disabled: true
    },
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    },
    CommonHTML: {
      EqnChunk: 20,
      EqnChunkFactor: 1.5,
      EqnChunkDelay: 200,
      linebreaks: { automatic:true ,width: "52% container" }
    }
  });
</script>
<script type="text/javascript" class="oxe_script_src" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_CHTML"></script>

On the other hand, to use fast-preview but set the chunking, use

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    //skipStartupTypeset: true, //Working
    MAXBUFFER:8*1024,
    'fast-preview': {
      Chunks: {
        EqnChunk: 20,
        EqnChunkFactor: 1.5,
        EqnChunkDelay: 200
      },
      disabled: true
    },
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    },
    CommonHTML: {
      linebreaks: { automatic:true ,width: "52% container" }
    }
  });
</script>
<script type="text/javascript" class="oxe_script_src" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_CHTML"></script>

See if those do it for you.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/cd14c3cf-e3ba-4fa0-a0e6-986c76a7cdd1%40googlegroups.com.
<huge.html>

Reply all
Reply to author
Forward
0 new messages