[LH5058] Unwanted indent in paragraph style after compilation

I’m using Scrivener version: 3.0.1.0 (1274136) 64-bit - 28 Apr 2021 on Windows 10
I’ve created a paragraph style (‘Citation’) to indent, italicise, and add grey highlight to quotations. It displays correctly in the editor (with every line indented by the same amount)
Under Format-Paragraph-Tabs and Indents I have First line and Left set to 0.35 inch, with Right set to 0
However, when I compile it to Kindle, the first line of such paragraphs has an additional indentation, i.e., the first line is indented more than subsequent lines in the paragraph.
I have a custom format but the same thing happens when I use the default Ebook format.

When editing the format, under Styles, I have used “Override paragraph project styles” to include the custom “Citation” style in the list - but it displays correctly in the preview and I can’t find any setting to change this behaviour

Can you help me create Kindle files where the indentation is as defined and displayed within the editor please?

1 Like

Hi and welcome,

By no means am I a compile expert, so it is very possible you’ve already addressed this, but in Compile settings for Kindle, in the Text Layout section, there are a number of ‘Remove first line indents’ controls.

Have you experimented with these?

Best,
Jim

Thanks for responding and for your welcome.
If you mean the Edit Format for my new format, then it’s set to Remove first line indents: From all paragraphs following other elements which seems to render the rest redundant (it greys them all out at least).
The significant thing seems to be that the problem only occurs on my ‘Citation’ style. All other paragraphs appear with no extra indentation on the first line. This suggests to me that it is something specific to the style, however, as I say, the style displays correctly everywhere else and I can’t find any style specific compile settings that change it

3 posts were split to a new topic: Using tabs to indent paragraphs creates too much indent

My issue isn’t with tabs, I haven’t been using any in the editor although I don’t know if there’s any way to see what is physically appearing in the mobi file that’s being produced.
The compiler no longer seems to use KindleGen, I was instead asked to install the Kindle Previewer (unless that includes KindleGen) - is it possible there’s a problem with the external tool?

1 Like

Yeah, your post clearly has nothing to do with errant tabs, but I strongly suspect the other issue is related to that. Tabs don’t do anything meaningful in HTML anyway.

All right, so I’ve had a look at the source, and the problem has to do with poor HTML output, basically. Here is what you get when applying a style like this:

<p class="citation"><em><span class="citation">Blah blah...</span></em></p>

So there are two problems with that. One is that the span is entirely unnecessary since all of that formatting can be applied directly to the paragraph. There is hardly ever a need to wrap an entire paragraph in a span like that. The <em> is also unnecessary of course, since the .citation class itself can and does define italics. But these could be brushed aside as redundant styling—where it becomes problematic is when you add CSS like this:

.citation {
  margin: 0rem 0rem 0rem 3rem;
  text-indent: 0rem;
  /* etc. */
}

You may be able to spot the issue, since both the paragraph and the text within the paragraph is classed as .citation, both get a left margin offset of 3rem. One indents the whole paragraph block, the other indents the text within the paragraph block, creating what looks like a first-line indent, even though we have that set to zero.

So one way of solving this is to add the following to the CSS compile format pane:

.citation .citation { margin: 0rem 0rem 0rem 0rem; }

That’s probably the best workaround, because once this bug gets fixed the CSS will end up doing nothing, and you won’t have to go back and change anything. It also allows you to continue using your style the way you want in the editor.

The other workaround would be to make the style paragraph-only, and add the character level formatting you want (text colour, italics, etc.) into the CSS pane yourself. But then these will just look like indented text in the editor.

Debugging Mobi Files...

As for examining Mobi output, I don’t know if there are any editors or even viewers that can examine these files more closely. What is best to do is to go into your general options tab in the compiler, and enable the setting that exports the source files along with the .mobi. That’s exactly what Scrivener hands off to KindleGen, so you can see what’s going on, and you can even make tweaks to the source files, and drop the .opf file into KindlePreviewer to have it assemble a preview for you.

So that’s what I’d suggest doing, so you can see exactly what CSS Scrivener is generating for the .citation class, and examine the DOM and interactions with any other CSS that may be impacting it, using your brower’s page inspection tools.

Kindle Previewer includes KindleGen, and that’s what we’re using to make the conversion.

1 Like

That’s a marvellous analysis and explanation of the problem. Thanks for taking the time to dig in and find precisely what was happening, I really appreciate it and am thoroughly impressed.

I have a general understanding of HTML but never really got to grips with CSS, nevertheless I seem to have applied your workaround successfully (appending it to the bottom of the Custom Stylesheet in the CSS pane of the Format settings). It has corrected the problem completely.

Thanks again

CSS is a great skill to pick up if you’re thinking of making your own ebooks, and it’s really not that difficult to learn the basics of how to construct a valid formatting command. The one I pasted for you means: look for elements that are assigned to “citation” that are inside other elements named “citation”, and reduce the margin settings to 0 in every direction (top/right/bottom/left) for that inner element.

That’s a slightly more complicated request than simply saying .citation { stuff }, which styles anything assigned to “citation”. With basic requests like that you can do a lot, and bring your book formatting to the next level.