# \textminus in tex4ht

Is there a way to make tex4ht aware of the \textminus command?

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

\begin{document}
\textminus 5
\end{document}


works as expected with pdflatex --- --- but creates a simple hyphen when converting to HTML using

mk4ht htlatex texput.tex "xhtml,bib-"


I'd like it to print a Unicode minus sign instead; I can print an em rule by saying

\def\textminus{--}


in the preamble, but I understand that an em rule is something different than a minus sign.

The MWE is also at GitHub, use make texput.html after checking out the tex4ht-textminus branch to generate HTML output.

-

There is no configuration for textcomp, so you can provide your own file with suitable redefinition of \textminus.

Create file textcomp.4ht and place it to directory with your document:

\renewcommand\textminus{\HCode{&\#x2212;}}


this will output hexadecimal html entity of minus sign. This entity will be later replaced by tex4ht command to other character, so it is important to output your file in unicode, because in default case, it is converted back to the - char!:

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


edit

More detailed and more correct setup is described in Redefine output for a specific TS1 code point (=glyph?)

-
Thanks! Actually, I'm targeting ooffice, so I don't need to care about UTF-8 anymore, right? Can I define this also in a .cfg file? –  krlmlr Feb 20 at 11:59
I've also seen on the minus sign page that the HTML entity &minus; is equivalent to the hex code; would that still need the UTF-8 encoding? –  krlmlr Feb 20 at 12:11
@krlmlr yes, you can use this also in the cfg file –  michal.h21 Feb 20 at 12:22
@krlmlr in the case of &minus;, I am not sure if it is supported by all viewers, particularly if you are interested in ooffice. but you can try it. in that case you don't need utf-8 encoding –  michal.h21 Feb 20 at 12:24
The &minus; literal does work with HTML output, but LibreOffice fails to display it. The explicit Unicode character code works in LibreOffice; for HTML output, it requires the UTF-8 switches as you suggested. Thanks again. I've pushed the fixed MWE to the tex4ht-textminus-fix branch. -- Any chance this could be made part of upstream tex4ht? –  krlmlr Feb 20 at 13:26