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.

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

I'm using TexLive 2011 on Ubuntu 11.10. Take this for example:


Then I run htlatex test.tex to convert it to html, but after conversion, the Chinese characters are not displayed in the browser. Then I checked the html source, it's like this:

<!--l. 3--><p class="noindent" ><span 

Seems like it's converting the characters in the weirdest way.

So how do I configure it to let it produce readable Chinese? If tex4ht isn't able to do this, what other tools should I look into?

share|improve this question
It is mainly because of the wrongly produced .htf files. (htf 文件没做好,以前是不同人做的,不匹配。这是已知的问题,ctex-kit 上很早的 issue 了,不过都觉得应用很少没人处理。) – Leo Liu Mar 15 '12 at 12:45
You can find more information at code.google.com/p/ctex-kit/issues/detail?id=46 – Leo Liu Mar 15 '12 at 12:48
@LeoLiu I'm translating a book written in Latex. It uses tex4ht to produce an HTML version. Guess it leaves me no choice :\ – Wang Dingwei Mar 17 '12 at 14:43
up vote 5 down vote accepted

The reason is because tex4ht can't find the htf font files, i.e. unisong51.htf etc. However, tex4ht does come with utf8song*.htf files in %TEX4HT%/ht-fonts/unicode/cjk/utf8/, so you could just create copies of those. (%TEX4HT% is likely to be %TEXMF%/tex4ht on your system.)

Here's what I did.

  • Create a copy of each utf8song*.htf to unisong*.htf, and modify the first and last lines of the file contents to unisong* accordingly.
  • In my case, I had to also edit %TEX4HT%/tex4ht/base/unix/tex4ht.env. (Or in win32 if you're on Windows). Change all the ~/tex4ht.dir/texmf in that file to the actual path where my TEXMF tree really is, especially the ones under the heading <unihtf>.
  • Then run the following command:

    htlatex test.tex "xhtml,charset=utf-8,NoFonts" " -cunihtf -utf8"

I was then able to get a readable webpage in Chinese.

share|improve this answer
Personally I don't think tex4ht is a proper tool to produce HTML pages. pandoc is a better choice, I think. – Leo Liu Mar 15 '12 at 12:58
@LeoLiu +1 for pandoc, I use it for writing my "first drafts". But IMHO tex4ht wins hands-down on most "real-life" LaTeX documents. pandoc can't handle beyond a few common LaTeX packages, while tex4ht can almost handle any packages you throw at it. So it really depends on how complicated your LaTeX document is, especially w.r.t. the kinds of macros and packages you're using. – LianTze Lim Mar 15 '12 at 13:20
@Lim: Well, I would just use markdown for pandoc to produce both HTML and PDF (via LaTeX). – Leo Liu Mar 15 '12 at 14:40
@LianTzeLim It finally works. Thanks! – Wang Dingwei Mar 17 '12 at 14:45
@LianTzeLim I think this only solves font issues for simsun or 新宋体. How do I make it work for all Chinese fonts, like simhei, simkai, and those Wenquanyi fonts? – Wang Dingwei Mar 18 '12 at 3:22

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.