tips on creating ebooks

ePUB logo

Centering for an ePUB

This is how we center the text for our ePUB files. After creating our ePUB files we found that the centering of text didn’t always work – even on devices where we’d tested the ePUB files during the build. This is due to the ePUB that eventually ends up on the ereading device going through the proprietory load process for the device, and some of them render the centering commands differently. We therefore used a combination of approaches to centering – though it is also worth considering if you want to center at all. Some devices offer the user the chance to control how the text is shown, what justification to use, and some of the code suggested below will mean that the user’s preferences are ignored, so don’t use this approach too widely.

This is what is needed around the text you want to center within each of the text html files:
<p class=”yourclass”><span class=”centered”>Your text to center</span></p>

This is also needed, assuming that you want the whole ‘body’ centered then can add the ‘id’ centertext, but still do the spans around each individual paragraph (p):
<body class=xyz id=”centertext”>
With the main text area that makes up the ‘body’. This is the main area of the book chapter it starts with  <body> and ends with </body>
</body>

These are the controls for this that we included in the style.css:
#centertext {
text-align: center;
text-indent: 0em;
}
span.centered {
display:block;
text-align: center;
text-indent: 0em;
}

The style.css was associated to each file with the following code at the top of the html file in the head section:
<head>
css” rel=”stylesheet” type=”text/css” />
<title>Your title</title>
</head>


Definitions:

ePUB – format for an electronic book

ereader – device to read an ebook

css – cascading style sheet, set of shared formatting commands to control the appearance

html – hypertext markup language. The formatting words that go around the text to tell the ereader how you want the book to appear (within < and > characters)

0em – here used for text-indent, this gives the size of the indent. It says it is made up of no (zero) elements of the type called ’em’. The size of  em is the equivalent to the size of the ‘m’ character of the font you are using for that part of the text

#centretext – the name of this section of the css file

p, class, span, /span, /p, body, /body, head, /head, link, href, rel, type, title – html commands

text-align, text-indent, span.centered, display-block – css control commands


11 September 2014

Reading about ePub

We thought we’d better find out a bit about ePub files before we started converting our Kindle ebooks. Mainly because there are many more devices and retail sites to cater for when building ePub. Originally with just Kindle files, we only had one device supplier to consider, and as we’d used Amazon’s kindlegen program to generate the files it has all gone fairly smoothly. But would ePubs be more complicated? Many publishers use conversion companies, however with one of the company partner’s having a background in IT we thought we’d give it a go at DIY.

Before doing so a bit of background reading was in order. We wanted to make sure we considered any known incompatibility problems, to make sure our files were as clean as possible when we did eventually create them, and to try to find the lessons others had already covered. So here are a few of the books we read when looking for tips on what to do, and more importantly on what not to do.


Smashwords Style Guide by Mark Coker

SmashWords Style Guide

An excellent guide. SmashWords use their own program (their ‘meat-grinder’) to convert ebooks submitted to their platform to all major devices. This is the setup guide for their submissions, and is a good overall guide to how to set up and check your files.


What is EPUB3

What is EPUB3 by Matt Garrish

This is a very good guide to the new ePub3 standard by Matt Garrish, who is on the standards group. Although there are very few devices yet that can read ePub3 files it is still worth reading the guide now.


Accessible EPUB 3 by Matt Garrish

Accessible EPUB3 by Matt Garrish

Again on ePub3 so the devices aren’t really available yet but this is an extremely helpful guide to making the ebooks more accessible or usable by people with some ability to use the reading devices in the standard way.


EPUB From the Ground Up: A Hands-On Guide to EPUB 2 and EPUB 3 by Jarret Buse

EPUB From the Ground Up: A Hands-On Guide to EPUB 2 and EPUB 3 by Jarret Buse

This covers ePub2 and CSS, and a bit on ePub3 and HTML5. Although initially disappointed in this book, mainly as it didn’t have the values we needed to check at the time, in the end we found it was useful and overall a worthwhile investment. It isn’t comprehensive but has enough information to get you going and points you to some very useful tools – largely free or donation based ones.


LEarning PHP, MySQL, JavaScript, CSS & HTML5

Learning PHP, MySQL, JavaScript, CSS & HTML5 by Robin Nixon

This is really for website  developers, but the CSS and HTML bits are useful. And the HTML5 can be useful when building ePub3 files in the future.


HTML FIXES FOR KINDLE

HTML FIXES FOR KINDLE by Aaron Shepard

Even though this is for Kindle and not for EPUB it is still useful as it contains some workarounds to consider if things don’t display correctly. But you have to decide for yourself if the workaround is worth doing, or if it is a quirk of a particular device, or of that device’s operating system at that particular time.


08 July 2014