This is an excerpt of the book “Better Books with LaTeX.” The book comes with a LaTeX template you can use to easily create your own books.

While using LaTeX can save you a lot of time by automatically formatting each page, it has its limits. For example, you might end up finishing a section or chapter with one line that ends up alone on a page. This is ugly but it is nothing LaTeX can do anything about. The program’s hands are tied because it cannot rewrite the text for you. It will display every line—even if the final line in a chapter is “orphaned.”

Let us now look at a checklist you should go through before releasing the book (and after you have completed all the texts, indexes, bibliography, etc.):

 Clean up Empty Space

Skimming through a book and seeing large unused white spaces is a telltale sign of an unpolished book. Do not be tempted to add a photo of your cat or some meaningless diagram just to fill the empty spaces. In addition, it is literally a waste of space and ultimately of book pages (affecting printing costs, weight, shipping costs, etc.). Depending on your contents, it is possible to save a dozen pages by cleverly arranging your text. While LaTeX provides some functionality by automatically arranging images, you do not want to end up in a situation where the image is far from the position in the text where it is referenced. Most of the time, you want the image to show up exactly where it should be (the default setting of the template). Likewise, enforcing page breaks and having sections starting on the right side can lead to a number of empty pages. Let us examine a number of items to look out for:

  • Combining paragraphs. If you need to save space, you can combine two closely related paragraphs into one large paragraph. While this might come at the cost of some readability, it is very easy to implement.
  • Breaking paragraphs. On the other hand, if you need to fill white space, be more generous with starting new paragraphs. This reexamination of your text might actually improve readability by splitting it into smaller parts.
  • Shortening sentences. If your paragraph spans to the next page due to just a few words, shortening your text might be the best way to clean it up. The downsides are the additional editing work as well as ending up with the same problem should the previous text happen to increase in size.
  • Rearranging images. You can play around with moving an image before or after a paragraph and check if this solves the problem. For example, if you have a paragraph followed by white space followed by a picture on the next page, you could simply switch the picture with the paragraph, ending up with half of the paragraph on the first page and half on the second page, saving you space and eliminating unused white space.
  • Resizing images. Besides simply rearranging images, you can also limit or increase their size by either changing the limits of the \adjustbox{} command or by making the image itself smaller or larger. Be advised that using \adjustbox should be the last resort. While scaling photographic images is no problem, any image containing lines, tables, etc. will end up not looking good. Also, you should take extra care to have all your images share the same font sizes. A better option for vector graphics is to change the actual graphic, for example by reducing the distance between boxes in a diagram.
  • New page. Sometimes you want to add a blank page or have the next section start on a new page. For example, you have a section starting at the lower right page, with just half a paragraph fitting on that part of the page. Here, it is best to move the whole section to the next page and fill the empty space as discussed above. You can do that by simply adding \newpage (or \blankpage if you want to finish the current page and add an empty page).

As each change will possibly affect subsequent pages, you have to check the results page by page from front to back. When moving things around, take special care to have images near their references in the text—and to have a reference for every single image! The best experience for the reader in regard to the images is if he or she does not need to browse back and forth to connect what you write about the particular image and the image itself.

If you encounter any “lost lines” (single lines that are put on the next page although they could fit on the current one), try adding a \newpage command at the end of the paragraph. This is an issue that sometimes occurs with the LaTeX compiler.

Left Hand / Right Hand Pages

When you have cleaned up your empty white spaces, you should again preview your entire PDF file. For this, you can either use Amazon’s online previewer or a prepared PDF file in your PDF reader.

For the latter, I use Adobe Acrobat Reader DC (, load the generated PDF file, select “File” / “Print…,” select “Microsoft Print to PDF,” and select pages “ii – (your last page).” By moving the second page to the first page, we can now open the new file and switch to “View” / “Page View” / “Two Page View” and are now able to look at both pages exactly how they would end up in the printed book, with the even page numbers on the left, and the odd page numbers on the right.

Now, go through the entire book again to double-check whether the chapters and sections start on the correct side of the book.

 Clean Up Graphics

To understand graphics in the book production process, you have to understand file formats. In principle, there are three types of image files:

  • Vector graphics. Vector graphic files like EPS or PDF contain code to actually draw the picture in question. This code is understood even by the printer itself, which can help to improve the print quality tremendously. Imagine how much better a printer can deal with the information “draw a line from A to B” as opposed to “draw pixel to position 35/20, 36/21, 37/22, …” Use these file formats whenever possible. TikZ graphics produce vector graphics, and stock image sites like offer many files both as normal images files as well as vector graphics. Both EPS and PDF files will work, although PDF files are the preferred format because P is also your output format. They do not need to be converted but can be embedded directly into the final PDF by LaTeX.
  • Lossless PNG images. PNG images undergo a compression algorithm, but the type of compression used does not cause any loss of quality—the resulting PNG image has the same exact image information as the original picture. If you do not have vector graphics available, use PNG files.
  • Lossy JPG images. The limiting factor of e-books is the total file size; the limiting factor for printed books is the number of pages. JPG images are optimized for size, so if possible, do not use JPG files for any graphic in your printed book. As image size is not an issue in print, it’s better use lossless PNG images if you have them available.

resolution use use it with

Lossy JPG 300-600dpi e-books photos

Lossless PNG 600dpi PDF photos, diagrams

Vector graphics n/a both graphs, diagrams

Figure 8.1: Comparison of graphic formats and their application.

With this in mind, examine the images you are using now and maybe try to find better versions of those images or replace them with vector graphics (we can help you with that, see Chapter 3.8). For lossless and lossy images, choose a resolution of 600 dots per inch, as printers usually use this resolution for black on white printing.

Gimp   Gimp is a free graphics editor ( with which you can create, scale, or convert images.

Gimp can show you the resolution, but you can easily calculate it yourself. Simply take the width of your picture in pixels (e.g., 1245) and divide it by the width of your page in inches (e.g., 4.15”, which would result in 300 dots per inch).

Please note that when scaling JPG and PNG files in Gimp, you can also scale the DPI resolution. For example, a 1245 pixel wide image with 300 dpi will appear smaller than a 1245 pixel wide image with 100 dpi.

To calculate the whole width of a page in your book, take a look at your settings in lib/bookformat.tex:

\usepackage[paperwidth=5.25in, paperheight=8in, inner=0.80in, outer=0.3in, top=0.7in, bottom=0.5in]{geometry}

The space where you can actually put text is paperwidth – inner – outer. In this case, 5.25in – 0.8in – 0.3in = 4.15in. With a desired resolution of 600 dots per inch, you need an image with a width of 4.15in * 600 = 2490 pixels.

Lightshot   Lightshot is a free screenshot utility (see that saves the entire screen or parts of it into an image file at the press of a button.

One problem I faced with the screenshots in this book is that (at least with Lightshot) images are saved at 120dpi. If I include them directly into the book, they will look pixelated and way too large. Opening the image in Gimp, selecting Image / Scale Image, and changing the X/Y resolution from 119.990dpi to 300dpi does the trick.