This is a template project for generating a novel or story collection from markdown files and building an ePub file, a SFFMS format manuscript PDF, and an electronic-submission-friedly DOCX file using Pandoc, LaTeX, and GNU Make. This project is fork of pandoc-novel, upated for the needs of modern writers who stil seek traditional publication. For the time being I have deprecated print-ready PDF support because the createspace package on which it depends is weird and old and hard to set up.
Well formatted ePub should be enough for publishing ebooks books with Amazon KDP, Barnes and Noble Press, Smashwords.com, and other self-publishing outlets.
You can see example output for ePub, DOCX and manuscript PDF.
- Pandoc
- LaTeX
- the
sffms
package for formatting a manuscript-format PDF.
git clone [email protected]:jp-fosterson/pandoc-novel.git
...or fork the repo (it's a template), and clone your own copy.
cd pandoc-novel
make
This will build three targets out/example.epub
, out/example.docx
, and example-ms.pdf
. Open them in your favorite viewers.
If you're on macOS make view-epub
will attempt to build the epub
target and open the file in Calibre's ebook viewer component (without actually adding the book to your library). Likewise make view-pdf
will build the pdf
target and open it with the default PDF viewer (probably Preview
). If you're not on macOS, you can edit these targets in the Makefile
to open the documents in your favorite viewers.
The most important part of the novel, the text, goes in markdown-format chapter files in the text/
directory. Aside from the .md
extension, there are no particular requirements about the file names, chapter ordering will be defined in the Makefile
(see below). Chapter titles should be indicated with a H1
-level header. If you wish your chapters to be unnumbered, tag them with {.unnumbered}
after the title. Backmatter such as acknowledgements and an author bio should just be included as {.unnumbered}
chapters; they will be indicated in the Makefile
.
Set the SLUG
variable in the Makefile to change the prefix used on the output files
#
# Slug: filename prefix that will be used for the generated
# files. e.g. example.epub and example.pdf, plus intermediate
# files like example.tex
#
SLUG=example
To define the chapter ordering add the chapter files, in order, in the CONTENTS
and BACKMATTER
variables in Makefile
:
#
# The main text of the book. This sequence determines the
# chapter order.
#
CONTENTS = \
text/beginning.md\
text/middle.md\
text/end.md\
\
#
# The stuff in the back, not part of the story.
#
BACKMATTER = \
text/ack.md \
text/about.md\
\
The title, author, copyright notice, ePub cover image, and other important metadata are defined in metadata.yaml
.
make
ormake all
--- makes the main ePub and PDF targets inout/
.make docx
-- builds the submission-ready book DOCX.make epub
--- builds the epub book.make ms
--- builds the manuscript-format PDF.make unzip
--- Builds the ePub document, which really just a zip archive full of files, and then unzips it intoout/$(SLUG).unzip
so that you can examine the contents. This is fun for the curious, or if you need to understand the style classes used in the document when modifying the stylesheet (see below).make clean
--- cleans up everything, including the output and all the LaTeX shrapnel left in the directory after building.make tkcheck
--- searches for "TK" in the text and fails if it finds any. [Editors use "TK" to indicate more to come, i.e. unfinished writing. You can domake tkcheck all
to build the documents only when all TKs are removed.]
You can customize the style of the generated ePub via CSS stylesheets, and the PDF via the LaTeX document template. The style of the DOCX requires a reference doc.
A default reference doc is provided in the templates
directory, but this can be edited with Microsoft Word or Google Docs to suit your needs. It is currently in beta.
The STYLESHEET
variable in the Makefile
selects the stylesheet to use when building the ePub document. Two stylesheets are provided in the /css
directory, one with an indented paragraph style and one with a block-paragraph style. Either can be used as a starting point for a new style. If you're not sure what style classes you need to modify, do make unzip
then examine the chXXX.xhtml
files in out/$(SLUG).unzip/EPUB/text
.
The LaTeX files that generate the book and manuscript PDF are built from templates in templates/book.tex
and templates/sffms.tex
. They use Pandoc template syntax.
For the book PDF, the title page design for the book template was taken from Peter Wilson's great collection of LaTeX title pages, feel free to replace it with a design you like better. The page header and numbering are controlled by the fancyhdr package.
For the manuscript PDF, I had to define or override a handful of LaTeX commands to get some things to work (e.g. sections). Inputs that deviate consierably from the example text may require some LaTeX tinkering to get right. By default, the manuscript omits the backmatter like "Acknowledgements" and "About the Author" sections. To include them, add $(BACKMATTER) to the $(SLUG)-ms.tex
target in the Makefile
.
Amazon KDP will take an ePub doc and covert it to a Kindle book, and it does a fairly good job. If you're curious what it looks like, you can get Kindle Previewer, and other ebook sites take ePubs directly.
I have only tried KDP, but the KDP site does a pretty good job of showing how your PDF will fit in different page trim sizes. I found that despite using the "pocket" size parameter in the createspace
package, it fits well in 6x9" with good size margins (IMO).