# Redefine output for a specific TS1 code point (=glyph?)

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.

\documentclass{scrartcl}
\usepackage{textcomp}
\pagestyle{empty}

\DeclareTextSymbolDefault\homegrowntextminus{TS1}
\DeclareTextSymbol\homegrowntextminus{TS1}{61}

\begin{document}
+5 \homegrowntextminus 5
\end{document}

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?

-

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:

\DeclareTextSymbol{\textminus}{TS1}{61}

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:

'&#x2212;' ''            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:

(/home/mint/texlive/2012/texmf-dist/tex4ht/ht-fonts/iso8859/1/charset/unicode.4hf

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

'&#x2212;' ''  '-' ''

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:

(/home/mint/texlive/2012/texmf-dist/tex4ht/ht-fonts/unicode/charset/unicode.4hf)

different definition is used there:

'&#x2212;' '' '\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 Feb 27 '14 at 13:54