92

I was wondering if there are any good settings to produce a PDF suitable for reading on a (6 inch) kindle. Main use is for intermediate reading of academic papers while they are being written:

  1. Text needs to be large enough to be readable.
  2. Equations need to be readable.
  3. I don't care much what happens to the figures. They may appear on a separate page

I prefer a solution with 3 files for every project, one which contains the text and equations (paper), one which compiles to standard format, and one which compiles to kindle friendly format.

2

8 Answers 8

79

Here's a plan:

Create a kindle-friendly preamble (or a document class)

  • Redefine your page geometry to match your screen ratio (geometry package)
  • Remove most of the margins (also with geometry)
  • Remove or resize headers and footers (perhaps with fancyhdr)
  • Enlarge text until it is readable to you (depends on which TeX friend you are using)
  • Choose appropriate (legible) fonts (depends on which TeX friend you are using)
  • Redefine you section titles to smaller spacing (titlesec package)
  • Reduce other spacing as well (various lenghts like \abovecaptionskip)

Don't use absolute sizes in your documents:

  • Rescale your figures to fit factor\textwidth
  • Mathematics should automatically break at the end of the line (breqn package might help)

If you didn't create a document class:

  • Extract your document content (textbody) to a content-file
  • \include{content-file} after the \begin{document}

If you created a document class, you will just have to change your class before compiling.

Possible result

Kindle pdf result

The figure is the result of the following code:

\documentclass[10pt]{article}

\usepackage{fontspec}      % font selection
\setmainfont{Cambria}
\usepackage{breqn}         % automatic equation breaking
\usepackage{microtype}     % microtypography, reduces hyphenation
\usepackage{polyglossia}   % language selection
\setmainlanguage{english}

\usepackage{graphicx}      % graphics support

\usepackage[font=small,labelformat=simple,]{caption}   % customizing captions

\usepackage{titlesec}      % customizing section titles
\titleformat{\section}{\itshape\large}{}{0em}{}
\titlespacing{\section}{0pt}{8pt}{4pt}
\titleformat{\subsection}{\itshape}{}{0em}{}
\titlespacing{\subsection}{0pt}{4pt}{2pt}
\titleformat{\subsubsection}[runin]{\bf\scshape}{}{0em}{}
\titlespacing{\subsubsection}{0pt}{5pt}{5pt}

\usepackage[papersize={3.6in,4.8in},hmargin=0.1in,vmargin={0.1in,0.1in}]{geometry}  % page geometry

\usepackage{fancyhdr}   % headers and footers
\pagestyle{fancy}
\fancyhead{}            % clear page header
\fancyfoot{}            % clear page footer

\setlength{\abovecaptionskip}{2pt} % space above captions 
\setlength{\belowcaptionskip}{0pt} % space below captions
\setlength{\textfloatsep}{2pt}     % space between last top float or first bottom float and the text
\setlength{\floatsep}{2pt}         % space left between floats
\setlength{\intextsep}{2pt}        % space left on top and bottom of an in-text float

\begin{document}

In another moment down went Alice after it, never once considering how in the world she was to get out again.

\section{Wonderful section title}

Either the well was very deep, or she fell very slowly, for she had plenty of time as she went down to look 
\begin{figure}[htb]
\includegraphics[width=\textwidth]{alice}
\caption{Quite wide picture, resized to fit}
\end{figure}
about her and to wonder what was going to happen next.

\subsection{Tufte-style subsection}

then she looked at the sides of the well

\subsubsection{Saving space running in} and noticed that they were filled with cupboards and book\-shel\-ves. 

\begin{dmath}[label={sna74}]
\frac{1}{6} \left(\sigma(k,h,0) +\frac{3(h-1)}{h}\right)
+\frac{1}{6} \left(\sigma(h,k,0) +\frac{3(k-1)}{k}\right)
=\frac{1}{6} \left(\frac{h}{k} +\frac{k}{h} +\frac{1}{hk}\right)
+\frac{1}{2} -\frac{1}{2h} -\frac{1}{2k},
\end{dmath}

\end{document}

Different font sizes can be easily selected using fontspec.

12
  • 30
    Last step: don’t forget to document and release your document class on CTAN. Commented Apr 27, 2011 at 10:35
  • 1
    @willem: I added using breqn package for automatic line breaking in math typesetting to the answer.
    – ipavlic
    Commented Apr 27, 2011 at 11:54
  • 2
    This is also a good read: mobileread.com/forums/showthread.php?t=107585
    – willem
    Commented Apr 28, 2011 at 13:08
  • 2
    @ipavlic silly question, but this presumably doesn't produce reflow-able text. Is there a way to do that?
    – snim2
    Commented Jan 24, 2012 at 13:22
  • 2
    @snim2 If there is, I don't know of such a way. As far as I know, postscript and pdf are absolutely positioned documents, best suited for printing. Latex is a system that makes fine adjustments at "compile time" to produce beautifully positioned (typeset) document elements for the required output. Short of having a latex distribution of some sort on your e-reader, I don't really see how that might work. It would be something of a square peg in a round hole to do so anyway -- most e-readers have nice e-reading software that reads a suitable format (often xml-backed) and reflows it nicely.
    – ipavlic
    Commented Jan 24, 2012 at 14:20
15

While ipavlic's answer works more than fine, what is below does not require fontspec and breqn and is somewhat more minimalistic. Based on this thread, with a few tweaks that improve it's working with formulas (in my opinion). Very long formulas still partly disappear, and it does not work with tables. Figures are fine though, as long as they are included using relative width as in ipavlic's answer.

\documentclass[12pt]{article}  
\usepackage[papersize={108mm,144mm},margin=2mm]{geometry}  
\sloppy 
\pagestyle{empty} 
\usepackage[scaled]{helvet}
\renewcommand{\familydefault}{\sfdefault}
8

I created some files for my Sony ebook reader. My final solution was to actually create ebooks from these papers. While it is possible from PDF - equations typically didn't survive this process.

The solution with best results for me was to create the document as HTML (can be done with latex2html) with the equations and figures as PNG files. This converts nicely.

As converter from HTML to ebook I used calibre.

Both utilities have a command line interface and could be put in your makefile.

Thinking about the kindle - maybe it is also possible to upload the HTML directly. Also I'm not sure - maybe it also supports MathML - which might lead to even nicer looking equations.

4

Another option would be to use Pandoc to convert your LaTeX to EPUB. This would be reflowable, and would work on different sized readers without adjustment. Equations are handled quite nicely.

2
  • Have you tried this? From my past experience, Pandoc does not do well converting from LaTeX (for example, it would discard figures and captions). I don't think it handled custom definitions either. Hopefully it has improved?
    – Jonathan
    Commented Sep 27, 2014 at 19:26
  • 1
    I've converted LaTeX to EPUB, although it's not something I do a lot. You're right that figures are tricky. I'd be very interested in a neat solution to the problem. This filter might be a start: github.com/jgm/pandocfilters/blob/master/examples/tikz.py (I haven't tried it.)
    – twsh
    Commented Sep 29, 2014 at 8:29
4

Not yet mentioned here: tex4ebook:

from 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.

If you want to use tex4ebook commands, add this line to your document preamble:

\usepackage{tex4ebook}

but it is optional. There's no need to modify your TeX files.

3

I had the same problem. I use Xelatex compilator. And I upload my .pdf to Amazon KDP. My margins were too big. The result was hardly readable at Kindle format/size.

I highly recommand to test the replacement of

\documentclass[ebook,13pt,a5paper]{book}

by

\documentclass[ebook,a6paper]{book}
\usepackage[left=0.5cm,right=0.5cm,top=2cm,bottom=2cm]{geometry}

It solved my problem. Regards Olivier

2

Main advises:

  • Use a6paper in geometry option list, this may be the designed paper size for 6 inch Kindle.
  • Remove all header/foot utils, they just waste spaces for the 6 inch kindle.
  • Use relative width value for all width settings, especially environment related, i.e., for Figure, use .9/textwidth is a good trying, and you may find let this constant setting in your new environment is a good tip.
  • For code environment, I recommend use \begin{lstlisting}, and you can use \lstset to customise it, and set breaklines=ture is another good tip.
  • For tables, do not make over 3 columns, or you can rotate the table and change to use longtable if need.
  • Add a new tag in your Makefile to create Kindle edition as long as the PC edition.
2

Here's a link to the template that I use. I generate both an A4 sized document and a 'Kindle sized' one when I compile my document. I've got some macros in there for reformatting columns and margin paragraphs in there too: https://github.com/Todd-Davies/latex-template

I also wrote a blog post on it a while ago (now slightly out of date): http://todd-davies.github.io/2014/01/08/latex-and-the-kindle/

You must log in to answer this question.

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