I am working on 2 rendering, the first one with the classical latex command and the other with htlatex command (tex4ht).

I have defined the following \newcommand :


and use them like this :


The rendering with latex command is what I expect :

latex rendering

You can notice that I want for each of \newcommand a little shift between upper and lower indices.

My issue is that I can't reproduce the same rendering with htlatex command. Here what is displayed on generated HTML page :

htlatex rendering

It seems that MathJax doesn't take into account the 2 \newcommand.

I produce the HTML page with the following command :

htlatex source.tex config_mathjax

and config file "config_mathjax" :

<script type="text/x-mathjax-config">                                         
    TeX: {       
      Macros: {   
                     beq: ['{\\mathbf\{\#1\}}',1],
                     btFma: ['{\$\\mathfrak\{e\}_\{\\mathbf\{\#1\}\}\$\$_\{\}\^\{\\mathbf\{\#2\}\}\$}',2],
                     btFmb: ['{\$\\mathfrak\{e\}\^\{\\mathbf\{\#1\}\}\$\$\^\{\}_\{\\mathbf\{\#2\}\}\$}',2],
      equationNumbers: { autoNumber: "AMS" }
    extensions: ["tex2jax.js"],
    tex2jax: {     
      inlineMath: [ ['\$','\$'], ["\\\\(","\\\\)"] ],
      displayMath: [ ['$$','$$'], ['\begin{equation}','\end{equation}'], ['\begin{align}','\end{align}'], ["\\[","\\]"] ],}
      processEscapes: true

I don't understand why htlatex doesn't take into accound these 2 \newcommand.

Maybe the \newcommand \bFma and \bFmb are too complex for htlatex, if someone knows how to simplify them, I will take them.

And if someone has or had the same type of issue, this would be fine to tell me how to circumvent it.


  • this is not tex4ht issue, it passes math input verbatim to MathJax, as expected. MathJax doesn't render your commands for some reason
    – michal.h21
    Jun 3, 2018 at 11:39

2 Answers 2


MathJax only processes macros in math mode, not in text mode (it doesn't include text-mode macros). That includes inside \textrm{} and other commands that switch to text mode. To use this with MathJax, you would need to remove the \textrm{} and change the definition of the macro to expect to one in math mode originally.


Remove dollar signs from definition:


Remove \textrm from equation:


Remove dollars signs from mathjax config:

 btFma: ['{\\mathfrak e}_{\\mathbf \#1}{}^{\\mathbf \#2}',2],

BTW: you can use \quad or \qquad instead of \,\,\,\,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.