# TeX4HT Equation unchanged with newcommand or def command

I would like to convert all the inline-math and display-math should be LaTeX format only and not for image. I had referred tex4ht leaving equations unchanged and tex4ht leaving equations unchanged - including $...$ and $$...$$. But author defined macros are not converted to HTML.

LaTeX MWO:

\documentclass{article}
\usepackage{amsmath,amssymb}
\newcommand{\La}{\Lambda}
\def\B{\beta}
\newcommand{\twosilt}{\mbox{\rm 2-silt}}
\begin{document}
In this section, we $\B$ recall some definitions and results.
Throughout $\alpha+\B$ this section, let ${\La}$ be a finite dimensional algebra.
\begin{equation*}
\Phi:\Lambda\longrightarrow\twosilt\Lambda,\ \ \ (X,P)\mapsto \Phi(X,P):=P_X\oplus P[1].
\end{equation*}
\end{document}


How do achieve this?

I am not really sure, what you are looking for, purpose of questions and answers you linked to is exactly not to convert macros to html, to be processed with some tool like mathjax. Try this configuration file, with definitions of your macros for mathjax:

\usepackage{verbatim}
\Preamble{xhtml}
% Configure for mathjax
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
\unexpanded{La : "\\Lambda",
B: "\\beta",
twosilt: "\\textrm{2-silt}",}
}
},
extensions: ["tex2jax.js"],
tex2jax: {
\unexpanded{
inlineMath: [ ['\$','\$'], ["\\\$$","\\\$$"] ],
displayMath: [ ['$$','$$'], ["\$","\$"] ],}
processEscapes: true
}
});
</script>
}}
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}

\newtoks\eqtoks
\def\AltMath#1${\eqtoks{$#1$}% \HCode{\the\eqtoks}$}

\begin{equation*}
\Phi:\Lambda\longrightarrow\twosilt\Lambda,\; (X,P)\mapsto \Phi(X,P):=P_X\oplus P[1].
\end{equation*}

\end{document}


I added fontenc package in order to correctly convert all characters and replaced \ \ \ in your equation with \;. I suppose that you wanted bigger space, but \ seems to be not supported by mathjax.

Now you can compile your file with:

htlatex mwo myconfig


you can see the result here

• Thanks for your help and i have many author defined macros and would like how to do in automatically conversion way instead of manual add in MathJax? – Balaji Mar 13 '14 at 5:12
• it would be more difficult, you would need to redefine every macro you use to print its name. adding your macros to mathjax seems much easier. but I would suggest you to switch to mathml with mathjax: you would get best performance. – michal.h21 Mar 13 '14 at 13:34
• Equations is can convert to image and any possible all the inline and display equations should convert to alt attribute? – Balaji Mar 21 '14 at 6:45
• The config file here sufffers some of the same typos as mentioned here in the comments, in case michal hasn't updated this answer. (And I'm waiting to see if michal agrees.) Additionally, this one has \AltlMathiI instead of \AltlMathI. – alex.jordan Oct 5 '14 at 2:38
• @alex.jordan yes, the errors are same, as I just copied the same file between different answers – michal.h21 Oct 5 '14 at 8:57