How I typeset my books

published: 2023-12-01


A few people have asked me over the years how I make ebooks. Until now, my answer has always been to shrug and say, "I just throw them into Calibre." But I realize that's not an actual answer, just an oversimplification because I usually don't have the energy to type out whole essays into one person's inbox, especially when the question is only being asked for the sake of curiosity and not because they want to make a book of their own.

My earliest books were made by throwing whatever poorly-formatted Microsoft Word documents I could squeeze out of Google Docs into Calibre and then using a Calibre plugin to merge them into a single book. Because the documents were split by "part" and not by "chapter", the resulting Table of Contents wasn't exactly useful. Then, around the time of Living Wasteland, I got my first computer and switched to LibreOffice for all my (non-school) writing. I also started writing a separate document for each chapter. During the typesetting of this book (or maybe it was Me Before You) I learned that Calibre allows you to make a blank book and then open an ebook editor and import Microsoft Word and HTML documents directly into it.

After The Duality Of Mankind, instead of using LibreOffice for writing, I just used a plaintext editor and wrote everything in Markdown. I was tired of the poor formatting and cruft that both Microsoft Word and LibreOffice spat into exported HTML files, and I was also seeking to reduce the size of the resulting files. Plus there was also the privacy concern of copy-pasting entire chapters into an online HTML stripper to forcibly remove <style> and <div> tags. Markdown files thrown into an HTML converter like smu have little to no formatting by default, which is why the earliest books of mine look radically different style-wise than, say, Mori's Mirror and The Poetry Factory.

At the time of writing, I have just finished the typesetting for Ultrawhite and moved into the editing stage. While it's still fresh in my memory, here's how I typeset my books nowadays:

  1. Open Calibre. Right-click "Add books" and select "Add empty book". Fill in the metadata fields for title, author, series, etc. and select "EPUB" under "Also create an empty e-book in format". Afterwards, click "Edit metadata" and add a cover.
  2. Click "Edit book" to open the editor. Right-click the pre-generated start.xhtml file and delete it. Then go to Tools and click "Add cover". This will insert an actual title page into your book.
  3. At this point, you should convert your Markdown files to HTML ones. You can either import the HTML files directly into the book or create a blank .html file inside of the book and copy-paste that chapter inside. The advantage of the second one is that Calibre can automatically insert the <style> tag for a book-wide CSS file, which is helpful in case you didn't bother to make a CSS file before creating the book and now you need to.
  4. Because the default header font in Calibre and most HTML renderers is boring, you should go to the Font Library and find a font that you like and that has a license compatible with your book. Remember to credit the font's creator and link to the license on your book's copyright page or similar. When importing the font file into your book, Calibre should ask if you want to add the appropriate @fontface rules to your book's CSS file.
  5. After importing all the files into your book, you should create a Table of Contents by going to Tools, then "Table of Contents", then "Edit Table of Contents". Click the button that says "Generate ToC from major headings". Depending on your book's structure, this should be good enough, although you may need to manually insert an entry at the top for the title page. If you have a "first page of part/act" page with both an <h1> and <h2> tag, there will be a duplicate ToC entry for that page that you should remove.
  6. When done, or if things are feeling wonky, click the bug icon. Alternatively, go to Tools, then click "Check book", or press F7. If Calibre finds any errors or quirks in the book's HTML or CSS files that may prevent ebook readers from properly rendering the book (or at all), it will show an alert with the exact location of the error. It will also show an alert for any files that are extraneous (unused) or missing, incorrect mimetypes, HTML files that are long enough to cause errors on some devices, and CSS rules valid but generally not usable by ebook readers.

Congratulations! You've created an ebook without the cruft of Microsoft Word, Amazon's book publishing service, or shady online file converters.


CC BY-NC-SA 4.0 © Vane Vander