[LH4378] Compiling to mobi, how to get rid of margins?

Whenever I compile to mobi format I always get these huge margins. Am I missing a setting somewhere in the compiler or is it something to do with kindlegen?

I’m using the current Beta 40 and using the kindlegen from KindlePreviewer 3.

It is the reader who decides on the margins. You set it inside the mobi reader you use.

It looks like you are using Calibre’s viewer, if you right-click in the viewer you will get some display options, from which you can select “Page Layout”. In the top area you’ll find settings for the margin box. Mine are set to 20 pixels each, which isn’t very much.

If that’s not it, then it is indeed possible to add additional padding in addition to whatever the reader itself is adding. Ordinarily you would never want to do that, and default Ebook compile format settings are set to 0rem all the way around each paragraph—but this is a fully customisable program.

What works best is to go into the General Options tab of the compile overview screen and enable the option to export the source files. Then you can look at the actual HTML and CSS directly and see where the source of the padding is coming from (if any), and from that it can be deduced what features in Scrivener are involved. Just looking at the end result in a book reader like this is always going to be guessing game.

Thank you for your suggestions! I did as you said and played around with the source files a bit. I have some experience with html and css so I was able to figure out that it’s not a margin setting at all. They are all set at 0rem. I even went as far as taking out the link to the style sheet to find that it’s not the style sheet causing the problem. It seems to be the blockquote tag that starts at the beginning of the body text of each chapter. Once I removed it from the html file, the extra space went away.

So assuming it is this blockquote tag causing the problem, how do I go about preventing it from being generated, if at all possible?

Ah ha, that would indeed cause a block indent in most viewers. By default you would only see this happen if the entire text were assigned to the Block Quote style, either in the text itself—or as a function of the compile settings (a Section Layout is dynamically assigning the style to all unstyled text).

But this is also a flexible system. How this really works: in the HTML Elements compile format pane you can assign a style to output as

(styles being set up in the Styles pane of course).

So those are the places I would check. My first test would be to disable block quote output in the HTML Elements pane, run a test with that off, and if it goes away, trace the problem backward from there.

I ended up using a customized style sheet that set the margin elements of the blockquote to 0. It fixed the problem!

If you get a chance to dig in a bit deeper into why it is happening, it would be appreciated, for the beta. If the software is adding this unnecessarily, it should be fixed.

The preset with section title and body text adds the blockquote tag, from what I can tell.

Thanks, it looks like it may take a little more than that though, given the testing I just did. I’m attaching the test project so you can take a look at it and see what might be different with it and your project. Of note:

  • Each of the four text files (scene a, etc.) has been assigned to a different Section Type, as can be seen in the Outliner view in the top split
  • The reason for this is that there are four different Layouts that broadly match your description of having a section title with body text. So I’ve assigned one type to each layout in the compile settings.

After compiling the source files out, I run grep on the command-line to scour the output for any use of

, but get no results, and an examination of the .xhtml files doesn’t reveal any issues.
blockquote_check.zip (121 KB)

So after playing around a bit I was able to recreate the problem and isolate it!

The two screenshots below are two different generated ebooks. The settings that I changed are in the screenshots below. When left to “none” for everything but the title (as I have it in my project) I am getting the blockquote tag.

If I use your default settings with something selected for each element the ebook comes out without the blocktag.

Let me know if you want me to isolate it further.



Thank you, lagamine! We managed to reproduce the problem with the empty HTML compile elements and a fix will be available in the next update.