6

I'm trying TeX4ebook on the following minimal LaTeX file:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{csquotes}

\title{Título}
\author{Autor}
\date{Fecha}

\begin{document}

\maketitle

\textquote{¡Hola, mundo!}
áéíóúÁÉÍÓÚüÜñÑ.

\end{document}

Accented characters appear in the epub file as á´aé´eí´ıó´oú´uÁ´AÉ´EÍ´IÓ´OÚ´UüÜñ˜nјN. Umlauts are fine.

Here's a screenshot of the epub file from the Calibre viewer.

Following the suggestions on this question, I'm calling tex4ebook with the following options:

tex4ebook -t tex4ebook-test-spanish.tex "html5,charset=utf-8" " -cunihtf -utf8"

All messages from tex4ebook seem to be fine:

[STATUS]  tex4ebook: Conversion started
[STATUS]  tex4ebook: Input file: tex4ebook-test-spanish.tex
HTML Tidy for Linux version 5.6.0
[STATUS]  tex4ebook: Conversion finished

I'm using the TeXLive version that comes packaged with Ubuntu 20.04.

1 Answer 1

8

You definitely don't need to provide "html5,charset=utf-8" " -cunihtf -utf8" to tex4ebook, as it creates UTF-8 encoded documents by default. The html5 option may even cause issues, as Epub 2 expects XHTML documents, not HTML 5. This shouldn't be a issue in most cases though.

It seems that the character decomposition is caused by Babel. You have two options:

  • use LuaLaTeX for the compilation
  • use an explicit call to the Fontenc package

Easiest for you should be to use LuaLaTeX. Try to add the -l option to your tex4ebook call:

tex4ebook -l -t tex4ebook-test-spanish.tex

If this doesn't work for your real document, you can add the Fontenc package:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{csquotes}

\title{Título}
\author{Autor}
\date{Fecha}

\begin{document}

\maketitle

\textquote{¡Hola, mundo!}
áéíóúÁÉÍÓÚüÜñÑ.

\end{document}

You don't need the -l option in this case.

Either way, it should produce this result:

enter image description here

1
  • I tried the LuaLaTeX and the fontenc options (separately) and they both work like a charm. Thanks!
    – nemarona
    Commented Nov 15, 2020 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .