2

If I compile a latex document with tex4ht (under Tex Live 2016 / Windows 10) using

htlatex "my_doc.tex" "xhtml,charset=utf-8,fn-in" " -cunihtf -utf8"

the apostrophe character in LaTeX source, either U+2019 (’) or U+0027 ('), is rendered in HTML source as ’ instead of just .

Is it possible to fix this, maybe with a custom configuration?

Thanks in advance.

2

tex4ht uses special file, unicode.4hf, to translate certain characters in the converted document to some other characters, or XML entities. Otherwise, they are written as utf8 characters, when you use -utf8 option for tex4ht.

This file is requested by -c option for tex4ht command, in your case it is unihtf. There are several version of unicode.4hf in the distribution, their locations are configured in the tex4ht.env file:

<unihtf>
i~/tex4ht.dir/texmf/tex4ht/ht-fonts/unicode/!
i~/tex4ht.dir/texmf/tex4ht/ht-fonts/ascii/!
i~/tex4ht.dir/texmf/tex4ht/ht-fonts/alias/!
</unihtf>

the first located file is used. You can find which one in the command line output:

tex4ht.c (2012-07-25-19:36 kpathsea)
tex4ht -utf8 
  -cunihtf 
  sample.dvi 
(/usr/local/texlive/2016/texmf-dist/tex4ht/base/unix/tex4ht.env)
(/usr/local/texlive/2016/texmf-dist/tex4ht/ht-fonts/unicode/html/charset/unicode.4hf)

when you open this file, you can see at the beginning:

'&#x003C;' '' '&#x003C;' '' 
'&#x003E;' '' '&#x003E;' '' 
'&#x0022;' '' '&#x0022;' '' 
'&#x2019;' '' '&#x2019;' '' 
'&#x0026;' '' '&#x0026;' '' 

The character to be looked for is in the first field and it must be in the form of numerical xml entity. The output character is in the third field and it can be any string, in this case it is the same entity as in the source.

So, to output the apostrophe in the document, copy the unicode.4hf to your document's directory and remove the line

'&#x2019;' '' '&#x2019;' ''

Sample output:

<!--l. 7--><p class="noindent" >hello’ world’
</p>
  • Thanks! Actually I modified the original unicode.4hf and it works. I'll have to remember this at every new installation of Tex Live. – mmj Sep 7 '16 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.