Skip to main content
HamRadioHK
From Zero to Radio Hero – Your Learning Starts Here.

Main navigation

  • Home
  • Blog
  • About
User account menu
  • Log in

Topics: | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Others |

Adding MathJax to HTML header

By hamradiohk , 25 March 2026

In order to show mathematic equations on webpages, one can take advantage of the MathJax library. In this site, we used Drupal CMS and had installed the JS and CSS Asset Injector module. We can ask Drupal to load MathJax library upon each document load. Typically, in JS Asset Injector, we can add the following code to ensure that MathJax is loaded. 

(function () {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src  = "https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js";
  document.getElementsByTagName("head")[0].appendChild(script);
})();

Can you see an equation properly below?


The formula for speed is: \(v = \frac{d}{t}\) where:

  • \(v\) is speed
  • \(d\) is distance
  • \(t\) is time

Or in block mode:

$$\text{Speed} = \frac{\Delta \text{distance}}{\Delta \text{time}}$$


The above nice equation is actually created by the following LaTeX code:

The formula for speed is: \(v = \frac{d}{t}\)
Where:
\(v\) is speed
\(d\) is distance
\(t\) is time
Or in block mode:
$$\text{Speed} = \frac{\Delta \text{distance}}{\Delta \text{time}}$$

 

Tags

  • site
  • Log in to post comments

Comments

Quick Links

Morsle - the daily Morse code challenge.
Radio Garden - Explore live radio by rotating the globe.

To suggest a link, please write to info@hamradiohk.com.

Press Ctrl + D (Windows) or ⌘ + D (Mac) to bookmark this site.

© 2026 HamRadioHK.com All Rights Reserved. All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.