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>

or

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