TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

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


  \textminus 5

works as expected with pdflatex --- -5 --- 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


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.

share|improve this question
up vote 5 down vote accepted

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:


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"


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

share|improve this answer
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 '14 at 11:59
I've also seen on the minus sign page that the HTML entity − is equivalent to the hex code; would that still need the UTF-8 encoding? – krlmlr Feb 20 '14 at 12:11
@krlmlr yes, you can use this also in the cfg file – michal.h21 Feb 20 '14 at 12:22
@krlmlr in the case of −, 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 '14 at 12:24
The − 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 '14 at 13:26

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.