Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-21-2012, 08:07 AM   #1
backwoodsman
Junior Member
backwoodsman began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle 3
hanging indents alignment on Kindle

I am trying to align the left margin of a hanging indent with the continuation paragraph which has no indent. This works in the epub, but the converted file in mobi format on the kindle 3 gives a different indentation when the hanging indent is absent.

For example
Code:
p.lm1 {
  margin-left: 50px;
}
p.hlm1 {
margin-left: 50px;
text-indent: -50px;
}
gives a much greater left margin for "lm1" than for "hlm1", so they do not line through. The same thing occurs regardless of whether the left margin is defined in %, ems, or px. How can the converted left margin be controlled in calibre?

ADDITIONAL: I see that calibre renders the paragraphs without the hanging indent as blockquotes, measured in pixels (seemingly arbitrary numbers of pixels too), whereas the hanging indent paragraphs are rendered with text-indent and margin-left, measured in points. Unsurprisingly, the two rarely give the same value. Surely a bug?

Last edited by backwoodsman; 04-21-2012 at 09:58 AM. Reason: new information
backwoodsman is offline   Reply With Quote
Old 04-21-2012, 09:59 AM   #2
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
I think the problem is the mobi format and it's lack of support for CSS styles.

If I remember correctly indents are handled by converting them to block quotes, so you have no level of precision over their size.
itimpi is offline   Reply With Quote
Advert
Old 04-21-2012, 10:12 AM   #3
backwoodsman
Junior Member
backwoodsman began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle 3
Quote:
Originally Posted by itimpi View Post
I think the problem is the mobi format and it's lack of support for CSS styles.

If I remember correctly indents are handled by converting them to block quotes, so you have no level of precision over their size.
It seems that css _is_ used for the hanging indents (and they render correctly on the device), so it should be possible to either

- turn off the blockquote approximate translation for the evenly indented paragraphs too.

- Or alternatively to use the same units for both so that the distance indented matches.
backwoodsman is offline   Reply With Quote
Old 04-21-2012, 11:34 AM   #4
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
Quote:
Originally Posted by backwoodsman View Post
It seems that css _is_ used for the hanging indents (and they render correctly on the device), so it should be possible to either

- turn off the blockquote approximate translation for the evenly indented paragraphs too.

- Or alternatively to use the same units for both so that the distance indented matches.
No, Mobi has no support whatsoever for CSS. CSS can be used in the input files to a program which creates Mobi books (such as Calibre), but it all ends up getting converted to attributes in the HTML tags, which is what Mobi uses.

Mobi's way of doing indents is to use the "width" attribute of a "<p>" or "<div>" tag. Eg,

Code:
<p width="1em">
will produce a 1em indent on the first line of the paragraph, while:

Code:
<p width="-1em">
will produce a 1em hanging indent.

If you want fine control over the appearance of the Mobi, you'd be better off using these Mobi attributes directly in your HTML source, rather than relying on CSS being "converted" the way that you assume it will be.
HarryT is offline   Reply With Quote
Old 04-21-2012, 12:54 PM   #5
backwoodsman
Junior Member
backwoodsman began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle 3
Quote:
Originally Posted by HarryT View Post
No, Mobi has no support whatsoever for CSS. CSS can be used in the input files to a program which creates Mobi books (such as Calibre), but it all ends up getting converted to attributes in the HTML tags, which is what Mobi uses.
That would be fine if the conversion was always in the same units, not rounded differently into different units.
Quote:
Mobi's way of doing indents is to use the "width" attribute of a "<p>" or "<div>" tag. Eg,

Code:
<p width="1em">
will produce a 1em indent on the first line of the paragraph, while:

Code:
<p width="-1em">
will produce a 1em hanging indent.
No, AFAICS, width="2em" gives a very narrow paragraph (or div), whereas width="-2em" seems to create a 2em margin on the right (I think). The only way I can find to get an indent or hanging indent is using text-indent. The problem I am facing is that calibre uses a different method to render whole paragraphs with a left margin from paragraphs with the first line indented. And the calculation of the left margin position finishes up different -- sometimes by a lot!
Quote:
If you want fine control over the appearance of the Mobi, you'd be better off using these Mobi attributes directly in your HTML source, rather than relying on CSS being "converted" the way that you assume it will be.
I would be happy enough to do that if it was clear exactly which attributes to set. Obviously passing the information via css is simpler, but a good editor can globally set attributes easily enough.
backwoodsman is offline   Reply With Quote
Advert
Old 04-21-2012, 02:27 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,779
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no unit of width that can control a blockquote. A blockquote in MOBI is always rendered with a fixed margin. The amount of that margin depends on the MOBI renderer in question and cannot be controlled in the MOBI file. You are not going to be able to get hanging indents to work in mobi in a reliable way.
kovidgoyal is offline   Reply With Quote
Old 04-21-2012, 02:42 PM   #7
backwoodsman
Junior Member
backwoodsman began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle 3
Quote:
Originally Posted by kovidgoyal View Post
There is no unit of width that can control a blockquote. A blockquote in MOBI is always rendered with a fixed margin. The amount of that margin depends on the MOBI renderer in question and cannot be controlled in the MOBI file. You are not going to be able to get hanging indents to work in mobi in a reliable way.
Thanks for the reply.

How are the paragraphs with hanging indents rendered in the MOBI? Presumably not via a blockquote. The "inspect" function in the calibre viewer shows them as simple p elements. If that is so, why can the indented ones not be rendered the same way, so that each level of indent can be the same with and without the indent? It would matter much less what the actual indent was as long as a continuation paragraph matched the one above it.

It is frustrating not being able to see what is going on inside. Calibre says you can inspect the elements in a browser after clicking "explode epub", but that seems to only show the source formatting, not the formatting embedded in the mobi. Is there any way to see the mobi contents?
backwoodsman is offline   Reply With Quote
Old 04-21-2012, 02:47 PM   #8
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
There's a tool called "Mobiunpack" which will decompile a Mobi file and show you what's inside it. A search should find it.
HarryT is offline   Reply With Quote
Old 04-21-2012, 02:49 PM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,779
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to see the insides of a MOBI file there are many tools that can unpack MOBI. calibre-debug --inspect-mobi is one. MOBI is based on a 20 year old dialect of HTML with proprietary extensions, have fun.
kovidgoyal is offline   Reply With Quote
Old 04-22-2012, 03:36 AM   #10
backwoodsman
Junior Member
backwoodsman began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Apr 2012
Device: kindle 3
hanging indents alignment on Kindle [SOLVED]

Thanks to both Harry and Kovid. Since it was already installed (even though undocumented), I used calibre-debug to unpack one of my mobi files. I now understand:
  • the non-standard use of the html negative width property for the hanging indents
  • full left margin indents can only be made using blockquote
  • Different devices use different widths for the levels of nested blockquote, so it is impossible to force any other formatting to reliably align with them.

My application is for play scripts. There is no practical alternative but to redesign the typography for the Kindle, and to manually deal with each case where a character begins a speech in song or in verse (therefore needing indenting after the character name and any stage directions).

I have marked the title "SOLVED", even though it is a poor solution... It is the best available. Thanks again for the help.
backwoodsman is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Indents and hanging indents in epub poetry Derek R ePub 14 02-19-2012 04:43 AM
Hanging Indents John123 Sigil 5 12-04-2011 02:33 AM
Display of Hanging Indents crutledge Workshop 1 09-25-2009 06:09 PM
Hanging indents? llasram Kindle Formats 11 01-05-2009 10:59 AM
Hanging indents in HTML2LRF or Book Designer? LaughingVulcan Sony Reader 10 08-22-2007 06:53 PM


All times are GMT -4. The time now is 05:40 PM.


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