I've overheard mention of LaTeX being used for the production of eBooks. I'm thinking that it's in reference to producing small pages of a fixed size, say 7", fixed type size, say 8pt, for reading pdf files on the ever more popular Tablet Computers, but not particularly the eInk eReaders that have even smaller screens than that and primarily use ePub, Mobi or Kindle formats.
On second thought, I figured I could be wrong about that. It seems like a programmer could more easily create a LaTeX compiler (a hypothetical alternative to pdfLaTeX) that instead generates epub, mobi or something else I don't know about, which flows to the size of the eReader screen, and resizes to the preferred font size its reader likes.
Has that already been done for those who'd love to use LaTeX for reflowable eBooks, but NOT pdf eBooks?
Best Answer
tex4ebook can be used for LaTeX to ebook formats conversion. It supports
epub
,epub3
andmobi
formats.I've had some presentations about it last year, slides in Czech are online, as well as source code of examples. Examples include sample code and results, so they are interesting even when you don't understand Czech.
Default look is rather plain and basic, you need to use custom CSS to add some custom design. Maybe use some CSS framework which supports responsive design, it is important in order to support devices with various screen sizes. The CSS can be added in the
.cfg
file, such as this one:packages
include4ht
andaddfont4ht
are part of helpers4ht bundle, which isn't on CTAN yet. They provide commands\AddCss
for adding custom CSS (scale.css in this case), and\NormalFont
,\BoldFont
and\ItalicFont
, which add custom fonts in.woff
format. All needed files can be found in previously linked repository with examples for my presentation.this code declares included
EBGaramond
font to be used in the document, it needs to be included after all otherCSS
code, so we must use this special construct to insert something into HTML header.Unfortunately all these features (custom fonts, responsive CSS etc.) supports only
epub3
format. You can compile your TeX file using commandYou can see example of TeX file converted using this converter and styled with
scale.css
here