TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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,


share|improve this question
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 Aug 27 '12 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 Aug 27 '12 at 9:29
yeah, version with math environment seems little bit hackish to me, in text is \textsubscipt much better – michal.h21 Aug 27 '12 at 10:29
accepting suffices, but you can try also upvoting, I think you have enough reputation – michal.h21 Aug 27 '12 at 10:30
up vote 3 down vote accepted

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}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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