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 04-25-2019, 01:19 PM   #1
mariowarner
Member
mariowarner began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Aug 2018
Device: kindle
Reduce margins and normalize line spacing

Hi guys! Is it somehow possible to reduce the margins more than what's available in the kindle settings? I've got some epub books which I convert to kfx (used to convert to azw) with Calibre. I tried a few different methods but to no avail...

Also I need to switch the line spacing everytime I change a book as the option is systemwide... If there is a way to set the line spacing when I convert the books it would be awesome!
mariowarner is offline   Reply With Quote
Old 04-25-2019, 02:02 PM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,612
Karma: 145863177
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Yes there is a way to reduce the margins. It works with KF8. But I cannot say if it works with KFX.

Code:
html {
  margin-right: -45px;
  margin-left: -45px;
}
Put that at the top of the CSS and it will reduce the margins. -45px is for a 6" 300dpi screen. Feel free to adjust as needed.

You do have to remove the DRM from KF8 eBooks that have DRM.
JSWolf is offline   Reply With Quote
Advert
Old 04-25-2019, 02:31 PM   #3
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,819
Karma: 6769540
Join Date: Mar 2015
Device: Kindle, iOS
I don't know about KFX, but for KF8, I add a media query so that it doesn't affect epub renderering engines.

Code:
@media amzn-kf8 {
	html {margin-left: -36px; margin-right: -36px; }
	}
Also, more specific margin-left and margin-right rules will override the above. So you need to look for and revise/delete things like:

Code:
p.para {margin-left: 0; margin-right: 0}
p.txt {margin:0}
This can get tedious.

To normalize line-height, I delete most, if not all, line-height rules to allow the Kindle to set the line-height per user settings.

ETA: Updated this post using <html> instead of <p>. When I first started playing with negative margins, <p> was the only thing that worked for me, but now <html> is working, not sure what changed. But I'm happy about it!

Last edited by odamizu; 08-27-2019 at 12:49 AM. Reason: updated info
odamizu is offline   Reply With Quote
Old 04-25-2019, 02:59 PM   #4
mariowarner
Member
mariowarner began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Aug 2018
Device: kindle
Thanks! I already tried something similar, but with kfx files, and it didn't work. Will retry with kf8!

Last edited by mariowarner; 04-25-2019 at 03:53 PM.
mariowarner is offline   Reply With Quote
Old 04-25-2019, 03:29 PM   #5
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: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
Moved to the “Kindle Formats” forum.
HarryT is offline   Reply With Quote
Advert
Old 04-25-2019, 03:53 PM   #6
mariowarner
Member
mariowarner began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Aug 2018
Device: kindle
Could you make a quick walkthrough? I opened Calibre, right click on a book, edit book, then I'm confronted with a lot of different File browser tabs. Which one do I have to edit to add the code, look for the rules that could override the code and delete the line-height?

It would be really appreciated Thanks!
mariowarner is offline   Reply With Quote
Old 04-25-2019, 11:48 PM   #7
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,819
Karma: 6769540
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by mariowarner View Post
Could you make a quick walkthrough? I opened Calibre, right click on a book, edit book, then I'm confronted with a lot of different File browser tabs. Which one do I have to edit to add the code, look for the rules that could override the code and delete the line-height?

It would be really appreciated Thanks!
  • Look for the .css file under File Browser > Styles
  • Go to the bottom of the file and add: @media amzn-kf8 {html {margin-left: -36px; margin-right: -36px; }} (You can pick whatever negative value you prefer, doesn't have to be -36px)

    From here it can get tricky if you're not familiar with css due to all the variables, but you can try this as a starting point:

  • Search for "margin-left:" and "margin-right:" (e.g., "margin-left: 0" or "margin-right: 1em", etc.) If the value is 0, 0%, 0em, or any variation of 0, delete the whole rule (e.g., delete "margin-left: 0;"). If the value is a number, you should probably leave it, but this is where understanding css helps.
  • Search for "margin:" This can take many forms, e.g., "margin: 0" or "margin: 0 5px" or "margin: 0em 5px 0em 5px", etc. If this rule turns up, it's best to learn some css to figure out how to revise it to your liking.
  • Search for @page (e.g., @page {margin: 5px;} ) and delete the whole rule
  • For line-height, search for "line-height:" (e.g., line-height: 1em) and delete the whole rule

Good luck!

Last edited by odamizu; 08-27-2019 at 12:50 AM. Reason: more detail
odamizu is offline   Reply With Quote
Old 04-26-2019, 07:10 PM   #8
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: 31,000
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by mariowarner View Post
Could you make a quick walkthrough? I opened Calibre, right click on a book, edit book, then I'm confronted with a lot of different File browser tabs. Which one do I have to edit to add the code, look for the rules that could override the code and delete the line-height?

It would be really appreciated Thanks!
The CSS is the most proper place (in each file, and paragraph inline <I see this a lot in Kindle books>)

line-height: 1.2 (or 120%) is a traditional standard
There are occasions to use a different number, but those, IMHO, should be exceptions (eg 2 line chapter titles), bot the basic body of the work.
theducks is offline   Reply With Quote
Old 05-02-2019, 03:21 PM   #9
Notjohn
mostly an observer
Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.
 
Posts: 1,519
Karma: 987654
Join Date: Dec 2012
Device: Kindle
>line-height: 1.2 (or 120%) is a traditional standard

And isn't that the default in Kindle?
Notjohn is offline   Reply With Quote
Old 05-02-2019, 08:13 PM   #10
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,612
Karma: 145863177
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by odamizu View Post
I don't know about KFX, but for KF8, I have not found margin rules to work with <html> or <body>. Instead, I use <p> and add a media query so that it doesn't affect epub renderering engines.

Code:
@media amzn-kf8 {
	p {margin-left: -36px; margin-right: -36px; }
	}
Also, more specific margin-left and margin-right rules will override the above. So you need to look for and revise/delete things like:

Code:
p.para {margin-left: 0; margin-right: 0}
p.txt {margin:0}
This can get tedious.

To normalize line-height, I delete most, if not all, line-height rules to allow the Kindle to set the line-height per user settings.
The negative left/right margins of -45px in HTML works. I have seen it on a PW3.
JSWolf is offline   Reply With Quote
Old 05-02-2019, 08:16 PM   #11
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,612
Karma: 145863177
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Notjohn View Post
>line-height: 1.2 (or 120%) is a traditional standard

And isn't that the default in Kindle?
Yes. That's why a line-hight is not needed. It's not even needed in an ePub.
JSWolf is offline   Reply With Quote
Old 05-02-2019, 11:19 PM   #12
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,819
Karma: 6769540
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by JSWolf View Post
The negative left/right margins of -45px in HTML works. I have seen it on a PW3.
Interesting. It's been a while, but the last time I tried it in <html> and <body> it didn't work for me. I had to resort to <p>. Maybe something has changed in the Kindle rendering software since then. When I get a chance, I will try again.

As for -45px, I'm sure that works, too. I just use -36px as a matter of personal preference.
odamizu is offline   Reply With Quote
Old 05-03-2019, 09:27 AM   #13
mariowarner
Member
mariowarner began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Aug 2018
Device: kindle
Hi guys and girls! So if I understand this, changing the line height in the CSS won't affect what's displayed on the kindle? Is the font size also default? It seemed to me that I had to change the settings between the books as the feel wasn't the same... Will have to check back to see if it's not my brain plalying tricks hehe!

Also I tried the 2 different methods for the margins, and only the <html> worked for me as the <p> lines would disappear after saving the editor. Weird he?

Also thanks to all of you for taking the time to explain, I'm really grateful for that!
mariowarner is offline   Reply With Quote
Old 05-03-2019, 04:21 PM   #14
Hitch
Bookmaker & Cat Slave
Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.
 
Hitch's Avatar
 
Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
Quote:
Originally Posted by mariowarner View Post
Hi guys and girls! So if I understand this, changing the line height in the CSS won't affect what's displayed on the kindle? Is the font size also default? It seemed to me that I had to change the settings between the books as the feel wasn't the same... Will have to check back to see if it's not my brain plalying tricks hehe!

Also I tried the 2 different methods for the margins, and only the <html> worked for me as the <p> lines would disappear after saving the editor. Weird he?

Also thanks to all of you for taking the time to explain, I'm really grateful for that!
Are you messing with them for your own reading pleasure, or are you making production books for people to buy on Amazon? That affects the answer.

Hitch
Hitch is offline   Reply With Quote
Old 05-04-2019, 12:38 AM   #15
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,819
Karma: 6769540
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by mariowarner View Post
... only the <html> worked for me as the <p> lines would disappear after saving the editor. Weird he?
I just tried <html> and it's working for me, too! Not sure what changed from the last time I tried it (years ago). Strangely, <body> still doesn't work. If anyone has any theories on why this is, I'd be really interested to learn this.

@mariowarner: What does this mean: "the <p> lines would disappear after saving the editor"? (I use Sigil rather than Calibre, so maybe it's a Calibre thing?)

Last edited by odamizu; 05-04-2019 at 12:50 AM. Reason: typo
odamizu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reduce line spacing int the main window ? PO40600 Library Management 8 12-29-2015 04:15 PM
How do I reduce line spacing when I have superscripts jrjung Conversion 2 09-04-2015 03:36 PM
Hack to reduce KF8 line height JSWolf Kindle Developer's Corner 2 10-05-2014 05:06 PM
Icarus 9.7 'Pdf Reader' app and spacing, margins and fonts einkuser Onyx Boox 2 03-21-2014 08:04 PM
Line Spacing and Margins la3541 Sony Reader 0 06-02-2008 06:35 PM


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


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