View Full Version : Inconsistent Spacing


N00ter
04-12-2012, 08:42 AM
I have created a fairly large ePub file (5MB in size or so). The process I used was that I put the entire book together in MS Word 2011 and then exported as a filtered HTML file. I then loaded the HTML file into Calibre and converted it to ePub and mobi. The mobi file reads just fine in the eReaders that I've tried. When I load the ePub into my iPad and read it in iBooks, however, it has awkward spacing.

http://i44.tinypic.com/33js4mo.png

Any thoughts on what I could do to fix this? I'm somewhat at a loss and running out of ideas.

Toxaris
04-12-2012, 09:06 AM
First of all iBooks has it quirks and strange way of working. That being said, I don't think it is your problem in this case.
If you use Word, it is good to save it as filtered HTML. However, even that file is really bloated and contains tons of unnecessary code which can cause unexpected effects in rendering on readers. Using Calibre to convert will not help you there.
If you really want to solve this, there is no solution but to clean either the ePUB or the HTML export of Word.

If you don't want to look at the code at all, download and use Atlantis Word Processor. Load your Word document in that. Check your layout and then you can save as ePUB.

N00ter
04-12-2012, 09:10 AM
I will give Atlantis a try.

N00ter
04-12-2012, 09:12 AM
One problem, however, is that I can't use Atlantis on my mac. Is there any mac alternative?

WillAdams
04-12-2012, 09:18 AM
Set the text FLRR (flush left, ragged right).

Every ebook viewer I've seen has a greedy, one-line at a time, justification algorithm (w/ no hyphenation).

You _might_ be able to help the text by inserting discretionary hyphens into long words like ``establishmentarian'', but only one those readers which actually support such.

If you want more control than that you'll need to make an App or a .pdf.

William

Toxaris
04-12-2012, 10:04 AM
I don't think justifaction is the issue, but the spacing at the location of the endnote. So, vertical spacing.

Sorry, don't know of a Mac alternative. Personally I would use my HTML-export macro from Word or a thorough cleanup in Sigil. For that basic (X)HTML/CSS knowledge is required.

N00ter
04-12-2012, 10:09 AM
Is vertical spacing something I can control in Sigil? The vertical spacing in relation to the hyperlinks really does appear to be the culprit.

dwig
04-12-2012, 10:16 AM
...When I load the ePub into my iPad and read it in iBooks, however, it has awkward spacing....
Any thoughts on what I could do to fix this?...

Which "awkward spacing" are you referring to??

If you are referring to the horizontal word spacing seen in the third line then there is nothing you can do other than to spec the book to use left alignment instead of justification or to use different reading software. There is nothing you can do in the book's code to change the reader's justification decisions (word spacing, letter spacing, hyphenization, and/or not justifying a problem line).

If you are referring to the vertical spacing before line five, then there are things you can do that can/may help. You can either change the superscript endnote to not be superscript or reduce it's size. The former always works to restore uniform line spacing but looses the traditional look. The latter, size reduction while retaining the superscript, works sometimes with some reading software depending on the amount of the size reduction and the abilities of the ereader.

N00ter
04-12-2012, 10:58 AM
I think I'm just going to change the endnote style so that it is the same size as the rest of the text. In fact, I just did it, and it worked well. Now everything is aligned and attractive like I wanted. It's too bad the iPad doesn't allow attractive superscripts that don't mess up the vertical spacing.

Thanks for the help, everyone!

mmat1
04-12-2012, 11:09 AM
One problem, however, is that I can't use Atlantis on my mac. Is there any mac alternative?

Is Open Office / Libre Office available for Mac ? If yes, there's a plugin to create an epub, no need to bother calibre.

You might try Toxaris' "Word to clean html" Export Macro (here in this forum). I can't give a guarantee, but maybe it works on a mac as well.

But some junk-code in the html is not your problem in this case.


Is vertical spacing something I can control in Sigil? The vertical spacing in relation to the hyperlinks really does appear to be the culprit.

You can control nearly any aspect of an epub with Sigil, the downside is it needs some experience with Html /Css coding. You should do what dwig mentiones to cleanup the vertical spacing.

BTW, a question to the others: Is there any "soft-hyphenation" in Html, such as Winword uses it ? A dash which can be placed inside a word and is only shown, if the word is separated at a line-end ??

JSWolf
04-12-2012, 11:16 AM
Use Sigil to go in and have a look at the CSS and remove ALL instances of line-space.

N00ter
04-12-2012, 11:18 AM
JSWolf, if it's a large book, is there a way to do it without going line by line?

JSWolf
04-12-2012, 11:55 AM
JSWolf, if it's a large book, is there a way to do it without going line by line?

You don't have to go through it line-by-line if the problem is in the CSS. So just look at the CSS and remove every instance of line-height and see what happens. And if it doesn't fix things, then just search for line-height and when you see it, remove it. Then it should be fixed as fat is inconsistent line spacing.

sellew
04-12-2012, 08:23 PM
I also found the same problem with ADE (in Sony PRS650). I handle it by using the 'vertical-align' property in the CSS code, setting it to:

vertical-align: text-top;

then it respects the line spacing.

To be more specific, I assign this property to the <sup> tag or to the class it is using.

N00ter
04-12-2012, 11:51 PM
Every line-height: property in the ePub is set to 1.2. All of the vertical-align properties were set to middle.

Here is a new piece of information, because changing those two properties listed above haven't worked. It is the first paragraph under each new section-heading that has the tight spacing. I have examined almost the entire book and am finding very consistently that this is the case. Why would only the first paragraph after a new section heading have this tight spacing?

N00ter
04-13-2012, 12:20 AM
Here is some more information to work with. As I dig through the ePub with Sigil I find that the first paragraph of each new section is classified as "OpeningParagraph." So I went to the css stylesheet and this is what it says under the .OpeningParagraph section:

.OpeningParagraph {
color: black;
display: block;
font-family: MinionPro-Regular;
font-size: 0.875em;
line-height: 1.2;
margin-bottom: 6pt;
margin-left: 0;
margin-right: 0;
margin-top: 0;
text-align: left;
text-autospace: none;
text-justify: inter-ideograph
}

Does the key lie in changing some value in this section that I am just totally missing?

N00ter
04-13-2012, 12:25 AM
Above was a quote from the stylesheet css. Here is a quote from one of the paragraphs that has the screwed up spacing. Maybe something in here will make sense to some of your more trained eyes:

<body class="calibre">
<p class="ChapterNumber" id="calibre_pb_38"><a class="calibre20" id="Chapter11"><span class="calibre25" xml:lang="EN-GB">11</span></a></p>

<p class="ChapterTitle"><span class="calibre25" xml:lang="EN-GB">Revolutions in American Religion and Society:<br class="calibre10" />
the Shadow of Civil War</span></p>

<p class="OpeningParagraph"><span class="calibre26" xml:lang="EN-GB">&nbsp;</span></p>

<p class="OpeningParagraph"><span class="calibre26" xml:lang="EN-GB">Christianity was a highly pervasive feature of the dynamically changing nineteenth-century American society, helping to mould its national cultural values, yet it was competed over and divisive territory. The freedom which Americans enjoyed to practice the religion of their choice did not bring greater tolerance, but a diversity of approaches to the interpretation of Christian teaching and models of Christian practice. The first Amendment deregulated religion, but made no attempt to establish what ‘the’ religious truth was, and as the nineteenth-century progressed, a multiplicity of claims about it were unleashed. A free market in religious opinion followed, with religion hawked across the land like any other product in the years before the American Civil War.<a class="calibre23" href="../Text/ePub%20Version_split_043.htm#_ftn632" id="_ftnref632" title=""><span class="calibre24">[632]</span></a> Many had their own vision of what godly America would look like, with little prospect that those visions would be united through compromise or consensus.<a class="calibre23" href="../Text/ePub%20Version_split_043.htm#_ftn633" id="_ftnref633" title=""><span class="calibre24">[633]</span></a> Over the big issues confronting America, such as the role of women in society, or slavery, the churches had much to say, but it was often delivered by means of diametrically opposing arguments, usually based on varying interpretations of the Bible.</span></p>

Sorry if I'm sharing information you all don't need. I know my way around HTML just a bit, but this is my first time really digging through the code of my ePub file before.

mrmikel
04-13-2012, 10:19 AM
It pays to check the code when you have this kind of problem. Sometimes seemingly unrelated things have an effect on spacing. It depends on the readers internal programming.

With relatively limited memory in readers, support for hyphenation is necessarily limited. Better support would be the key for prettier text. Some day....

sellew
04-13-2012, 02:38 PM
Above was a quote from the stylesheet css. Here is a quote from one of the paragraphs that has the screwed up spacing.

1. This piece:

<p class="OpeningParagraph"><span class="calibre26" xml:lang="EN-GB">&nbsp;</span></p>

is creating an extra blank line between the chapter title and the first paragraph.

2. The hyper-links like that one:

<a class="calibre23" href="../Text/ePub%20Version_split_043.htm#_ftn632" id="_ftnref632" title=""><span class="calibre24">[632]</span></a>

can create higher space between lines depending on the CSS code of class "calibre24". If the vertical-align property is set to 'super' then most probably this is the cause. Usually, setting it to 'text-top' or 'top' solves the issue.

Jellby
04-13-2012, 04:14 PM
... or add a "line-height: 0" to the footnote style. Depending on the other settings, it may cause the footnote to overlap with the previous line, but it can also look fine. I do it quite often.

ProDigit
04-14-2012, 05:32 AM
looks to me you have your text layout justified instead of left aligned.
That's perhaps why the weird spacing.

N00ter
04-14-2012, 09:39 AM
I'VE DONE IT! Sorry for the all-caps. Here is what I did.

I had to tinker with the file. I have no idea why it was this way, but I went into the CSS Stylesheet and started experimenting with different line heights, but only in the Opening.Paragraph section. I left the line height at 1.2 for all other sections, but I changed Opening.Paragraph to 1.4. Sure enough, I go back into the book and it's perfect. I wonder if there is something in the iPad that is causing the line spacing in the Opening Paragraph of a new section to skew tighter for some reason.

Oh well - problem solved! Thanks, all!

JSWolf
04-14-2012, 09:42 AM
Every line-height: property in the ePub is set to 1.2. All of the vertical-align properties were set to middle.

Here is a new piece of information, because changing those two properties listed above haven't worked. It is the first paragraph under each new section-heading that has the tight spacing. I have examined almost the entire book and am finding very consistently that this is the case. Why would only the first paragraph after a new section heading have this tight spacing?

You don't change them. You remove them. You get rid of line-height and vertical-align. Just delete them.

JSWolf
04-14-2012, 09:45 AM
Here is some more information to work with. As I dig through the ePub with Sigil I find that the first paragraph of each new section is classified as "OpeningParagraph." So I went to the css stylesheet and this is what it says under the .OpeningParagraph section:



Does the key lie in changing some value in this section that I am just totally missing?

Should become...

.OpeningParagraph {
display: block;
font-family: MinionPro-Regular;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
text-align: justify;
}

If you aren't using an embedded font, you can delete the font-family command. As for a line-height of 1.2em, that's just way too big and should be deleted.

JSWolf
04-14-2012, 09:48 AM
Above was a quote from the stylesheet css. Here is a quote from one of the paragraphs that has the screwed up spacing. Maybe something in here will make sense to some of your more trained eyes:



Sorry if I'm sharing information you all don't need. I know my way around HTML just a bit, but this is my first time really digging through the code of my ePub file before.

That is some really bad code.

<body>
<p class="ChapterNumber">11</p>
<p class="ChapterTitle">Revolutions in American Religion and Society:<br/>the Shadow of Civil War</p>
<p class="OpeningParagraph">Christianity was a highly pervasive feature of the dynamically changing nineteenth-century American society, helping to mould its national cultural values, yet it was competed over and divisive territory. The freedom which Americans enjoyed to practice the religion of their choice did not bring greater tolerance, but a diversity of approaches to the interpretation of Christian teaching and models of Christian practice. The first Amendment deregulated religion, but made no attempt to establish what ‘the’ religious truth was, and as the nineteenth-century progressed, a multiplicity of claims about it were unleashed. A free market in religious opinion followed, with religion hawked across the land like any other product in the years before the American Civil War.<a class="calibre23" href="../Text/ePub%20Version_split_043.htm#_ftn632" id="_ftnref632" title=""><span class="calibre24">[632]</span></a> Many had their own vision of what godly America would look like, with little prospect that those visions would be united through compromise or consensus.<a class="calibre23" href="../Text/ePub%20Version_split_043.htm#_ftn633" id="_ftnref633" title=""><span class="calibre24">[633]</span></a> Over the big issues confronting America, such as the role of women in society, or slavery, the churches had much to say, but it was often delivered by means of diametrically opposing arguments, usually based on varying interpretations of the Bible.</p>

That is somewhat better looking now.

N00ter
04-14-2012, 10:00 AM
Well, JSWolf, I did try a version of the book with the line-heights deleted completely. For some reason, the iPad was still making the first paragraphs a little tighter than the rest.

By manually causing the opening paragraph to space wider, it's counteracting whatever iBooks is doing with the opening paragraph. The problem is solved, but it isn't elegant.

You may have seen how I'm generating this eBook, but I write the whole thing in Word, export it to HTML, and then convert with Calibre. How am I supposed to get better code? Is manually changing it in Sigil the only way to go?

JSWolf
04-15-2012, 10:51 AM
The only way to get better code is to manually edit the mess that Word makes. Sigil will allow you to easily edit the mess. As you can see from my posts above, it's possible to edit manually like I did. Have you looked at the XML code where the spacing is off to see if there is anything there?