By now I know how to make \textminus in tex4ht work, but this does not seem to be enough to display a proper minus with the \num macro of siunitx. Joseph Wright provided a workaround, but I'd like to know how to make this work at a more general level.



  +5 \homegrowntextminus 5

Is there a way to configure tex4ht so that it prints a proper minus sign (as in the pdflatex output below) when converting to HTML without knowing or modifying \homegrowntextminus?

+5 -5

GitHub MWE: https://github.com/krlmlr/lm-template/tree/tex4ht-own-textminus.


1 Answer 1


What was showed in textminus in tex4ht may be good for small changes, but correct process is different. Because textcomp is basically font selection package, existing tex4ht support is not done by redefining macros in textcomp.4ht file, but a special mapping file for font used by textcomp, tcrm.htf exists. It is located in texmf-dist/tex4ht/ht-fonts/unicode/jknappen/tc directory. You can copy this file to your working dir and edit it according to your needs.

These .htf files are used by tex4ht processor to convert glyphs in the dvi file to internal representation, which is then converted using .4hf files to actual characters.

Structure of .htf files is described in tex4ht help. We need to find position of \textminus in this file and correct provided definition. It corresponds to position in font encoding. textcomp package uses TS1 font encoding, which is defined in ts1enc.def. If we search for \textminus, we find this line:


This means that \textminus is defined on position 61 in the tcrm.htf file:

 '-' ''            61

as you can see, - is hardcoded here. We can modify that to use unicode minus instead:

 '−' ''            61

It is best to use this hexadecimal form, because it is used by .4hf files to convert to the actual character.

If you compile your file with htlatex textput now, and watch output of tex4ht command, you will see this line:


if you search this file for x2212, you will find line:

 '−' ''  '-' ''

this means that unicode minus is converted back to -. This is why this work only with unicode output with

 htlatex texput "xhtml, charset=utf-8" " -cunihtf -utf8"

different .4hf file is used now:


different definition is used there:

 '−' '' '\226\\136\\146\' ''

this converts entity to the unicode value.

Now back to this question, situation is simpler, as you have added your own symbol at position 61, where original \textminus is placed and which we already redefined. So this will work also for \homegrowntextminus.

  • Thank you so much for taking the time to derive the necessary steps and to explain them. It will help me and others in similar situations, and sheds some light on the internals of tex4ht. I do hope this can be applied to upstream tex4ht -- for my one-shot project, patching siunitx has turned out to be faster than patching three of tex4ht's files.
    – krlmlr
    Commented Feb 27, 2014 at 13:54

You must log in to answer this question.

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