Take the 2-minute tour ×
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.

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:

\documentclass[10pt]{article}
\usepackage{subscript}
\newcommand{\tsub}{$a_b$}
\begin{document}
x\textsuperscript{n}
y\textsubscript{1}
$a_b$
\tsub{}
\end{document}

... 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,

--Mathieu

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
add comment

1 Answer

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:

\NewConfigure{textsubscript}{2}
\renewcommand\textsubscript[1]{%
\a:textsubscript#1\b:textsubscript
}
\Configure{textsubscript}{\Tg<sub>}{\Tg</sub>}

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

share|improve this answer
add comment

Your Answer

 
discard

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.