# TeX4ht superscript symbol problem

I have small tex file which is as the below

%%%%%%%%%%%%%%%test.tex%%%%%%%%%%%%%%%%%

\documentclass{article}

\def\mysubsup#1#2#3{#1_{#2}^{#3}}

\begin{document}

This is small sample $\mysubsup{P}{2}{3}$

\end{document}


When I run as the below

htlatex test.tex "xhtml, mathltx, early_, early^"

The output html has the missing character of "^"

This is small sample

How to retrieve the superscript symbol

• This happens only with the macro. Its works fine when the superscript is typed in directly. (just an observation) – AJN Apr 27 '16 at 7:37
• In the generated html, for the directly typed formula, the super and subscripts are of smaller font and the html tags <sup> and <sub> are present. For the macro version, the font change html tags are still present, but the <sup> and <sub> html tags are missing. – AJN Apr 27 '16 at 7:47
• The root cause of the problem is that argument "early^" wrongly passing to tex4ht option as "early" only. to avoid this I have used for "early^^". Kindly request to fix the problem in htlatex argument. Regards Baskar – Baskar May 2 '16 at 3:32

Subscripts and superscripts in macros are common source of problems in tex4ht, it is usually needed to redefine these macros in tex4ht patch files, or in the custom config file. early_ and early^ options try to fix this problem, but the fail often.
 \def\mysubsup#1#2#3{{#1}\sb{#2}\sp{#3}}

first change is to include your first argument in a group, in order to include the whole contents of the argument in the base. \sb and \sp macros works for subscripts resp. superscripts without problems
The default output with htlatex test.tex "xhtml,mathltx:
You may get better output with mathml option, but it works only in Firefox browser (you can use mathjax to render mathml in other browsers