% [![Build Status](https://travis-ci.org/michal-h21/tex4ebook.svg?branch=master)](https://travis-ci.org/michal-h21/tex4ebook) # Introduction `TeX4ebook` is bundle of Lua scripts and `LaTeX` packages for conversion of LaTeX files to ebook formats, for example `epub`, `mobi` and `epub3`. `tex4ht` is used as conversion engine. Note that while `mobi` is supported by Amazon Kindle, most widespread ebook reader, it doesn't support `mathml` and this means that math must re represented as images. The same is true for `epub`. This is not a good thing, especially for inline math, as you may experience wrong baselines. If your ebook contains math, the only correct solution is to produce `epub3`, as it supports `mathml`. The issue with `epub3` is, that majority of `e-ink` ebook readers doesn't support this format, reader applications exists mainly for Android and Apple devices. For books which contains mainly prose, all formats should be suitable, but `epub3` supports most features from web standards, such as `CSS`. As with `tex4ht`, the emphasis is on conversion of document's logical structure and metadata, basic visual appearance is preserved as well, but you should use custom configurations if you want to make the document more visually appealing. You can include custom `CSS` or fonts in configuration files. ## License Permission is granted to copy, distribute and/or modify this software under the terms of the LaTeX Project Public License, version 1.3. # Usage Run on the command line: tex4ebook [options] filename You don't have to modify your source files unless you want to use commands defined by `tex4ebook` in the document, or when your document uses some unsupported package like `fontspec` (see details bellow how to solve this issue). If you want to use `tex4ebook` commands, add this line to your document preamble: \usepackage{tex4ebook} but it is optional. You shouldn't need to modify your \TeX\ files ## Available commands - `\coverimage{coverimage.name}` - include cover image to the document. # Command line options `-c,--config` : specify custom config file for `tex4ht` **example config file**: File `sample.cfg` \Preamble{xhtml} \CutAt{section} \begin{document} \EndPreamble run tex4ebook -c sample filename.tex This config file will create `xhtml` file for every section. Note that this behaviour is default. `-e,--build-file (default nil)` : Specify make4ht build file^[https://github.com/michal-h21/make4ht#build-file]. Defaulf build file filename is `filename.mk4`, use this option if you use different filename. `-f,--format (default epub)` : Output format. epub, epub3 and mobi are supported. `-l,--lua` : Runs htlualatex instead of htlatex. `-m,--mode (default default)` : This set `mode` variable, accessible in the build file. Default supported values are `default` and `draft`. In `draft` mode, document is compiled only once, instead of three times. `-r,--resolution` : Resolution of generated images, for example math. It should meet resolution of target devices, which is usually about 167 ppi. `-s,--shell-escape` : Enable shell escape in htlatex run. This may be needed if you run external commands from your source files. `-t,--tidy` : process output html files with `HTML tidy` command^[It needs to be installed separately]. `-v,--version` : print version number # Configuration `tex4ebook` uses `tex4ht`^[http://www.tug.org/tex4ht/] for conversion from LaTeX to html. `tex4ht` is highly configurable using config files. Basic config file structure is \Preamble{xhtml, comma separated list of options} ... \begin{document} ... \EndPreamble Basic info about command configurations can be found in a work-in-progres *tex4ht tutorial*^[https://github.com/michal-h21/helpers4ht/wiki/tex4ht-tutorial] , *tex4ht documentation*^[http://www.tug.org/applications/tex4ht/mn11.html], and in series of blogposts on CV Radhakrishnan's blog: *Configure part 1*^[http://www.cvr.cc/?p=323], *Configure part 2*^[http://www.cvr.cc/?p=362], *Low level commands*^[http://www.cvr.cc/?p=482]. Available options for `\Preamble` command are listed in the article *TeX4ht: options*^[http://www.cvr.cc/?p=504]. *Comparison of tex4ebook and Pandoc output*^[https://github.com/richelbilderbeek/travis_tex_to_epub_example_1] Great source of tips for `tex4ht` configuring is *tex4ht tag on TeX.sx*^[http://tex.stackexchange.com/questions/tagged/tex4ht], there is also a *tag for tex4ebook*^[http://tex.stackexchange.com/questions/tagged/tex4ebook]. Examples of interesting questions are *including images and fonts in ebooks*^[http://tex.stackexchange.com/a/213165/2891] or *setting image size in em units instead of pt*^[http://tex.stackexchange.com/a/195718/2891]. ## Provided configurations `tex4ebook` provides some configurations for your usage: \Configure{UniqueIdentifier}{identifier} Every epub file should have unique identifier, like ISBN, DOI, URI etc. Default identifier is URI, with value `http://example.com/\jobname`. \Configure{OpfScheme}{URI} Type of unique identifier, default type is URI. It is used only in epub, it is deprecated for `epub3` \Configure{resettoclevels}{list of section types in descending order} Configure section types which should be included in the `NCX` file. Default value is the whole document hiearchy, from `\part` to `\paragraph`. \Configure{DocumentLanguage}{language code} Each epub must declare the document language. It is inferred from `babel` main language by default, but you can configure it when it doesn't work correctly. The `language code` should be in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) form. \Configure{CoverImage}{before cover image}{after cover image} By default, cover image is inserted in `