2

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 :

\newcommand{\btFma}[2]{$\mathfrak{e}_{\mathbf{#1}}$$_{}$$^{\mathbf{#2}}$}                
\newcommand{\btFmb}[2]{$\mathfrak{e}^{\mathbf{#1}}$$_{}$$_{\mathbf{#2}}$}   

and use them like this :

\begin{equation}                                                                         
\,\,\,\,\textrm{\btFma{i}{j}}=\beq{e_{i}}\otimes\beq{e^{j}}\,\,\,\,;\,\,\,\,\textrm{\btFmb{i}{j}}=\beq{e^{i}}\otimes\beq{e_{j}}
\end{equation}

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" :

\Configure{@HEAD}{\HCode{
<script type="text/x-mathjax-config">                                         
  MathJax.Hub.Config({
    TeX: {       
      Macros: {   
        \unexpanded{ 
                     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: {     
        \unexpanded{
      inlineMath: [ ['\$','\$'], ["\\\\(","\\\\)"] ],
      displayMath: [ ['$$','$$'], ['\begin{equation}','\end{equation}'], ['\begin{align}','\end{align}'], ["\\[","\\]"] ],}
      processEscapes: true
    }                
  });                
</script>
}}

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.

Regards

1
  • 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

1

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.

1

Remove dollar signs from definition:

\newcommand{\btFma}[2]{\mathfrak{e}_{\mathbf{#1}}{}^{\mathbf{#2}}}

Remove \textrm from equation:

\begin{equation}                                                                         
\btFma{i}{j}
\end{equation}

Remove dollars signs from mathjax config:

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

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

You must log in to answer this question.