When processing a LaTeX source with tex4ht, I can't seem to reliably convert subscripts in text mode to <sub> tags in the HTML output. My only solution so far is to switch to math mode. But for some reason, if I define the same math code as a macro with \newcommand (to avoid typos when typing long math expressions), the <sub> tags are gone again!

Example source:


... which I process using:

htlatex example.tex 'html, charset=utf-8' ' -cunihtf -utf8'

Is there an easy way to make tex4ht honor \textsubscript or $_{}$ commands in \newcommand macros?

Thanks for any suggestion,


  • Thanks michal.h21, that did most of the trick. \newcommand{\foo}{$foo_{bar}$} still fails silently, but \newcommand{\foo}{foo\textsubscript{bar}} fulfills my needs.
    – Mathieu
    Commented Aug 27, 2012 at 9:24
  • Also, I don't know if there is something I should do to tag the question as solved (upvoting requires more reputation than I have)...
    – Mathieu
    Commented Aug 27, 2012 at 9:29
  • yeah, version with math environment seems little bit hackish to me, in text is \textsubscipt much better
    – michal.h21
    Commented Aug 27, 2012 at 10:29
  • accepting suffices, but you can try also upvoting, I think you have enough reputation
    – michal.h21
    Commented Aug 27, 2012 at 10:30

1 Answer 1


It seems there is no configuration for subscript package, so you must create one. Configurations for packages are stored in files with extension .4ht, so for subscript create subscript.4ht:


This file will be automatically loaded by tex4ht when you call \usepackage{subscript}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .