Page 1


Mundy Obilor Jim


Handcraft EPUB In 7 Steps by Mundy Obilor Jim. Copyright Š 2015 JimArts Publishing. All rights reserved. ISBN 978-82-998906-9-4 No portion of this book may be used for further publication without the written permission of the publisher as it is protected under the copyright laws. Permission is not required for the use of the code examples in this book as the major objective of the book is to assist new authors and self-publishing authors alike.

Preface To effectively write and publish an e-book as a self-publisher or as an author, you will be confronted with many questions. Handcraft EPUB In 7 Steps will not only answer most of these questions but also give a right foothold to anyone dreaming to be a good author in our ever-changing, 'digital publishing' world. The book aims at truly emphasizing on the word 'crafting'— as it will in a stepby-step fashion, show how you can create an EPUB with your own resources without paying too much attention to the associated syntax and semantics and without using any conversion software. The book will not bore you with coding! See every code in this book (CSS or XHTML) as a 'mini formula'. You should be able to build on these steps even as you proceed further in epublishing. Some of the questions bothering new intending, do-it-yourself writers include the following: 1. Can I publish my e-book myself without the fear of first learning all sorts of coding like XHTML and CSS? YES you definitely can, even though the skills of writing in mark-up languages are rewarding. 2. Should I publish in EPUB2 or in EPUB3 format? Good question! While EPUB3 has richer features in styling and structure — it gives the possibility of adding media content for example, EPUB2 remains the more widespread format at present time. Often the assertion is that many platforms now support EPUB3. To some of us, The reality here is that the 'many' happens to be just in the 'minority'. 3. I have read that an EPUB is just a website in a box. Does it mean I have to learn some special packages or understand some web design? No! As long as you have your resources ready (text, images, etc.), you can hand-craft your own EPUB by following the simple steps outlined in this book.

4. What if I just use a conversion software or tool to convert my e-book to EPUB? Is there any big difference? This is not a bad idea but the fact remains that you might not get the best layout you desire and most importantly, you will still be far away from imbibing the attitude of 'do-it-yourself' on one hand; and on the other hand, you may encounter several errors during validation. Bear in mind that some distributors may stipulate that you submit a validated EPUB and they often advise authors to avoid submitting books converted with third party software. But I must submit to anyone that in our modern computing times, there is a whole lot you can do yourself without pain, stress or those long periods of waiting for professionals to complete the entire process of your publishing adventure. 5. If I decide to do it myself, will I be able to have my e-book on several sales platforms? Yes, as long as you are willing to sit back and write your book, you will learn how to publish your book within multiple sales platforms. Chapter 1 attempts to degrade or destroy the fear of coding. The word 'degrade' is probably more suitable as you will find out that it is a good idea to acquire some knowledge and understanding of CSS, especially the basic ones. In Chapter 2, we will look at the best practical methods to place items like images and videos. We will at best, show how to hand-craft an EPUB in Chapter 3 in seven instructional steps before we see in Chapter 4 how we can publish and sell our e-book. In a few words, this book can be titled "EPUB creation made simple for authors.

Contents Summary 1. Preface 2. CHAPTER 1. Codes Are o Barriers 1. The EPUB Structure 2. From EPUB To MOBI 3. Fear No codes 4. MathML or Images 3. CHAPTER 2. Media Best Practices 1. Stinginess with CSS 2. Drop caps fever 3. Image Placements 4. When Videos Are Essential 5. Exuberant Aesthetics 4. CHAPTER 3. Let's Go Crafting 1. Step 1: Getting Set 2. Step 2: Using A Blanc EPUB 3. Step 3: Start Writing 4. Step 4: Front Cover, A First Impression 5. Step 5: The EPUB-Kindle clash 6. Step 6: Tidying Up 7. Step 7: Validation Methods 5. CHAPTER 4. Publish, Sell, Honest Opinions 1. Publishing options 2. Sales and royalties 6. Bibliography 7. Appendix

Terminologies 1. 2. 3. 4. 5. 6. 7.

MathML — Mathematical Mark-up Language CSS — Cascading Style Sheets XHTML — Extensible Hypertext Mark-up Language LaTeX — Lamport TeX IDPF — International Digital Publishing Forum KDP — Kindle Direct Publishing EpubCheck —A software tool for validating EPUB files

CHAPTER 1 Codes Are o Barriers The first running thoughts of Authors when they have finished with the manuscript of their books in raw formats (Microsoft Word, Text, HTML, etc.) are the thoughts of how best to get the book published as a standard e-book so that it can be on the shelves for people to view, read or buy. More often than not, new authors are usually embroiled in the making of two choices: the first is to find and utilize a conversion package (some of which are free) to convert the books to any format. It turns out that in most cases, they are not completely happy with the outcome— they think their dream e-book should look better than that. The second option for beginners is to approach some conversion experts to do the job so that the e-book looks the way they desire; or better still, to approach an 'aggregator', who will do the conversion of the book and ultimately distribute the e-book through various retailers. Either way, these are good choices and ultimately, the e-book is now a material that the world can see and purchase. I have personally utilized both avenues extensively but I must again and again submit to anyone who intends to take responsibility that the process will take away some precious time, at least if you consider that your plan is to write three to four books within a short period of time. However, your desire may be that you want to understand the publishing process, do things yourself and even publish your book, at least from a business start-up point of view. Then you are reading the right book. If the term "EPUB" is not in your project or planning dictionary and you are thinking more in other e-book formats like MOBI, never mind. Just feel at home as you will happily arrive at that final e-book of your choice, including a MOBI format for a market place like Amazon. In other words, this book is not only for those who want to create EPUBs. It goes a little further— with a well-formatted or finished EPUB, you can publish your book on platforms like the Amazon Kindle Store? We shall outline this simple process in Chapter 3 (Let's Go crafting) and Chapter 4 (Publish, Sell, Honest

Opinions). The objectives of this book are very simple: 1. To help writers and intending publishers to see that working with codes such as putting your texts, book information and images within XML or XHTML and using CSS to style the display are no stumbling blocks but that it is better to see the codes as tools to wrap up your book rather than seeing the coding process as some 'must have skill' criteria. 2. To show the art of writing and formatting a standard e-book, whether it is meant for the e-book market place or the idea is to archive office or similar documents in EPUB formats. 3. Explain certain best media practices which include proper handling and placement of images and other media contents within your e-book. 4. Render some basic tips on how one can publish an e-book. For simplicity and adapting this book to be of suitable use to self-publishing authors, we will not dwell much on some of the hyped features of EPUB3 like media overlay and text-to-speech functions for now.

The EPUB Structure EPUB stands for electronic publication and is often written in a style format, 'ePub'. It is the globally accepted e-book format! Well I guess anyone can fault this seven-word definition by arguing that PDF, MOBI, among others are also globally accepted formats. No fussing! The format was designed to bring a standard to e-book publishing. It can be read on a wide range of e-readers, including the Apple iBooks, Nook e-reader, Sony e-reader, Kobo e-reader application, Google Play etc. The format has grown dramatically. It is designed for reflowable content, and this means that EPUB readers do have the capacity to amend text sizes and font styles for a particular display device. In addition, EPUB also supports fixed-layout content in its 3.0 and later versions. As mentioned in the preface, it is not part of the objectives of this book to dwell on EPUB semantics. It is rather channelled towards self publishing authors who are probably unwilling to start the publishing process of their books because of what they view as long processing, coding and syntax barriers or what they term as 'complex' after reading the previews of some EPUB-related published materials. That notwithstanding, let's see what the official definition of EPUB is and as stated earlier, it's best to avoid going into

details of syntax and semantics but rather go towards our goal— to hand-craft an EPUB in Chapter 3. In the definition of the IDPF (International Digital Publishing Forum), an EPUB is The distribution and interchange format standard for digital publications and documents based on Web Standards. EPUB defines a means of representing, packaging and encoding structured and semantically enhanced Web content— including XHTML, CSS, SVG, images, and other resources— for distribution in a single-file format. EPUB allows publishers to produce and send a single digital publication file through distribution and offers consumers interoperability between software/hardware for unencrypted reflowable digital books and other publications.[1]

A simple EPUB structure The image next shows a simple structure of an EPUB containing one chapter— with all the zip components, which sometimes include several other XHTML files.

Figure 1.1 – A simple EPUB structure The first dotted line just indicates that the table of content file 'toc.xhtml' can be optional (for EPUB2) as toc.ncx renders the table of contents. However, EPUB3 takes it a little further with the <nav> element as you will realize when you start writing in this format. We will use this structure to hand-craft our ebook later in Chapter 3 using the XHTML 1.1 standard. Please refer to this chapter for the actual code examples you can use. Let's breakdown the structure, but never mind if they sound too complex. Their technicalities cannot slow down an author. 1. container.xhtml— an XML file contained in the META-INF folder which points the operating system to the content of the e-book. 2. chapter1.xhtml— contains the first chapter or section of the book. 3. content.opf— contains, among other items, the metadata, title, publishing information and the identifier of the book. As you will see in Chapter 3, this file also contains two other segments— the 'manifest', which refers to all resources available within the book, and the 'spine' which contains references to the XHTML files (using identifications or 'IDs' defined in

4. 5. 6. 7.

8. 9.

the manifest). front-cover.xhtml— is like every other XHTML file. The cover image is rendered more easily through this file and managed with a simple CSS style. stylesheet.css— is referenced from within the head element of the XML document and is used for describing the look and formatting of the book. toc.ncx— is a table of content file created within an XML resource. Although deprecated for EPUB3 which favours the <nav> element, backward compatibility allows its inclusion. OEBPS— This folder simply stands for 'Open eBook Publication Structure (OEBPS) and is an XML-based specification for the content, structure and the presentation of e-books'. It is very practicable to create sub-folders inside this folder, especially for images when there are several of them within a book. mimetype— An e-reader usually looks for this mimetype, and then looks for the meta info in the container and sees the OPF file. This ASCII text file simply explains that the content is an EPUB document. toc.xhtml— is also a table of content rendered as an XHTML file and it is sufficient to have it in EPUB2 but note that there is an interesting change in EPUB3 with the introduction of the <nav> element and it's common to have it in this new format as shown ahead. This navigation document which may also be included in the spine section, is a major requirement in EPUB3.

<nav epub:type="toc" id="toc"> <ol> <li> <a href="chapter1.xhtml"> Handcraft EPUB</a> </li> </ol> </nav>

The latest version of EPUB (approved in 2014) is 3.0.1. EPUB3 is a common goal amongst many publishers but for many distributors and retailers, migration from EPUB2 to EPUB3 has been understandably slow and this has made EPUB2 the more widespread format in the e-book market supported by virtually all e-reading applications and devices including Apple iBooks,

Google Books and Amazon Kindle (a validated EPUB is, by yhe way, an acceptable format by Amazon KDP). Some argue that EPUB3 is not supported fully by all e-readers and that at best, it has moved towards the internet browser capabilitiesâ&#x20AC;&#x201D; a little drift-away from the classification of a book. In a quest for IDPF members and EPUB experts to reach this goal, they have realized that deciding the modes of e-book publishing business and encouraging the interaction between authors and distributors are two opposite sides of the coin; just as research work can be far away from practical work realities on ground in any technical endeavour. The advantages of EPUB3 over EPUB2 are remarkable but to tell when the global e-book market will be under the umbrella of that single definitionâ&#x20AC;&#x201D; an EPUB being 'a globally accepted ebook format' seems to be far away from reality. The benefits of EPUB3 include 1. 2. 3. 4. 5. 6. 7.

Audio and video embedding Scripting and intractability MathML inclusion Fixed Layout publication Improved accessibility Right-to-left inclusion of language text Media overlay (reading aloud)

EPUB3 also supports the embedding of scalable vector graphics (SVG) and fonts. Be aware that adding or not adding fonts has been a subject of debate but it is ultimately a matter of choice. Like many, your opinion may be that there is no much need to add fonts since, after all, end users make choice of fonts based on what is available on their reading devices and applications. Having outlined those benefits, there are some major advantages of EPUB2 (at least in my own opinion) that are making them still flourishing and not outrightly giving way to EPUB3. The last three of the outlined advantages of EPUB3 which include improvement in accessibility, the possibility of e-book reading from right to left as obtained in some Asian literary cultures and the media overlay capabilities are indeed great achievements as far as the e-book world is concerned. However, even though it is a breakthrough to have such wonderful features as audio, video and media overlay, there remains a battle between elegant refinement and the passionate culture for reading.

1. A large number of people, especially the fiction or novel readers just want to read as many books as they can and not necessarily watch videos or listen to any audio. So if these end-users are just passionate to read and read more books, EPUB2 might as well have a thumbs up! 2. At the moment, not all e-readers (tablets, phones) in the hands of users are of large capacity in terms of storage or how much content they can hold. An e-book containing audio or video increases the e-book size considerably, some of them in gigabyte range. With this analogy, the desire to have a good number of books in one's e-reader will most likely still have EPUB2-formatted books dwell supreme. 3. One critical area is the issue of using MathML, a great asset for Scientific and Technical writers but as things are, a large number of distributors, retailers and publishers will not accept EPUB3. Secondly, some of those who accept EPUB 3 may for some reasons, not want to publish MathML content. Well, I figured out the best way out as we will see later in this chapter.

From EPUB to MOBI Let's relax some minds, especially of those who are asking themselves how to convert their EPUBs to MOBI files: Having the book as a validated standard EPUB format is good enough to be ready to publish on Amazon. To have the book published on Kindle, the first step is for you to sign up and create an account with KDP and have a book file that has been formatted in one of the supported formats. Good enough for those of us who dwell on EPUBs, it is one of the formats that Amazon KDP accepts. So you see, you can get acquainted with creating your books in EPUB formats and still easily publish them with Amazon. A few crucial tips of what should be practically avoided and what should be included into the EPUB text files specifically meant for a Kindle file 'journey' will be mentioned in Chapter 3.

Fear o Codes To a non-coding person, the intimidating process or step is to read and understand CSS or XHTML codes. To some, the codes are some jargon and at a start there is a feeling it wont just work. The mindset might be that debugging

the code is something not worth venturing into as it would cause so much distraction. My recommendation is simple: See the coding part of your e-book as some of the components of your car engineâ&#x20AC;&#x201D; you don't know how they function to form the integral parts of the car and yet you drive off and are happy behind the wheels. As you will see in Chapter 3, we will attempt to create and validate an EPUB from scratch without being burgled by codes and the associated semantics. This means that you don't need to be a coding expert to create an EPUB once you understand the basic process. Then writing another book will become as easy as eating a piece of cake.

MathML or Images MathML is a mathematical mark-up language, an application of XML useful for describing mathematical notations and capturing both its structure and content. The aim is to integrate mathematical formulae into World Wide Web pages and other similar documents. It happens to be the recommendation of the W3C maths working group and is also part of HTML5. It can be embedded inside the XHTML files of your EPUB using XML namespaces (A namespace in XML provides a method whereby element name conflicts are avoided). At browser level, MathML has been embraced very warmly and equations and maths notations are currently at their best on a good number of web browsers. A group like MathJax Consortium is doing a great job in high-quality display of mathematical notations in all browsers. MathJax is a joint venture of the American Mathematical Society (AMS) and the Society for Industrial and Applied Mathematics (SIAM), working to advance mathematical and scientific content on the web. However, e-readers are still striving to be in terms with MathML and the ugly delay is a function of technology catch-up and ultimately, a subject of business. Sometimes you come across reading devices which have high percentage support for MathML, even as much as 90 percent; but as a technical writer, the mathematical or scientific notations you intend to add to your content may lie within the margin of the 10 percent difference. So what is the way out? It was indeed a great relief for authors whose write-ups contain maths and equations to hear the news of EPUB3 release (I was extremely happy to use MathMl to write my first book, 'Seabed Seismic Techniques' even though I had

to later release an EPUB2 version). Prior to the release of EPUB3, one of the best ways to add mathematical equations was to convert your equations to images which are then in the usual way, added to the document. But behold, adding equations as images into EPUBs is NOT a thing of the pastâ&#x20AC;&#x201D; it is still one of the best ways to make your e-book develop wings to fly into the diverse e-book market. The equation in Figure 1.2 is placed as an image, whereas in utilising EPUB3, the MathML code shown next will render the same equation when the code is used in an XHTML document without the need of placing an image; making the equation nice, clean and a re-flowable part the book content (you will notice the change in equation fonts and style as you would with the other fonts even when changes are made to the preferences of the reading device). So the most important caution to using equations as images is to ensure that the image is legible enough and not too small in font size as they will not be reflowable.

Figure 1.2 â&#x20AC;&#x201C; A simple equation

MathML code for Figure 1.2 <math mathvariant='italic' display='inline'> <msub> <mi>X</mi> <mtext>CMP</mtext> </msub> <mo>=</mo> <mfrac> <mn>1</mn> <mn>2</mn> </mfrac> <mo maxsize='1'>(</mo> <msub> <mi>X</mi> <mi>S</mi> </msub> <mo>+</mo> <msub>

<mi>X</mi> <mi>R</mi> </msub> <mo maxsize='1'>)</mo> </math>

Remember that MathMl has to be declared in XML header like so xmlns:m=" Math/MathML"

and namespace declared in the CSS (See Step 3 in Chapter 3). Having said all that and without too much debate, it can be seen that we just have to comfortably wait for e-readers and publishers to get to a wide level of readiness for EPUB3 and its excellent maths-display capability while authors can out of choice still publish maths content in EPUB2 format without loosing their messages. So a seemingly old-fashioned method of displaying equations as images on the web and in e-books is still standing on the platform waiting for an elusive dreamâ&#x20AC;&#x201D; that EPUB3 buries EPUB2.

To the lovers of LaTeX This is a quick advice to authors of maths and science who wish to embrace EPUB3 to make their e-books but are reluctant to learn the codes of MathML. This is due to the fact that they are very much used to LaTeX (a high-quality typesetting system with features designed for the production of technical and scientific documentation). While it is indeed obvious that LaTeX is very robust and it's syntax are much straight forward and concise, it is possible to obtain some free tools to convert your LaTeX codes to MathML codes; and in that sense, you are not just learning or programming in MathML since your validation and display process will ensure you are on a good track. As an example, The LaTeX code for the equation in Figure 1.2 will be $X_{CMP}=\frac{1}{2}(X_S+X_R)$

and it will render the same equation. But EPUB3 does not have support for LaTeX. It supports MathMl. So a quick conversion of the LaTeX code to the corresponding MathML code shown becomes an easy ride for Technical and Science author.

Handcraft ePub in 7 Steps  

‘Handcraft EPUB In 7 Steps’ makes ePub creation simple for Authors. The book aims at truly emphasising on the word ‘crafting’— as it will in...

Handcraft ePub in 7 Steps  

‘Handcraft EPUB In 7 Steps’ makes ePub creation simple for Authors. The book aims at truly emphasising on the word ‘crafting’— as it will in...