Page 1


HANDCRAFT EPUB In 7 STEPS

Mundy Obilor Jim


Imprint

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 No 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 No 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 No 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="http://www.w3.org/1998/ 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.


CHAPTER 2 Media Best Practices Technical and Science writers, and other professional authors will find this chapter very useful. A classic novelist might be tempted to think that understanding how to place an image in an e-book using a styling tool like CSS will not be of use to them. While this may be true, one should bear in mind that writing is also an art and the future of a writer may drift to some new technological direction. In any case, the best options for new authors when it comes to display styles include being stingy with CSS, avoiding too much aesthetics and deciding judiciously as to whether or not to include certain media content, especially videos.

Stinginess With CSS The use of cascading style sheet (CSS) is one thing a publishing author will find indispensable. One of the best ways of escaping a lot of coding is to use minimal CSS. This means avoiding extreme aesthetics, and it is for one major reason: the physical outcome of your text layout may vary from one reading device to another. As an example, when you use the CSS attributes of 'maxwidth' and 'max-height' for your image placement, and run your validated EPUB through Amazon Kindlegen, it will result to errors, and getting rid of these properties eliminates the errors. Therefore, it is much better to avoid such attributes, which in any case, make very little difference in your e-book layout. That is just one example and it points to the fact that there are CSS rules that may not pass the Kindlegen test or the test requirements of other e-reading devices.

Drop caps fever Just as in print books publication, drop caps are great and can be part of the


beauty and art of an e-book but they also have their best practices and drawbacks. They have caused so much 'fever' to new authors especially when they notice that their drop caps have disappeared or have become disjointed in some reading devices or applications. Sometimes it is really convenient to use them (see Figure 2.1) and some other times, it's best practice to avoid their beauty as they may just appear differently across different reading applications or devices.

Fig 2.1 â&#x20AC;&#x201C; Drop cap fits Figure 2.2 shows what we can call a drop cap 'drop-off'. An EPUB was converted to a MOBI file by an aggregator and the result is a shifted drop cap.

Fig 2.2 â&#x20AC;&#x201C; Drop cap 'drop-off' What is the best way out? Just avoid drop caps when you are not sure of their accurate rendering and possibly use CSS to make the first letter bold when targeting devices that do not guaranty a proper drop cap display style. As at the time of writing this book, you will have to reformat your book using the Kindle Format 8 method to be able to have drop caps display well on the Amazon Kindle. The best way to approach this though, is to ensure that one


gets acquainted with the publishing guidelines of any distributor or retailer of interest. If you are publishing for an e-reader application that suggests the minimal use of CSS, it is best to avoid drop caps. Otherwise, they are truly great when viewed as decorative and when used to serve as clear beginnings of chapters/paragraphs. It is possible that the drop caps used in this book are not displayed if you are reading this book on some Kindle devices/applications. The following CSS code will generate a drop cap as it appears in Figure 2.1. This style cuts across two horizontal text spacing and adjustments can be made to the CSS to increase this spacing corresponding to a larger font size. Tweaking these parameters creates different effects. For example, varying the value â&#x2C6;&#x2019;0.015em for the property 'margin-right' moves the drop cap either to the left or to the right depending on whether the 'font-weight' choice is normal or bold. span.dropcap{ font-size:3.5em; font-weight:normal; font-family:sans-serif; float:left; line-height:1em; margin-bottom:-0.26em; width:0.8em; margin-top:-0.088em; margin-right:-0.015em; color:#000000; }

Please note the use the span element in the XHTML document: <p> <span class="dropcap"> T</span>he use of CSS (Cascading Style Sheet) is one thing... </p>

The parameters can be varied until a suitable drop cap is achieved. Note also that the chosen colour here is black '000000' but can be changed to any other colour. When it comes to using drop caps, there is one more caution. It is very important to find out if there are specific CSS properties recommended or


outlined for the targeted reading device. For example, in the 'Kindle Guidelines For Publishers', writers are advised to avoid 'using the margin and padding CSS properties',[2]; and also specify the values in percentage (%) and not in em units. So You may tweak the CSS properties as follows. span.dropcap{ font-size:320%; ... ... }

Image placements The placement of images in e-books requires a bit of skill to attain the desired display. Using the <figure> attribute available in EPUB3, images are rendered with excellent display, which includes compact figure captions which are not available in EPUB2. In any case, it has to be a matter of choice and consequently the appropriate use of CSS in deciding the way images should appear. Although this is not a book focusing on CSS, it is worth noting that the bother shadow on Figure 2.2 is achieved with the use of the next CSS rule. Box shadow around an image is by all means not a best practice on e-books as it is on the web because it may not appear in certain reading devices. img{ padding:5px; box-shadow:2px 2px 3px gray; margin-top:0.3em; width:90%; }

It is a difficult and challenging task with EPUB2. The reason is that the reflowable nature of EPUB tends to have the captions disjointed from the figure more often. There are ways to get around this: one method is to place the image within a <div> element as shown below with the use of a basic CSS class, 'enclose'. <div class="enclose"> <img src="images/EPUB2_image.jpg" alt="image example" /> <p class="caption"> Figure 1.2</p>


</div>

The sub-folder 'images' created in the OEBBS folder may not be necessary if you have just one image, which may well be the front cover image of the book. div.enclose{ text-align:center; page-break-inside:avoid; }

Figure 2.2 â&#x20AC;&#x201C; EPUB2 image At this point, let us look at the beauty of image placement in EPUB3. As we have in some other structural packages like LaTeX and Matlab, figure captions are structurally part of the image placement in EPUB3. This means that without the use and tweak of the <div> element, the figure element of EPUB3 renders a better looking image of figure 2.3.


The mark-up that yields Fig 2.3 is as follows (Fig 2.3 was grabbed from an EPUB3-formatted book):

<figure> <img src="images/EPUB2_image.jpg" alt="epub3 image" /> <figcaption> Figure 2.3 â&#x20AC;&#x201D; This is the caption of the image as it will appear in EPUB3. </figcaption> </figure>

So the figure is the replica of Figure 2.2 as it will show in EPUB3 using the <figure> and <figcaption> elements: a more robust way of positioning both the image and the caption without tweaking around with the <div> element to ensure that caption is not re-flowing outside of the image but specifically positioned with it.

When Videos Are Essential This is purely a subject of EPUB3 publication. You may just glance and pass to the next section if you are not interested in embedding videos in your book. It has been hinted earlier that embedding videos on e-books does not ALWAYS turn out to be an additional experience to the reader as many authors and e-


book specialists claim, especially when the genre of the book is targeted at novel and fiction lovers; or even worse, when the book size becomes too large as a result of the video inclusion. For example, the size of the sample EPUB file craft.epub with just two images referenced (the front-cover image and another image) is 659 KB but with the addition of a 5-second video, the size increases to 1.4 MB and this file size will double or triple if there is a need to add fall-back video contents in case the primary video does not play in some devices (which is usually the case). Oops, how much more with a video of 5 minutes! Adding an external link to the video is one good way of retaining a minimal electronic file size but note that many distributors or retailers prohibit this smart way. In summary consider the following before you embed a video content into an e-book. 1. It may be crucial to add a video if you are writing an illustration book but ensure that you trim the video size to a minimal size. 2. Use some video size reduction software to cut down video size and still retain good quality playback. 3. Avoid the inclusion of videos entirely if your book will not loose any taste or content without them. 4. If your target reading device or application allows the placement of external links in your book (unfortunately most e-readers prevent that for commercial reasons), then this becomes a viable option.

The video tag element It is a great deal that EPUB3 supports HTML5 video and you might have tested that successfully. That's great, but it is important to watch out for the conditions spelt out in the user guidelines for each of the various reading devices. Apple iBooks will advise you use M4V video format while other devices may play the video in MP4 formats, and so goes with the variation for audio formats. While Apple iBooks for example, adhere to their iconic M4V video and M4A (audio) formats, you may get away with just adding the basic MP4 video or MP3 audio using HTML5 tags for other devices. A typical way of adding HTML5 video to the web is as follows <video poster="seas.jpg" controls> <source src="craft.mp4" type="video/mp4">


<source src="craft.ogg" type="video/ogg"> Sorry, your browser does not support the video format. </video>

The image, seas.jpg is a poster image. There are two video files included in the above tags: MP4 and OGG formats, and of course, if none of these two are supported on the device, the reader is left with the message, 'Sorry, your browser does not support the video format'. This has been a great success in the web browser applications. For some specific reasons, the tags above are not quite practicable across board for EPUB creation. Why? 1. Having two formats of the same videos will add a considerable size to the overall book 2. Certain validation errors will occur for the target device if a wrong video or audio formats are used. 3. For every reading device, there are varying guidelines on how to embed video contents. Assume an author plans to publish on iBooks and in Kindle formats at the same time. While Apple iBooks requires M4V videos, Amazon Kindle will accept MP4. Then the viable option here is to submit two versions of the e-booksâ&#x20AC;&#x201D; one for iBooks store and the other for Kindle store. 4. Web link options: It will be a good idea to add a link to play the video somewhere on the web as this will shrink the actual book size. With regard to playing the video via a web, the video source, 'src' can be changed like so: <video src="http://thewebsite.com /videos/craft.mp4" controls>

Where the folder, 'video' may contain several videos. In situations where the video is specifically meant for EPUBs, it's best to add width and height to the video display as shown next. <video class="adjust" width="320" height="240" poster="seas.jpg" src="craft.mp4"


controls="controls"> <div> <p> Sorry, your browser does not support the video format. </p> </div> </video>

The following CSS rule will centralize the video with the given margins video.adjust{ margin:0px 0px 0px 20px; text-align:center;

The audio tag element To embed audio to the e-book, a simple HTML5 tag can be added as follows. <audio src="the_song.mp3" controls="controls"> <div> <p> Sorry, it appears your system does not support audio playback. </p> </div> </audio>

Note that the same challenge of increasing book size applies to embedding audio files.

Exuberant Aesthetics If you are a new writer or you are already self-publishing, you will agree that there are times you just want to add some fancy into your book layoutâ&#x20AC;&#x201D; be it in the form of font colour and stylish fonts or even using images and symbols as headers or drop caps. While these are all good and appear as nice presentations, authors should be aware that they may be going beyond the required CSS rules specified for the reading device and consequently, the desired fancy style expectation will result to some hodgepodge displays across various reading devices. To My Loved


â&#x2122;Ąâ&#x2122;Ąâ&#x2122;Ą

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore... Fancy styling should be avoided in favour of generally accepted standards. Otherwise, this may well narrow down the distribution channel options. Therefore, it's best practice to avoid what may be regarded as exuberant aesthetics. As an example, a novel author can decide to add three love symbols to the header of their book chapters or sections using the codes below but may be disappointed to find out that they are not displayed properly on some devices. It cannot be overemphasised that understanding the CSS rules allowable for the target reading device is crucial. <h5> To My Loved</h5> <h5> &#9825;&#160;&#9825;&#160;&#9825; </h5> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, seddo eiusmod tempor incididunt ut labore... </p>

The HTML entities in line 3 render the heart symbol and the corresponding spaces respectively.


CHAPTER 3 Let's Go Crafting Now you are ready to create your EPUP carefully by hand, and getting it right means two things: On one hand there will be a lot less frustration with third party conversion software and on the other hand you become more acquainted with the structure of this versatile e-book format. Once again the emphasis is not to dwell on XHTML, XML or CSS technical 'know-hows' but to give authors the opportunity to take advantage of the EPUB structure shown in Figure 1.1 and build an e-book with their available resources. The extra effort required here depends on how much change is needed to make to the body layout or structure for example, and this can be achieved with some tweaking of the CSS. No e-book author should be weary of understanding and using CSS. Let's start this way: The following CSS is enough to give a basic layout style for an e-bookâ&#x20AC;&#x201D; displaying the elements as blocks and giving two prioritized list of fonts. body { display:block; font-family:arial, helvetica, sans-serif; }

If anything else, an author should endeavour to understand and use the margin properties which enables the right and left extra space as seen in print books. The CSS margin properties used for this book (placed within the body above) are as below. margin-top:2em; margin-bottom:2em; margin-left:6em; margin-right:2em;


Let's go ahead and start to hand-craft our EPUB.

STEP 1. Getting Set Publishing a book requires that you have certain resources in place before or after your manuscript is ready for a final journey to the e-stores. Acquiring an ISBN, outlining your book information and assembling all the required resources such as images and videos, are all what we regarded as 'Getting Set'. 1. ISBN: This is an International Standard Book Number. It was made up of 10 digits in length up to the end of December 2006, but since 1 January 2007 they now always consist of 13 digits[3]. It can be written as '9788299890694' or written with some hyphen as '978-82-998906-9-4'. Any book made publicly available, whether for sale or on a 'free purchase' basis, can be identified by an ISBN. One may already have an ISBN but some distributors or aggregators will be happy to assign one to your book for free or at a price with some condition attached. It is therefore best to understand these conditions and make a decision as to whether you stick to your own ISBN or not. Bear in mind that some ebook stores may have a category by which a book is accorded some preferential sales spots when the ISBN is not strictly that of the author. 2. Book Information: The book information including author name and publisher name, should be ready, almost all of which will be part of the OPF or NCX files (see Step 3 for examples). 3. Media content: Your images should not be too large. They should not be blurred either. The best way to check an image is to really test how it will look on an e-book application as you write along. In your progress as an author, you will find out that the best option will be to either reduce or increase the image size and this happens when you preview your "workin-progress". Use a grey colour of any image if that will suit your content or message so that the book does not get too large for download except if coloured images are essential parts of the publication.

STEP 2.


Using An EPUB Template Most authors prefer to use an EPUB template file for a start. With this, the book can be cracked-open and additional contents can be added without altering the main EPUB structure or doing any change to the mimetype and container files. Why use an EPUB template? 1. You are sure of working with an already validated EPUB even if the document contains only a one-page chapter. 2. The existing book information like Title, Creator, Description, Publisher and Date can all be changed in the OPF and NCX files without much hassles. 3. XHTML files body and header contents can be changed. For example, you may remove MathML and any other declarations from the header if they are not needed in the new book. XHTML files can be added and can also be removed with the proper adjustments made to the OPF file. 4. As in (3), images, videos, fonts etc. can all be added or removed while adjustments are made to the OPF file. 5. A careful look at the CSS file and the kind of layout the author desires will determine the kind of change to be made to the stylesheet. It does not matter if you are a Mac, Windows or Linux user. There are some editors or packages that can open EPUB as it is and allow you as an author to edit or include additional content (chapters, media resources, etc.) as you go along writing.

STEP 3. Start Writing If you are novelist or are writing just some sort of prose without any concern for media content or some sort of list or table, all you need to understand is that every of your paragraph goes into the p element as follows (with some paragraph or style adjustment that can be achieved with CSS):


<p>Lorem ipsum dolor... </p>

Please note that one key process to get your book out there for the world to see is 'VALIDATION'. The best practice in this regard is to carry out the validation of your book as you progress in writing. If your are using any EPUB editor that supports validation, this is done with a single click. Otherwise, utilize the other methods explained in Step 7. Let's write the first chapter of a book titled 'craft.epub' in a text editor. We will be writing it in EPUB2 format and also show how the structure differs from EPUB3. Please refer to the section, 'EPUP structure' in Chapter 1 to grasp the simple concept which includes the XHTML files, the container, mimetype, ncx, etc. Here is the first paragraph of Chapter 1 of our EPUB. Our first paragraph <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore...</p>

The goal here is not to teach HTML but to truly encourage authors to see that it's not a high hurdle to jump over. The p and /p in the angle brackets connote the beginning and the end of a paragraph and in a book chapter we usually have several of them. Our first resource is 'Chapter 1' and for simplicity, it is the short paragraph above and we want to have it as an XHTML file. Again this book is by no means organized to teach any mark-up language but if you are a bit curious as an author, just note this simple definition: XHTML is a logical combination of HTML and XML. In your text editor, save a blanc document as chapter1.xhtml. What is next? One important thing the author should recognise is this: every XHTML file has some text at the beginningâ&#x20AC;&#x201D; with a minimum of required tags for our EPUB creation. Let's make an acronym for authors and call this text XHTML-Head):

XHTML-Head


<?xml version="1.0" encoding= "UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C// DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/ xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/ xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <title>Chapter 1</title> </head>

Now place this text (from <?xml to </head>) at the beginning of your blanc document, chapter1.xhtml, where you will later place your first paragraph. Please refer to the Appendix section of this book and copy, if you would, the EPUB3 text versions of the OPF, NCX and stylesheet of a standard document. Another reminder: that as an author, it's possible to avoid dwelling on the details of the XHTML1.1 standard or the XML version and still reach your goal. Next we place the body of the chapter immediately after </head>, which again, for teaching purpose, we shall call XHTML-Body which contains our first paragraph. XHTML-Body <body> <h1>Chapter 1</h1> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore... </p> </body> </html>

So XHTML-Head combined with XHTML-Body gives us the XHTML file, chapter1.xhtml or any other XHTML document within the OEBPS, like frontcover.xhtml. This file will only have a major variation in the second part, XHTML-Body. However, XHTML-Head may sometimes have some extra


declarations as you will notice later, especially for EPUB3. You can go a little further to save some more XHTML files as chaptet1.xhtml, chaptet2.xhtml, section1.xhtml etc., and add them to the OEBPS folder. As a matter of choice, you may instead of waiting to validate your EPUB which is a zip file, simply check the validity of your XHTML file at the W3C Markup Validation Service site link (Validation is treated in Step7). Let us simplify our our XHTML template with a simple diagram. This is simply called a template here as from an author's point of view, it hardly changes.

Figure 3.1 â&#x20AC;&#x201C; Author's XHTML formula. Note specially where the content of the chapter comes in and as expected, a chapter will have several paragraphs. All we need to do is to add our chapter within the <p> and </p> paragraph elements. Try it. If you are working with an EPUB template, just replace an existing XHTML text with your chapter1.xhtm text. Hurray! We now have our first XHTML file, chapter1.xhtml.

Stylesheet We have a simple initial stylesheet for our book and as an author, you will most likely build upon this stylesheet. body{ display:block; font-family:arial, sans-serif; }


For example, You may prefer large font size in your header and you may wish to reduce body fonts in certain sections. These two examples can be achieved by adding extra CSS rules as shown below (the characters /* and */ indicate the start and end of comments). /*--- body display ---*/ body{ display:block; font-family:arial, sans-serif; } /* ---Chapter heading----*/ h1{ font-weight:bold; font-size:1.5em; text-align:center; }

Furthermore, if we want to have every paragraph start with indent to the right, we can add the following to the initial stylesheet by using the class, "indent". p.indent{ text-indent:1.5em; }

If we want to reduce the font size of our imprint page, we can enclose the entire text in a <div> element and use the class 'small' like so: div.small { font-size:90%; }

As an example, the XHTML-Body of our Imprint page may look like this <body> <h1>Imprint</h1> <div class="small"> <p class="indent"> <i>Handcraft EPUB</i> by John Smith. <br /> Copyright &#169; 2015 eBook Publishing Ltd. <br /> All rights reserved.<br /> ISBN 978-82-998906-9-4 <br /><br /> No portion of this book may be used for further publication without the written permission


of the publisher... </p> </body> </html> </div>

Changing body display is one key area where every author has to figure out what their needs are and once they get it right, writing another book becomes easier. A novel author will probably fish for CSS rules that make changes to paragraph layout while a technical writer will most likely be concerned with image placements and with ordered and unordered lists adjustments. Now save your CSS as 'stylesheet.css' and as usual, add it to the OEBPS folder. If you are working with an EPUB template, just replace the stylesheet text with your desired CSS.

Container and Mimetype files As far as making EPUB's is the goal, you will have little or no business editing or playing around with the container.xml file; and the case is the same for the mimetype. If you are not working with a blanc EPUB, then from your text editor, save them with the corresponding extension into the OEBPS. They look as follows

container.xhtml <?xml version="1.0"?> <container version="1.0" xmlns="urn:oasis:names:tc: opendocument:xmlns:container"> <rootfiles><rootfile full-path=" OEBPS/content.opf" media-type=" application/oebps-package+xml"/> </rootfiles> </container>

mimetype application/epub+zip

The OPF file


As explained in Chapter 1, this package document which you should also save using your choice text editor as content.opf has three components residing within itâ&#x20AC;&#x201D; metadata, manifest and spine (Please refer to Chapter 1 for the explanation to the structure of these files).

content.opf <?xml version="1.0" encoding=" UTF-8"?> <package xmlns:xsi="http://www.w3.org/ 2001/XMLSchema-instance" xmlns:opf="http://www.idpf.org/ 2007/opf" xmlns:dc="http://purl.org/dc/ elements/1.1/" xmlns="http://www.idpf.org/ 2007/opf" version="2.0" unique-identifier="bookid"> <metadata> <dc:title>Handcraft EPUB </dc:title> <dc:language xsi:type="dcterms:RFC3066">en</ dc:language> <dc:identifier id="bookid"> ISBN: 9788299890694 </dc:identifier> </metadata> <manifest> <opf:item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/ <opf:item id="front_cover" href="front-cover.xhtml" media-type="applicat <opf:item id="chapter1" href="chapter1.xhtml" media-type="application/xh <opf:item id="style" href="stylesheet.css" media-type="text/css"/> </manifest> <spine toc="ncx"> <opf:itemref idref="front_cover"/> <opf:itemref idref="chapter1"/> </spine> </package>

Our metadata section contains the book title, the ISBN and the book language within their appropriate tags. Our manifest has four resources or elements: the NCX file, the stylesheet, the front cover and Chapter 1 ( the last two being XHTML files). The spine which is a table of content function of the NCX file,


renders the front cover and Chapter 1 in that order. Bear in mind that for the EPUB3 format, the OPF file contains a different package.

EPUB3 package differs If you are hand-crafting EPUB3, your OPF document will look different as shown below as compared with our earlier XHTML-Head acronym rendered for EPUB2. The difference is obvious between the two packages. <package xmlns="http://www.idpf.org/ 2007/opf" xmlns:dc="http://purl.org/ dc/elements/1.1/"xmlns:xsi= "http://www.w3.org/2001/ XMLSchema-instance" xmlns:dcterms="http://purl.org/ dc/terms/" version="3.0" xml:lang="en" unique-identifier="bookid">

front-cover.xhtml The best practical way to add a book cover to an EPUB is to use an XHTML file which you can simply call front-cover.xhtml. The cover image should reside either as a resource in the OEBPS folder like every other XHTML file or in a sub-folder, 'images' which you can place inside the OEBPS folder. If the cover image is in this sub-folder, then the XHTML file will read it accordingly. <item id="cover" href="images/cover.jpg" media-type="image/jpeg"/>

and not <item id="cover" href="cover.jpg" media-type="image/jpeg"/>

Otherwise you will keep getting an error which says that 'the resource not found in the OPF file'. Here is a simple html code for the front-cover.xhtml file:


<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <title>book cover</title> </head> <body> <div id="front_cover"> <img class="fullpage" src="images/cover.jpg" alt="cover" /> </div> </body> </html>

We have used a simple CSS rule to ensure that the cover image spreads out on a full page. img.fullpage{ margin:0; padding:0; text-align:center; }

toc.ncx <?xml version="1.0" encoding=" UTF-8"?> <ncx xmlns:ncx="http://www.daisy.org/ z3986/2005/ncx/" xmlns="http://www.daisy.org/z3986/ 2005/ncx/" version="2005-1"xml:lang="en"> <head> <meta name="dtb:uid" content="http://my-URI-stub/"/> <meta name="dtb:depth" content="1"/> <meta name="dtb:totalPageCount" content="0"/> <meta name="dtb:maxPageNumber" content="0"/> </head> <docTitle> <text/> </docTitle> <navMap> <navPoint id="front_cover" playOrder="1"> <navLabel> <text>Handcraft EPUB</text>


</navLabel> <content src="front-cover.xhtml"/> </navPoint> <navPoint id="chapter1" playOrder="2"> <navLabel> <text>Chapter 1</text> </navLabel> <content src="chapter1.xhtml"/> </navPoint> </navMap> </ncx>

As earlier stated, this file renders the table of contents of the book although it is optional in EPBUB3 but is often used for backward compatibility.

The EPUB3 dimension If we make reference to our XHTML-Head and XHTML-Body, we will have a change for the EPUB3 format. In regards to the <nav> element (shown in Chapter 1) and OPF document (shown earlier in this chapter), you may refer to the Appendix to copy the text if you are working in EPUB3 format. The <video>, <audio>, <figure> and the <figcaption> elements are all children of EPUB3 and have been explained in Chapter 2. You can also grab a copy of EPUB 3 Template for Authors and easily handcraft your EPUB3 document with it. There are lots of rich content in EPUB3 in terms of the tag elements. Let's just mention two without boring new authors: the use of <section>, which enables one to wrap sections of primary content, and the broad possibility of using background images and colours are excellent approaches. But remember some pieces of the caveatâ&#x20AC;&#x201D; your background colour or images may not show in some devices or worst case scenario, your EPUB3 may not have access to so many reading devices. Again read the specification guidelines for the targeted device. The use of MathMl is easily achieved by adding the following into our coined XHTML-Head, xmlns:m="http://www.w3.org/1998/ Math/MathML"


to get an updated XHTML-Head like so: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/ xhtml" xmlns:epub="http://www.idpf.org/ 2007/ops" xmlns:m="http://www.w3.org/1998/ Math/MathML"> <head> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> <title>Chapter 1. Chapter 1 Title</title> <meta charset="utf-8" /> </head>

Our stylesheet has to reflect this MathMl inclusion with a namespace declaration: @namespace m "http://www.w3org/1998/Math/MathMl";

STEP 4. Front Cover, A first Impression One crucial component that most authors spend too much time to find out how best it should be or how much size of it is required is the book cover. Different e-readers require different cover sizes. So the wise thing to do is to find out the required book cover size at the early stage of the publishing process. Serious authors sometimes have the will and desire to create their covers themselves (I have been there). My opinion is that this design process be left to the professionals if possible. The face of your e-book is its cover, and in many designers' opinions, a book cover should with it's title convey the subject of the book within 4 seconds of reading. Again, it is important to utilize the available guidelines for the e-book application you are interested in. This book was first structured as an EPUB on a first journey to the Amazon Kindle application and the cover size is 1875 by 2500 pixels. In the process of writing and editing, previews were done in apple's iBooks and the cover image size


used is 1536 by 2048 pixels. Most authors chose not to use an image for a title page as this practice even though elegant, adds enormously to the size of the ebook. The title page for this book is rendered with a single XHTML file with a separate CSS file named 'stylesheet2.css'. Please take note of the difference between a market cover and an internal cover. Some publishers may ask for a market cover that is between a resolution range of 150 â&#x20AC;&#x201C; 300 dpi (dots per inch) whereas your internal cover is just great at 72 dpi.

Cover legibility At a quick glance, any book cover tells what the book is all about irrespective of the fancy, style or colour of the fonts. Quite unlike taking a look at the spines of physical books in a library or in book shelves, more often than not, viewers see several e-books on the shelf for the first time even before deciding to view a particular book much further by clicking on that first cover image. Let's take two cover examples of the same title.

Figure 3.2 â&#x20AC;&#x201C; Comparing cover legibility on an e-book shelf, cover 1 (left) and cover 2 (right) At this image size of approximately 170 pixels wide by 128 pixels high, many viewers might not be able to quickly see and read the title of cover 2 as compared to how quite easily they can grasp what cover 1 is all about. Cover 1 itself has an illegible use of the word 'for' (it can be better). Although, a great cover design is an excellent marketing tool for a book, the title text not being legible can just be a 'first-impression disaster'. Just be aware that no matter how beautiful you think your cover is, the first time it will be looked at is on those congested e-book shelves (at a thumbnail size if you


like).

STEP 5. The EPUB-Kindle Clash Perhaps you have smiled at the "congratulations" that your e-book has past the EPUB check. But wait a minute! Some retailers have what I call "the validation extras" and this results into a clash. Let' take two practical examples to help any self-publishing author and save them the long time of scratching the head or even giving up and cast the blame on the inventors of mark-up language and CSS. An EPUB can be converted to a MOBI format. Remember that A validated EPUB is acceptable when transition is made to Amazon Kindle Direct Publishing. One way of doing this is to verify that the EPUB passes through the Kindlegen application. Let's run our final EPUB with this application (you have to install Kindlegen in your Mac or windows to carry out this test). We will not dwell on the nitty gritty of using Kindlegen here. But let's see how this can be run on a Mac to convert our EPUB to a MOBI file after it has been downloaded on the desktop. This can also be done on Windows computers.

EPUB to MOBI conversion (Kindlegen) 1. The first step is to download Kindlegen to your computer (all right on the desktop!) 2. Open the Terminal on your MAC— Applications → Utilities → Terminal 3. From inside the downloaded Kindlegen folder, drag Kindlegen exec file into the Terminal 4. Drag the validated EPUB into the Terminal to get the following before hitting the return key. My-Name-iMac:~ myname$ /Users/myname/ Desktop/KindleGen/kindlegen / Users/myname/Desktop/crft.epub

Here cries our validated EPUB after running through Kindlegen and yielding


errors: Warning(prcgen):W14016: Cover not specified Info(prcgen):I1037: Mobi file built with WARNINGS!

All we need to do at this point is to go to the OPF file and add the following lines <meta name="cover" content=" my-cover-image"/>

and <opf:item id="my-cover-image" href="images/cover.jpg" media-type="image/jpeg"/>

to the 'metadata' section and to the manifest respectively and this means a little change in name of the cover 'id'. You probably first had <item id="cover" href="images/ cover.jpg" media-type="image/jpeg"/>

The two lines above solves our current problems but you may encounter several other errors with Kindlegen, most of them being the result of using some disallowed CSS rules. The summary here is: having a validated EPUB is a good step to self-publishing with Amazon Kindle and that sitting back to get rid of the errors and stepping into the circle of 'your MOBI file format is ready' is a great asset. My Dear Authors always avoid treading on the path of coding. But alas, you can enable a standard compression and allow a more detailed processing output information by adding -c1 and -verbose after the EPUB file at the command-line before hitting the return key.


STEP 6. Tidying up No one will argue the fact that editing and spell-checking your book is an essential part of any publishing process. At this stage you are already checking if the desired layout of the book is what it is. It is also possible to take a final look at the images in the book, as some cropping can be done on the images that will reduce the book size without losing any content. This is the best stage to go through again the table of contents (the toc.ncx and/or the nav.xhtml files) to ensure that they are in order and that all links are functioning accordingly.

STEP 7. Validation Methods Validation is a process whereby the EPUB file is passed through a software checking test to confirm whether or not it is a standard and acceptable document. The best way to validate an EPUB is to do so several times in the process of writing especially if you are a beginner. This is crucial because trying to find out the reasons for many listed errors and consequently correcting them may be a tough and discouraging job for authors. There are errors that are easily traced and fixed. 'Resource not found in OPF' for instance may simply tell that the image you added in the XHTML file and the image folder may not exist or has not been declared in the OPF. As you go along creating EPUBs, you will probably prefer just one way of validation and this may be a simple 'click to validate' process or an 'upload and validate' process. However, you will notice a bit later in this section that utilising the standard tool EpubCheck, which is always being updated by IDPF, is a delightful adventure. 1. IDPF website: you can upload an EPUB document and validate it on the IDPF website in two simple steps: 'choose file' and 'validate'. Your file has to be 10 MB or less in size at present time (2015). The validator, which uses EpubCheck will detect the EPUB version of your document and tells whether or not the document is valid. 2. EPUB editors: There are good editors that can validate an EPUB document with a single click which you can do as you are writing. This


book is probably not the best to advertise any of them but as an author who lives to write, it may be wise to invest in one of them if they are not free. 3. Third party applications: There are some third-party software packages or applications which offer a graphical user interface (GUI) for EpubCheck in which case there will be no need to use the command-line tool, but anyone who goes through the next process will admit that using the command-line is pretty straightforward and is surely the best way after all. 4. EpubCheck: This is a tool that can be used as a standalone command line to validate EPUB files. It can detect many errors and can be run in three modes: basic, advanced or expanded mode. Let's go practical using a Mac (a Windows machine is also sufficient) to run the basic and advanced mode checks.

Running EpubCheck 1. Action 1: You should have Java (preferably the latest version) installed on your computer and the best way to ensure that Java is running is to open the Terminal, type java -version and hit the return key. If Java is running successfully, it will display the following text: java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Otherwise take a moment to install Java on your computer. 2. Action 2: Download the latest version of EpubCheck unto the desktop (you may choose somewhere else). As at the time of editing this book, the latest version is 3.0.1. You will notice a file, epubcheck-3.0.1.jar in the downloaded folder. 3. Action 3: On the Terminal window, type java -jar. Give space and drag epubcheck-3.0.1.jar file from the finder to the Terminal (this you may also type instead of dragging in the file). Now you have the following display: My-name-iMac:~ myname$ java -jar /Users/


myname/Desktop/epubcheck-3.0.1/epubcheck-3.0.1.jar

'My-name' is used here for convenience. It is actually name and last name as in John-Smith or whatever the name of your mac is. 4. Action 4: Next, let's drag (or type) in our file location, craft.epub into the Terminal after /epubcheck-3.0.1.jar

to have the following final display before hitting the return key: My-name-iMac:~ myname$ java -jar /Users/ myname/Desktop/epubcheck-3.0.1/ epubcheck-3.0.1.jar/Users/myname/ Desktop/craft.epub

Our working document here is in EPUB3 format and so we see the result displayed (next) on the terminal: Validating against EPUB version 3.0 No errors or warnings detected. My-Name-iMac:~ myname$

Advanced EpubCheck What we have shown is the basic mode of validation with EpubCheck. In the Advanced mode, we can validate a single file in the EPUB zip folder, but in this case we must specify the file type. Let's choose the OPF file or the package document and the EPUB version (either 2.0 or 3.0). The command for single file validation is as follows: java -jar epubcheck-3.0.1.jar singleFile -mode MODE -v VERSION

Let's go ahead and run the advanced mode command. Advanced Mode


java -jar epubcheck-3.0.1.jar singleFile -mode MODE -v VERSION [1]

The word 'MODE' can be replaced with opf, nav, xhtm, etc and 'VERSION' can be replaced with either 2.0 or 3.0 (the EPUB version). In the advanced mode, a single file within the EPUB zip content can be validated. This becomes handy as some authors prefer writing their books chapter by chapter and in this case it may mean validating an XHTML document. Please note that for EPUB3 format, other files like the nav (navigation document) and mo (for media overlay) can also be validated separately. Let's validate our OPF file. 1. Again on the Terminal, type java -jar and drag the epubcheck-3.0.1.jar file into the Terminal. 2. Next drag in your OPF file and type in the correct version. java -jar /Users/myname/Desktop/epubcheck-3.0.1/epubcheck-3.0.1.jar /Users/myname/Desktop/epub2_craft/OEBPS/content.opf -mode opf -v 2.0

3. Hit the return key to see the result: File is validated as a single file of type opf and version 2.0. Only a subset of the available tests is run. No errors or warnings detected.

We have been running the EpubCheck on a Mac but if you are to run it on Windows, here is a summary of the steps you should take: Right-click on the Start Menu â&#x2020;&#x2019; Run On the run terminal type cmd.exe On the Command prompt, type java -jar (leave space after -jar) In the same manner with the Mac operating system, drag the epubcheck-3.0.1.jar file into the command prompt, give space and also drag the EPUB file into the terminal and hit the return key 5. If all is well, you will get the same message summary, that 'No errors were detected'. 1. 2. 3. 4.

Common validation errors


Validation is not always an easy ride for authors who dare to take the challenge to hand-craft their own EPUBs. We can list a few common validation errors that an author should be very much aware of. Bear in mind that the list of errors can be long but have the tendency to shrink and become minor as your skills of creating EPUBs increase. As you have most likely realized so far, this book is practical-oriented and so the errors mentioned next are part of the errors that came up in the course of writing this book. 1. OPF cries more: The errors associated with the package document seem to occur much more often than any other error. Let's give just two examples: 1. Description: 'OEBPS/images/epub-structure.jpg': referenced resource missing in the package. The error is traced to chapter1.xhtml The problem: The image epub-structure.jpg is actually in the OEBPS as epub_structure.jpg (with an underscore). The solution was to replace the hyphen in the image tag with an underscore. 2. Description: 'image file OEBPS/images/image.jpg is missing' The reason for this error was that a PNG image was uploaded to the OEBPS folder but the image format in the OPF and the XHTML documents was JPEG. 2. Missing ID's: A broken link can give a headache. An error referring to the ncx file came up with the description: ''The 'id' attribute does not have a unique value". It happened that a wrong 'id' was used within a <navpoint> element in the ncx file, which was corrected. 3. Improper links: If you are writing in EPUB2 format, your NCX file should be well structured, and even though it is a fall-back content for EPUB3, it should have all links and 'IDs' laid out properly. For example, at the end stage of editing this book, it was decided that the subsection,


'Advanced EpubCheck' should appear in the table of content (i.e. within toc.ncx), so an ID 'advanced' was first added to the <navpoint>: <navPoint id="advanced" playOrder="25">

At validation, we get the error: Description: 'advanced': fragment identifier is not defined in 'OEBPS/chapter3.xhtml'

So to fix this error, we go straight away into chapter3.xhtml file and add the ID like so: <h3 id="advanced">Advanced <em>EpubCheck</em></h3> <p>Let's go ahead and...</p>

Final validation: Double-check If you are happy thus far, having gone through Step 7, then you are done. Yes that's it, especially after going through Step 3 diligently and finally arriving at Step 7. You might have done some additions and 'takeaways' to the EPUB unconsciously. It is crucial to double-check your work and carry out a final validation, save your e-book as any_name.epub, ISBN.epub or in any other name format specified by the target distributor or retailer. Then go, publish and sell. Chapter 4 renders some tips and personal opinions on how to publish and sell.


CHAPTER 4 Publish, Sell, Honest Opinions After I published my first e-book, I was excited to have it available on one of the most popular e-book stores. Indeed I was. I had used an aggregator but of the 25 possible retailers I was entitled to have my books available for sale on their book shelves at that time, the book got stuck with only one retailer. The stumbling block was not only that the book was in EPUB3 format but that it also contained MathML and HTML5 video and audio. Frankly speaking, these two elements of MathML and video/audio are enough to shrink considerably, the market base of any e-book. I sincerely apologize to those who have wholeheartedly embraced EPUB3 and are have made clear their best wishesâ&#x20AC;&#x201D; that it should flourish and take its place. As a matter of fact, when you deliver any book published in the EPUB3 format, it will be gladly accepted by aggregators and distributors or publishers who welcome the version but the choice will remain yours and will solely depend on your objectives. My personal opinion is that if you want your e-book to be available on several platforms and in the end attain a wide follower-ship, minimize the use of, or avoid MathML and excess videos. Ultimately, I also recommend that authors degrade their publication to a more versatile EPUB2 format and still retain a version of EPUB3 on the shelves; at least for now. Currently, it is unfortunate that far more e-readers are better off with EPUB2 as compared to EPUB3. Remember that a large number of book lovers have the mindset of reading and enjoying a good book and less expectation of watching video clips and listening to audio rendition of music embedded in your e-book even though these extras, to some degree, add a good reading experience. A novel enthusiast for example wants to read your book and go read another novel. So you may as well not impress a whole lot of people if you are bent on adding a video clip to your e-book. Of course for illustration books, children's books and other special books, EPUB3 will stand out but weighing the


advantages and disadvantages of adhering to either EPUB2 or EPUB3 publication may solely be a matter of business senseâ&#x20AC;&#x201D; yes business sense and not just the glory of improved syntax and semantics. What do we really mean by 'avoid MathML'? MathML renders equations and other properties like Figure descriptions and captions beautifully as already explained in Chapter 1 and Chapter 2. That notwithstanding, using equations as images (as some distributors would suggest to prospective authors) and publishing the e-book in EPUB2 format does not seem to show any form of drift-away from the book's objective. Am I crying against, or opposed to the proponents of EPUB3 or MathML? NO. My first book contained MathML. Most distributors, retailers and publishers will not smile when accepting EPUB3. But there is no cause for worry when we remember that we can still publish the EPUB3 version of an e-book with MathML alongside the EPUB2 version and one quick way of doing this is to publish the same book with a different ISBN and still be in deep love with the standards of EPUB3. The trend of computing and digital publishing technology may change drastically in the future but for now, my opinion is that e-books should be published in such a way that a large variety of applications, ereaders and browsers can render them adequately.

Adding Videos You are probably being dragged to making your Book in EPUB3 format because you intend to place some video items by all means. If this is your ultimate choice, please refer to Chapter 2, but remember that even though embedding HTML5 videos on the web is a bit straightforward, you should ensure to adhere to the reading device specifications for adding any media content.

Publishing options There are several ways and channels to publish your e-book. One way is to steadfastly work in EPUB formats and in this way, you can publish through popular channels like Amazon or Apple iBooks. Other ways to rest your publishing strength could be to publish through just one channel. It could be


through Amazon KDP or even Google Books, both of which may accept EPUB2 or EPUB3 formats. Of course your choice may be to be independent and solely sell books from personal websites. The publishing options remain ultimately yours. It is very important to understand majority of the available distribution options to get your e-book into the hands of potential buyers. While no rule forbids any author to sell their e-book from their personal websites, being aware of the existing distribution guidelines across devices will help any serious author to take important decisions as it relates to them. As an author you will come across three terms: 1. Publishers 2. Retailers 3. Aggregators Sometimes these names become synonymous to the other. A publisher usually may have some long-term rights after issuing you an ISBN and still act as a retailer. In the e-book industry though, it is difficult to grasp clear-cut differences, and sometimes the definition of a retailer or a publisher may simply mean what you understand or what you want.


Figure 4.1 â&#x20AC;&#x201C; An author may not have direct access to all retailers. An aggregator is any organization that takes the books of a self-publisher and places them on the purchasing shelves of the retailers at a cost. Sometimes this cost is a one-time fee and other times the aggregator retains a percentage of every book sold. The role of aggregators may be indispensable if for some reason one finds themselves unqualified, or with some limitations, to place their books with a major retailer. Take two examples: 1. You may be required to have some tax documentation to be able to sell your books on Apple iBooks, and if you are living outside of the U.S., using an aggregator may be the only option. 2. While an aggregator, at a cost, may reformat your book into several formats (including EPUB, MOBI, etc.) strictly according to retailers requirements, it may be a lot of hassles for a new author to do all the diverse conversion and standardization. You ask why? Take these real scenarios: (1) Your EPUB is valid but a retailer may require a different front cover specification from the book. (2) Your EPUB is well-formatted


but the reading device you are targeting may not support that background image property you have used in your style. Some aggregators simply have the work-flow to tweak your e-book into several standards or formats while you sit back and plan to publish other books.

Sales and royalties The one point to be made here is in relation to how authors can keep tab of the purchases of their books and how often they receive payments. The choice of a distributor or an aggregator sometimes depends on how regular the accounting records are made available to the author. Some authors prefer a weekly account report system while others are comfortable with aggregators who render sales report every 2-3 months. So learning how financial reports work with every potential aggregator can help to determine the authors' choice of sales channels. Finally, fixing the price of an e-book depends entirely on the author but it is also a function of the royalty plans outlined by the publisher or retailer There are retailers who operate with a flat royalty plan and there are those who have varying plans. Let's take just two examples (note that using an aggregator changes the overall royalty plans of the retailers they deal with). 1. Flat royalty: Let's fix a price of an e-book for $9.0. An aggregator may stipulate a 15 percent cut of every copy sold which may sound reasonable; but may not quickly explain that one of the most popular retailers will take another 30 or 40 percent of the $9.0. Having a direct access to this retailer, however, leaves the self-publisher with a margin of about 60 percent. 2. Varying royalty: Another popular retailer does it differently. A selfpublisher will have a maximum of 70 percent royalty provided their ebook set price is not greater than a certain price, say $9.9. A set price greater than $9.9 will leave the self-publisher with just 30 percent royalty.


Bibliography 1. EPUB 3 Overview, International Digital Publishing Forum, 26 June 2014. 2. Amazon Kindle Publishing Guidelines, version 2014.1.1, 2014. 3. ISBN-International.org, 2006.


Appendix Resources (text) Templates The following 'texts' are for EPUB3 and can be reused with modification. content.opf text <?xml version="1.0" encoding="UTF-8"?> <package xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dcterms="http://purl.org/dc/terms/" version="3.0" xml:lang="en" unique-identifier="bookid"> <metadata> <dc:title>Handcraft Epub</dc:title> <dc:language id="pub-language">en</dc:language> <dc:identifier id="bookid">ISBN9788299890618</dc:identifier> <meta property="dcterms:modified">2014-02-20T22:17:24Z</meta> </metadata> <manifest> <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/> <item id="htmltoc" properties="nav" media-type="application/xhtml+xml" h <item id="front_cover" href="front-cover.xhtml" media-type="application/ <item id="chapter1" href="chapter1.xhtml" media-type="application/xhtml+ <item id="style" href="stylesheet.css" media-type="text/css"/> <item id="img01" href="seabed.jpg" media-type="image/jpeg"/> <item id="cover" href="cover.jpg" media-type="image/jpeg"/> <item id="video1" href="prolog.mp4" media-type="video/mpeg4"/> </manifest> <spine toc="ncx"> <itemref idref="front_cover"/> <itemref idref="chapter1"/> </spine> </package>

toc.ncx text <?xml version="1.0" encoding="UTF-8"?> <ncx xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/" xmlns="http://www.daisy.org/z3986/2005/ncx/"


version="2005-1" xml:lang="en"> <head> <meta name="dtb:uid" content="ISBN9788299890618"/> <meta name="dtb:depth" content="1"/> <meta name="dtb:totalPageCount" content="0"/> <meta name="dtb:maxPageNumber" content="0"/> </head> <docTitle> <text/> </docTitle> <navMap> <navPoint id="front_cover" playOrder="1"> <navLabel> <text>Book title</text> </navLabel> <content src="front-cover.xhtml"/> </navPoint> <navPoint id="chapter1" playOrder="2"> <navLabel> <text>Chapter I</text> </navLabel> <content src="chapter1.xhtml"/> </navPoint> </navMap> </ncx>

chapter1.xhtml text

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <title>Chapter 1</title> </head> <body> <h1>Chapter 1</h1> <p>The use of cascading style sheet (CSS) is one thing a self-publishing indispensable. One of the best ways of escaping a lot of coding is to use css.</p> <div style="text-align: center;"> <video class="intro" width="320" height="240" poster="seabed.jpg" control <source src="prolog.mp4" type="video/mp4"/> <p>Sorry, it appears your system either does not support video playback o


Mv4 format provided.</p> </video> </div> </body> </html>

stylesheet.css text @charset &quot;utf-8&quot;; @namespace m &quot;http://www.w3org/1998/Math/MathMl&quot;; body{ font-family:arial, helvetica, sans-serif; font-size:100%; margin-top:2em; margin-bottom:2em; margin-left:6em; margin-right:2em; background:transparent; } /* ---------paragraphs-- */ p{ margin-top:0.2em } /* ---------Headers--- */ h1{ border-bottom:1px solid lightgray; text-align:center; font-weight:bold; font-family:georgia, helvetica, sans-serif; font-size:1.4em; margin-top:20px !important; margin-bottom:15px; } h2{ font-size:1.2em; font-weight:bold; font-family:georgia, sans-serif; color:#000000; /* ---you can change H2 colour---- */ margin:20px 0 0 0; } /* -----Figures and Images-- */ figure.fullpage{ max-height:100%; max-width:100%; margin:0;


padding:0; } figure.inside_img{ max-height:95%; max-width:95%; margin:0; padding:0; text-align:center; } figure figcaption{ font-size:90%; text-align:center; font-weight:normal; font-style:italic; font-family:"Free Serif", serif; } /* -----toc-- */ #toc ol{ list-style-type:none; } /* ------video---- */ video.intro{ margin:0px 0px 0px 20px; text-align:center; } /* ----Audio---- */ p.adio{ font-size:0.8em; text-align:center; font-style:italic; } audio.outro1{ text-align:center; }

The EPUB3 toc.xhtml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.or <head> <link rel="stylesheet" type="text/css" href="stylesheet.css"/> </head> <body> <nav epub:type="toc" id="toc"> <ol>


<li><a href="front-cover.xhtml">Handcraft EPUB</a></li> <li><a href="chapter1.xhtml">Chapter 1</a></li> </ol> </nav> </body> </html>

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...

Advertisement