Skip to content

Latest commit

 

History

History
69 lines (42 loc) · 2.83 KB

BUILD.md

File metadata and controls

69 lines (42 loc) · 2.83 KB

Introduction

As open source books, ebooks and pdf format should be created on fly, the following sections describe those solution in detail.

The solution below is based on Pro Git; while it is little updated on format inside.

Making Pdf books

PDF format is used to read/print in nice way like real book, pandoc good at this and it is used instead to generate latex from markdown, and latex tool xelatex (is part of TexLive now) is used to convert pdf from latex.

Please check ctax and TexLive for more background for latex, which is quite complicated and elegant if you have never touched before.

Ubuntu Platform

Ubuntu Platform Precise (12.04) is used mainly and it is continuously verified by travis-ci.org as well.

pandoc can be installed directly from source, which version is 1.9.1.1.

Though texlive 2011 can be installed separately, the default one texlive 2009 from Ubuntu repository is good enough so far.

$ sudo apt-get install pandoc $ sudo apt-get install texlive-xetex $ sudo apt-get install texlive-latex-recommended # main packages $ sudo apt-get install texlive-latex-extra # package titlesec

You need to install related fonts for Chinese, fortunately they exist in ubuntu source also.

$ sudo apt-get install ttf-arphic-gbsn00lp ttf-arphic-ukai # from arphic $ sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei # from WenQuanYi

Then it should work perfectly

$ ./mkbok

Just remind you, some extra pandoc markdown format is used inside this book:

  • code syntax highlight (doesn't work in pdf, while it should work in html/epub which needed later)
  • footnote

Making Ebooks

I start to use pandoc for epub and html as well, since from 1.8.x, pandoc supports them as well.

You can simple run the command below to generate related ebooks

$ ./makeebooks zh # default for html $ FORMAT=epub ./makeebooks zh # for epub

It seems pandoc had limitation on 1.8.x

Cover

In pandoc 1.8, the cover is not supported for epub, calibre is used to change it manually.

Handle PDF

Below solution is not used, latex \includegraphics[scale=0.8]{ebooks/cover.pdf} is used directly.

When cover and other pdf pages are changed using pdftk, the bookmark is lost, extra tool is used to fix this.

pdftk sdcamp.zh.pdf dump_data > in.info
pdfbokmark.rb --input in.info > pdfmarks # may update pdfmarks for broken pages
pdftk A=book-cover.pdf B=sdcamp.zh.pdf cat A3-4 B3-end A7 output merged.pdf
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=sdcamp.zh.community.book.pdf merged.pdf pdfmarks