Categories

## Polishing a Book for Print

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

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 not something 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 writing, 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. 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, forcing page breaks and having sections starting on the right side can lead to a number of blank pages.

Let us examine several items to keep in mind:

• 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 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 improve readability by splitting it into smaller parts.
• Shortening sentences. If your paragraph spans to the next page due to just a few words, edit the paragraph.
• 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, eliminating unused white space.
• Shrinking images. Besides simply rearranging images, you can also limit their size by either changing the limits of the \adjustbox{} command or by making the image itself smaller. Be advised that using \adjustbox{} should be the last resort. While scaling photographic images is no problem, any image containing fonts, lines, tables, etc. will end up not looking good. If you want to scale such vector graphics down, the better option is to make changes to the actual graphic, for example by reducing the distance between elements in a diagram, making the overall image more compact while keeping the original font and line sizes.
• 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 blank space as discussed above. You can do that by simply adding \newpage (or \blankpage if you want to finish the current page and add a blank page). As mentioned in Chapter 14.1, this does not affect the e-book version of your book.

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 with respect to images is if he or she does not need to browse back and forth to connect what you write about a particular image and the image itself.

If you encounter any “orphaned 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 (https://get.adobe.com/reader/), 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 look at the pages exactly as they would appear in the printed book, with the even page numbers on the left and the odd page numbers on the right. The formal terms for these are “verso” for the left-side page of a book and “recto” for the right-side page. By book publishing convention, the first page of a book (and in the template, of each chapter) is a recto page.

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. Use these file formats whenever possible. TikZ graphics produce vector graphics, and stock image sites like shutterstock.com offer many files both as regular image files and vector graphics. Both EPS and PDF files will work, although PDF files are the preferred format because they do not need to be converted but can be embedded by LaTeX directly into the final PDF.
• 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 is better to use lossless PNG images if you have them available.

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 14.9). For lossless and lossy images, choose a resolution of 600 dots per inch (dpi), as printers usually use this resolution for black on white printing.

Gimp ⋅  Gimp is a free graphics editor (https://www.gimp.org) 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., 1,245) 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 1,245-pixel-wide image with 300 dpi will appear smaller than a 1,245-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.25 in – 0.8 in – 0.3 in = 4.15 in. With a desired resolution of 600 dots per inch, you need an image with a width of 4.15 in * 600 = 2,490 pixels.

Lightshot ⋅  Lightshot is a free screenshot utility (see https://app.prntscr.com) 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 120 dpi. 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.990 dpi to 300 dpi does the trick.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## The LaTeX Book Template

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

In a previous article (and the book), we we have covered the mainfront, and the back chapter folders of the LaTeX Template. Now we will discuss those folders again in more detail and go through the remaining folders. This will help you to know where the configuration for each part of the template can be found and allow you to make changes.

## Template Library Files

Let us first focus on the lib directory. There, each file is a set of new commands or configurations to set up the style and contents of your book.

### Packages File

A packages file is simply a LaTeX file linking to a number of other LaTeX files or containing additional functionality not provided in the default LaTeX configuration. To import a package in LaTeX, you simply use the \usepackage command before the \begin{document} command. In the template, the lib/packages.tex file loads all the other files in the lib directory and also loads some additional packages, depending on the output format.

The first two commands load the nag package to provide additional warnings if you are using outdated or invalid packages and expand the output of error messages (\errorcontextlines 1000) in the log file to help you fix issues quickly.

The ifxetex package loads a small script that we can use to check whether the target platform is a printed PDF (with XeLaTeX) or an HTML file (with pdfLaTeX). It follows the basic format of:

\ifxetex{} (executed if XeLaTeX is used) \else{} (executed if pdfLaTeX is used) \fi{}

Think of \ifxetex{} as the main junction between the e-book (the HTML file output using pdfLaTeX) and the print book (the PDF file output using XeLaTeX).

Next are several packages and configurations specific to either of those platforms. The adjustbox packages adjust figures to fit onto a page—a feature needed only for the printed PDF as e-book readers automatically adjust graphics depending on the screen resolution. The psvectorian package allows us to add curly horizontal lines at the end of sections and chapters—a feature not supported by e-books.

TeX4ht ⋅ TeX4ht is a tool to translate LaTeX code into an HTML document.

The next command, \hrule, is not supported by TeX4ht, so we create a specific command, \myrule, and translate it into an HTML <hr /> command correspondingly. For the em dash, we need to add spaces (even if it is just 0) left and right of it to allow for line breaks. For the HTML output, we simply use the ASCII code for the em dash (#8212;).

At the end of the file, all relevant packages of the lib directory are loaded, so we need only to include lib/packages.tex to load the entire configuration. On the following pages, I will discuss each package.

### Language Selector

In an Overleaf project that is based on the template, you can select the language by changing the parameter of the babel package in output.tex. In the file, either the command \babelDE or \babelEN gets activated by the command \usepackage[ngerman]{babel} or \usepackage[american]{babel}, respectively. The command sets \languagename either to “ngerman” or “american.” In lib/languageselector.tex, the new command \babelDE{content} checks whether “ngerman” is set, and then displays the content. If it is not set, nothing is displayed. Likewise with the \babelEN{content} command, resulting in only one of the languages being displayed. The first use of this command can be seen at the end of the file, where we overwrite the naming of the table of contents depending on the language we have selected.

If you want to add a different language, for example, Spanish, replace “american” with “spanish” in output.tex (\usepackage[spanish]{babel}). Next, add the following commands in lib/languageselector.tex and you are ready to use \babelES as a command in your text.





### Bibliography

In lib/bibliography.tex, the bibliography feature is added to the document and (due to compatibility issues) either loads biblatex or natbib depending on whether you use XeLaTeX or pdfLaTeX. It also loads the actual bibliography file from the bibliography directory, depending on the language you have selected previously (see Chapter 17.1.2). The parameters of loading biblatex determine whether cited titles should be added to the index automatically (“indexing=cite”) and what citations look like. There are numerous possible combinations of the author name, the year of publication, and the title, each with different degrees of detail and verbosity. The setting authortitle in my template replaces citations with the author name followed by the title. Without the setting, the default would be a simple number that is referenced again at the back of the book in the bibliography.

At the end, the file also loads the nameref library. With it, you can reference the label of a chapter or section and get the chapter or section title in return. Instead of just referencing an abstract chapter number, adding the title helps the reader to know what you are talking about. Any changes to the referenced chapter or section title are automatically synchronized. For example, look at this code:


\chapter{My First Chapter}\label{c1_myfirstchapter:sec} Yesterday, I bought a car. \chapter{My Second Chapter}\label{c2_mysecondchapter:sec} Chapter ‘‘My First Chapter’’ discussed buying a car.



If we changed the chapter title “My First Chapter” to “How I Bought My Car,” we would have to update the reference in the second chapter. With the \nameref{} command, this is no longer necessary:



\chapter{How I Bought My Car}\label{c1_myfirstchapter:sec} Yesterday, I bought a car. \chapter{My Second Chapter}\label{c2_mysecondchapter:sec} Chapter~\nameref{c1_mychapter:sec} discussed buying a car.



### Book Format

Next is lib/bookformat.tex. The first thing you notice is the long list of \usepackage commands with the one marked with 5.25” x 8” uncommented. Here is your choice of how large your book should be. This applies only to a printed version of your book. For e-books, the size of your book is determined by the device your reader will use.


\usepackage[paperwidth=13.34cm, paperheight=20.32cm, inner=0.80in, outer=0.3in, top=0.7in, bottom=0.5in]{geometry} % 5.25’’ x 8’’



Did you know?

Why choose 5 x 8? Ratios like 5 x 8 are found throughout nature. We find them appealing because our perception is “calibrated” to find objects displaying this particular ratio. Why? In nature, the fundamental problem for plants is to get as much sunlight as possible. If the leaves are arranged according to a regular pattern, such as “Leaf / quarter-turn / leaf / quarter-turn, …” the leaves will overshadow one another. The challenge is to find an angle of rotation which can be continuously repeated so that no two leaves grow directly above one another (see Figure 17.1). Nature’s solution is using a Fibonacci number sequence (1, 1, 2, 3, 5, 8, 13, 21, …) to calculate the “golden ratio” (5/3, 8/5, 13/8, 21/13, …). → Read more in Philosophy for Heroes: Knowledge [Lode2016]

Personally, I like 5.25” x 8” but it is totally up to you. Look at your personal library (and take a ruler) and check out the different formats. Besides personal preference, the only thing to keep in mind is that smaller formats lead to more pages if you do not also reduce the font size (which is not recommended!). Amazon KDP supports all those formats, but if you decide to have the PDF printed by your local printer, first check which formats your local printer supports, otherwise you might have to do some redesigning.

Looking at the \usepackage[…]{geometry} command itself, you see the self-explanatory paperwidth and paperheight parameters, as well as four parameters to determine the space between the margins of the book and your text. Instead of parameters that determine left and right margins, you see the parameters inner and outer. Given the way paperback books are bound, the inner margin needs to be significantly larger, otherwise the reader would have difficulties reading the book. Also, printers are not 100% accurate, so you need to keep some safe space to account for printing errors.

The parameters as defined in the file work nicely for my books. Feel free to experiment with different settings, but make sure you keep them within the range the printing company (be it Amazon or another provider) has defined.

### Fonts

If you want to adapt the typography, lib/fonts.tex is the place to look. It consists of:

• Little tweaks for footnotes,
• Line height for listings,
• Space between paragraphs and paragraph indentation,
• Font sizes for captions and the index,
• Font of URLs,
• Background color and font size of listings,
• Typographical tweaks (microtypelmodern),
• The selection of the font (libertine), and
• A command that inserts blank pages.

The tweaks are universally recommended, although feel free to select a different font instead of libertine. As the typography is under the control of the specific device when reading an e-book, this applies to only the printable PDF, not the HTML (and thus e-book) output.

The \sloppy command is optional; it reduces the readability of some lines, but it ensures that no lines go beyond the left or right border (something that makes printing the book impossible). For further optimization, you could (after having finished the book using the sloppy command) replace it with the \fussy and manually fix any issues with text going beyond the border. Both commands change parameters of how to stretch spaces between words and how to handle hyphenation.

### Chapter Design

For ease of use, you can use the command:

\begin{chapterpage}{title}{label}…\end{chapterpage}

which is loaded from lib/chapterpage.tex. It sets up the style of the chapter page, as well as the following blank page.

The actual design of the chapter page for the print version is changed in the file lib/chapterbox.tex. It replaces the standard chapter design and uses a full page with a border and the chapter title in large letters.

To reset the chapter page design to the default settings (for example, for all back matter chapters) with a simple headline with the chapter title and a horizontal line, use either \input{lib/chapterfont.tex} or \chapter instead of \begin{chapterpage}.

In lib/headerfooter.tex, you can edit the style and content of the header and footer. The command:

puts the chapter or section title to the inside and the page numbers to the outside of a page. Whether left or right is “inside” depends on whether it is an odd or even page. If you are working on an e-book, you can safely ignore this command because pages of an e-book have no header, footer, or page number.

The next command, \automark[section]{chapter}, lets the title in the header alternate between the chapter title and section title. If you do not want the section to show up in the header, replace “chapter” with “section.” The third command redefines \headfont and causes the heading to be in small capitals and italics. Finally, the naming of the chapter is redefined, setting it to “Chapter X name of the chapter” without adding a period after the chapter number.

### TikZ Initialization

TikZ ⋅ TikZ is a vector-based drawing language with which you can draw diagrams, charts, tables, fractals, etc.  in high resolution using minimal space.

In lib/inittikz.tex, the TikZ graphics system is loaded. Creating graphics in TikZ goes beyond the scope of this book, but we can help to get you started (see Chapter 14.9). For now, we will look only at the initialization.

After loading the basic TikZ packages (including the float package, which allows you to put a figure at a specific place in the text instead of having the LaTeX compiler decide), the style of various graphical elements is set up. For example, the text in the nodes of a diagram should have a small font, thick borders, and should be placed a certain distance from other nodes.

By default, TeX4ht exports TikZ graphics as vector graphic files (SVG files) and then loads them in the HTML file. Most modern browsers can show vector graphics, but the current e-book converters cannot. They work only with regular images, hence we need to change the behavior of TeX4ht. This is achieved by the code block at the end of the file. It causes all TikZ graphics to be exported into a cache folder, and then to be loaded again from there—as opposed to directly embedded into the PDF as vector graphics.

Long story short, we have to override the tikzpicture command to produce an external PNG file and load that in the HTML file. The PNG files are stored in the tikz-cache/ folder. Their resolution can be adapted by changing the density parameter value of the convert command.

Let us look at the details:

• -extent 1245 This extends the transparent part of the graphic to 1,245 pixels. This means all converted TikZ vector graphics will have a width of 1,245 pixels.
• -gravity center If the image is smaller than 1,245 pixels, this centers the graphic in the middle of the extended file.
• -quality 100 Sets maximum compression for TikZ graphics. This reduces the file size, at the cost of an increased compile time.
• -density 300 Sets the output to 300 dots per inch. This affects the effective size in pixels of the generated graphic.

Turning to the next file, lib/tableofcontents.tex, we now arrive at more intricate programming. For the table of contents in the e-book, we need to insert code directly into the HTML output file. So, we check whether the current compiler supports \HCode (only TeX4ht supports that), and insert <nav> commands to tell Amazon that what follows now is the table of contents.

For the PDF output, in the case that \HCode is undefined, the command \KOMAoptions{open=…} changes on which side (left or right) the new chapter begins. The template is configured to start chapters on the right side by default (by using the documentclass scrbook—we will discuss this later). For the table of contents, I have decided to let it start on the left (even) page so that the reader can see the full contents of the book in one view. With the following command \KOMAoptions{open=right}, the original setting is restored. Finally, the page needs to be cleared and reset with an empty page style in order to hide the header—we do not want any page numbers in the table of contents section itself. This is accomplished by the command \thispagestyle{empty}\pagestyle{empty}\clearpage.

### Boxes

After finishing my first book, Philosophy for Heroes: Knowledge , I found that it needed additional layers of information to accommodate different types of readers. After considering various options, I decided to add summary (idea) boxes at the end of each section, additional examples, biographies, questions for the reader, and boxes that provide a preview of future books in a series.

Building these boxes is the task of lib/boxes.tex. This file contains graphical elements you can add throughout your book and adapt to your needs. Please note that the box icons are not included in the template; upload them on your own and uncomment the relevant lines in lib/boxes.tex.

\begin{lstlisting}\end{lstlisting} In this environment, everything will be output as you wrote it. This is useful to print out code (like this paragraph) without having to replace all the slashes and braces. The \lstset command determines the formatting of the output, such as break lines at the end of the page, light gray background, indentation, and small font size.

\begin{problem}…\end{problem} For the print book, it creates a box with a question mark icon and the text “Question” at the top of the box. Use it at the beginning of a section to ask the reader a question that is answered in the text.

\begin{idea}…\end{idea} For the print book, it creates a box with a lightbulb icon and the text “Idea.” Use it to summarize the previous section and answer the question in the question box.

Example

\begin{example}\end{example} Creates a box with a book and test tube icon and the text “Example.” Use it for examples that deepen the understanding of the topic in question, but could be safely skipped.

Biography —Name

\begin{biography}{Name}\end{biography} Creates a box with a book and an identity card as an icon and the text “Biography.” Some readers want to know more about the people you are discussing in your book, while others want to skip that part. Creating a biography box will accommodate both types of readers. Note the additional parameter (the name of the person), use it like this: \begin{biography}{Alan Watts} Alan Watts was born in …\end{biography}.

Did you know?

\begin{preview}{bibliography id} …\end{preview} Creates a box with an opened book as an icon and the text “Did you know?” at the top. When referencing your previous books (or giving a preview of your future books), you can use these boxes as additional promotional space. It gives the reader an interesting bit to read and might make him or her curious enough to buy or pre-order your next book. Notice the additional parameter (the name of the book), use it like this: \begin{preview}{BBWLtAW} In my previous book …\end{preview}. → Read more in Better Books with LaTeX the Agile Way [Lode2019]

Definition ⋅  \begin{definition}{Term}\end{definition} Creates an indented block of text with a black bar to the left (for the PDF output) and the given parameter (the name of the term) in bold and small capitals. This can be used for glossary items to precisely define a concept you have written about in your text.

\begin{quotation} …\end{quotation} Creates an intended block of text with a quotation mark graphic in front of it. It signals that this is a quotation from another author. You can use this throughout your book, but I would recommend putting it at the beginning of a section to set the theme or to bring up a particular question.

Finally, we need to display multiple columns in the glossary with lib/multicolbalance.tex.

\begin{multicols}{number of columns}\end{multicols} Splits the text into several columns. This is the typical format of the glossary at the end of the book. Books with larger formats might use these throughout the book if necessary. The contents of the columns are balanced (as opposed to filling first the left column and then the right). For readability, the ideal number of columns is two.

## Core Files

We already filled the folders main/back/front/biographies/examples/ideas/questions/glossary/, and images/ in Chapter 13. We will discuss the remaining files for the HTML conversion in the css/ and htlatex/ folder, as well as the latexmkrc and pgfsys-tex4ht.def files in the appendix in Chapter 24. Let us now take a look at the core files of a LaTeX project in the root directory. There you can find the entry file that initializes the language settings (output.tex), and the main project file that binds everything together and provides the structure of the book (main.tex).

As pointed out above in Chapter 17.1.2, in Overleaf, you can change the language of your project in output.tex. The parameters american or ngerman of the \usepackage{babel} command reflect this choice. Other than that, the following settings are configured:

• \documentclass[ …]{scrbook}. This sets the document class of your project to a book, introducing odd and even pages with extra space in the middle for the binding. The standard document class is book, using scrbook instead loads several additional commands (the KOMA scripts) which we will be using throughout the template. For detailed documentation of the KOMA script, check out https://www.ctan.org/pkg/koma-script. In the template, the pagesize is set to auto, and the bibliography is set to totocnumbered so that it shows up in the table of contents.
• \title{Title}. This sets the title of your LaTeX project. This title will not show up in the final document but is the name of the project listed in Overleaf.
• \hyphenation{…}. Here, you can enter custom hyphenations for fine-tuning. The packages xspace and hyphenat are required for it to work. Not every word is known to LaTeX, and the rules differ between, for example, British and American English. With the hyphenation command, you can enter the hyphenation for special cases yourself. For example, in the Oxford dictionary, “everywhere” is hyphenated as “ev-ery-where” but it might look odd in your text, so you can add \hyphenation{every-where} to tell LaTeX to hyphenate only in the middle. For additional words, simply add them into the bracket: \hyphenation{every-where ti-ger la-tex kit-ten}. You do not need to add a comma or semicolon to separate additional words, just put a space before each new word.

Once the language is set up, the entry file loads lib/packages.tex and then goes into the main file main.tex which is split into five parts:

• Preamble. For the PDF output, the index is initialized. E-books do not have indexes as they do not have fixed page numbers. Then, the document is started. Everything between \begin{document} and \end{document} is written to the output.
• Front matter. Front matter pages are numbered with Roman numerals (i, ii, iii, iv, …) to set it apart from the main matter. The numbering begins on the title page (not the cover itself) with the command \frontmatter. The template is also set up to use only basic chapter title formatting (no fancy box) for all the chapters in the front matter. To hide page numbering on a certain page (for example, the title page), add \thispagestyle{empty} at the beginning of the page.We start with the half title page showing the title, and the title page with the book cover image when compiling it as a PDF. Then come the publisher, dedication, epigraph, and table of contents page. For the PDF version, we activate the chapterbox formatting to show fancy full-page chapter titles. Next, we show the foreword and the preface by the author.
• Main matter. For the main matter, we switch back to numeric page numbering and insert all the chapter and section files. This is where the bulk of your writing will be added. This is also the place where you can move around or remove individual sections. For example, if you do not want a page with book advertisements, simply put the comment symbol (%) in front of \input{back/advertisement} and it will no longer appear in the output. Remember to use a separate tex file for each individual chapter. If you copied your entire book into the main.tex file, organization would become difficult.
• Back matter. In the back matter, we show the reader how to proceed from here by advertising our other books and recommending additional books written by other authors. Next, we insert the author’s biography, as well as the story of how the book was created, giving the interested reader a look behind the curtain. We switch back to the basic chapter design and provide the reader with summaries of the boxes we used (question, idea, and glossary items), as well as a list of sources for the quotations (which we omitted in the text for better readability). Finally, the full bibliography is added.
• Appendix. The appendix provides the reader with the index (for the PDF output), a reminder to write a short review online, and farewell words.

Again, you are free to move sections around as you see fit or even disable individual parts by commenting them out (adding a percentage % sign in front of the line). As you organize your book, think about what the reader would expect in a particular location of the book. While especially the front and back matter are more or less superfluous parts of a book, they also tell a story and give the reader a context to better understand what you have written in the main part of the book, and why.

This concludes the discussion of the template. In the remaining chapters, we will proceed to discuss how to polish both the e-book and the print version for release, especially when it comes to graphics, and how to publish the book via specific platforms.

While we have tested the template together with this book several times, you will likely encounter an issue not discussed here. Creating a document in LaTeX is more complicated than in Word. Remember: If you encounter any error or have a question about LaTeX in the template, please do not hesitate to contact us at mail@lode.de and we will see what we can do!

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## Index Creation in LaTeX

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

As opposed to their electronic counterparts, printed books do not have a search functionality to find specific words in the text. Instead, they have an index at the end as a service for the reader to quickly find certain parts of the book that he or she wants to read. If you are planning to publish only an e-book version of your book, you could skip this section—e-books do not have indexes because they do not have fixed page numbers: they are formatted differently on different devices. Keep in mind, though, that you might want to create a paperback edition at a later date and that your knowledge about your book is still fresh now. Even without a paperback edition, working on an index will help you to find possible keywords you could use for marketing, and it is a useful method of reviewing your book’s content paragraph by paragraph.

Unfortunately, there is no easy way to generate an index automatically—at least not in the quality a human can. Why is that?

Beyond merely listing all the concepts in a book, a good index is like an intelligent filter. The person creating the index has to think about what a reader might search for and list that word, even though it might never literally appear in the book. Likewise, if a concept consists of multiple words, it might be good to include both variations, for example, “language → mathematics” and “mathematics → language” to refer to the language of mathematics and mathematics as a language.

But how can LaTeX help in this regard? In traditional bookmaking, creating the index of a book is a separate process after the actual book is finished. You can imagine it basically as having the printed book in front of you, then going through page by page, noting which concepts appear on a particular page. This approach gets problematic if you want to make changes to the book that affect the page numbers: you would have to redo the entire index each time.

## Indexing in Word

In Word, you can select the word or words you would like to use as an index entry and click on Mark Entry (on the References tab, in the Index group). A dialog shows up (see Figure 16.1) where you can configure the index entry (search for “Create and update an index” to find Microsoft Office help on this topic). Once done, Word switches into a hybrid mode that shows things like line breaks or index entries which are usually hidden (you can activate/deactivate the mode yourself by clicking on the ¶ button). If you want to edit an existing index entry, you have to edit the generated code. For example, the code for a subentry “mathematics” of the index entry “language” looks like this in Word:


Mathematics{*XE*"language:mathematics"*}



## Indexing in LaTeX

In LaTeX, insert the index command by adding the \index{…} directly into the text. For example, if you have the sentence “The yellow lab was voted America’s favorite dog again this year,” you could add two entries: “The yellow lab\index{yellow lab} was voted America’s favorite dog\index{favorite dog} again this year.” The page number that shows up in the index will then correspond to the place where you have inserted the index command. If the sentence “The yellow lab was voted America’s favorite dog again this year,” is printed on page 7 of the book, the index will show “yellow lab, 7” and “favorite dog, 7” assuming there is no mid-sentence page break.

The big question is: which words should you index? Let us look at an overall indexing strategy.

My approach in the first phase is to index all the terms that need to be indexed no matter what. Those are:

• Names of persons. Whenever you mention (or quote) a person, add the index command after his or her name. The format for indexing someone’s name is \index{last name, first name middle name}, for example, \index{Darwin, Charles Robert}.
• Media titles. Likewise, whenever mentioning a work of art (book, movie, software, etc.), add the index command after its title. If you have the title in your bibliography, \citetitle{bookid} does the job for you and adds the item automatically to the index. The “bookid” stands for the id you have given in the bibliography file. The exception to using \citetitle would be titles that start with an article (a, the) which is usually put at the end (e.g., Last Unicorn, The instead of The Last Unicorn). In those cases (or when you do not reference a book from your bibliography), use \index{title of the work@\textit{title of the work}}. The “@” character is necessary for the indexing engine to recognize the italic font formatting.
• Concept definitions. When introducing a concept and providing its definition (especially in glossary items), you want the reader to look at a particular passage before any other. When indexing, you can accomplish this by marking those entries in bold by adding “|textbf”: \index{word|textbf}. For example:
Science\index{science|textbf} is the formalized process of gaining new knowledge.

Note that you must not index entries within captions of figures. This will cause problems during compilation. Instead, index the place where the figure is referenced in the text.

Once those basics are implemented, you move into the second phase. Here, you go from paragraph to paragraph and ask yourself each time what concepts are discussed. Add the first occurrence of each concept to the index. This paragraph-by-paragraph approach is the best compromise between accuracy and usability. You save time by adding a particular concept to the index only once per paragraph. The reader sees if a paragraph on a particular page spills over to the next page and will read on. The index page number basically says “start reading here until the paragraph is finished.”

If the same word is indexed in multiple paragraphs, LaTeX will combine them into a single index entry. That is, a single number if all occurrences are on the same page, or a list (or range) of pages where the concept is discussed (e.g., “5-7, 9”, “273-279, 401”, etc.).

Once you are done with indexing individual words, in phase three, you can take a break and have your editor (or a friend) take the role of a reviewer. Alternatively, take an extended break and revisit your book one month later with a fresh mind. For the review, go one by one through the index, go to the page specified, and ask yourself if the passage really explains the concept. If not, remove the entry from the index.

Phase four then deals with cleaning up this “overindexed” index. Look at the index and see if you can find entries that can be combined. For example, you might find you have the following entries in your index: “Greek alphabet,” “Latin alphabet,” and “Phoenician alphabet.” Here you have to ask yourself if your readers might also search for “alphabet” or already have a specific language in mind. In my book Philosophy for Heroes: Knowledge , I decided for the former and combined the index entries into the category “alphabet” with “Greek,” “Latin,” and “Phoenician” as subcategories. This categorization can be done in LaTeX with the following construct:


\index{main category!subcategory}



In our example, use \index{alphabet!Greek}\index{alphabet!Latin}, and \index{alphabet!Phoenician}, respectively. You can also go one level deeper, although that should be the exception. For example, you could categorize “natural numbers in mathematics” as \index{mathematics!number!natural}. In both cases, LaTeX will automatically combine those three entries and arrange them together. With this in mind, I recommend reading a few indexes of the books in your library to learn how the authors combined their concepts. If you want to know more about the theory of knowledge and categorization of language in philosophy, check out Philosophy for Heroes: Knowledge , which explains it in detail.

Next, in phase five, you might want to explain to the reader the case of two different words in the index referring to the same concept. Maybe there is a popular expression for something and (in your field of work) the correct expression for something. In the index, you can point one expression to the other. For example, one application is when citing a person who has different names, maybe a real name and an artist name. Readers might look for either version of the name. For example, the mathematician Leonardo Bonacci is also known as Fibonacci. You might list both names and tell the reader that you are referring to the same person. If you used “Leonardo Bonacci” in your text, you could add an index entry with the following format: \index{one version of the word|see{other version of the word}}. In our case this would be “Leonardo Bonacci was a famous mathematician.\index{Bonacci, Leonardo}\index{Fibonacci|see{Bonacci, Leonardo}}.” Another example and a bit of an inside joke would be recursion: “If a statement relates to itself, it is called recursive.\index{recursion}\index{recursion|see{recursion}}.”

Finally, read through the entire index again to identify double entries, e.g., the same concept listed twice because of a misspelling. These can happen because the LaTeX commands are hidden in any PDF output you might be using for proofreading. That is it!

Here again are the steps of the index creation as a list:

• Index all the basic terms (titles, people and place names, definitions).
• Go through the entire text and index all the terms that are explained in a particular passage.
• Check all index entries by going backward from the index to the text.
• Combine index entries into groups.
• Add references from one index entry to another (e.g., for people with several names).
• Check for spelling errors.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## Comparing Word and LaTeX

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

What is magic for? What use is wizardry if it cannot save a unicorn?

Peter S. Beagle, The Last Unicorn [Beagle1991, cf. p. 187f]

Having written six books on topics including project management and philosophy, I have gained a great deal of respect for a well-written book. It is not enough to just have a stack of notes that you sort into chapters. It is not enough to spend a lot of time editing and organizing those notes. It will create a book, but is a book really what you wanted? It might sound a bit strange, but the goal of writing a book is not the book itself. It is that the book will be read.

Even the best technologies cannot save a unicorn—or make us better authors. They cannot tell us what to write. But they can help us to bring our imagination and ideas onto paper more quickly and efficiently. All you need to become a successful author is your mind, a pen, and paper. Everything you need to become a published author more quickly is in the following chapters.

## Comparing Word and LaTeX

Everyone knows Word. However, “knowing” Word mostly refers to ease of use, as it is a “what you see is what you get” (WYSIWYG) text editor. But if I asked how, using Word, to refer to another document’s text block and add that as a citation in a footnote, most people would have to look on the Internet to find out how that could be done. While most of the functionality is available through icons, you still need to know where to look when something is not a standard command like those used in formatting, making lists, or choosing fonts.

Word ⋅  Word usually refers to Microsoft Word. Generally, it is used as an umbrella term for all word processors that directly show you what you will get as an end result (as opposed to first having to process the file). This approach is more intuitive, but it makes editing large projects very complicated.

In LaTeX (pronounced LAH-tekh or LAY-tekh), you instead create a text document which is then translated into an actual formatted document (your book). Formatting is done through commands you enter as text into the document. To write a LaTeX document, you never have to touch your mouse, as you can enter everything by keystrokes alone.

LaTeX ⋅  LaTeX is a typesetting system that works more like a compiler than a word processor. While initially complicated, LaTeX allows better management of larger projects like theses or books by splitting the document into sections: style, references, and text.

Word and LaTeX each have particular advantages:

If you know the commands, creating a LaTeX document will be quicker than writing a Word document. You never have to break your concentration to access a special command. Sure, there are shortcuts in Word, too, but those have to be learned as well.

Because all commands are part of a LaTeX document, you can edit your text on any device with any editor you like, while Word documents require an installed editor (well, Word) that does not show the formatting and control information.

The upside of Word is its automated grammar check. LaTeX online platforms like Overleaf provide spell checks, but no integrated grammar check. We will have to wait for future releases in that regard.

Word offers integrated basic graphic functionality for symbols while LaTeX has to rely on a rather complicated vector graphics engine.

Editing a Word document using different versions of the software might lead to compatibility problems and it will certainly not look the same in all versions. While there are collaborative online editors for Word, you are then on the same level as LaTeX online editors like Overleaf and you lose the ability to work on your document while on the road without Internet connectivity. Compatibility issues are especially problematic if you are co-authoring a book or working with an editor, or when relying on exact page numbers. Do not forget that books can exist for quite a long time. Will your Word file still work in 10 or 20 years when it’s time to release a new edition of your book or use parts of your book in a new book or article?

LaTeX’ more substantial post-processing of each change allows for much more complex algorithms, which provide you with better hyphenation and professional-looking typography—both features come out of the box and require little to no tweaking. In LaTeX, the document is processed in the background with a delay (a few seconds up to several minutes), while Word has to provide any change in real time, which requires that editing is optimized primarily for speed. While LaTeX updates the whole document with each committed change, you need to update some elements manually in Word (for example, the table of contents and the index).

In LaTeX, an element of the style of the entire document can be changed with a single line of code, while it takes 10 clicks in Word to change the style of a document. While Word does have a sophisticated versioning system, this applies only to the text itself. The style information (for example, the formatting of headers or footers) in Word is not part of the visible document. Hence, changes to the style are not directly visible in the document version history.

Versioning system ⋅  A versioning system is a tool to track changes to a document. That means you can go back and check what has been changed and by whom.

If your document contains graphics, processing Word files can become really slow, or the program might even crash. Why? Because while you are editing, all the images have to be cached somewhere, which takes a lot of memory. When editing LaTeX documents, images in the editor are visible only by their text reference and are only later—one by one—compiled into a PDF or e-book.

LaTeX is known for its beautiful typography. For example, it supports kerning (see Figure 11.1) and ligatures (see Figure 11.2), giving a typeface its finishing touch. Improved hyphenation, proper small caps, and proper justification are other features LaTeX offers that Word cannot do as well or without additional work.

While Word has several tools inbuilt that support multiple languages (dictionary, basic grammar check, special characters, etc.), it is not designed to handle multiple languages at the same time. If you want to produce, for example, a German and an English version of your book, the best advice would be to use two separate documents and translate and compare them paragraph by paragraph. In LaTeX, a single document can contain multiple languages. To create a multi-language project, you can put each paragraph of the second (or third) language below the original language. This makes translation work more manageable and reduces work for synchronization when making revisions. This is possible by a simple switch command that uses all entries marked with either one language or with another.

In LaTeX, you can add functionality to switch between e-book and print output without having to manage two separate documents. For example, my Philosophy for Heroes: Knowledge project produces four output files: the German e-book, the English e-book, the German PDF, and the English PDF. Even if your ultimate goal is to focus on the printed version of your book, merely having a more affordable e-book version will help to increase sales as it gives your readers a choice. Those who do not have a preference about reading your book in print or as an e-book might opt for the cheaper version rather than not buying your book at all.

Because LaTeX documents are compiled, you have the option to build your document not as one huge file like in Word, but as a collection of many files. As mentioned above regarding images, you can also include text files at any part of the document (as opposed to copying the whole text into one huge file). This makes it easier to divide the work and proceed section by section, as opposed to having to locate the part you are currently working on each time you open the document. It also makes rearranging sections easier: you no longer have to copy and paste pages over pages (never being sure if you have successfully copied everything and nothing was lost). Instead, you just move the reference to a section to another place. For example, let us assume you write a book about dogs and cats and first discuss dogs, then cats. In LaTeX, you would put each discussion into a separate file, and include them into your main file like this:

\input{main/aboutdogs}
\input{main/aboutcats}

Moving your discussion about cats to the front is done by simply switching the position in the main file:


\input{main/aboutdogs}

If your document contains formulas, LaTeX provides an entire scientific library of functions to edit and display them directly in the document. While you can create basic formulas in Word, for any complex mathematics you need to use a separate program to create and embed an image. Likewise, especially non-fiction books rely heavily on citation. To manage your sources in Word, you need a separate plugin or third-party program (like Citavi), while LaTeX supports the most widely used standard BibTeX for free, with no plugins required.

Citavi ⋅  Citavi is a plugin for Word (see https://www.citavi.com) to manage your bibliography and citations.

LaTeX is open source and free (even the online editor Overleaf is free if you can do without password protection), while you have to pay license costs for Word.

Ultimately, it depends on your needs. If you want to write a complex document like a book, the advantages of LaTeX outweigh those of Word. If you want to quickly write a few pages, Word is superior. For longer and more complex books, LaTeX takes less effort (see Figure 11.3). In this book, I will help you to get your book done and published with LaTeX using the free template provided with the book.

Categories

## How to Get Early Feedback from Readers

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

While we have discussed how to include the reader by creating user stories and personas, we have not included actual readers in our publishing process. In this chapter, we will discuss how listening to your audience can help to improve the quality of a book.

## Learning from and Connecting with Your Audience

Learning from your audience can be done in various ways:

• Examine feedback from a previous similar book you have released. This is an especially relevant option if you are writing fiction books in the same genre, or if you are writing a new edition of a book on technology.
• Set up ads and examine the statistics. See Better Books with LaTeX the Agile Way.
• Send out copies to trusted reviewers and listen to their feedback. This is undoubtedly the gold standard of improving a book with the help of a reader. The most significant drawbacks are that the reviewer might have a lot of other books to read before yours and that the process of reviewing takes time.

First, there are niche books that required a lot of work and sell easily for more than $50. An example would be books about current technologies: they have a unique selling point given that there is not a lot of competition. In this case, you might want to limit the amount of work you publish on your website. Second, if you are writing your book to advertise professional services, people copying your work should be a welcome situation as a means of reaching a wider audience. Think of it as people copying your advertisement and showing it to other people for free. Third, if your book is your product—not your services—you need to weigh your options. On the one hand, if you release individual chapters on your website, people could combine them together and have a complete book to read and no longer see the need to buy the actual book. On the other hand, they might tell other people about your book, or they might not be inclined to spend the time compiling your articles and instead buy the compiled book. You could also put more advertising on your website, release only excerpts, or limit access to those articles to trusted reviewers. ## Amazon Ads and Market Research Ads are another way to connect with your readers. Start your first ads when your book is ready for pre-order—ideally, on day one! Amazon sets a maximum time limit of three months for pre-orders, so aim for releasing at least four books each year to get the most out of it. Alternatively, you can use Google Play or Leanpub (see Better Books with LaTeX the Agile Way) which have no time limit. Have a first draft of your cover and upload that, together with your user stories (minus the names) as a description. Even though this might take extra work, any information you can get from your readers before the actual book launch will be helpful. For example, you might notice that one keyword does exceptionally well. You could use that information to improve your book’s description, pointing out that this (the keyword) is something you write about, and you could add an additional or extend an existing chapter about this topic. On Amazon, you have the following options: • Product Display Ads: You can display your book as an ad by Interest (on Kindle), by Category (on Amazon.com), or by Product (on Amazon.com). The first type of ad is relevant to you if you write for a specific genre and have an audience using mainly Kindle to read books. The second type of ad is also recommended if you write for a specific genre but aim for people browsing on the Amazon website. The third type allows you to place your ad on the page of a specific product on Amazon. This should only be used if you know that people who are interested in that product will very likely also read your book. For example, you could advertise your gardening book on a product page of a popular gardening tool. • Sponsored Ads: Sponsored Ads show up when a customer searches for a product. You can either set automatic targeting or manual targeting. With the former, the keywords will depend on your existing product information. If you have put relevant keywords into your description, this might be the fastest way to get an ad up and running. For more fine-grained control, manual targeting is highly recommended. If you are (also) producing paperback editions of your book that include an index, you are at an advantage here. Creating an index for your (offline) readers is the same as creating a list of keywords for your online readers to search for. While it requires some extra formatting, you can basically copy your entire (!) index into the keyword field on Amazon. While most of the index keywords are irrelevant, you will quickly (depending on your traffic) see which keywords people click on and which they do not (Amazon provides a detailed analysis for each keyword). Over time, deactivate non-performing or low-performing keywords and increase spending on the high-performing keywords. Once you have found the core keywords that sell your book, you can then optimize your copy by setting up multiple ads with the same keyword, but different copy. While this evolutionary approach will not revolutionize your sales (give yourself at least six to 12 months to learn the trade), it will most likely reduce your unnecessary spending and will likely increase the conversion rates of your ads. But again, ads can only do so much. Ultimately, it is your cover, your ratings and reviews, and the topic you are writing about that sells the book. A valuable side effect of running ads is certainly that you will learn more about the market and what people are searching for—invaluable information for deciding the topic of your next book. Also, you could put your top seven performing ad keywords into the book description. Free advertising! Beyond optimizing your keywords and your ad copy, you can also optimize your product page. To accomplish this, you have to have ads running for a certain amount of time depending on your sale volume (for example, one month), then pause those ads, make changes to your product page, and create identical new ads. By comparing the conversion rate (number of sales divided by number of clicks), you can then compare both versions of your book’s product page. If you want to rely on third parties to advertise for you, make sure you can track the conversion rate and start small. For example, someone might offer to publish your book ad to Facebook groups of 25,000 people. But that might only help you to get maybe 10 clicks because many people in those groups never see the post on their timeline. Paying$10 for this service will actually cost you \$1 per click—more expensive than a Facebook ad you place.

A bestseller is properly defined as “a book for which demand, within a short time of that book’s initial publication, vastly exceeds what is then considered to be big sales.” But many authors falsely call their book a “bestseller” if it was for an hour at the top of an Amazon category instead of relying on a trusted bestseller list by an established authority (e.g., New York Times). Hence, one should be cautious with people promising to make your book a bestseller.

That is the reason why, for the copy (in the ad and the product page) itself, it is best to refrain from the usual marketing buzzwords that come to your head. Sure, adding “bestseller” will create the illusion that everyone else likes your book so something about it must be special. But if it is not truly a bestseller, calling it one is dishonest and will make you and your book look cheap.

If you want to advertise in forums, write an article about your book, or create a video. The best approach is to not simply tell your audience what the book is about, but to evoke an emotional reaction; whether they love or hate your approach, at least you will get them talking about it. Then you can begin to collect early feedback.

Whatever approach you choose, keep in mind that the idea is to lay the groundwork for a long-term relationship with your audience. A quick sell can always be made at the cost of your reputation. Set as your goal to deliver on your promises with a well-researched, well-written book.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## How to Optimize the Work Process

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Substitute “damn” every time you’re inclined to write “very;” your editor will delete it and the writing will be just as it should be.

Mark Twain

Once you have written and ordered all your user stories, put your writer’s hat on back again. With this different perspective, take another look at the list of user stories and ask yourself if you know exactly what you will write to implement each user story. Do you still need to do research that will distract you from writing? Is it still unclear how your characters would act in a particular situation? Are you unsure about the sequence of the arguments to make your point? If you find something that will block you, it is better to hold off on writing and put your idea hat on again, and do the required research or work on the concepts.

• Add a reminder whenever you know more work or research is needed (but would require you to switch to another hat) on the chapter you are currently writing.
• When finished with the chapter, have your editor read through it, and have him or her add reminders if necessary.
• When getting back the corrected version, work through all the reminders. If you make any changes, mark them with with a different reminder (e.g., “TODO EDITOR”) to make it clear to your editor that you have made changes that need a final check. Again, platforms like Overleaf or Google Docs can highlight your changes automatically.
• Work through issues identified by automated spelling and grammar checkers like Grammarly. Remember to review each suggestion, because some will improve your writing while others will not fit the context of your book.
• Finally, during your daily or weekly chat with your editor, review all reminders and clear them up one by one.

Grammarly ⋅  Grammarly is an automated spelling, grammar, and plagarism checker. It also checks for weak vocabulary, repetitions, and overly long sentences. You can get an account here: https://www.grammarly.com.

In terms of time organization, there is no single solution that works for everyone:

• Work on a single user story or chapter each day, no matter how long (or short) it takes.
• Set a fixed timebox (e.g., from 9 to 5), stop once you have reached it, and pick up where you left off on another day.
• Set a fixed timebox, and work on as many user stories as possible. Whenever you finish a user story, estimate whether you can finish the next story on the same day. If not, take an early break.

A successful writing day depends on whether you have prepared the user stories in advance so that you do not have to switch your hats all the time.

If you suffer from writer’s block or procrastination, another approach is to go not by time or user story, but by volume. If you set a word count goal, the danger of stopping to find the perfect words will be lower. And if you have a well-written outline, a complete description of your characters and their background, and a description of the world in which they are living, then there is little that can stop you from continuing writing. Even if you think you are writing uphill or it is going nowhere, just keep on writing: you can get back to it during editing. With non-fiction books, have your arguments and research texts prepared in advance and see the actual writing as an exercise to connect all the points you want to make.

Your goal should not be to create “perfect” paragraphs: what counts is the overall quality of your book. The reader will put your book away on the weakest page. If you have spent all your time perfecting one part and then run out of time or energy for the rest of the book, the entire project will suffer. The book need not (and indeed cannot) be “perfect.” What is important is that it gets finished and that the quality is consistent throughout the book.

### Project Planning

Beyond planning individual user stories, you also have to plan the whole project. In project management, there are usually three main factors to think about: time, cost, and quality (or content). The basic idea is that you usually can meet only two of those goals. If you want to publish faster and achieve better quality, hire more people. If you want to keep costs down, take more time or reduce quality. If your publication date is fixed, you can either hire more people or reduce quality.

For a book project, you probably cannot afford or make use of additional writers. It might be worthwhile to hire a freelancer for basic research or for writing a first draft, but ultimately, it is up to you, the author. This leaves you with either increasing time or with decreasing quality (or reducing content). With the user story approach where you build up your book step by step, you can stop at any time and release what you have so far, so it is best to timebox your book project. Even if you have chapters left to write, you can always move them to a second book and add a preview to your first book. Also, you are always free to re-release your first book’s contents later, working in any feedback you received. To decide when to divide a book, you might want to take a look at your competition and the book size your readers expect:

• 25,000 words: Short e-book. Strange Case of Dr Jekyll and Mr Hyde is an example of this at about 25,000 words.
• 40,000 – 50,000 words: Most non-fiction books/short novels. Better Books with LaTeX the Agile Way has around 50,000 words. Printed books for sale in book shops should have at least this length so that their spine is large enough for display.
• 70,000 words: Long non-fiction book/novel.
• 100,000+ words: Very long non-fiction book/long novel.

For more examples of lengths of famous novels, check out http://commonplacebook.com/art/books/word-count-for-famous-novels/. For counting words, you can simply use Word’s function (Review/Word Count), or copy your text into Google Docs (Tools/Word Count).

### Working with an Editor

My recommendation is to involve an editor to review your work regularly. Myself, I chat with my editor two times each week, during which time we discuss issues with past books, sales, newly written chapters, and her insights on chapters I wrote the previous week. This way, my memory is fresh and issues can be addressed right away. If I were to wait until the manuscript was done, I might no longer be able to implement some of the suggestions made by my editor.

Ideally, your editor also acts as a writer’s coach and helps you to reflect on your progress. Having someone to report to every week is using social pressure to your advantage. With all the processes outlined above, it is good to have someone look out for you so that you do not get sloppy and make excuses. Alternatively, create a blog where you force yourself to record your progress each week— similar to a diary, but for the public eye. Another possibility is to join a local writers’ group whose members report on their writing progress and motivate each other.

It is too easy to fall into the trap of writing as if you are writing a report and talking to the computer instead of a person. Your editor’s job is to ask you what you actually mean in questionable paragraphs. This puts you into the state of mind of having to explain it to an actual human being.

In terms of tools, there are many that can help you in the process of editing:

• For collaborative editing, it is vital that you see changes the other person made or is making during your chat meeting. I am using Overleaf (see the book for a detailed discussion) for this.
• For shorter books or documents, I use Google Docs, which you can also use collaboratively with your editor.
• For documenting ideas “on the spot” when you are traveling, you can also use these apps on your smartphone. Alternatively, track your ideas in your calendar (app) or make audio recordings.
• For automatically checking your texts, you might want to give Grammarly a try.

### Summary

To sum up the recommended steps to optimize your workflow:

• Prepare your work beforehand; do not switch too frequently between conceptualization/research and writing.
• Find the right tools to work with an editor collaboratively.
• Use automated tools for basic checking of your text.
• Answer your editor when he or she asks what exactly you want to express with a particular paragraph. This will help you to write as if you are talking to a person.
• On a daily basis, figure out what type of goal works best for you: writing for a fixed amount of time, reaching a certain word count, or finishing a user story.
• Finalize individual user stories or chapters, even if it means that details will still have to be added later.
• Commit to deliver completed chapters/sections in regular time intervals. An editor can help.
• Deliver the same level of quality throughout the book. Limiting yourself to regular deliveries will help you with this.
• Commit to a publishing date. Sticking to regular deliveries will make it easier to be prepared to publish your work at any time.
• If necessary, cut your work in half, publish what you have, and get early feedback.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## The Rules of Your Book

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

In non-fiction works, the rules of your book are simply the rules of reality. In order to have a consistent quality throughout your book, I recommend deciding early on how deeply you will be researching specific topics. For the reader, it might be odd to have one chapter full of references, while the others only scratch the surface. If you indeed need different rules for different chapters, make it clear. Ideally, write down these rules in a separate document and have your editor check whether you are following them. In Agile terms, this is called Definition of Done—conditions that have to be met in order for your editor to accept your work. This document could also include things like grammar rules, spelling, rules about usage (e.g., capital letters, lower case, contractions), formatting, citation styles, image resolutions (what prints well?), caption style, tone (formal, informal), or perspective (first person, third person, etc.). This document is typically referred to as a style guide.

In fiction works, after creating your world and characters, it is time to put them into a specific situation and think about how they would act. This ensures that they will come to life and that they really are the actors of your story—and do not seem like they are hanging from the strings of a puppeteer.

If your book follows the (fictional) world’s rules throughout (with very few exceptions), you keep your readers on edge, not knowing how the characters will come out on top. Breaking those rules is possible, but should be done only sparingly to put more emphasis on a scene, for example, “Sometimes, Superman can overcome even kryptonite.”

If you do not provide limitations for your fictional characters, a common mistake is to create “Mary Sue” characters who always do the right thing. This approach means that your characters are driven by the plot, rather than driving the plot. It leaves out internal development. You should handle characters as people who have gone through a series of defining experiences. In order for them to be believable, they had to discover their own strengths and limitations. Even if you want to portray an ideal, you need to explain how they became who they are—this is true even for superheroes. You cannot simply wish yourself to be a hero. Someone who thinks that he or she can do anything without effort is not a superhero but a Mary Sue.

Mary Sue ⋅  Mary Sue is the term for a seemingly perfect fictional character. It originated from a parody of Star Trek fan fiction stories where writers included new characters with a major role in the story, but without making an effort to describe how they reached their position.

Likewise, if you allow your characters to have superpowers when it is convenient, it reduces the relevance of the actual climax of the story. The reader would assume that your characters are unlimited and could overcome any challenge by breaking the rules.

This also applies to non-fiction works if you are discussing people and their achievements: do not forget to include their failures, and how they dealt with challenges privately, in order to paint a complete picture of internal and external development.

Your readers will notice when you are trying to play God within the book’s world. It will break the “fourth wall,” destroying the illusion that these are real characters acting, and not a writer making them act. If you want your characters to reach a certain place or situation, you can create events that shake things up, but those events have to be believable based on the rules you have set up for your world. If you want the reader to think that the person he or she is reading about is a conscious being reflecting on his or her actions, you must create and follow your world’s rules.

The fourth wall ⋅  The theater stage is usually surrounded by three walls, with the fourth wall facing the audience. In this context, breaking the fourth wall is a reference to the characters becoming aware that they are being watched and directly addressing the audience.

Before you define the rules of your book, though, you should have a clear picture of the reader for whom you are writing the book. Some writers advise using 8th-grade level language, especially when it comes to complex topics. This is the same level that, for example, Harry Potter was written in, and which around 80% of Americans can read. With tools like https://readable.io, you can get an idea of the quality of each chapter. With such a feedback tool, you can also train yourself to write at a lower language level than you naturally do. For example, I write (English) at an 11th-grade level, and my books are aimed at adults and professionals, but I am thinking about writing special editions for children.

Likewise, reading is a linear activity, and you do not want the reader to put away the book because he or she stumbled over a weak part of the story. A true page-turner requires the same quality throughout the book. One of the big advantages of using the Agile approach to writing is that (at least to a certain degree) you spend roughly the same amount of time on each part of the book. This maintains a certain level of quality throughout your book. If you catch yourself getting lost in details, it is often better to just finalize open ends (and remove half-finished texts) and prepare your book for a first print. After a break, do a complete read-through. This method helps you more than spending too much time on any one part of the book.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## How to Organize Your Ideas (Fiction Books)

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Don’t say the old lady screamed. Bring her on and let her scream.

Mark Twain

For fiction books, you cannot simply map your user stories directly into individual chapters of your book. Instead, you have to approach the project in several phases:

Second, you will be creating the characters of your world. Some characters you can immediately draw from your choice of genre. For example, in the “noir” genre, you often have a “femme fatale,” a woman protagonist who is rejecting societal expectations like marriage or motherhood. Another example is (a very early part of) the “Western” genre, often with a protagonist who fought on the Confederate side of the American Civil War and is basically portrayed as a “dead man walking.”

Using the template provided by a genre instead of coming up with your own can help you to get started. While it is true that choosing a genre will mean more competition for you, the only alternative would be to do a lot of market research and create and market your own genre. While there are authors who have defined a new genre, these instances are rare—think of William Shakespeare (drama), Homer (poetry), or J. R. R. Tolkien (fantasy).

In contrast to the previously discussed non-fiction books, in fiction books, you are not necessarily describing parts of the real world, you are instead building a new world and fresh characters. Here, your readers cannot tell you what they want to read about, except in a general way. They might want a “Western in space,” but it is up to you to describe how the characters in your world act and react.

As a writer, you set up the fictional world and its rules. If you have done a thorough job, at this point, you can let it play out and unfold on its own, with you just continuing from where you have started setting everything up. Your characterization of the individuals and the world they are living in become the main drivers of the story. A positive effect of applying rules to your fictional world is that it forces you to become more creative. For example, if your Western setting does not allow for magic or modern medicine, you have to come up with other ways your character survives a gunshot wound.

Please note that the general artistic argument is to not listen to what the market “wants” but to write what comes to your mind. I think this is a valid point, given that your mind, your experiences, and your ideas are by default unique in the market. So, whatever you write will automatically fill a niche. Even with this approach, selecting a fitting genre might be useful. You can put your story into a fantasy or science fiction setting without losing its core. If you know that, currently, science fiction stories are most sought after, you might want to give it a shot. The fundamental decision you have to make, though, is whether you are writing as an art form, with the goal of expressing and exploring your emotions and ideas, and learning the trade itself, or if you look at writing as a business, where you have to attract “likes” and “subscribes” to build external validation.

To summarize the difference between how to organize your writing for non-fiction and fiction books:

• Non-fiction: User stories are things your readers (personas) want to know. Group them into topics, then order them in a way so that they build upon the previous stories.
• Fiction: Select a genre based on the interest of your target audience. Create separate user stories for the elements of the world, for each character,and for each scene or event.

Finally, your book needs an overarching theme, moral, or philosophic view. Please note that even if you do not start out by defining it explicitly, you will still have one. We are all driven by a philosophy, consciously or unconsciously. So, whether you intend it or not, your book will have a viewpoint. It could be a whole system of philosophy, or it could be simplistic as in “crime is bad.” We always have some viewpoint. Either we follow the predominant views of the society we live in, or we consciously decide upon a specific theme, morality, or philosophy.

Similar to (physical) rules of your world, you also need ethical rules of your world. If those rules are contradictory or inconsistent, this can lessen the tension in your story and your world will be somewhat chaotic. If the reader can expect anything to happen, then nothing is at stake. An alternative is to maintain contradictory philosophies, but with characters representing them.

The issues are similar to those with non-fiction books: if you decide upfront on a theme or moral, you run into the danger of moralizing and breaking the rules of your “world” (the world within your book) just to prove your point. If you develop the moral while writing the story, you give up control over your world, and you have to adjust the world in a clever way to ultimately demonstrate the point you want to make.

My advice is to start with your views, but the tool to express those views should be the world you have created in your book (or the real world). If you cannot create a world where the scenes or events you have thought about can happen, it might be time to reconsider your ideas.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## How to Organize Your Ideas

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Previously, we have discussed the approach of creating personas and what various personas might want to read. If you are writing a non-fiction book, the next steps are straightforward. What the reader wants to read and what you will provide with user stories is very much aligned. A reader has a specific problem, need, or interest, and you are trying to solve it by providing instructions or information. For example, Better Books with LaTeX the Agile Way deals with topics relatively limited in scope: Part I discusses a project management method, Part II a technology and its application.

For simple non-fiction books, I recommend following these steps:

• Group your user stories by topic.
• Write the book based on the user stories.

But following this step-by-step approach, you get something like a how-to description, dictionary, or encyclopedia. By contrast, in my Philosophy for Heroes series, my goal was to provide a comprehensive discussion of philosophical and scientific concepts for the reader to figure out for himself or herself how to be a (better) hero in real life. As I also used the series as a way to form my own opinion of the topic while continuing to study it, my original approach to plan everything from the start failed.

If you are not already an expert on a topic, if it is not a simple how-to description of a proven method, you will have to go back to the start of your writing again and again to fix something you learn later. Split your project into a series; be open to telling the reader that you have changed your opinion on something discussed in an earlier part of the series to demonstrate that it is also a learning experience for you, the author.

If you want to write a book that takes the reader by the hand and guides him or her through the topic you are discussing, you need something more. You need a big picture, theme, vision, or an overarching story that you want to tell with your book.

For this, you have two options:

• Arrange and re-arrange the user stories and tell a story explaining why they are in this sequence. I recommend writing the user stories on stickers and putting them on a wall, making the whole scope of your book easily visible and easily changeable.
• Start with an overarching vision and then go back to arranging (and possibly modifying) the user stories in a way that supports that vision.

The challenge with the second approach is that you might curtail your creativity. If you start out with the conclusion, all your efforts are focused on proving it, instead of also looking left and right and investigating alternative views on the topic. So, when choosing the second approach, you should be careful to set only a general direction, not a fixed result.

For example, instead of writing a book about how “Word is the best software to write books,” set a more general theme for your book, such as “The advantages of using Word as an author.” This leaves the outcome of your research open but keeps you on track. You could gather a number of arguments, examine alternatives, and end up with clear advice for whom and what kind of book projects Word is the best software. This is also the more scientific approach, helping to prevent falling into the trap of confirmation bias.

Whichever option you choose, you will end up creating some kind of outline of your book, either as a starting point for your user stories or as a tool to connect them together into a consistent theme. This outline will be like a streamlined version of your book. Use it when you practice describing your book in a 30-second “elevator pitch.” If you cannot deliver the message of your book in that time, you could consider either splitting your book into two or more books or rewriting the outline. You could even use the outline as an article you release online (we will discuss releasing parts of your book early in another article and the book).

An additional or alternative approach is to start your book with the front cover. Having to limit the way you describe your book by a title, an image, and a short subtitle automatically helps you to focus on a single idea. It is also the cover, not your outline, that will ultimately sell your book. You can reuse your outline on the back cover or in an online description of your book, but the first contact point with your readers is the cover.

In summary, we have the following two approaches to start writing your book:

Option 1:

“Peter is a paleontology student.”
“Peter wants to know about dinosaurs in the Jurassic Age to study for an upcoming exam.”
• 3.Group your user stories by topic.
“Dinosaurs in the Jurassic Age.” “Dinosaurs in the Cretaceous Age.”
• 4.Arrange your groups of user stories into a sequence that fits into the narration of your book. One story or group of stories should build upon the previous one. When in doubt, put more important user stories before less important user stories.
“First Jurassic Age, then Cretaceous Age…”
• 5.Write a basic outline or come up with a theme or vision of the book that fits the written user stories.
“In this book, we will discuss the different Ages of life on Earth in chronological order.”
• 6.Write the book based on the user stories.
“Dinosaurs first appeared during the Triassic period, between 243 and 233 million years ago…”

Option 2:

• 1.Write a basic outline, come up with a theme or vision of the book, or create a book cover.
“In this book, we will discuss the different Ages of life on Earth in chronological order.”
“Peter is a paleontology student.”
“Peter wants to know about dinosaurs in the Jurassic Age to study for an upcoming exam.”
• 4.Group your user stories by topic.
“Dinosaurs in the Jurassic Age.” “Dinosaurs in the Cretaceous Age.”
• 5.Arrange your groups of user stories into a sequence that fits the outline, theme, or book cover. When in doubt, put more important user stories before less important user stories.
“First Jurassic Age, then Cretaceous Age…”
• 6.Write the book based on the user stories.
“Dinosaurs first appeared during the Triassic period, between 243 and 233 million years ago…”

For Part II, I decided on the second option. Market research has shown me that there is a demand for books about writing, but only a limited supply in terms of books discussing how to write books in LaTeX. While there are many introductory books about LaTeX, there are only few that focus on helping book authors. I want only what gets someone from A to B (in this case, writing a book) and nothing else.

But instead of asking people if LaTeX is what they actually want, I went for the niche simply because my objective of the book was to reflect upon and document my own writing process. The advantage of this approach was that I was able to write a well-rounded and focused book; the disadvantage of this approach was that I might not have taken the actual needs of readers into account. I simply present the proven solution I have found. Maybe the bigger market would have been the people writing books in Word?

For the elevator pitch for Part II, I used the following form:

• For: First-time authors, novel writers who want to write a first non-fiction book, writers who are looking for better tools, LaTeX experts, editors who want to expand their services, LaTeX beginners who are looking for an introductory book, self-publishers who are seeking insights, and professionals who want to add a book to their portfolio,
• The: “LaTeX” part
• Is an: introduction to building books with LaTeX
• That: takes readers through a variety of topics on publishing, from A to Z with the focus of using LaTeX as the central word processor.
• Unlike: pure LaTeX books that focus on the technology or pure publishing books that ignore the difficulties of managing more complex books with Word,
• We: provide a template and a tutorial that even beginners can use and professionals can refine for their purposes and embed this technical knowledge into a discussion of publishing, polishing, and editing.

For the user stories for Part II, I developed the following list (the “what” part is in bold for each user story):

• 1.Mary wants to know about the possible advantages of using LaTeX instead of Word to make an informed decision on whether to use LaTeX for her future books.
• 2.Mary wants to know how and where to insert the texts (foreword, preface, publisher information, TOC, glossary, etc.) into the template for an e-book / printable PDF.
• 3.John wants to learn the basics of LaTeX so that he can make small adjustments to the template and enjoy a head start when learning more complex commands.
• 4.John wants to know how to better manage bibliographical references to save time and reduce mistakes.
• 5.John wants to know how to better manage indexes to save time during index creation and after page changes.
• 6.John wants to know the reasoning behind the organization of the template in order to make informed adaptions.
• 7.George wants to know how to convert his LaTeX document into an HTML file to publish it as a website article.
• 8.George wants to know the special requirements of final polishing (which image quality to choose, what to do about blank spaces and page breaks, etc.) of the PDF to make a professional-looking printed book.
• 9.George wants to know how to tweak the HTML output (page breaks, table of contents, etc.) to improve conversion quality for mobi (KDP) in order to have an e-book of high quality.
• 10.Clara wants to know how to publish her books and e-books on Amazon KDP, so that she will have a central place to manage and sell them.
• 11.Peter wants to know about how to create a book cover, LaTeX graphics, etc. and how Lode Publishing can help to create an appealing book.12.George wants to know how to reuse glossary items and other text blocks to save time when writing a series.

For the user stories of this book, I developed the following list:

• 1.Peter needs a pep talk to prepare him for possible disappointments when starting a book project.
• 2.Peter wants to know about the potential sales of his book in order to better plan his expenses (and manage his own expectations).
• 3.Clara wants to know the general approach to investing money so that she doesn’t waste any.
• 4.Clara wants to know how she can incorporate her book into her professional career and benefit from it more than just through book sales.
• 5.Peter wants to know where to start with a fresh book project so that he will not get lost in endless edits that prevent him from completing and releasing the book.
• 6.Peter wants to know how to better decide what to include in the book and what to leave out to create a better book more efficiently.
• 7.Tina wants to know how to use personas so that she can write for her target audience.
• 8.Mary wants to know how to have the same quality of language and content throughout the book to keep the reader engaged.
• 9.Clara wants to learn a method for organizing her ideas and how not to get lost in details so that she can write a comprehensive but to-the-point book.
• 10.Tina wants to know and stay in contact with her audience as a means of increasing future sales.
• 11.Mary wants to know how to conduct market research for books and how to include that into the writing process so that she can sell more books.
• 12.Peter wants to understand what working with a professional editor or coach looks like and how it could help him in order to make an informed decision about whether to hire someone and whom to hire.
• 13.Mary wants to know how to work more efficiently with her editor to speed up the writing and editing processes.
• 14.John wants to know how to better organize his communication with an author in order to reduce overhead and better deliver what the author expects.
• 15.Mary wants to know how to create better ads on Amazon to increase sales.
• 16.Peter wants to know how to properly cite so that he will respect the work of others.
• 17.Mary wants to get earlier feedback for her book so that she can incorporate market demand and readers’ wishes into her book.

This is an excerpt from Better Books with LaTeX the Agile Way. You can get a copy here.

Categories

## Did Bilbo Sail to the West?

### How to improve the overall quality of a book

Was it
Bilbo who sailed to the West? Reading Philosophy for Heroes: Knowledge, the first in a four-part series on what it means to be a hero, this seems to be the case. On page 5:

Now, while the case could be made that Bilbo underwent a heroic transformation, that he fought evil, that he traveled to the West and might have used a boat at some point, the story sounds much more like Frodo’s story in Lord of the Rings. The author himself is well versed in fantasy literature, and the amount of media related to the subject is anything but sparse. How could such an error happen?

Well, first, let me admit that I am that author. I am not sure if this is the right or smart way to discuss my own book, but some self-reflection is a great way to grow. So, let us analyze where I, the author, went astray.

My usual judgement on products (in this case, a book) is that they are a mirror of the company behind them. If you have a little bit of background information, reviewing a product can be like an archaeological dig. Philosophy for Heroes: Knowledge is a multi-layered book. First, it is part of a series. When writing the first book, the other three books had to be kept in mind. In addition, especially being the first book, it had to stand on its own despite its dealing with the basics (philosophy and language). You cannot sell a book called “Philosophy for Heroes” and then tell the reader to wait for part 4 to finally read about what heroism means. Second, it contains a variety of components: study questions, ideas summarizing a section, biographies adding a human element to sometimes abstract explanations, and real life examples. Skimming through the book, especially those components seem to be “added features” that—while adding value to the book—could just as well be removed. This points to an evolution of the book. Looking back, this is actually true, it underwent a number of transformations:

1. A single, very large book
2. A five-part series
3. Then, a four-part series
4. Then, a four-part series with the first book required to stand on its own
5. Finally, a four-part series, the first book standing on its own, and additional components (study questions, ideas, biographies, examples, etc.)

As this evolution played out, the later changes underwent the least amount of review, while certain parts, that were already finished when devising the initial large book, had so many reviews, the time spent on dragging them along was a waste of time. How does one write a book without having such a large variance of quality between its parts?

For this, we look at software development. A piece of software faces the same problem, it evolves, some parts are “fresh,” others have been looked at and tested for years. The solution people came up with is called “Agile” (with one variant being “Scrum”). My current project deals with this subject, feel free to check it out here.

The best approach to write something—anything—is to make sure that its pieces stand for themselves. The advantage of this approach is to have those pieces complete and ready, and you can publish each to get feedback and build an audience. Looking back, I should have published each section separately. Sure, someone could piece all the sections together and then have a copy of the book for free. But that takes a lot of effort. Even if it is just half an hour of work, you could have easily bought the book for yourself. Also, the final edit of a book surely connects the independent parts to a greater whole.

In any case, if I did follow that “Agile” approach, it would have been Frodo, not Bilbo, throwing the ring into the fire and traveling to the West.

Lesson learned.