# tex4ebook accents displays as wrong characters + only produces ePub 2.0 no 3.0

I've installed newest tex4ebook (didn't tried for about a year). Now I can't get ePub 3.0 - only ePub 2.0 (as says Sigil 0.9.5 when opening) and Sigil says it has to fix some characters in ePub. My test file (UTF8):

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}
\usepackage{hyperref}
\usepackage{tex4ebook}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}

\title{Geometrické algoritmy}
\author{Mgr. Stanislav Kopejtko}
\date{25. 7. 2014}
\begin{document}
\maketitle
\tableofcontents

Test:
ěščřžýáíéůú
ĚŠČŘŽÝÁÍÉŮÚ
$$e=\dfrac{12}{x^2}$$

\end{document}


When I use this command:

tex4ebook -f epub3 -t ebook.tex "mathml"


it produces errors in accented chars and title (Calibre viewer):

Geometrick� algoritmy Test: ěščřžý���ů� ĚŠČŘŽÝ���Ů�

When I use command:

tex4ebook -f epub3 ebook.tex "mathml"


it produces good looking text but title of document (not in displayed text content) is still Geometrick� algoritmy (if there is a TOC there are wrong chars also)

I've upgraded to HTML Tidy for Linux version 5.1.48 (I've noticed it uses this program even if there is no -t switch)

When I open any of this epubs on my mobile with Gitden, it displays wrong chars and only title screen - any text or math (Test:...)

Is the latest version broken or am I doing something wrong? I have now TexLive 2015.

Many thanks for any help.

EDIT: found parameters in documentation:

tex4ebook -f epub3 -t ebook.tex "html5,mathml,charset=utf-8" " -cunihtf -utf8"


made it well - now chars are OK

Even Sigil thanks to -t parameter opens it without error

But Mathml formulas doesn't work in Gitden on Android since it's ePub 2.0 :-(

Edit:

There was linked code in the comments, which generated wrong page order. That was caused by another bug in tex4ebook in epub3 mode. The problem is that pages which contain math should be marked in the OPF file. Every chapter creates it's own html page. Math was configured to register current in page sequence list and to register mathml property for the curent page. The problem was that pages without math were registered in the page sequence later than pages with math, so they came earlier in the page order. I've fixed that on Github, I will wait some time for other bug before I will update CTAN.

The other issue is with \uv command, which is provided by Czech babel and it is used to print quotes. It is translated as

 <sub>”</sub>=lsložitý“


with OP's code. The issue can be solved with fontenc package with T1 encoding. Correct file would be then:

\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}
\usepackage{hyperref}
% \usepackage{tex4ebook}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{latexsym}
\usepackage{esvect}
\usepackage{color}
\usepackage{makeidx}

\title{Geometrické algoritmy}
\author{Mgr. Stanislav Kopejtko}
\date{25. 7. 2014}
\begin{document}
\maketitle

\tableofcontents

\chapter*{Předmluva}
%
\uv{složitý}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\markboth{Předmluva}{Předmluva}

\part{test 2}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\markboth{}{}
\clearpage

\chapter*{test 3}
$$x=\dfrac{x^2}{x}$$
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\section{test 4}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\subsection{test 5}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

\chapter{test 6}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
$$x=\dfrac{x^2}{x}$$
\section{test 7}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\subsection{test 8}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
$$x=\dfrac{x^3}{x^2}$$

\end{document}


note that you don't need to use tex4ebook directly in your document unless you want to include the cover image in the main document.

I've found also another problem, which is actually tex4ht bug:

 \chapter*{Předmluva}
%
\uv{složitý}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.


is converted as

  <h2 class="likechapterHead"><a
id="x3-2000"></a>Předmluva</h2> „složitý“ Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. <a
id="Q1-3-3"></a>


with missing <p> tags. The problem is in configuration for \chapter* command, it doesn't request new paragraph. Until this bug is resolved in tex4ht, you can use following config file, mycfg.cfg:

\Preamble{xhtml}
\Configure{likechapter}{}{}
{\HCode{</h2>}\IgnoreIndent\par}

\begin{document}
\EndPreamble


\chapter* is configured with \Configure{likechapter}, the only change from default configuration is \par command after \IgnoreIndent.

Compile the document with:

 tex4ebook -f epub3 -c mycfg filename mathml


the result:

  <h2 class="likechapterHead"><a
id="x3-2000"></a>Předmluva</h2>
<p class="noindent">„složitý“ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. <a
id="Q1-3-3"></a>

</p>


This is a regression, Latin1 output with XML entities for accented characters is generated. It probably doesn't work in epub3 because Unicode is required in this format, in epub2 it is optional.

This bug was caused by unification between make4ht and tex4ebook, in order to support the same handling of options. But I forgot that I need to handle Unicode, which is used by default in tex4ebook, but with --unicode option in make4ht.

I've updated tex4ebook on Github and will update it on CTAN soon.

• Thank you for the fast response. It's much better but still I can't get epub3 - only epub2. – d3im Mar 31 '16 at 13:43
• ouh, try tex4ebook -f epub3 -t ebook.tex "html5,mathml,epub3 – michal.h21 Mar 31 '16 at 13:53
• it is another regression – michal.h21 Mar 31 '16 at 13:54
• check github now :) – michal.h21 Mar 31 '16 at 13:58
• Nice work! Now it produces epub3 but I noticed in real document conversion it has no correct order of pages (when it produced epub2 the order was correct) – d3im Mar 31 '16 at 14:11