Man reading book

Publishing a book

Over the last thirty plus years I’ve been involved in software development I’ve written a few half decent articles. Mostly for colleges and myself. I wanted to publish the articles into a hard back book format, so that I always had a copy to refer to.

LuLu is a service which allows you upload a PDF and print an on demand copy of your published book. They offer professional hardcover binding starting at around $11 for a 24 page book. The price increases depending on the number of pages in your book and if you require the internal pages to be printed in colour.

Forging FHIR article

The process of producing the PDF file which LuLu could use to print the book was relatively easy as all my articles were written using the typesetting system LaTeX. There were a few changes that I needed to make which are outlined below.

The first step was to convert all the articles from a two column report using an A4 paper size, to a single page formatted for the US letter size. I also had to slightly modify the margins. Here’s what I used in my global style sheet.


\usepackage[paperwidth=6in,paperheight=9in]{geometry}

\geometry {
    verbose,
    tmargin  =2.5cm,
    bmargin  =2.5cm,
    lmargin  =2.5cm,
    rmargin  =2.5cm,
    headsep  =0.89cm,
    footskip =0.89cm,
    columnsep=1.5cm,
    headheight=1.5cm
}

Each of the articles were published to its own PDF file, so I used the PDFtk command line tool to join the individual PDF files into a single book file. It was this book PDF file that I upload to LuLu.


pdftk dabbling_in_docker.pdf grokking_git forging_fhir.pdf cat output book.pdf

Now that I could create the book, I needed to ensure that the page numbering was correct for each article. For example, The Dabbling in Docker article is twelve pages long, so I needed to start the page numbering for the Grokking Git article from thirteen.

I used the setcounter command at the start of each LaTeX document to set the page to the correct offset value.


\setcounter{page}{13}

Next, I wanted to ensure that each new article started on the right-hand page of the book. Like it should. This meant if the article didn’t start on the right-hand page I needed to pad out the previous article so that it would. This meant adding the occasional newpage command to the previous article to force the next article onto the correct side.


\newpage

Finally, when publishing a book, it’s best if the total number of pages within the book are divisible by four. So the final tweak I made was to add enough newpage commands to the last article in the series to ensure that the total number of pages was divisible by four.