Tuesday, May 25, 2010

InDesign flubs exporting headers to ePub

When you export an InDesign document, and choose a TOC style, InDesign exports the paragraphs that are part of the TOC as headers (h1, h2, etc.) and everything else as a p element. In both cases, the name of the style in InDesign is used as the class for the element in the XTML. So far, so good.

The only problem is that it seems to get the spacing (text-indent and margin properties) all messed up when it exports headers.

Here's the specs for the header paragraph style as defined in InDesign:

Header specs in InDesign

If I export to ePub without using the TOC (and thus without converting this paragraph into a "header"), I get the following reasonable CSS approximation of the style. Notice the 1/2" space before, and right and left margins, are converted to 1em, and the 4" are converted to 8em. That makes sense.

p.header {
font-family: "Cochin";
font-weight: bold;
font-style: normal;
font-size: 3em;
line-height: 1.20em;
text-decoration: none;
font-variant: normal;
text-indent: 0em;
text-align: center;
color: #1c910a;
margin: 1em 1em 8em 1em;
}

But if I export to ePub using the TOC, I get this:

h1.header {
font-family: "Cochin";
font-weight: bold;
font-style: normal;
font-size: 3em;
line-height: 1.20em;
text-decoration: none;
font-variant: normal;
text-indent: 0em;
text-align: center;
color: #1c910a;
margin: 0.01em 0.01em 0.11em 0.01em;
}

Notice the difference in the values for margin. They're completely messed up. I don't know if InDesign is trying to compensate for some dubious default font size for the h1 element, or what, but it's not effective. The difference in the output is universal, from Adobe Digital Editions, to web-based ereaders, to iBooks, and must be manually fixed. (Because if you don't choose the TOC style, you won't get a navigational menu.)

7 comments:

  1. This one bugged me to no end until we got Springy - now I open all of our ePub files and manually adjust the spacing of those TOC menu items in the css file. Not all that time consuming, but it is aggravating that it happens at all!

    ReplyDelete
  2. I'm wondering if specifying em (instead of inches) as the unit of measure in the InDesign style would make any difference. Hmmm.

    ReplyDelete
  3. Interesting idea, but InDesign won't take ems.

    ReplyDelete
  4. I did try both picas and inches, btw, earlier, before I realized it was the TOC/header thing that was triggering the behavior.

    ReplyDelete
  5. omg, I just realized how stupid my comment was! sorry, LOL.

    ReplyDelete
  6. I recently discovered the same problem. Has this been posted to the Adobe forums?

    ReplyDelete
  7. Setting the horizontal and vertical ruler units to points should make spacing export normally, even if the style is in the TOC style list.

    ReplyDelete

More of my books