View Full Version : Space before paragraph not coming through in epub


steve2112
05-16-2012, 11:52 AM
I'm using InDesign CS6 (just upgraded from CS3) to create epubs.
I'm using the paragraph style to define space before and space after a paragraph (which many people explain is the better way of getting spacing rather than using carriage returns).
However, for headings, the space before is not translating through into the epub document - but the space after is (i.e. if I change the spacing after the paragraph, I can see the difference as soon as I create the epub, but the spacing before is zero, no matter what value I have in InDesign)

Any help appreciated.

Thanks

wahahey
05-22-2012, 03:03 PM
I have been tearing my hair out all day with the same problem.

steve2112 - you can try "style mapping" and map styles to tags. It's under the fly-out menu in Paragraph Styles. Useful video here: http://tv.adobe.com/watch/learn-indesign-cs5/styles-mapped-to-tags-in-indesign-cs55-for-improved-epub-export/

This has helped me a bit, in that it has standardised the spaces. But for some reasons I can only apply spacing to paragraphs (p tags in xhtml) and not to headings (h1, h2 etc in xhtml) used in epubs.

I've even tried editing the .css in the unzipped epub files but that doesn't work either.

Stopping while I still have some hair.

DiapDealer
05-22-2012, 03:47 PM
However, for headings, the space before is not translating through into the epub document - but the space after is (i.e. if I change the spacing after the paragraph, I can see the difference as soon as I create the epub, but the spacing before is zero, no matter what value I have in InDesign)
CSS spacing before a heading (or any element) that's been assigned the "page-break-before" CSS directive will be ignored by ADE (or at least it won't render). This happens a lot when the epub consists of one single html document with page breaks assigned via CSS.

In other words if you want spacing above the first item following a page break.. you need to physically start a new html file at that point. Otherwise, you won't be able to assign any spacing before that element.

I'm attaching a sample epub that demonstrates the issue.

Jellby
05-23-2012, 07:04 AM
CSS spacing before a heading (or any element) that's been assigned the "page-break-before" CSS directive will be ignored by ADE (or at least it won't render). This happens a lot when the epub consists of one single html document with page breaks assigned via CSS.

That's true, and it is an accepted (but optional) behaviour in the spec.

In other words if you want spacing above the first item following a page break.. you need to physically start a new html file at that point. Otherwise, you won't be able to assign any spacing before that element.

There are other possible methods. Only margin is thrown away after a forced pagebrak. You can get space through padding, or by having the pagebreak in a previous element, like this:

<div class="pagebreak"/>

<h2>Chapter 5</h2>

where div.pagebreak has "page-break-before: always" and h2 has some top margin.

Whether this is possible to generate directly from ID, that's a different matter.

DiapDealer
05-23-2012, 07:11 AM
I didn't know that about the padding attribute. Thanks! :)

wahahey
05-24-2012, 05:13 AM
CSS spacing before a heading (or any element) that's been assigned the "page-break-before" CSS directive will be ignored by ADE (or at least it won't render).

True - but this is the same behaviour we see in InDesign - so I expect that to be the case and is not a problem for me (Sorry - I'm starting to feel like I've hijacked someone else's thread, but I do think this is relevant as it is about Heading spacing).

The problem I am seeing is not related to elements which have been assigned the "page-break-before" directive, at least not intentionally. With CS6 epub exports is that any heading, no matter what paragraph style is associated with it, no matter how it is mapped, no matter what, always has any 'space before' removed rather than converted into css padding or margin. Am I missing something else?

DiapDealer
05-24-2012, 11:46 AM
With CS6 epub exports is that any heading, no matter what paragraph style is associated with it, no matter how it is mapped, no matter what, always has any 'space before' removed rather than converted into css padding or margin. Am I missing something else?
I don't know enough about how InDesign (or its ePub plugin) works to be very helpful, I'm afraid. I can tell you what might be wrong (or missing) with the final ePub output, but not what you'd have to do in ID (if indeed you can do anything) to produce the proper result in the ePub. I do know I hear a lot of people talking about having to manually tweak the ePub after exporting from ID.

meme
05-24-2012, 04:00 PM
That's true, and it is an accepted (but optional) behaviour in the spec.



There are other possible methods. Only margin is thrown away after a forced pagebrak. You can get space through padding, or by having the pagebreak in a previous element, like this:

<div class="pagebreak"/>

<h2>Chapter 5</h2>

where div.pagebreak has "page-break-before: always" and h2 has some top margin.

Whether this is possible to generate directly from ID, that's a different matter.

This doesn't appear to work on the Kobo. With the class="pagebreak" the header is at the top of the page despite the margin-top setting on the header (and with with the text all the way at the top its a bit squashed).

Using separate files works ok.

steve2112
05-25-2012, 03:18 AM
Thanks everyone for all this info - there's more info than I was expecting as I was looking at headings through the text, not necessarily just after a page break - but this info helps even more.
I focused on the exploded epub files and found that there was no top margin info being passed from ID when creating the ePub. So I manually went in and added "margin-top:20px;" (for example) into the relevant paragraph styles in the CSS file. This worked, though it's obviously fixing a problem after the event rather than sorting it out at the source.

Steve

wahahey
06-01-2012, 06:20 AM
InDesign produces tags with complete reliability. I think it is best to use those and create a new stylesheet (or stylesheets) for ebooks. Certainly for e-ink Kindle books this is the least painful way to go, seeing as Kindle decides which fonts are used anyway!

Since my earlier post I've decided to use Indesign's export tagging to assign h1, h2, h3, etc and p tags to every paragraph used. I also assign a class e.g. myh1, myh2, plus various different paragraph styles based around what sort of spacing and other styling each paragraph style requires.

I have also created several stylesheets, and used CS6's Additional Stylesheet feature to include these. This enables me to keep several sets of styles, and decide whether or not to override what InDesign exports (if it isn't working - as seems to usually be the case).

You can even have different stylesheets for different e-readers, all contained in the same epub. It isn't quite the nice tidy solution I expect from InDesign but it does work if you know what you are doing with css, and also means you can keep editing in Indesign and re-exporting epubs without having to then re-edit the Indesign-produced stylesheet to put the margins back in every time you do a new export.

Marie_D
06-02-2012, 11:56 AM
Apparently, this is a bug in CS6:

http://forums.adobe.com/message/4458453

DiapDealer
06-03-2012, 09:47 AM
Apparently, this is a bug in CS6:

http://forums.adobe.com/message/4458453
Actually, all the discussion so far seems to imply it's a fug... or possibly a beature. :D

It's hilarious to me that the CS6 epub plugin developers seem to be at odds over whether the exclusion of the "margin-top" property was an intentional feature or a bug. :blink:

GMcG
06-03-2012, 04:46 PM
@steve2112
I use an empty paragraph (or two) before the headline to adjust the text, like
<p>&nbsp;</p>
</h3>Headline</h3>
This can be done in the source.
The heigth of the empty paragraph depends on the font-size in paragraph with text, normally 1em. You can modify it by creating a new <p class>. But that's after conversion.

George

JSWolf
06-05-2012, 01:43 PM
@steve2112
I use an empty paragraph (or two) before the headline to adjust the text, like
<p>&nbsp;</p>
</h3>Headline</h3>
This can be done in the source.
The heigth of the empty paragraph depends on the font-size in paragraph with text, normally 1em. You can modify it by creating a new <p class>. But that's after conversion.

George

That is very poor code. Get rid of <p>&nbsp;</p> and in the CSS have a top margin of 1em in h3

h3 {
margin-top: 1em;
margin- bottom: 1em
}

GMcG
06-06-2012, 04:57 AM
Yes, it is poor, but I understood that css didn't give the result the OP wanted.
He said: "... for headings, the space before is not translating through into the epub document."
And wahahey says: "With CS6 epub exports is that any heading, no matter what paragraph style is associated with it, no matter how it is mapped, no matter what, always has any 'space before' removed rather than converted into css padding or margin."

George

DiapDealer
06-06-2012, 08:26 AM
As noted in one of the previous posts/links, the "margin-top" attribute seems to have been left out of CS6's epub export plugin. Until such time as they release an update to rectify that (if indeed they first decide it "needs" fixing), hoop-jumping and post-export code tweaking in general seems like the only way around this particular issue.