Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 07-13-2011, 08:46 AM   #1
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Kindlegen and negative indents

I don't know the technical term for what I'm doing; whether it's considered a "hanging" indent or otherwise.

Anyway. I can achieve what I want with a single paragraph by supplying Kindlegen with xhtml and simple css (with a negative "text-indent" attribute). Works great! But Kindlegen seems to ignore the same request for a negative paragraph indent inside a blockquote element (either with css or with attributes directly in the xhtml. I don't know if this is expected behavior or not, but I'm looking for a work-around, if so.

Basically I'm hand-crafting a TOC, and there are certain elements that I want to be nested (nested—only in a visual kind of way—nested). The problem is... the text for each entry in the TOC can be quite long, which causes them wrap to the next line on small screens. I'd like those that do wrap to be negatively indented by a small amount—so they don't look like a brand-new entry. This is a breeze to achieve at the parent level with a negative-indent css attribute. Kindlegen likes it so far. However... at the child level (inside a blockquote element) all requests to indent negatively are completely ignored.

Any suggestions/alternate solutions?
DiapDealer is offline   Reply With Quote
Old 07-13-2011, 11:00 AM   #2
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
I believe the mobipocket format does not support any kind of nesting, just as it does not support CSS. It just has a few supported tags and attributes, so:

For a <P> element the WIDTH attribute is interpreted as first-line indent.

For a <BLOCKQUOTE> element the WIDTH attribute is interpreted as a left margin.

If you want both a left margin and a first-line indent (negative or positive), I'm afraid that's not possible in mobipocket.

But you could add some vertical space between entries, or put some kind of bullet for each one.
Jellby is offline   Reply With Quote
Advert
Old 07-13-2011, 11:54 AM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by Jellby
If you want both a left margin and a first-line indent (negative or positive), I'm afraid that's not possible in mobipocket.
Are you sure?? I have poetry sections that have increased left margins and positive indents all over the place. I'll guess I'll have to unpack one of those mobi's to see how it's being achieved.

Quote:
For a <P> element the WIDTH attribute is interpreted as first-line indent.

For a <BLOCKQUOTE> element the WIDTH attribute is interpreted as a left margin.
What about the WIDTH attribute on a <P> element inside a <BLOCKQUOTE> element? Is it ignored? Or are <p> elements just not allowed within <blockquote> elements?
DiapDealer is offline   Reply With Quote
Old 07-13-2011, 12:23 PM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by DiapDealer View Post
Are you sure?? I have poetry sections that have increased left margins and positive indents all over the place. I'll guess I'll have to unpack one of those mobi's to see how it's being achieved.
I'm only 80% sure. It's been a while since I last tried anything with mobipocket. For poetry, I used the "trick" of having a <P> for each line, so it looks like margins plus indents:

Code:
<P WIDTH="2em">"You are old, Father William," the young man said,</P>
<P WIDTH="4em" HEIGHT="0em">"And your hair has become very white;</P>
<P WIDTH="2em" HEIGHT="0em">And yet you incessantly stand on your head--</P>
<P WIDTH="4em" HEIGHT="0em">Do you think, at your age, it is right?"</P>
That gives a 2em margin, with further 2em indents in the 2nd and 4th lines.

Positive indents can also be emulated with &nbsp;...

Quote:
What about the WIDTH attribute on a <P> element inside a <BLOCKQUOTE> element? Is it ignored? Or are <p> elements just not allowed within <blockquote> elements?
I believe it was just ignored, as if the text were directly inside the <BLOCKQUOTE>, with no intervening <P>.

That is, of course, with hand-written pseudo-HTML code, converted to mobipocket directly with MobiPerl. Whatever kindlegen does with the source format, I don't know.
Jellby is offline   Reply With Quote
Old 07-13-2011, 05:47 PM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Well, after spending the morning with Kindlegen, mobiunpack.py, and the Kindle Previewer... I think I can confirm that negative indents AND increased left margins are not possible at the same time. Jellby called that (happy for Jellby, sad for me). However, positive first-line indents with increased left margins are certainly possible (on the Kindle, anyway) without resorting to too much trickery.

First off: the WIDTH attribute of the <blockquote> element always controls first-line indention of the text within that blockquote (when the mobi is built with kindlegen)—always.

Then, if you ignore HTML convention and put a <blockquote> element inside a <p> element... the WIDTH attribute of that <p> element becomes the control for the left-margin of the <blockquote> element. Seems weird to me but maybe people already know this.

Anyway... take the following code example:
Code:
<p width="0">
  <blockquote width="0">
    <font size="-1">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</font>
  </blockquote>
</p>
That gives you the standard blockquote left margin with no first-line indent. Increasing the width parameter of the <blockquote> element will increase the first-line indent of that blockquoted text accordingly:
Code:
<p width="0">
  <blockquote width="2em">
    <font size="-1">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</font>
  </blockquote>
</p>
Here's the kicker—again, I apologize if everyone knows this already—to increase the left margin of the blockquoted text, you increase the width attribute of the <p> element NEGATIVELY. "-1em" "-2em" "-3em" will move all of the text further to the right:
Code:
<p width="-2em">
  <blockquote width="2em">
    <font size="-1">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</font>
  </blockquote>
</p>
It all blows up when you try to give the <blockquote> element a negative width. You'll get your hanging indent, but you lose any left margin you had.

I'm attaching a mobi that will show the different results on the Kindle. It was made with Kindlegen, so you can unzip it to get to the source html as well. Maybe someone else can benefit.

It was an enlightening morning for me... but then again, I'm easily amused.

EDIT: the negative increasing of the <p> parameter only seems to have that effect on the actual Kindle and in Kindle Previewer. It has no affect on the left margin in K4PC or MobiPocket reader.
Attached Files
File Type: mobi indents.mobi (11.9 KB, 293 views)

Last edited by DiapDealer; 07-13-2011 at 06:08 PM.
DiapDealer is offline   Reply With Quote
Advert
Old 07-14-2011, 04:23 AM   #6
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
... and people still ask why ePUB should be preferred over mobipocket...
Jellby is offline   Reply With Quote
Old 07-14-2011, 07:12 AM   #7
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
... and people still ask why ePUB should be preferred over mobipocket...
To be fair, epub may be easier, but both formats have numerous consistency issues across the various platforms. It's maddening trying to make an ebook that looks the same on all devices regardless of the format.
DiapDealer is offline   Reply With Quote
Old 07-31-2011, 06:59 PM   #8
hapax legomenon
Erotica Writer
hapax legomenon doesn't litterhapax legomenon doesn't litter
 
hapax legomenon's Avatar
 
Posts: 102
Karma: 106
Join Date: Jul 2007
Location: Tulsa, OK
Device: ipad, Sony Reader PRS 505, Cybook 3
DiapDealer: but the epub discrepencies across devices are relatively minor and have more to do with dealing with devices of eink-size and tablet size. (i.e., some effects would work great in tablets, but look silly on an eink epub reader like the Nook Touch).

I spend 5x the amount of time making Kindle look nonsucky as I do for epubs.
hapax legomenon is offline   Reply With Quote
Old 07-31-2011, 09:08 PM   #9
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I'm not here to argue degrees of suckitude, hapax. The fact is, neither format's standards are "standard" across all devices/apps.
DiapDealer is offline   Reply With Quote
Old 11-08-2011, 12:46 AM   #10
virtual_ink
Zealot
virtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheese
 
virtual_ink's Avatar
 
Posts: 107
Karma: 1000
Join Date: Sep 2010
Location: Melbourne, Australia
Device: iPad2, Kindle
DiapDealer, I'm currently trying to achieve a similar thing with poetry. Maybe you can help clarify what is possible?

My CSS for the original ePub is:

p.verse-long {
font-size : 1em;
line-height : 1.2;
text-align : justify;
text-indent : -16px;
margin : 0px 0px 0px 16px;
}

When I convert epub to mobi via Kindlegen, Kindle ignores the '-16px' indent I've set for the first-line. I've read that the text-indent attribute doesn't support negative numbers in mobi. Have tried the width attribute in both CSS, and at line level, but its affecting the entire paragraph, not just the first line. I hadn't given up, but are you saying its not possible to achieve this hanging paragraph effect?
virtual_ink is offline   Reply With Quote
Old 11-08-2011, 07:12 AM   #11
virtual_ink
Zealot
virtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheese
 
virtual_ink's Avatar
 
Posts: 107
Karma: 1000
Join Date: Sep 2010
Location: Melbourne, Australia
Device: iPad2, Kindle
I ended up getting the desired effect by by setting all margins to 0px, with the above text indent of -16px. Kindlegen retained the negative indent despite what I read to the contrary elsewhere. I'm using the recent 2011 $79 Kindle, not sure if earlier models will render differently. Touch wood, if it works accross the board, its so simple.
virtual_ink is offline   Reply With Quote
Old 11-08-2011, 07:14 AM   #12
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
A negative number in the text-indent attribute IS supported in mobi (or at least mobi's built by kindlegen), they just don't work in conjunction with the left-margin being greater than zero.

You can create a hanging indent by using "text-indent: -16px", but it will be left-aligned (no left margin).

You basically have to choose between a hanging indent or a left margin. To get both, you'd have resort to images of text or manually building your paragraphs with combinations of <br /> and &nbsp; (which might behave badly when users increase font-size).

Quote:
Originally Posted by virtual_ink
I'm using the recent 2011 $79 Kindle, not sure if earlier models will render differently. Touch wood, if it works accross the board, its so simple.
I can verify that it works as far back as the Kindle 2.

Last edited by DiapDealer; 11-08-2011 at 07:28 AM.
DiapDealer is offline   Reply With Quote
Old 01-02-2012, 05:41 PM   #13
PiVi1962
Member
PiVi1962 is on a distinguished road
 
Posts: 12
Karma: 60
Join Date: Nov 2009
Device: none
Quote:
Originally Posted by DiapDealer View Post
You can create a hanging indent by using "text-indent: -16px", but it will be left-aligned (no left margin).

You basically have to choose between a hanging indent or a left margin. To get both, you'd have resort to images of text or manually building your paragraphs with combinations of <br /> and &nbsp; (which might behave badly when users increase font-size).
It is also possible to use the "&emsp;" and "&ensp;" in conjunction with UTF-8 character coding... but it looks like a really dirty trick.
PiVi1962 is offline   Reply With Quote
Old 01-13-2012, 12:56 PM   #14
NicWest
Member
NicWest began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Nov 2010
Device: Kindle
Hanging indents will also work inside table cells provided you do something like this:

Code:
<td><p class="hanging-indent">your text here</p></td>
I'm sure if your prepared to be incredibly dirty you might be able to get this to work for you.

make sure you offset your negative indent with an equal padding-left (note: NOT margin-left as kindle just seems to add the two numbers together and you end up with a mess).
NicWest is offline   Reply With Quote
Old 01-13-2012, 02:31 PM   #15
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Tables almost always result in disaster for me when used to format text in MOBIs. Usually just increasing/changing font size is enough to start blowing things up. Other than just presenting tabular data, I avoid them like the plague (and even then I usually try to find another way).
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone using Kindlegen? simonp Kindle Formats 11 09-16-2011 05:17 AM
Troubleshooting TOC fails in Kindlegen 1.1, not Kindlegen 1.0 cyberbaffled Amazon Kindle 3 12-25-2010 05:21 PM
kindlegen running on Linux JiYu Amazon Kindle 0 09-20-2010 06:08 AM
KindleGen 1.1 pdurrant Kindle Formats 0 08-08-2010 06:18 AM
Kindlegen now for Mac OS X (Intel) pdurrant Kindle Formats 4 04-27-2010 02:46 PM


All times are GMT -4. The time now is 06:01 AM.


MobileRead.com is a privately owned, operated and funded community.