| 1 |
\section{Introduction}\label{introduction} |
| 2 |
|
| 3 |
\texttt{TeX4ebook} is a tool for conversion from \LaTeX~to ebook |
| 4 |
formats, such as EPUB, MOBI and EPUB 3. It is based on |
| 5 |
\texttt{TeX4ht}\footnote{\url{https://tug.org/tex4ht/}}, which provides |
| 6 |
instructions for the actual \LaTeX~to HTML conversion, and on |
| 7 |
\texttt{make4ht}\footnote{\url{https://ctan.org/pkg/make4ht?lang=en}}. |
| 8 |
|
| 9 |
The conversion is focused on the logical structure of the converted |
| 10 |
document and metadata. Basic visual appearance is preserved as well, but |
| 11 |
you should use custom configurations if you want to make the document |
| 12 |
more visually appealing. You can include custom \texttt{CSS} or fonts in |
| 13 |
a configuration file. |
| 14 |
|
| 15 |
\texttt{TeX4ebook} supports the same features as \texttt{make4ht}, in |
| 16 |
particular build files and extensions. These may be used for |
| 17 |
post-processing of the generated HTML files, or to configure the image |
| 18 |
conversion. See the \texttt{make4ht} documentation to see the supported |
| 19 |
features. |
| 20 |
|
| 21 |
\section{Installation}\label{installation} |
| 22 |
|
| 23 |
\texttt{tex4ebook} is included in major \TeX~distributions such as |
| 24 |
\href{https://www.tug.org/texlive/}{\TeX~Live} and |
| 25 |
\href{https://miktex.org/}{MiKTeX}, so manual installation is usually |
| 26 |
not required. A working \TeX~distribution that includes |
| 27 |
\href{https://tug.org/tex4ht/}{\TeX4ht} is required to run |
| 28 |
\texttt{tex4ebook}, as it depends on \LaTeX~and various programs and |
| 29 |
packages provided by \TeX~distributions. |
| 30 |
|
| 31 |
You only need to install it manually if you want to use the development |
| 32 |
version. For detailed instructions, see the |
| 33 |
\href{./INSTALL.md}{\texttt{INSTALL.md}} file. |
| 34 |
|
| 35 |
\section{License}\label{license} |
| 36 |
|
| 37 |
Permission is granted to copy, distribute and/or modify this software |
| 38 |
under the terms of the LaTeX Project Public License, version 1.3. |
| 39 |
|
| 40 |
\section{Usage}\label{usage} |
| 41 |
|
| 42 |
Run on the command line: |
| 43 |
|
| 44 |
\begin{verbatim} |
| 45 |
tex4ebook [options] filename |
| 46 |
\end{verbatim} |
| 47 |
|
| 48 |
You don't have to modify your source files unless you want to use |
| 49 |
commands defined by \texttt{tex4ebook} in the document, or when your |
| 50 |
document uses a package which causes a compilation error. |
| 51 |
|
| 52 |
If you want to use \texttt{tex4ebook} commands, add this line to your |
| 53 |
document preamble: |
| 54 |
|
| 55 |
\begin{verbatim} |
| 56 |
\usepackage{tex4ebook} |
| 57 |
\end{verbatim} |
| 58 |
|
| 59 |
But it is optional. You shouldn't need to modify your \TeX~files |
| 60 |
|
| 61 |
\subsection{Available commands}\label{available-commands} |
| 62 |
|
| 63 |
\begin{itemize} |
| 64 |
\tightlist |
| 65 |
\item |
| 66 |
\texttt{\textbackslash{}coverimage{[}\textless{}graphicx\ options\textgreater{}{]}\{coverimage.name\}} |
| 67 |
-- include cover image to the document. You can pass the same options |
| 68 |
as to \texttt{\textbackslash{}includegraphics} command in the optional |
| 69 |
argument. |
| 70 |
\end{itemize} |
| 71 |
|
| 72 |
For example: |
| 73 |
|
| 74 |
\begin{verbatim} |
| 75 |
\thispagestyle{empty} |
| 76 |
\begin{document} |
| 77 |
\coverimage[scale=0.8]{coverimage.name} % include scaled cover image |
| 78 |
... |
| 79 |
\pagestyle{headings} |
| 80 |
\end{verbatim} |
| 81 |
|
| 82 |
\begin{itemize} |
| 83 |
\tightlist |
| 84 |
\item |
| 85 |
\texttt{\textbackslash{}epubpage} -- add page break to the document. |
| 86 |
\end{itemize} |
| 87 |
|
| 88 |
\section{Command line options}\label{command-line-options} |
| 89 |
|
| 90 |
\begin{description} |
| 91 |
\item[\texttt{-a,-\/-loglevel}] |
| 92 |
Set message log level. Possible values: debug, info, status, warning, |
| 93 |
error, fatal. Default: status. |
| 94 |
\item[\texttt{-c,-\/-config}] |
| 95 |
specify custom config file for \texttt{TeX4ht} |
| 96 |
\end{description} |
| 97 |
|
| 98 |
\textbf{example config file}: File \texttt{sample.cfg} |
| 99 |
|
| 100 |
\begin{verbatim} |
| 101 |
\Preamble{xhtml} |
| 102 |
\CutAt{section} |
| 103 |
\begin{document} |
| 104 |
\EndPreamble |
| 105 |
\end{verbatim} |
| 106 |
|
| 107 |
run |
| 108 |
|
| 109 |
\begin{verbatim} |
| 110 |
tex4ebook -c sample filename.tex |
| 111 |
\end{verbatim} |
| 112 |
|
| 113 |
This config file will create \texttt{xhtml} file for every section. Note |
| 114 |
that this behaviour is default. |
| 115 |
|
| 116 |
\begin{description} |
| 117 |
\item[\texttt{-e,-\/-build-file\ (default\ nil)}] |
| 118 |
Specify make4ht build file\footnote{\url{https://github.com/michal-h21/make4ht\#build-file}}. |
| 119 |
Default build file filename is \texttt{filename.mk4}, use this option if |
| 120 |
you use different filename. |
| 121 |
\item[\texttt{-f,-\/-format\ (default\ epub)}] |
| 122 |
Output format. Possible values are \texttt{epub}, \texttt{epub3}, |
| 123 |
\texttt{mobi}, \texttt{azw} and \texttt{azw3}. |
| 124 |
\item[\texttt{-j,-\/-jobname}] |
| 125 |
Specify the output file name, without file extension. |
| 126 |
\item[\texttt{-l,-\/-lua}] |
| 127 |
Use LuaLaTeX as TeX engine. |
| 128 |
\item[\texttt{-m,-\/-mode\ (default\ default)}] |
| 129 |
This set \texttt{mode} variable, accessible in the build file. Default |
| 130 |
supported values are \texttt{default} and \texttt{draft}. In |
| 131 |
\texttt{draft} mode, document is compiled only once, instead of three |
| 132 |
times. |
| 133 |
\item[\texttt{-s,-\/-shell-escape}] |
| 134 |
Enable shell escape in the \texttt{htlatex} run. This is necessary for |
| 135 |
the execution of the external commands from your source files. |
| 136 |
\item[\texttt{-t,-\/-tidy}] |
| 137 |
clean-up output HTML files using the \texttt{HTML\ tidy} |
| 138 |
command\footnote{if it is available on your system}. |
| 139 |
\item[\texttt{-x,-\/-xetex}] |
| 140 |
Use xelatex for document compilation |
| 141 |
\item[\texttt{-v,-\/-version}] |
| 142 |
Print the version number. |
| 143 |
\end{description} |
| 144 |
|
| 145 |
\section{Configuration}\label{configuration} |
| 146 |
|
| 147 |
\texttt{TeX4ebook} uses \texttt{TeX4ht}\footnote{\url{http://www.tug.org/tex4ht/}} |
| 148 |
for conversion from LaTeX to html. \texttt{TeX4ht} is highly |
| 149 |
configurable using config files. Basic config file structure is |
| 150 |
|
| 151 |
\begin{verbatim} |
| 152 |
\Preamble{xhtml, comma separated list of options} |
| 153 |
... |
| 154 |
\begin{document} |
| 155 |
... |
| 156 |
\EndPreamble |
| 157 |
\end{verbatim} |
| 158 |
|
| 159 |
Basic info about command configurations can be found in a |
| 160 |
work-in-progres \emph{TeX4ht tutorial}\footnote{\url{https://github.com/michal-h21/helpers4ht/wiki/tex4ht-tutorial}}, |
| 161 |
\emph{TeX4ht documentation}\footnote{\url{http://www.tug.org/applications/tex4ht/mn11.html}}, |
| 162 |
and in series of blogposts on CV Radhakrishnan's blog: \emph{Configure |
| 163 |
part 1}\footnote{\url{https://web.archive.org/web/20180908234227/http://www.cvr.cc/?p=323}}, |
| 164 |
\emph{Configure part 2}\footnote{\url{https://web.archive.org/web/20180908201057/http://www.cvr.cc/?p=362}}, |
| 165 |
\emph{Low level commands}\footnote{\url{https://web.archive.org/web/20180909101325/http://cvr.cc/?p=482}}. |
| 166 |
Available options for \texttt{\textbackslash{}Preamble} command are |
| 167 |
listed in the article \emph{TeX4ht: options}\footnote{\url{https://web.archive.org/web/20180813043722/http://cvr.cc/?p=504}}. |
| 168 |
\emph{Comparison of tex4ebook and Pandoc output}\footnote{\url{https://github.com/richelbilderbeek/travis_tex_to_epub_example_1}} |
| 169 |
|
| 170 |
A great source of tips for \texttt{TeX4ht} configuration is \emph{tex4ht |
| 171 |
tag on TeX.sx}\footnote{\url{http://tex.stackexchange.com/questions/tagged/tex4ht}}. |
| 172 |
There is also a \emph{tag for tex4ebook}\footnote{\url{http://tex.stackexchange.com/questions/tagged/tex4ebook}}. |
| 173 |
|
| 174 |
Examples of interesting questions are \emph{including images and fonts |
| 175 |
in ebooks}\footnote{\url{http://tex.stackexchange.com/a/213165/2891}} or |
| 176 |
\emph{setting image size in em units instead of pt}\footnote{\url{http://tex.stackexchange.com/a/195718/2891}}. |
| 177 |
|
| 178 |
\subsection{Provided configurations}\label{provided-configurations} |
| 179 |
|
| 180 |
\texttt{tex4ebook} provides some configurations for your usage: |
| 181 |
|
| 182 |
\begin{verbatim} |
| 183 |
\Configure{UniqueIdentifier}{identifier} |
| 184 |
\end{verbatim} |
| 185 |
|
| 186 |
Every EPUB file should have unique identifier, like ISBN, DOI, URI etc. |
| 187 |
Default identifier is URI, with value |
| 188 |
\texttt{http://example.com/\textbackslash{}jobname}. |
| 189 |
|
| 190 |
\begin{verbatim} |
| 191 |
\Configure{@author}{\let\footnote\@gobble} |
| 192 |
\end{verbatim} |
| 193 |
|
| 194 |
Local definitions of commands used in the |
| 195 |
\texttt{\textbackslash{}author} command. As contents of |
| 196 |
\texttt{\textbackslash{}author} are used in XML files, it is necessary |
| 197 |
to strip away any information which don't belongs here, such as |
| 198 |
\texttt{\textbackslash{}footnote}. |
| 199 |
|
| 200 |
\begin{verbatim} |
| 201 |
\Configure{OpfScheme}{URI} |
| 202 |
\end{verbatim} |
| 203 |
|
| 204 |
Type of unique identifier, default type is URI. It is used only in the |
| 205 |
EPUB format, it is deprecated for EPUB 3. |
| 206 |
|
| 207 |
\begin{verbatim} |
| 208 |
\Configure{resettoclevels}{list of section types in descending order} |
| 209 |
\end{verbatim} |
| 210 |
|
| 211 |
Configure section types which should be included in the \texttt{NCX} |
| 212 |
file. Default value is the whole document hierarchy, from |
| 213 |
\texttt{\textbackslash{}part} to \texttt{\textbackslash{}paragraph}. |
| 214 |
|
| 215 |
\begin{verbatim} |
| 216 |
\Configure{DocumentLanguage}{language code} |
| 217 |
\end{verbatim} |
| 218 |
|
| 219 |
Each EPUB file must declare the document language. It is inferred from |
| 220 |
\texttt{babel} main language by default, but you can configure it when |
| 221 |
it doesn't work correctly. The \texttt{language\ code} should be in |
| 222 |
\href{https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes}{ISO 639-1} |
| 223 |
form. |
| 224 |
|
| 225 |
\begin{verbatim} |
| 226 |
\Configure{CoverImage}{before cover image}{after cover image} |
| 227 |
\end{verbatim} |
| 228 |
|
| 229 |
By default, cover image is inserted in |
| 230 |
\texttt{\textless{}div\ class="cover-image"\textgreater{}} element, you |
| 231 |
may use this configuration option to insert different markup, or even to |
| 232 |
place the cover image to standalone page. |
| 233 |
|
| 234 |
\begin{verbatim} |
| 235 |
\Configure{CoverMimeType}{mime type of cover image} |
| 236 |
\end{verbatim} |
| 237 |
|
| 238 |
Default value is \texttt{image/png}, change this value if you use other |
| 239 |
image type than \texttt{png}. |
| 240 |
|
| 241 |
If you don't want to include the cover image in the document, use |
| 242 |
command |
| 243 |
|
| 244 |
\begin{verbatim} |
| 245 |
\CoverMetadata{filename} |
| 246 |
\end{verbatim} |
| 247 |
|
| 248 |
in the config file. |
| 249 |
|
| 250 |
\begin{verbatim} |
| 251 |
\Configure{OpfMetadata}{item element} |
| 252 |
\end{verbatim} |
| 253 |
|
| 254 |
Add item to \texttt{\textless{}metadata\textgreater{}} section in the |
| 255 |
\texttt{OPF} file. |
| 256 |
|
| 257 |
\begin{verbatim} |
| 258 |
\Configure{OpfManifest}{maifest element} |
| 259 |
\end{verbatim} |
| 260 |
|
| 261 |
Add item to \texttt{\textless{}manifest\textgreater{}} section in the |
| 262 |
\texttt{OPF} file. |
| 263 |
|
| 264 |
\begin{verbatim} |
| 265 |
\Configure{xmlns}{prefix}{uri} |
| 266 |
\end{verbatim} |
| 267 |
|
| 268 |
Add \texttt{XML} name space to the generated \texttt{XHTML} files. |
| 269 |
Useful in \texttt{EPUB\ 3}. |
| 270 |
|
| 271 |
\subsubsection{Example config file}\label{example-config-file} |
| 272 |
|
| 273 |
\begin{verbatim} |
| 274 |
\Preamble{xhtml} |
| 275 |
\begin{document} |
| 276 |
\Configure{DocumentLanguage}{de} |
| 277 |
% Use following lines if your document has ISBN: |
| 278 |
% \Configure{OpfScheme}{ISBN} |
| 279 |
% \Configure{UniqueIdentifier}{3-0000-1111-X} |
| 280 |
% Another possibility is URI that points for example to the ebook homepage: |
| 281 |
\Configure{OpfScheme}{URI} |
| 282 |
\Configure{UniqueIdentifier} |
| 283 |
{https://de.wikipedia.org/wiki/Der_achte_Schöpfungstag} |
| 284 |
\Configure{CoverMimeType}{image/jpeg} |
| 285 |
% If you don't use \coverimage in the document text, |
| 286 |
% add cover image using this command: |
| 287 |
\CoverMetadata{coverimage.jpg} |
| 288 |
% You can also add more authors to your ebook metadata: |
| 289 |
\Configure{OpfMetadata} |
| 290 |
{\HCode{<dc:publisher>Deutscher Bücherbund</dc:publisher>}} |
| 291 |
\Configure{OpfMetadata} |
| 292 |
{\HCode{<dc:contributor>Image Artist</dc:contributor>}} |
| 293 |
\Configure{OpfMetadata} |
| 294 |
{\HCode{<dc:contributor>Trans Lator</dc:contributor>}} |
| 295 |
\Configure{OpfMetadata} |
| 296 |
{\HCode{<dc:date opf:event='original-publication'>1888</dc:date>}} |
| 297 |
\EndPreamble |
| 298 |
\end{verbatim} |
| 299 |
|
| 300 |
Remarks: |
| 301 |
|
| 302 |
\begin{itemize} |
| 303 |
\tightlist |
| 304 |
\item |
| 305 |
Leading percent signs in the \texttt{.cfg} file introduce comments |
| 306 |
\item |
| 307 |
If the unique identifier is a URI which contains diacritical |
| 308 |
characters, the\\ |
| 309 |
equivalent HTML code needs to be inserted. \texttt{UTF8} is not |
| 310 |
recognized at that place. |
| 311 |
\item |
| 312 |
\texttt{UTF8} characters may be used in the \texttt{OpfMetadata} |
| 313 |
sections. |
| 314 |
\end{itemize} |
| 315 |
|
| 316 |
\subsection{\texorpdfstring{\TeX4ht |
| 317 |
options}{4ht options}}\label{ht-options} |
| 318 |
|
| 319 |
\TeX4ht supports lot of options, that change produced HTML code without |
| 320 |
need to use configurations. Their list is available in the |
| 321 |
\href{https://www.kodymirus.cz/tex4ht-doc/texfourhtOptions.html}{\TeX4ht |
| 322 |
documentation}. You can pass options to \texttt{tex4ebook} in the |
| 323 |
argument that follows filename: |
| 324 |
|
| 325 |
\begin{verbatim} |
| 326 |
tex4ebook filename.tex "option1,option2" |
| 327 |
\end{verbatim} |
| 328 |
|
| 329 |
Alternatively, they can be put in the \texttt{\textbackslash{}Preamble} |
| 330 |
command in the config file: |
| 331 |
|
| 332 |
\begin{verbatim} |
| 333 |
\Preamble{xhtml,option1,option2} |
| 334 |
\end{verbatim} |
| 335 |
|
| 336 |
\subsubsection{\texorpdfstring{Options provided by |
| 337 |
\texttt{tex4ebook}}{Options provided by tex4ebook}}\label{options-provided-by-tex4ebook} |
| 338 |
|
| 339 |
\begin{description} |
| 340 |
\item[\texttt{no-cut}] |
| 341 |
By default \texttt{tex4ebook} splits document to separate HTML pages on |
| 342 |
\texttt{\textbackslash{}chapter} command when it is available. |
| 343 |
Othervise, it splits on \texttt{\textbackslash{}section}. This can be |
| 344 |
changed using the \texttt{\textbackslash{}CutAt} command or numeric |
| 345 |
options, but you need to use the \texttt{no-cut} option to prevent fatal |
| 346 |
error. |
| 347 |
\end{description} |
| 348 |
|
| 349 |
\subsection{Commands available in the config |
| 350 |
file}\label{commands-available-in-the-config-file} |
| 351 |
|
| 352 |
\begin{description} |
| 353 |
\item[\texttt{\textbackslash{}OpfRegisterFile{[}filename{]}}] |
| 354 |
register file in the \texttt{OPF} file. Current output file is added by |
| 355 |
default. |
| 356 |
\item[\texttt{\textbackslash{}OpfAddProperty\{property\ type\}}] |
| 357 |
add \texttt{EPUB3} property for the current file. See \emph{EPUB3 |
| 358 |
spec}\footnote{\url{http://www.idpf.org/epub/301/spec/epub-publications.html\#sec-item-property-values}} |
| 359 |
\item[\texttt{\textbackslash{}OpfGuide{[}filename{]}\{title\}\{type\}}] |
| 360 |
Add file to the \texttt{\textless{}guide\textgreater{}} section in the |
| 361 |
\texttt{OPF} file. See \emph{Where do you start an ePUB and what is the |
| 362 |
\texttt{\textless{}guide\textgreater{}} section of the \texttt{.OPF} |
| 363 |
file?}\footnote{\url{http://epubsecrets.com/where-do-you-start-an-epub-and-what-is-the-guide-section-of-the-opf-file.php}} |
| 364 |
for some details. Note that \texttt{\textless{}guide\textgreater{}} is |
| 365 |
deprecated in \texttt{EPUB\ 3}. |
| 366 |
\end{description} |
| 367 |
|
| 368 |
\subsection{Build files}\label{build-files} |
| 369 |
|
| 370 |
\texttt{tex4ebook} uses \texttt{make4ht}\footnote{\url{https://github.com/michal-h21/make4ht}} |
| 371 |
as a build system. It provides support for build files written in Lua. |
| 372 |
These build files can be used to call additional commands, like |
| 373 |
Bib\TeX~or Makeindex, post-process generated HTML files, change the way |
| 374 |
how images are created, or to modify parameters of the conversion. |
| 375 |
|
| 376 |
Sample build file can look like this: |
| 377 |
|
| 378 |
\begin{verbatim} |
| 379 |
if mode=="draft" then |
| 380 |
Make:htlatex {} |
| 381 |
else |
| 382 |
Make:htlatex {} |
| 383 |
Make:htlatex {} |
| 384 |
Make:htlatex {} |
| 385 |
end |
| 386 |
|
| 387 |
Make:image("png$", |
| 388 |
"dvipng -bg Transparent -T tight -o ${output} -D 170 -pp ${page} ${source}") |
| 389 |
\end{verbatim} |
| 390 |
|
| 391 |
The \texttt{mode} variable holds value of the \texttt{-\/-mode} argument |
| 392 |
to \texttt{tex4ebook}. The \texttt{draft} mode is used for faster |
| 393 |
compilation, it calls LaTeX only once. |
| 394 |
|
| 395 |
The \texttt{Make:image} function can configure handling of images |
| 396 |
created by extraction from the DVI file. It can be complex math, TikZ or |
| 397 |
PSTricks pictures, and so on. The |
| 398 |
\texttt{\$\{\textless{}name\textgreater{}\}} placeholders are filled by |
| 399 |
\texttt{tex4ebook} with parameters like current page number of the image |
| 400 |
DVI file, or output image name. |
| 401 |
|
| 402 |
You can compile your document with a build file using the \texttt{-e} |
| 403 |
option: |
| 404 |
|
| 405 |
\begin{verbatim} |
| 406 |
tex4ebook -m draft -e build.lua filename.tex |
| 407 |
\end{verbatim} |
| 408 |
|
| 409 |
See \texttt{make4ht} documentation for more details on configuration |
| 410 |
files. |
| 411 |
|
| 412 |
\subsection{\texorpdfstring{\texttt{.tex4ebook} configuration |
| 413 |
file}{.tex4ebook configuration file}}\label{tex4ebook-configuration-file} |
| 414 |
|
| 415 |
\texttt{tex4ebook} supports a default build file, which is loaded |
| 416 |
automatically without need to use the \texttt{-e} option. |
| 417 |
|
| 418 |
\subsubsection{Location}\label{location} |
| 419 |
|
| 420 |
The configuration file can be saved either in |
| 421 |
\texttt{\$HOME/.config/tex4ebook/config.lua} or in \texttt{.tex4ebook} |
| 422 |
in the current directory or it's parents (up to \texttt{\$HOME}). |
| 423 |
|
| 424 |
See the \texttt{make4ht} documentation for an example and more |
| 425 |
information. |
| 426 |
|
| 427 |
\section{Troubleshooting}\label{troubleshooting} |
| 428 |
|
| 429 |
\subsection{Kindle formats}\label{kindle-formats} |
| 430 |
|
| 431 |
\texttt{tex4ebook} uses \texttt{kindlegen} command for the conversion to |
| 432 |
Kindle formats (\texttt{mobi}, \texttt{azw} and \texttt{azw3}). |
| 433 |
Unfortunatelly, Amazon discontinued this command, so we use also |
| 434 |
\texttt{ebook-convert} provided by Calibre if \texttt{kindlegen} fails. |
| 435 |
|
| 436 |
\subsection{Fixed layout EPUB}\label{fixed-layout-epub} |
| 437 |
|
| 438 |
The basic support for the Fixed layout EPUB 3 can be enabled using the |
| 439 |
following configurations: |
| 440 |
|
| 441 |
\begin{verbatim} |
| 442 |
\Configure{OpfMetadata} |
| 443 |
{\HCode{<meta property="rendition:layout">pre-paginated</meta>}} |
| 444 |
\Configure{OpfMetadata} |
| 445 |
{\HCode{<meta property="rendition:orientation">landscape</meta>}} |
| 446 |
\Configure{OpfMetadata} |
| 447 |
{\HCode{<meta property="rendition:spread">none</meta>}} |
| 448 |
\Configure{@HEAD} |
| 449 |
{\HCode{<meta name="viewport" content="width=1920, height=1080"/>\Hnewline}} |
| 450 |
\end{verbatim} |
| 451 |
|
| 452 |
Modify the dimensions in the |
| 453 |
\texttt{\textless{}meta\ name="viewport\textgreater{}} element according |
| 454 |
to your needs. |
| 455 |
|
| 456 |
\subsection{Math issues}\label{math-issues} |
| 457 |
|
| 458 |
Note that while \texttt{mobi} is supported by Amazon Kindle, most |
| 459 |
widespread ebook reader, it doesn't support \texttt{MathML}. This means |
| 460 |
that math must be represented as images. The same issue is true for the |
| 461 |
EPUB format as well. This is problematic especially for the inline math, |
| 462 |
as you may experience wrong vertical alignment of the math content and |
| 463 |
surrounding text. If your ebook contains math, a better solution is to |
| 464 |
produce the \texttt{epub3} format, as it supports \texttt{MathML}. The |
| 465 |
issue with EPUB 3 is that majority of \texttt{e-ink} ebook readers don't |
| 466 |
support it. Reader applications exists mainly for Android and Apple |
| 467 |
devices. For books which contains mainly prose, all formats should be |
| 468 |
suitable, but EPUB 3 supports most features from web standards, such as |
| 469 |
\texttt{CSS}. |
| 470 |
|
| 471 |
\subsection{Compilation errors}\label{compilation-errors} |
| 472 |
|
| 473 |
When compilation of the document breaks with error during \texttt{LaTeX} |
| 474 |
run, it may be caused by some problem in \texttt{TeX4ht} configuration. |
| 475 |
Comment out line \texttt{\textbackslash{}usepackage\{tex4ebook\}} in |
| 476 |
your source file and run command: |
| 477 |
|
| 478 |
\begin{verbatim} |
| 479 |
htlatex filename |
| 480 |
\end{verbatim} |
| 481 |
|
| 482 |
if same error as in \texttt{tex4ebook} run arises, the problem is in |
| 483 |
some \texttt{TeX4ht} configuration. Try to identify the source of |
| 484 |
problem and if you cannot find the solution, make minimal example |
| 485 |
showing the error and ask for help either on \emph{TeX4ht mailing |
| 486 |
list}\footnote{\url{http://tug.org/mailman/listinfo/tex4ht}} or on |
| 487 |
\emph{TeX.sx}\footnote{\url{http://tex.stackexchange.com/}}. |
| 488 |
|
| 489 |
\subsection{Validation}\label{validation} |
| 490 |
|
| 491 |
In case of successful compilation, use command line tool |
| 492 |
\texttt{epubcheck}\footnote{you need to install it separately, see |
| 493 |
\url{https://github.com/IDPF/epubcheck}} to check whether your |
| 494 |
document doesn't contain any errors. |
| 495 |
|
| 496 |
Type |
| 497 |
|
| 498 |
\begin{verbatim} |
| 499 |
epubcheck filename.epub |
| 500 |
\end{verbatim} |
| 501 |
|
| 502 |
\subsubsection{Common validation |
| 503 |
issues:}\label{common-validation-issues} |
| 504 |
|
| 505 |
\begin{itemize} |
| 506 |
\tightlist |
| 507 |
\item |
| 508 |
WARNING: filename.epub: item (OEBPS/foo.boo) exists in the zip file, |
| 509 |
but is not declared in the OPF file |
| 510 |
\end{itemize} |
| 511 |
|
| 512 |
Delete the |
| 513 |
\texttt{filename-(epub\textbar{}epub3\textbar{}mobi\textbar{}azw\textbar{}azw3)} |
| 514 |
folder and \texttt{filename.epub}. Then run \texttt{tex4ebook} again. |
| 515 |
|
| 516 |
\begin{itemize} |
| 517 |
\item |
| 518 |
WARNING(ACC-009): hsmmt10t.epub/OEBPS/hsmmt10tch17.xhtml(235,15): |
| 519 |
MathML should either have an alt text attribute or annotation-xml |
| 520 |
child element. |
| 521 |
|
| 522 |
This is accessibility message. Unless you use some macro with |
| 523 |
annotations for each math instance, you will get lot of these |
| 524 |
messages. Try to use \texttt{epubcheck\ -e} to print only serious |
| 525 |
errors. |
| 526 |
\end{itemize} |