Here’s how to produce a good looking epub file of your work.
1 – Download and install Pandoc
First off, go download and install pandoc. Pandoc is a command-line tool used to convert ebooks files from one format to another. It is the heart of my little self publishing program, SPAB!. For fiction, the easiest thing to do is start in a markdown-formatted txt file.
2 – Gather your book files
- Your book as a .txt file, formatted using markdown. See the markdown notes below.
- a custom .css file (or not, but it’ll look way better with one. I have an example below)
- Your book cover image
I would put all of these files in one directory if I were you.
3 – Run pandoc to generate your epub
Open a command window by using the file explorer to find your book directory, hold the shift button and right click on it to get the expanded menu, then click on “Open command window here.”
You’ll get a old school command window that’s already in the directory you need.
Here’s a template for the pandoc command you need to type in.
pandoc -f markdown -t epub --epub-cover-image=cover.jpg -o final.epub --smart --toc --epub-stylesheet=epub.css inputfile.txt
Here’s what this does:
- pandoc the pandoc executable.
- -f markdown tells pandoc that your input file is in markdown formatted text. Pandoc would probably figure this out on its own, but better safe than sorry.
- -t epub tells pandoc to create an epub file. Pandoc can also generate all sorts of other stuff, like pdfs and openoffice odt files.
- –epub-cover-image=cover.jpg use the indicated image as the cover.
- -o final.epub name the output file.
- –smart convert all the striaght quotation marks to smartquotes. Also fixes apostrophes and some other stuff.
- –toc generate a table of contents. It uses all of your markdown headers (see markdown notes below)
- –epub-stylesheet=epub.css style the text in a way that looks professional. I’m including in this post the custom .css file that I use.
- inputfile.txt um, the name of the your text file.
Then hit enter.
Bam! Your epub is created.
Custom .css file
Here’s my custom .css file, which I think makes the prettiest, most professional ebooks ever. At least, it’s what I’m using now. This version is a little better than the one I include in the distribution of SPAB!.
Using Markdown to format your text files is simple. The following example explains you the formatting tricks most common to fiction authors.
Here’s a couple of files you can use if you just want to experiment with pandoc using the examplebook.txt and epub.css
Questions? Comments? Concerns? Exclamations?
Yeah. You know what to do.