Tuesday, May 3, 2016

Suggestions on Future Topics

As you may have noticed, it's been awhile since I've updated here. So, I'm going to ask you, the readers, what topics would you like to read about?

Formatting paragraphs in a word processor (Word, OpenOffice, Pages, etc)? Indenting, paragraph spacing, fonts, and sizes.

Creating a table of contents? How to do this in word processors. How to do this in html. How to create a linked table of contents.

Using special fonts in your book?

Linking footnotes?

Any other ideas not listed above?

If you have any ideas you'd like me to write about please leave a comment or email me (address can be found on Services Offered page).

Friday, August 23, 2013

How to Have No First Line Indent for Kindle eBooks

I hear this very often on Kindle formatting forums:

"I have no indents in my book, but when I publish it on Kindle there are indents on the first lines of every paragraph. Why are they there? How do I get rid of them?"

This most often happens when you format your book using Word (or any other word processor).

The sad truth is that if you set your first line indent to 0in in Word, you will get indents in your final Kindle book.

It seems that when you set the indent to 0 in Word, it doesn't actually set it to 0in, it set it to 'none'. What's the difference, isn't that the same thing? Well, in html (which is what all eBooks are based on) there is a difference.

If there are "no" first line indents:
What it Means: This means there is no mention of text-indent in the html.
The Result: The default indent of the device or program is used, for Kindle the default is a slight indent.

If first line indents are set to "0":
What it Means: "text-indent: 0" will be added to the style of the paragraph.
The Result: No indent.

So, what do you do if you want no indent?

In Word you can set the first line indent to a very small number (0.01in for example). This will set a very small indent (so that it won't go to default) and visibly it's not very different from 0in.

This could also happen if you edit your book as html or an ePub. In this case, the default indent can occur if you have no "text-indent" style for your paragraphs. To fix this simple add in "text-indent: 0".

Saturday, August 17, 2013

How to Keep Images and Captions Together in eBooks

I've come across this question a lot. How do I keep the captions below my images (or tables, figures, etc)?

As you know, eBooks don't have set 'pages', the text flows. The user can change the font, the size, and the margins of the text. So, what happens when your image is at the bottom of the screen and there's no room below it? Well, the caption is pushed to the top of the next screen. Many people don't like this, and I understand. The caption is supposed to stay with the image, that's why it's there.

The sad conclusion I've come to (after much research and experimenting) is that there is no easy way to keep the two together that will work on all devices or programs.

The first thing I tried was the html property "page-break: avoid".

You may use it in this manner:
<div style="page-break-inside: avoid">
<img src="../Images/example.jpg">
<p>This is the caption below the image</p>

This should cause those items within the "div" to not break across pages. Therefore the image and caption should stay together.

Note that I said should. I tried this method, and I found that whether it works or not depends on the device/program you use. Some would honor it, others wouldn't. Sadly, Amazon/Kindle does not honor this code.

At the time I was trying to code a Kindle book, so it was on to something else. I went to Amazon's website and found what html/css codes they support. If you're curious you can check it out here:
Supported HTML in eBooks in General
Supported HTML/CSS in KF8 eBooks

I found the codes "figure" and "figcaption" in the KF8 supported html. I thought maybe that would keep the two elements together. Unfortunately, in my tests it did not. I even tried combining the 'figure/figcaption' with the 'page-break-inside: avoid'. But, it still didn't work.

So in the end, the only method I've found that works right now (this may change in the future) is to place the caption within the image file.

To do this, open your image in some image editing program. GIMP is free and available for multiple operating systems. Add a little white space under your image and use the text tool to type in your caption.

One thing to keep in mind while using this method is that the text is now part of the image, which means the text will scale with the image. When your image appears very small (think about reading on an iPhone screen) the text will be very small as well. There's not much you can do about this. Try to make the text large enough to read on the majority of screens.

The good news it that this method will work on all devices/programs.

Friday, April 12, 2013

Using the 'title' Attribute with Chapter Titles

It's simple to set up your chapters to appear as you want them to in the Table of Contents (ToC) when they're a single line of text. Something like; Chapter One. But what if you want something more than that?

If you have a simple single line chapter title, all you need to do is format the line as a heading. In a word processor you would use one of the heading styles. If you're using html you would use h1, h2, h3, etc tags.

In this post I'm going to tell you how to have chapter titles that span multiple lines and chapter titles that are images. We're going to accomplish this by using the "title" attribute. To do this you'll need to be working with html. I don't know how to do this in the various word processors, and I'm not sure it's even possible. If anyone knows if it is possible please let me know.

If your chapter title is on separate lines, simply styling both lines as headings can cause problems. If your chapters are titled like this:

Chapter One
The Beginning

If you mark both lines as h1 they will both appear in the ToC as separate entries like in the image below.

If you decide to only use the h1 tag on the first line, then the second part "The Beginning" will not appear at all.

There are two ways to set this up so that it looks nice in the book and appears as you want in your ToC. One method is to use the h1 tag on the first line, and the p tag on the second line. Then use styling to make them look the same. The other method is to use the br tag. This will create a line break but will not start a new paragraph. The h1 tag wraps around both lines.

<h1 class="chaptertitle">Chapter One</h1>
<p class="chaptertitle">The Beginning</p>


<h1 class="chaptertitle">Chapter One<br />
The Beginning</h1>

Now you want your chapter titles to appear correctly in your ToC. If you add the "title" attribute within the h1 tag, it will be used instead of any text between the tags. Here's how it would look:

<h1 title="Chapter One - The Beginning" class="chaptertitle">Chapter One<br />
The Beginning</h1>

This will appear in the ToC as "Chapter One - The Beginning" like in the image below:

Now, what if you want to use an image as your chapter title? That brings a slightly different problem. You can use the h1 tag around the image to try to make it appear in the ToC. The problem is, since there's no text, the entry will appear blank. You can see that here:

But, if you use the "title" attribute, like in the two line chapter title, you can fix this. So, your code would look like this:

<h1 title="Chapter One" class="chaptertitle"><img src=".../Image/chap1.jpg" /></h1>

Now, Chapter One will appear in your ToC like this:

This can also be used if, for some reason, you want the text that appears on the page of your book to be different than the text that appears in the ToC.

(note: I used the h1 tag through my explanation, but this will work for all levels of headings: h1, h2, h3, h4, and h5)

Friday, April 5, 2013

How to Identify and Remove Tabs

There are a few thing that many authors do to try to make their work look nice, but ends up causing problems. One of those things is using the tab key to indent. This works fine for word processing files. It would also be okay if you plan on creating a PDF of your book. However, this does not work out if you plan on created an ePub or mobi eBook.

The tab key is evil! Do not use the tab key to indent your text!

How do you know if this is how your paragraphs are indented? The easiest way is to turn on the show/hide non-printing characters.
On the tool bar of your chosen word processing program there will be a symbol.

Here it is in Microsoft Word:

You can now see all the non-printing characters like spaces, paragraphs, and tabs. Here's an example:
Do you see those little arrows at the beginning of each paragraph? Those are the tabs.

Here is it in Open Office: 

And here's what you will see:

And finally it's a little different in Apple's Pages. In Pages it's called Show/Hide Invisibles and you have to access it through the menu:

And here's how things look in Pages:

So, what's the problem?

There are no devices or formats that I know of that support tabs. There are a few things that could happen to your tabs depending on what converter or format you use. In most cases they will simply disappear. The converter program/format/reader doesn't know what to do with tabs so they ignore them. In some instances I've seen tabs turn into spaces. Which, again, isn't ideal.

Oh no! I have tabs? What do I do?

So, you've written your book, but you used tabs instead of paragraph styling. You don't want to go back through the whole document and remove the tabs one at a time. That would be far too time consuming. Luckily there is a way to use each program's 'find/replace' feature to remove all the tabs from your document.

Here's the process for Microsoft Word:
Go to the 'Edit' menu, then 'Find', then 'Advanced Find and Replace'

Go to 'Replace' and note the small downward pointing arrow in the bottom left corner.
You can either type in "^t" in the find field (without the quotes). Or you can click that small arrow to bring up more options. From there select the drop down menu that says 'Special', then select 'Tab Character'.
Leave the 'Replace' field empty and hit 'Replace All'. Now all your tabs should be gone!

Here's the process for Open Office:
Go to the 'Edit' menu, and select 'Find & Replace'.
Now select the 'More Options' button in the lower left corner.
Make sure that 'Regular expressions' is checked. In the 'Search for' field enter "\t" (without the quotes) and leave the 'Replace with' field blank.
Now hit 'Replace All' and all your tabs should now be gone.

Finally, here's the process in Pages:
Go to the 'Edit' menu, select 'Find', then select 'Find'.
Go to 'Advanced'. Beside the 'Find' field there is a drop down menu that says 'Insert', click that and select 'Tab'.
A tab character is inserted into the 'Find' field, leave the 'Replace' field blank. Now hit 'Replace All' and all your tabs should disappear!

But I still want my text indented! What should I do?

Use paragraph styles! There are many different indent types that you can use. I find that a first line indent of between 0.2in - 0.33in looks best.

I will go through exactly how to add indents using paragraph styles with all three word processors (along with screencaps like I did in this post) in a future post.

Saturday, March 30, 2013

Using the @media query for Kindles

Amazon's new format, KF8, has added support for many features that the older mobi format was lacking. That's great, right? Well, KF8 is only supported on newer devices: the fourth generation of Kindles and newer.

But, I've heard from many authors that they don't want to limit their market. They want to sell their books on as many people as they can and I can certainly understand that.

So, what's the problem? The problem for me is, should I code the book for the older devices, or should I code it for newer devices?

The example I'm going to be using is tables since that's what I first experimented with.

Older Kindles had very limited support for tables. They supported simple tables, but they didn't look very great. So, the advice has generally been convert your tables to images and use that. That way you know your table will appear the way you want it to. On the other hand, the new KF8 format has much better support for tables. They also look and function much better.

If you code a table for a KF8 file, it won't look very good (or may display terribly) on older devices. But if you code a table for the older mobi format, you know that it could have been better on newer devices.

So, what to do?

Well, another new feature that came with KF8 was support for media queries. What does that mean? Basically you code for both versions in one file. The KF8 code will appear on devices that support it and the older code will appear on devices that don't.

I wrote up my experience when trying this for the first time as I was doing it. Here it is for anyone who would like to learn along with me:

So, first I build the book for KF8. That means building the tables in html. I like to do this separately at first. For example just open TextEdit/NotePad and write out the code for the table and fill it in. Once you're done with it you can copy/paste it into the book.


Ok, now that the book is all finished and formatted for KF8, it's time to go back and code in the table images that will (hopefully) appear on older devices.

So, here's what I've added to my stylesheet:

{ }
{ display: none; }

@media amzn-mobi
{ display: none; }
{ display: block;
margin-left: auto;

So, the "mobi" class should only display on devices using the old mobi format. And I didn't want to change any of the formatting I'd already done so I left the "kf8" class blank.

Any table I have in the document gets the class "kf8" and just below them I'm adding in the images and giving them the class of "mobi".

<table border="1" cellpadding="5" class="kf8">
<p><img class="mobi" src="../Images/filename.jpg" /></p>

I left off the mobi class first to make sure the images display properly. Add in the mobi and watch them disappear.

Now, do this to all the tables in the book.

Now to toss it into kindlegen and see what happens. *Fingers crossed*
It completed the book with no warnings, that's a good sign.

Now to test the file. First, I'll open it in Kindle for Mac and see how it looks. Other than forgetting a kf8 class on one of the tables it seems to have worked. Now to try it in Kindle Previewer... And it works. I'm kinda surprised it went that easily. The tables are displayed on the Paperwhite and Fire, and the images are displayed on the Kindle and DX. Now, a final test. Load the file onto my Kindle Touch (KF8 supported) to see how it looks.

The tables are looking very good.

A success!

Here's a sample from Amazon's Kindle Publishing Guidelines (slightly editted by me) that you can try out for yourself. Try it in sigil or your favorite eBook/HTML editor and learn how to apply it to your own work.

Here's what you would add to your stylesheet:

{ display: block; }
{ display: none; }
@media amzn-mobi
{ display: none; }
{ display: block; }

And here's the code that would appear in your book:

<table class="kf8" bordercolor="#E66C2C" border="1" cellpadding="4">
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
<td>Cell 1</td>
<table bordercolor="#003399" border="1" cellpadding="4">
<td>Nested 1</td>
<td>Nested 2</td>
<td>Nested 3</td>
<td>Nested 4</td>
<td>Cell 2</td>
<img class="mobi" src="../Images/tableimage.jpg" />

A final note:
I used tables as an example, but this is definitely not limited to that. You can use this for any coding that you want to appear differently on one device vs another.
Just apply the “KF8” class to what you want to appear on the devices that support the new format. And apple the “mobi” class to what you want to appear on older devices.

Sunday, March 24, 2013

Converting vs Formatting

It has never been so easy to publish your own book. And now eBooks are becoming more and more popular. There are multiple options for reading, or publishing, including (but not limited to) Amazon/Kindle, Barnes & Noble/Nook, Apple/iPad/iPod/iPhone, and various less well known mediums.

I know from my own personal experiences of purchasing eBooks that not all books are formatted well. Now, it varies from person to person, but those formatting errors can be minor annoyances or make a book completely unreadable.
It can be something minor. I've had a couple eBooks from big publishers that didn't have a working navigational table of contents. This meant that I couldn't 'flip' between chapters, and there were no chapters listed in the 'Go To' option.
Or it can be something major. I've seen eBooks that have spaces that take up have a screen, paragraphs that break in the middle of a sentence, or a complete lack of spacing so it's difficult to tell where one paragraph ends and the next one starts.

Of course, no one wants to have problems with their book. You've spent so much time and effort writing your book. You want other people to enjoy it. So, what do you do now? How do you ensure that your book looks nice, and works with whichever device you've decided to publish on? Maybe you've decided to format/convert the file yourself, or maybe you've decided to hire someone else to do it.

Now that brings up the question: What's the difference between formatting and converting an eBook?

In short, formatting requires much more time & work and ensures a good looking/functional final product, while converting is a quick automatic process (usually involving a conversion program) and the results can be unpredictable and may look slightly off or just wrong.

Formatting a document has to do with changing the way it looks and/or functions. Formatting eBooks requires knowledge of html and css. What does that mean? HTML is the basic structure of the eBook (paragraphs, chapter headings, images, etc) while css is the style of the book (fonts, sizes, spacing, colors, etc).

Basic formatting would include things like: first line indents, paragraph spacing, font sizes, text/image alignment, ensuring the eReader device "sees" the chapters, adding and linking a Table of Contents (if it's not already there), etc...

Converting a document is simply changing it from one file type to another. For example, you have a Word Doc and you use a program to convert it to mobi.

There are many free programs available that will convert your book between many different file types. They will not ensure that the book looks good, only that it has changed from one file type to another.

Now, I'm not saying that those conversion programs are bad. They can be very useful. Calibre, for example, is a very useful, free, conversion program. You can get fairly decent results, but only if you understand what all the options mean and how they apply to your book. In fact, if your Word doc is well formatted, and if the book is simple (mostly text), you can sometime use a converter program and get decent results.

Ah, but I just said 'well formatted', didn't I? Which leads me to...

In my opinion, it's not so easy to separate the two. At least, now when everything's properly done. A good eBook will look nice (formatting) and be in the file type you need (conversion). If you skip either of these processes your book won't work out very well. If you simply convert the book, your formatting will probably not be what you want. Just like a well formatted document won't mean much if it's not converted to the proper file type.

In the end, to get the eBook you want, you'll have to both format and convert your document. If you decide to do this yourself then take the time and effort and you'll be happier with the results. Or if you decide to hire someone to do this, make sure the person you hire will take the time to properly format your document before they convert it.