Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 01-16-2011, 03:13 AM   #1
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
puzzled by white space above chapter number

on Kindle 3 - after cleaning & converting chapters - I sometimes get what seems to be a blank line above the chapter number i.e. pagebreak, then blank line, then chapter number.. in other books the chapter number is right at the top of the page as I prefer it.

looking at epub code, I am struggling to nail this. I look at what calibre tag goes with the chapter number then I look in the style sheet for its definition.

it seems that the ones with the extra white space are simply defined as "block" in the stylesheet - nothing else. the one that I like better have a more specific style definition.

- so it this a side effect of "block" or a kindle-specific interpretation issue ? I suspect the latter because I do not see any extra space when viewed in calibre viewer, yet I do see it on both K3 and in kindle for PC

sample code which has the whitespace issue
Code:
</head>

<body class="calibre" link="blue" style="" vlink="purple">
  <div class="calibre4" id="calibre_pb_6"></div>

  <h2 id="heading_id_3"><a class="calibre7" id="_Toc85056267"><span>1</span></a></h2>
styles:
..calibre3 {
font-size: 0.75em
}
.calibre4 {
display: block;
page-break-before: always
}
.calibre5 {
color: blue;
cursor: pointer;
text-decoration: underline
}
.calibre6 {
display: block;
font-size: 2em;
font-weight: bold;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
margin-top: 0.67em;
page-break-before: always;
text-align: center
}
.calibre7 {
color: inherit;
cursor: inherit;
text-decoration: inherit

so calibre 4 followed by 7 is treated as "block"

is there a workaround. i.e. how can I alter these chapter heading styles/tags so that they appear right at the top of the page ?
cybmole is offline   Reply With Quote
Old 01-16-2011, 08:31 AM   #2
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
In your html snippet the chapter heading is contained in <h2>...</h2> tags. Is there anything in the CSS which specifically references h2?

Also the <h2> tag is a child of <body class="calibre" ...> and so will (I think) inherit styling from entries in the CSS such as
Code:
body or
body.calibre or
.calibre
I'm not sure about the first 2 but there is almost certainly an entry in the CSS for .calibre.

You could try and fix it during the original conversion by putting something like
Code:
h2 {margin-top: 0;}
in the ExtraCSS box on the Look&Feel page.
jackie_w is offline   Reply With Quote
Old 01-16-2011, 08:47 AM   #3
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
Quote:
Originally Posted by jackie_w View Post
In your html snippet the chapter heading is contained in <h2>...</h2> tags. Is there anything in the CSS which specifically references h2?

Also the <h2> tag is a child of <body class="calibre" ...> and so will (I think) inherit styling from entries in the CSS such as
Code:
body or
body.calibre or
.calibre
I'm not sure about the first 2 but there is almost certainly an entry in the CSS for .calibre.

You could try and fix it during the original conversion by putting something like
Code:
h2 {margin-top: 0;}
in the ExtraCSS box on the Look&Feel page.
nice hypothesis but nothing in stylesheet for h2, and the calibre entry has margin top set to zero:
.calibre {
display: block;
font-size: 1em;
margin-bottom: 0;
margin-left: 5pt;
margin-right: 5pt;
margin-top: 0;
padding-left: 0;
padding-right: 0;
page-break-before: always

I'd like to nail the cause before getting into the workarounds. could be as simple as understanding "BLOCK" means to Kindle software ?

i google html block & find this:
display: block

display: block means that the element is displayed as a block, as paragraphs and headers have always been. A block has some whitespace above and below it and tolerates no HTML elements next to it, except when ordered otherwise

so kindle & sigil book view apply the above - hence white space above

now here is one with no white space
Code:
<body class="calibre" style="">
  <div class="calibre1" id="filepos960107">
 <p class="calibre7"><span class="calibre5"><span class="bold"><span class="calibre8">Chapter 5</span></span></span></p>
styles:
.calibre {
display: block;
font-size: 1em;
margin-bottom: 0;
margin-left: 0;
margin-right: 5pt;
margin-top: 0;
padding-left: 0;
padding-right: 0;
page-break-before: always
}
.calibre1 {
display: block
.calibre5 {
font-size: 1.125em
}
.calibre7 {
display: block;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
text-align: center;
text-indent: 0
}
.calibre8 {
color: red


here, calibre7 has an explicit margin top 0 - I guess that over-rides the default ( inherited? )meaning of block, but if that's true, then why did it not apply in example 1 ?

Last edited by cybmole; 01-16-2011 at 09:00 AM.
cybmole is offline   Reply With Quote
Old 01-16-2011, 09:53 AM   #4
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
I wonder if the heading tags, <h2> etc,have implied margin-top and margin-bottom if not explicitly set.
jackie_w is offline   Reply With Quote
Old 01-16-2011, 09:56 AM   #5
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
Quote:
Originally Posted by jackie_w View Post
I wonder if the heading tags, <h2> etc,have implied margin-top and margin-bottom if not explicitly set.
that may well be the answer
cybmole is offline   Reply With Quote
Old 01-16-2011, 10:01 AM   #6
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Manually entering the h2 {margin-top:0} line in the epub CSS may test the theory.
jackie_w is offline   Reply With Quote
Old 01-16-2011, 10:57 AM   #7
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,778
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I see no useful purpose for that <div> above
so either blow that sucker away or add a margin: 0 to calibre1 (to override any defaults)
theducks is offline   Reply With Quote
Old 01-16-2011, 11:01 AM   #8
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
didnt seem to but maybe I messed up the syntax

other entries in .css begin with a .
so should it look like this
.h2 {margin-top:0}
when I first added it, it picked up start & end * somehow

trying again...
no mobi in kindle for pc looks like before
- and toc has mysteriously vanished from the epub save -( probably a separate bug or settign screw-up - so converted the mobi back to epub to fix that.
cybmole is offline   Reply With Quote
Old 01-16-2011, 11:10 AM   #9
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by cybmole View Post
didnt seem to but maybe I messed up the syntax

other entries in .css begin with a .
so should it look like this
.h2 {margin-top:0}
No definitely h2 {margin-top:0} with no dot at the beginning.

If your CSS has
Code:
h2 {margin-top:0}
it will be applied to html with <h2> tags.

If it has
Code:
.h2 {margin-top:0}
It will be applied to html with class h2, e.g
Code:
<p class="h2"> or
<div class="h2">or 
<h1 class="h2">
Edit: Also be careful if you do conversions of conversions of conversions .... The CSS class names calibrenn may get renumbered each time

Last edited by jackie_w; 01-16-2011 at 11:16 AM.
jackie_w is offline   Reply With Quote
Old 01-16-2011, 11:32 AM   #10
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
ok - well iv'e fixed up my the chapter numbers as simple h2 tags in sigil , to avoid gettign side trcked by TOC issue

i thought the filepos did nothign but then i found the final xhtml contained a toc coded with links back to those filepos values, thus is was gettign out of step and confused as I messsed around.

so I ditched that toc completely, make the chapter number sino h2 tags & let calibre & sigil do trheir thing.

I now have workign toc in both epub & mobi.
& chapter start code like this
Code:
body class="calibre">
  <div class="calibre1" id="filepos20356">
    <h2 id="heading_id_2">3</h2>
I am 99% sure the div - filepos line is now totally redundant but I will leave it there for now.

to test the h2 - margin top idea i go to .css
and add your line:
@namespace h "http://www.w3.org/1999/xhtml";
h2 {margin-top:0}
.bold {
font-weight: bold
}

save - convert to mobi .. and ...

no difference.

I reckon that kindle software insists on adding the space. when I@e not seen it it's because books had no chapter / header tags but just happened to have toc that worked

I think I will accept that the space is supposed to be there. note that I've learnt a bit about filepos & toc in the course of the afternoon, & quit while I'm ahead.

will be happy to read your feedback though
cybmole is offline   Reply With Quote
Old 01-16-2011, 11:50 AM   #11
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
PS once I start to dabble it's hard to stop! ...

if I want all my chapter header number to be centered on the kindle page what to I add to
<h2> chapter number </h2> to make that happen ?

& should things like that be done with find..replace.. or via stylesheets ?


well after googling it,
i guess putting this in the stylesheet is how it's done
H2 { text-align: center}

I could do that book by book, but is there any way to tell calibre to do it as part of a conversion - then save that in my general conversion preferences ? there is an input box called extra CSS but not a lot of guidance in the user manual ( it helpfully "advises" you to know what you're doing before trying to use this feature!

Last edited by cybmole; 01-16-2011 at 11:59 AM.
cybmole is offline   Reply With Quote
Old 01-16-2011, 12:04 PM   #12
ldolse
Wizard
ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.ldolse is an accomplished Snipe hunter.
 
Posts: 1,337
Karma: 123455
Join Date: Apr 2009
Location: Malaysia
Device: PRS-650, iPhone
Use the extra css box you found, just paste this in:
h2 {text-align: center}

If you want it for all books you convert just put it in your default settings for extra_css.
ldolse is offline   Reply With Quote
Old 01-16-2011, 12:20 PM   #13
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,206
Karma: 16228558
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
I'm not sure I can add anymore. My readers are Sony and PocketBook, so I read calibre-created epubs not mobi. Any experimentation I could do would not be relevant. Sorry

As for the centering stuff - what Idolse said. If you're going to add that line in your preferences you may as well change it to
Code:
h2 {text-align: center; margin-top: 0; padding-top: 0}
Then the whitespace above will be as small as you can get it.

Last edited by jackie_w; 01-16-2011 at 12:24 PM.
jackie_w is offline   Reply With Quote
Old 01-16-2011, 02:20 PM   #14
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
from an amzaon forum
quote
"This has a list of supported CSS properties
-->http://kindleformatting.com/book/fil...leHTMLtags.pdf

I know the list is not complete because it does not list margin-bottom and margin-left, which I have used. I don't think kindle supports margin-right and margin-top. "
end quote

centering stuff works fine, thanks, except that any book that I have converted once already has its own saved preferences, so adding extra css to default preferences does not get picked up - I have to keep adding it manually.

unless there's a way to wipe all those saved individual conversion preferences, most of which were set when i did'nt know what I should be doing!

update - google knew how:
"In any event, you can erase the saved conversion settings for books by selecting the books in question, opening 'edit metadata in bulk' (the E key if more than one book is selected), choosing 'remove stored conversion settings for selected books', and pressing OK."

Last edited by cybmole; 01-16-2011 at 02:23 PM.
cybmole is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ebook chapter titles: with or without chapter number? amoroso Writers' Corner 16 06-14-2011 06:35 AM
puzzled sanctum9 Sony Reader 6 12-15-2010 11:38 AM
Puzzled and need a little kick start TonytheBookworm Recipes 2 10-13-2010 11:10 PM
Removing unwanted white space JayLaFunk Sigil 4 03-19-2010 11:33 AM
Adding chapter breaks by number of pages/lines raptir Calibre 8 10-22-2009 12:11 PM


All times are GMT -4. The time now is 02:09 AM.


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