Posts Tagged ‘epub’

* Calibre Quick Start Guide Fourth Edition

Posted on February 22nd, 2014 by John. Filed under calibre.


The quick start guide is something I’ve been neglecting for quite some time. When calibre 1.0 was released I really should have updated the guide at that time but I didn’t. This past week I decided that it had been long enough and the guide had to be updated.

I’m happy to say that before I updated it, the majority of the information in the guide still applied. This is a testament to the stability of calibre. While lots of new feature are still being added the overall usage of calibre has remained consistent over this time. This is a good thing because it mean users don’t have to re-learn calibre regularly.

This update to the quick start guide is a major update. Most if not every paragraph was touched. Information about features not present in calibre during the last update have been added. For example, the cover grid view and the e-book editor. Outdated information, such as the a section about the PDB e-book format, has been removed.

I’ve updated the license on the guide as well. It’s still the same Creative Commons license but I’ve moved from version 3 to version 4. That said, the rights granted by the license haven’t changed.

I’m calling this release of the quick start guide the Fourth Edition. Previous releases didn’t have a version. They really should have. Thinking back about major updates this is probably (I can’t really remember) the fourth major update. Going forward I’m going to use an edition like most other books that get updates over time.

Not long ago I made a post stating that calibre’s new e-book editor is the successor to Sigil. I’m happy to say that I used the calibre e-book editor to update the Calibre Quick Start Guide. I didn’t just update the text but the entire structure of the book was updated. File names, locations, CSS, and HTML layout were all changed. The calibre e-book editor really is Sigil’s successor.

As usual the Calibre Quick Start Guide is included as part of calibre. It is still the first book in your library when creating a new, empty library. The fourth edition (update) is part of calibre release 1.25 (21 Feb, 2014). You can always directly download the latest version from the source repository.

Tags: , , , , .

    Comments Off


* Formatting Tips: Raised Initial

Posted on September 27th, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

This is a very easy formatting type and is similar to doing a drop cap. The big difference is a raised initial the letter is on the base line and is higher than the other letters. Only the first letter of the first paragraph of a chapter should be raised.

Simply wrap the first letter in a span tag referencing the appropriate CSS class like so.

<p><span class="ri">L</span>orem...</p>

The CSS for a raised initial is very easy. Simply make the font size larger than normal and set it to bold.

span.ri {
    font-size: 4em;
    font-weight: bold;
}

The best way to illustrate this concept is with an example. Download ft-raised-initial.epub. Opening the file with Sigil you will see the example chapters and the external CSS that is referenced by each XHTML file.

Tags: , , , , , , , .



* Formatting Tips: Endnotes and Footnotes

Posted on September 20th, 2011 by John. Filed under Formatting Tips.


About Formatting tips.

Many non-fiction books utilize footnotes or endnotes. Footnotes do not work very well with ebooks because footnotes need to be placed at the bottom of a page. It is possible with EPUB to specify content to be shown at the bottom of a page using the following:

<div style="display: oeb-page-foot">...</div>

I highly recommend against using the oeb-page-foot display style. Many reading devices and software do not support this and just ignore this text. My recommendation is to use endnotes.

All endnotes should be collected into a single page located at the end of the ebook. I recommend using either a * or increasing numbers. If you use numbers the number in the text should correspond and be displayed infront of the endnote. Use the sup tag and link to the end note.

<sup id="ra"><a href="c2.xhtml#enda">*</a></sup>

One thing to keep in mind is not all ebook reading device and software support a back button. So it’s a good idea to include a return link to take the reader back to the exact place in the text the endnote is referenced by. Make the return link subtle but not something the reader will over look. I just make the font smaller.

<sub><a class="return" href="c1.xhtml#ra">return</a></sub>
.return {
    font-size: x-small;  
}

The best way to illustrate this concept is with an example. Download ft-endnotes.epub. Opening the file with Sigil you will see the example chapters and the external CSS that is referenced by each XHTML file.

Tags: , , , , , , .

    Comments Off


* Formatting Tips: Sizing elements (Including Text)

Posted on September 13th, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

When dealing with the EPUB format there are number of ways to deal with sizes. Font size, indent, margin, spacing all allow for a variety of units to define their size. Sizes can be defined using any of the following: %, in, cm, mm, em, ex, pt, pc, px.

With all these choices it might be hard to decide which unit type to use. This decision is actually very easy. Alway use a relative size type. cm and in for instance are fixed size; 1 cm is always 1 cm and 1 in is always 1 in. % and em are relative sizes. An em is equivalent to the the current font size. So 1 em is equivalent to 12 pt if the font size is 12 pt.

It’s very important to use relative sizes because EPUB and EPUB reading software / devices allow for users to change font sizes. Also, there is significant variation in screen sizes. Using relative sizes means that spacing of elements (indents for example) will always appear the same.

I’ll admit using relative sizes is hard. In some of the examples for Formatting Tips I’ve used exact measurements. I apologize for this but this illustrates how difficult it can be to take into account all of the possible rendering issues that can arise from such a diverse reading ecosystem available today.

Be careful when using relative sizes. Each unit is unique. Using a % for the indent will be a % of the screen width. While using a % for a text size it will be relative to the text size of that element. An em is always going to be relative to the current font size. Be sure to check the layout with various text sizes and screen dimensions. You can simulate (it’s not perfect) by opening the book in something like Sigil or calibre’s ebook-viewer and change the zoom and window size.

Tags: , , , , , , .

    Comments Off


* Formatting Tips: Markdown, Textile and calibre

Posted on August 30th, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

Up to this point Formatting Tips have been focused on the EPUB format and working directly with the underlying XHTML and CSS. Not everyone wants or needs this level of control over the layout of their book. Often times a book only needs basic formatting such as headings, bold, and italic. There are other easier ways to format an ebook. However, in this case simpler does mean basic.

A very easy way to format an ebook is to start with a plain text file (TXT). Then use either Markdown or Textile to add the formatting. Both Markdown and Textile allow for simple text formatting and they are designed to be converted to HTML.

By using TXT with a formatting syntax you can use pretty much any text editor you want. Markdown and Textile are very simple formats that are much easier to learn than XHTML and CSS. Adding things like *bold* is as easy as putting a * before and after a segment of text.

I recommend looking at both Markdown and Textile. There are differences in what formatting they support but they both support the basics like bold, italic, and headings. I’ve found Markdown to be easier to use but Textile offers more options.

After adding your formatting to the text it’s very easy to turn the TXT file into your desired final format (EPUB or MOBI most likely). calibre supports TXT formatted with either Markdown or Textile. However, the Textile support is more robust. Simply convert to the output format of your choosing.

Tags: , , , , , , , , , , .



* Formatting Tips: Calibre as a First Step

Posted on August 23rd, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

Calibre’s robust conversion engine can be leveraged to help with formatting tasks. Converting with calibre helps when you are dealing with a format you cannot easily edit, or a format you aren’t very familiar. It’s also helpful in situations where the insides of the file is such as mess it’s hard to understand.

Many of these tasks are geared toward people who already have an ebook in an existing format that they need to clean up. A common case is a book from Project Gutenberg. Ebooks from Project Gutenberg are in no way poor quality. However, a TXT file is not going to have any formatting because the format doesn’t support it. There is a large number of people who want to add fancy formatting to classic titles. Another reason for conversion first is HTML documents produced by Microsoft Word. While Word is a great text editor its HTML output is atrocious. There is often lots of extra formatting information that is unnecessary and unused. Conversion can reduce the amount of time they need to spend adding formatting by using calibre as a first step.

Some common ebook formats MOBI (used by Amazon) and eReader PDB are compiled. They are not easily edited and one of the easiest ways to make changes is to convert to a format that has robust editing tools.

There have been many ebook formats over the decades that ebooks have been around. I’m not going to go into why there are so many ebook formats but know that many of them are not widely used any more. It’s easier to take a format like an ebook in the Plucker format from Project Gutenberg and convert it to an easy to edit format than working in the Plucker format.

Now that the whys are out of the way let’s move on to the hows.

When converting from any format there are a few output formats I recommend. EPUB is of course easy to edit using Sigil. If you want to use HTML as your base format I would commend looking into calibre’s HTMLZ output. HTMLZ is really a ZIP file with a single HTML file inside of it. One major advantage of HTMLZ over EPUB is HTMLZ output has some options that can be used to clean up the output. For instance HTMLZ can condense CSS styling to a basic set and produce a CSS HTML file inside of the archive.

Another option for conversion is TXT output. TXT by itself will remove all formatting. If the file is so poorly formatted it could be easier to start from scratch and add all formatting back yourself. TXT output also has the advantage of being able to produce Markdown or Textile formatted output. Both of these give basic formatting while removing extraneous formatting information.

Finally, when converting with calibre look at the Heuristic formatting options. They are disabled by default and should be used with care (Except with non-Markdown and non-Textile TXT input). There are heuristics for many common formatting needs such as detecting and formatting chapters and chapter subtitles. There are heuristics for italicizing common cases, removing unnecessary hyphens, and fixing broken lines. There are more options than these and it’s a good idea to go though them all and enable the ones that apply to the ebook your working on.

My recommendation is if you’re starting with a poorly formatted starting point use conversion to do some of the basic work for you. Conversion is an automated process and can take care of some tedious tasks for you but it’s not a replacement for human editing.

Tags: , , , , , , , .

    Comments Off


* Nook Covers Not Showing Up

Posted on August 21st, 2011 by John. Filed under articles.


The Barnes and Noble (B&N) Nook has issues reading covers for EPUB files. Not all Nooks have this issue it’s only the Color and Touch because the original Nook supported reading the cover from an external image file. The Color and Touch will only read covers from the EPUB files themselves (no cover thumbnails unfortunately). This issue with the Nook is caused by B&N not properly implementing the EPUB specification in their device.

Covers are defined by a meta element in the EPUB’s OPF file within the metadata section. The meta element needs to have two attributes, “name” which needs to be cover and “content” which points to the id of the cover item (needs to be an image) in the manifest section.

According to the OPF spec the OPF must be valid XML and conform to the OPF Package Schema. In XML the order of attributes does not matter. You can use any order for elements and they will conform to the schema.

This is where the issue with the Nook comes in. The Nook requires the attributes to be in a specific order. Namely, name followed by content. E.G.

<meta name="cover" content="id5" />

Again, the order according to the spec does not matter. Many reading device and software implement the spec correctly and do not have an issue with reading covers from EPUB files. It is only the Nook that has this peculiar requirement.

Sigil, 0.4.0, writes the attributes for elmenets in the OPF in alphabetical order. This is correct and why EPUBs created with this version of Sigil will not show a cover on the Nook. Version 0.4.1 of Sigil will include a fix for this issue.

The easiest way to deal with broken covers on the Nook is to use Sigil 0.4.1. First open the EPUB with Sigil and make sure the cover is properly set. Right click on the image in the Book Browser and under Add Semantics choose Cover Image if it is not already checked. This will add the meta element defining the cover to the OPF. Save and quit Sigil. That’s it, your done. However, be sure you’re not using Sigil version 0.4.0. You need to be using 0.4.1 or greater.

If you don’t want to use Sigil you can manually verify and if necessary add the above meta fragment to the manifest section. Remember name needs to be “cover” and content needs to be the id of the corresponding image in in the manifest section.

Next you need to edit the OPF file and change the attribute order for the meta element relating to the cover. If you’re on Windows you can use tweak_epub which is provided for free by the Atlantis Word Processor people. This allows tool will show you a list of all files within the EPUB and let you open the OPF for editing. If you’re on OS X or Linux change the .epub extension to .zip and unzip the file. This will create a folder with all of the files within the EPUB. Find the OPF, open and edit it.

You can unzip an EPUB because they are really just ZIP archives but they have some special requirements. You can’t just compress a folder and change the extension to EPUB. If you’re on OS X pdurrant on MobileRead has created an AppleScript application for rebuilding EPUBs from extracted content.

Finally, for command line people (Linux) pdurrant also provided these command line instructions for creating the archive with the zip command.

$ zip -X0 "full path to new epub file" mimetype
$ zip -rDX9 "full path to new epub file" * -x "*.DS_Store" -x mimetype

Once you have rebuilt your edited EPUB it should now have its cover appear on your Nook. If it’s not displaying properly reboot your Nook. Sometimes the Nook will not update the cover in it’s internal cache if you change it. Even if you deleted the book and put it back on the device it may not display correctly without a reboot.

Tags: , , , , .



* Formatting Tip: Poetry

Posted on August 16th, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

Poetry is one of the hardest elements to get right when formatting an ebook. The biggest issue is poems visually use a fixed width. Each line needs to be easily distinguishable. If they run together the rhyming and meter can easily be thrown off. Ebooks typically allow for reflowable text. This is where the text on screen changes to accommodate the users selected font, font size, and the screen size. This is exactly what happens on a web page how each line changes length when the browser window is resized.

When dealing with a poem do not put it in a pre tag. Do not use a single p tag and separate each line with a br tag. Do use an ul tag and hide the bullet. All of these methods will end up looking terrible.

When dealing with a poem there are two parts: the poem’s text and the attribution. Each of these parts will be in p tags. Lets start by setting a base p style with CSS. We want to remove the empty space between paragraphs.

p {
    margin-bottom: 0;
    margin-top: 0;
}

There are a few special things we want to do with the poem’s text. First, we want it pushed to the right so it is clear to the reader that they have entered a poem. One way to do this is to put the entire poem in a blockquote tag. I don’t like this because this affect can be achieved with CSS. Second, the text should be smaller than the regular text. Third, we want each line to not be indented. However we do want each line to be distinguishable even if the text is wrapped. The trick is to indent the portion of the line that wraps. Think of this like a reverse paragraph indent. We can make this happen by using a negative value for the text indent. Here is the CSS block to make all this happen.

.poem-text {
    margin-left: 3em;
    font-size: small;
    text-indent: -1em;
}

With many poems there are often breaks ever few lines. Handles these by putting in an almost empty paragraph. It’s necessary to put a non-breaking space in the empty paragraph because completely empty paragraphs are often ignored by devices and reading software.

<p>&nbsp;</p>

For the title we want to have it appear italicized. We also want to force a little space between the poem’s text and the title. The author we want to force some blank space after it so it doesn’t run into a paragraph below. Both the title and author need to be right justified. Finally, I like to use small caps with the title and author. However, there is one major issue with small caps. Many reading devices and software (one’s using Adobe’s software) do not support small caps. Sometimes you can get away with using a CSS transformation to uppercase. Check your targeted reading platform / device to make sure this will come through. If it doesn’t you will need to make the title and author uppercase in the text itself.

.poem-title {
    font-style: italic;
    text-align: right;
    margin-top: 2em;
    /* Pick one or neither */
    font-variant: small-caps;
    text-transform: uppercase;
}

.poem-author {
    margin-bottom: 2em;
    text-align: right;
    /* Pick one or neither */
    font-variant: small-caps;
    text-transform: uppercase;
}

The best way to illustrate this concept is with an example. Download ft-poetry.epub. Opening the file with Sigil you will see the example chapters and the external CSS that is referenced by each XHTML file.

Tags: , , , , , , .

    Comments Off


* Formatting Tips: Scene Breaks

Posted on August 9th, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

There are two types of scene breaks: hard and soft. Hard scene breaks are denoted by a visual separator between paragraphs. Typical identifiers are lines and stars. Soft scene breaks are created by putting white space between paragraphs. They both serve the same purpose but some authors prefer one style over the other.

Lets start by setting a style to create print formatted paragraphs. This makes seeing the distinction in the scene breaks easier.

p {
    margin-bottom: 0;
    margin-top: 0;
    text-indent: 5%;
}

There are two ways to create hard scene breaks I’m going to cover but they are very similar. Using a hr tag with a width set to 25% will create a nice line between paragraphs. We also want to set the top and bottom margins to 2em to give some space around the line so it’s easily visible. Another method is, instead of an hr tag, we can put three *’s in a p tag. In this case we don’t touch the width; we set the text alignment to center. This gives the centered three dots many books use for scene breaks. I use a CSS class .hb for the * method.

hr {
    margin-top: 2em;
    margin-bottom: 2em;
    width: 25%;
}

.hb {
    margin-top: 2em;
    margin-bottom: 2em;
    text-align: center
}

As with hard scene breaks I’m going to cover two methods for soft scene breaks. The easiest way to create a soft scene break is to use three empty paragraphs.

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

Another method for soft scene breaks is to use a single empty paragraph or an existing paragraph and set the top margin to 3em. Following is an example CSS style. To have a scene break before a paragraph set it to use this style.

.sb {
    margin-top: 3em;
}

One consideration with scene breaks is converting to another format. Using the above scene break methods the scene breaks will convert from one format to another if you convert using calibre. It is difficult for a conversion tool to understand intent such as a blank paragraph representing a scene break. However, calibre understands and looks for scene breaks using the above method. So, if you plan to convert form EPUB to another format using calibre you shouldn’t have any problems if you create scene breaks using these methods.

The best way to illustrate this concept is with an example. Download ft-scene-breaks.epub. Opening the file with Sigil you will see the example chapters and the external CSS that is referenced by each XHTML file.

Tags: , , , , , , .

    Comments Off


* Formatting Tip: Big First Letter

Posted on August 2nd, 2011 by John. Filed under Formatting Tips.


About Formatting Tips.

A common embellishment used in print books is to have the first letter of the first paragraph in a chapter appear much larger then the others. In addition to the letter being larger than the rest it also falls below the baseline. The rest of the paragraph will wrap around this first letter.

To achieve this we will use a little bit of CSS and a span tag. Surround the letter with a span tag and set it to use the class “bfl”.

<p><span class="bfl">L</span>orem...</p>

Add the following class to your CSS file linked by the document.

span.bfl {
    font-size: 450%;
    font-weight: bold;
    float: left;
    margin-top: -10px;
    margin-bottom: -15px;
}

The best way to illustrate this concept is with an example. Download ft-big-first-letter.epub. Opening the file with Sigil you will see the example chapters and the external CSS that is referenced by each XHTML file.

Tags: , , , , , , .

    Comments Off