tex4ht + mathjax-node-page sample

This is an example of LATEX to HTML conversion using tex4ht. The document was compiled to HTML + MathML first, then it has been post-processed using Mathjax-node-page to pure HTML + CSS. This method should work in all modern web browsers, as MathML has poor browser support. It should be also much faster than client side MathML rendering by MathJax.

I’ve used a sample document provided by Prof Toby Roberts.

The development version of make4ht, build system for tex4ht has been used. It has a support for Lua extensions, which can be used for modification of the generated files. It contains mathjaxnode extension for Mathjax-node-page (which needs to be installed on the system) support. The following command line invocation has been used for the compilation:

make4ht -uf html5+mathjaxnode -c stack.cfg maths.tex

The configuration file stack.cfg contains some commands to add some additional styling for the resulting HTML file:

    margin:40px auto;  
    font-size:1em; 0.88em;  
    padding:0 10px;}}  
\Css{@media (min-width: 29.63em){  
  :root {  
    font-size: 3vw;  
\Css{@media (min-width: 40.74em){  
  :root {  
    font-size: 1.375em;  
\Css{body {  
font-family: STIXGeneral, "Linux Libertine O", Gentium, Georgia,  
"Times New Roman",  "Iowan Old Style",  
 Palatino Linotype, Palatino, serif;  

The original content follows:

LATEX Mathematics Examples

Prof Tony Roberts

February 19, 2018


1 Delimiters
2 Spacing
3 Arrays
4 Equation arrays
5 Functions
6 Accents
7 Command definition
8 Theorems et al.

1 Delimiters

See how the delimiters are of reasonable size in these examples

even when there is no matching delimiter

2 Spacing

Differentials often need a bit of help with their spacing as in

whereas vector problems often lead to statements such as

Occasionally one gets horrible line breaks when using a list in mathematics such as listing the first twelve primes . In such cases, perhaps include \mathcode‘\,="213B inside the inline maths environment so that the list breaks: . Be discerning about when to do this as the spacing is different.

3 Arrays

Arrays of mathematics are typeset using one of the matrix environments as in

Case statements use cases:

Many arrays have lots of dots all over the place as in

4 Equation arrays

In the flow of a fluid film we may report

Alternatively, the curl of a vector field may be written with only one equation number:

Whereas a derivation may look like

5 Functions

Observe that trigonometric and other elementary functions are typeset properly, even to the extent of providing a thin space if followed by a single letter argument:

With sub- and super-scripts placed properly on more complicated functions,

and large operators, such as integrals and

In inline mathematics the scripts are correctly placed to the side in order to conserve vertical space, as in

6 Accents

Mathematical accents are performed by a short command with one argument, such as


7 Command definition

The Airy function, , may be incorrectly defined as this integral

This vector identity serves nicely to illustrate two of the new commands:

8 Theorems et al.

Definition 1 (right-angled triangles) A right-angled triangle is a triangle whose sides of length , and ,in some permutation of order, satisfies .

Lemma 2 The triangle with sides of length , and  is right-angled.

This lemma follows from the Definition 1 as .

Theorem 3 (Pythagorean triplets) Triangles with sides of length , and are right-angled triangles.

Prove this Theorem 3 by the algebra .