33

Does anyone know whether there is an organized effort to develop (La)TeX classes/packages specifically designed to create ereader-friendly PDFs?

My question is not how to create such PDFs using LaTeX, since Lev Bishop provides a fine summary of currently available methods in an answer to this question.

Edit: Would it be feasible to generate usable epub (or [insert your favorite eBook format here]) documents using LaTeX? I'm not very familiar with how epub documents/readers manage font-scaling, etc. If so, is there a project to create a program that would do this?

Also, I leave ereader-friendly open to your interpretation, but some features I had in mind are

  • ereader-specific page sizes (with small margins by default);
  • increased minimum font size;
  • a font thicker than CM (by default).
3
  • Feel free to edit the tags.
    – Z Norwood
    Apr 22, 2011 at 0:09
  • Read this on how to create ebooks from a tex file: d800fotos.wordpress.com/2015/01/19/…
    – user70857
    Jan 20, 2015 at 16:22
  • No idea if this approach is useful at all ( I never made ebooks), but for the record: pandoc allow convert LaTeX to epub and epub3 formats.
    – Fran
    Nov 23, 2018 at 7:14

5 Answers 5

17

I compile my ebooks (tested and liked on both Sony Reader and Kindle) in XeLaTeX with this preamble:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Cochin}

\usepackage[papersize={4.5in,6in},margin=0.5cm]{geometry}
\setlength{\parskip}{2pt}

\usepackage{fourier-orns}
\newcommand\textbreak{%
  \begin{center}%
  \decothreeleft \aldineleft \decosix \aldineright \decothreeright%
  \end{center}}

\pagestyle{empty}
\usepackage[pdfauthor={AUTHOR},pdftitle={TITLE}]{hyperref}

\begin{document}

As a result, I get small pages, with small margins, a really nice font, pleasant to read, and embedded in the PDF, and the PDF metadata set so that it shows up nicely in the e-reader book listing.

5
  • I'm not very familiar with XeLaTeX; can anything in this preamble not be done with LaTeX?
    – Z Norwood
    Apr 22, 2011 at 23:48
  • \setmainfont{Cochin} is really hard to get done in LaTeX: XeLaTeX gives you easy access to TrueType and OpenType fonts. Of course, if you've a favourite font in LaTeX, you don't particularly need XeLaTeX. Apr 27, 2011 at 16:22
  • 1
    Your answer works like a charm in concert with this: tex.stackexchange.com/questions/11059/…
    – andsens
    Dec 28, 2012 at 15:38
  • Can you please explain the effect (and use) of \usepackage{fourier-orns}? For that command alone I have to install a ~600MB package; also, Cochin font seems to be rather difficult to obtain on a GNU/Linux system. Can you provide an alternative? Jan 27, 2017 at 9:23
  • fourier-orns provides text ornaments that I used to build the \textbreak code black. If you don't want Cochin, pick some other TTF you have, and replace its name. Jan 28, 2017 at 13:25
9

Tuning font size, font family and margins are easy things to achieve in LaTeX.

For example, using scrbook, you can set the paper size, font size, and reduce the margins by playing with the DIV parameter:

\documentclass[paper=6in:9in,DIV=calc,12pt]{scrbook}

You can set the value of DIV manually to fit your needs. DIV represents the space allocated to the text in your page, so the bigger the value, the smaller the margin. Standard calculated values are listed in the Koma-Script documentation.

You can even set your margins manually. For example, I have a 6in:9in document with a 0.50in margin, a 0.50in binding correction to apply and a 0.125in mandatory bleed, so I set:

% Paper width
% W = 6.125in (6+0.125 --- bleed)
% Paper height
% H = 9.25in (9+2*.125 --- bleed)
% Paper gutter
% BCOR = 0.375in (0.5+0.5-0.625 --- margin with bleed)
% Margin (0.5in imposed on lulu, recommended on createspace)
% m = 0.625in (0.5+0.125 --- bleed)
% Text height
% h = H - 2m = 8in
% Text width
% w = W - 2m - BCOR = 4.5in
\areaset[0.375in]{4.5in}{8in}

As far as choosing fonts go, you can already switch to Latin Modern, which is a bit nicer than Computer Modern (de gustibus et coloribus...):

\usepackage{lmodern}

and then there's a lot of nice Type1 or OpenType fonts that can be used, too. pdf(la)tex embeds fonts in PDF documents, so there's no real limit to what you can do.

1
  • we have checked with \documentclass[paper=6in:9in,DIV=calc,12pt]{scrbook} and it is working. However, with \documentclass[paper=6in:9in,DIV=calc,14pt]{scrbook} it is more comforting to the eyes. We have compiled the TeX document with xelatex and pdflatex. Nov 22, 2018 at 5:56
6

See also this; in particular, Peter Flynn references a mailing list devoted to the topic.

1
  • Great link---thanks. Apparently there is a TUG11 conference on "LaTeX and eBooks."
    – Z Norwood
    Apr 22, 2011 at 23:46
6

The package ebook can actually export a file specialized for phones (font, position, spacing, etc). Reducing the pagesize of templates specialized for wide screens/books isn't much quicker than this:

\documentclass{...}
\usepackage{ebook}
...
\begin{document}
\ebook    %  be careful if not the first command
...
\end{document}

enter image description here

It can easily be switched back by commenting out \ebook. Compiling with XeLaTeX gives better result than pdfLaTeX (I don't know why).

2

As has been noted in other responses, and in links provided, it is easy enough to shrink margins and choose better fonts. However, the PDF reader software, available on phones and other devices, may have shortcomings. I can read PDF on my old iPod Touch v4 (yes, v4) using the Foxit app. Tiny screen, but works.

One general problem is that, in most cases, TeX does not place the space characters in the PDF. Words are separated by distance between them, not by an intervening space character. Some PDF readers understand that the distance is to be interpreted as a space, but others do not. This makes a big difference if the file is to be audibly read by having software parse the words. It also makes a big difference if the document is allowed to reflow, rather than simply zooming in by scale. Some software allows you to "force" reflow in PDF files that are not themselves set for reflow.

Currently, compiling with pdfLaTeX allows you to specify that spaces will be placed (they are drawn from a special font). But LuaLaTeX does not have this capability. I do not know about XeTeX.

Keep in mind that, as small screen size, the typographic merits of TeX will largely be obliterated. With reflow, they will actually be ignored. The main reason for using TeX for an ebook PDF is if you need equations and diagrams. But if the book is primarily text, you are better off simply doing it directly in XHTML (which converts easily to native ebook formats, rather than PDF). In this case, you will have little control over fonts, and even less control over typography.

Also, if your purpose is to sell licensed copies of your writing, then it will need to be in the ebook format marketed by the major providers. There is no easy way to attach DRM to a PDF (not for amateurs, that is). Existing methods either involve special software or a special server, and are a bit of a nuisance to general readers.

You must log in to answer this question.

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