Clone wiki

Publy / FAQ

If your question is not listed, please ask the mailing list: publy-list@googlegroups.com.

How does Publy render LaTeX equations?

Publy handles LaTeX formulas by leaving them untouched in the HTML, so that MathJax can render them when people view the website. The standard header file included with Publy (data/defaultHeader.html) includes the following JavaScript to load and configure MathJax:

<!-- Include MathJax to convert LaTeX formulas to HTML on the fly -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [['$','$'], ['\\(','\\)']],
      processEscapes: true
    },
    "HTML-CSS": { scale: 90 }
  });
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_CHTML" async></script>

In addition, by default, Publy tells MathJax to not process the abstract text, since it is typically hidden initially (this speeds up page load). It is then processed when necessary by the following JavaScript, found in data/base.js:

// Toggles abstract. Input: .abstract-container 
function toggleAbstract(abs) { 
    abs.slideToggle(500); 

    // Render the math in here, if necessary 
    if (abs.hasClass("tex2jax_ignore")) { 
        abs.removeClass("tex2jax_ignore"); 
        MathJax.Hub.Queue(["Typeset", MathJax.Hub, abs.get(0)]); 
    } 
} 

Updated