|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
linux user
![]() Posts: 6
Karma: 10
Join Date: Jan 2026
Device: Kobo Libra 2
|
Image does not appear centered in KOReader but appears centered in Calibre renderer
Good Afternoon,
I would like help formating an epub. I am not new to KOReader, but I _am_ new to manually formatting epubs with Calibre. Before I used to just use all epubs regardless of whether they were appropriately formatted, but lately I wanted to try getting some experience formatting them for them to look better. The main issue I have encountered for now is with a certain epub where an image appears centered in the Calibre renderer but not in KOReader. KOReader, if I remember correctly, uses crengine, and I assume the Calibre renderer must use something based on WebKit or something similar, so that explains the difference. However, I have yet to find a solution. The HTML body of the page concerned is below: Code:
<body class="calibre1"> <h2 class="part-number"><em>Zero</em></h2> <p class="centered-image-1"><img alt="Separator Image Missing" height="1" src="../images/line.jpg" width="84"/></p> <h2 class="part-title">7 August 1944</h2> </body></html> Code:
p.centered-image-1 {
text-align: center !important;
text-indent: 0;
margin-top: 0;
margin-bottom: 1em;
}
`img2.png` is a screenshot of KOReader's rendering. The image is the line after the header "Zero". I have yet to find a way to make the image properly center in KOReader. <br> <br> <br> Bonus question 1: Why do the same images, in different epub files but inserted with the same class, scale differently? In one epub, a width of `256` was sufficient, whereas with the other I had to change that to `512`. This difference is only present in KOReader, Calibre shows them at equal sizes when both are set to `256`. Bonus question 2: I have a publisher information page that gets rendered properly (with text centering) with Calibre but not with KOReader. `img3.png` is how it looks rendered by Calibre, `img4.png` is how it looks in KOReader. How can I make it look like on Calibre in KOReader? I know this is a lot so thank you very much for your time :) Last edited by ilikelilies; 01-09-2026 at 12:56 PM. |
|
|
|
|
|
#2 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,797
Karma: 731691
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
The test case as given doesn't render as in the screenshot. There's either another style in the book or a style tweak like left align most text is active (or perhaps embedded styles are disabled). Please provide a complete minimal testcase if it's not one of the latter two.
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 591
Karma: 32228
Join Date: Feb 2012
Device: Onyx Boox Leaf
|
Try this
Code:
.centered-image-1 img {
display: block;
margin: 0.5rem auto;
width: 84px;
}
|
|
|
|
|
|
#4 | |
|
linux user
![]() Posts: 6
Karma: 10
Join Date: Jan 2026
Device: Kobo Libra 2
|
Quote:
As for the styles, here's the complete HTML of the page: Code:
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>All the Light We Cannot See</title>
<link href="../stylesheet.css" rel="stylesheet" type="text/css"/>
<link href="../page_styles.css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body class="calibre1">
<h2 class="part-number"><em>Zero</em></h2>
<p class="centered-image-1"><img alt="Separator Image Missing" height="1" src="../images/line.jpg" width="56"/></p>
<h2 class="part-title">7 August 1944</h2>
</body></html>
I don't know what a "complete minimal testcase" is, but I'd be happy to provide it if you explain what it is :) |
|
|
|
|
|
|
#5 |
|
linux user
![]() Posts: 6
Karma: 10
Join Date: Jan 2026
Device: Kobo Libra 2
|
|
|
|
|
| Advert | |
|
|
|
|
#6 | ||
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,797
Karma: 731691
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
Quote:
Quote:
|
||
|
|
|
|
|
#7 | |
|
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,582
Karma: 21743811
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Code:
p { text-align: justify !important }
For what it's worth, that kind of code usually works fine for me. I have all style tweaks disabled (except footnotes, and a custom one for smallcaps), and the "traditional book look" enabled. |
|
|
|
|
|
|
#8 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,797
Karma: 731691
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
Quote:
See https://drafts.csswg.org/css-cascade/#cascade-origin |
|
|
|
|
|
|
#9 | |
|
linux user
![]() Posts: 6
Karma: 10
Join Date: Jan 2026
Device: Kobo Libra 2
|
Thank you, this actually worked!
Just one minor issue, is there a way to keep the text justified without it messing with the image centering? Is it what the other user was talking about regarding `p { text-align: left !important; }` ? Do I just make that a styletweak (put it in my `$KOREADER/styletweaks` as a css file) and enable it globally? Quote:
And thank you again for your help :) |
|
|
|
|
|
|
#10 | ||
|
linux user
![]() Posts: 6
Karma: 10
Join Date: Jan 2026
Device: Kobo Libra 2
|
Quote:
Quote:
Thank you again for your help :) |
||
|
|
|
|
|
#11 | |||
|
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,582
Karma: 21743811
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
![]() Quote:
|
|||
|
|
|
![]() |
| Tags |
| calibre, centering, epub, koreader |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I get centered images using Sigil? | provlima | Sigil | 4 | 04-30-2022 11:13 AM |
| Centered initial caps? | nabsltd | ePub | 60 | 08-26-2017 09:06 AM |
| Centered but left align? | mtrahan | ePub | 15 | 04-01-2012 04:56 PM |
| would like toc to be centered | alansplace | Kindle Formats | 9 | 11-20-2011 12:47 PM |
| Calibre screwing up centered-text b/c of forced tabs | lurker316 | Calibre | 0 | 12-21-2010 10:36 PM |