Second paragraph indent being removed in Kindle compile

(I have looked at every thread with the word ‘indent’ in the title from the last three months and can’t find this problem.)

My current book compiles perfectly to PDF. The same file gives me a problem I have not seen before when compiling to Kindle. The first paragraph has no indent, as expected. However, the indent has also been removed from the second paragraph, which has the indent built into the style. Third and subsequent paragraphs all appear with the intended indent.

Since my first paragraph of each chapter uses a style setting that does not have an indent, I have tried changing that to use the same indented style as the other paragraphs. No change, meaning the indent is still removed from the first two paragraphs.

I have gone into the ‘Text Layout’ section of the compile dialog and removed the check marks from all five indent settings. No change.

I have a second book that uses the same layout and has the same problem with Kindle compile only. None of my other books use indented paragraphs, so I can’t do further checks. My chapters are set up as new sections. Changing the layout to be ‘as displayed’ makes no difference. The screen display remains correct, of course.

I am on v3.1.1,

Ideas welcome.

And I have tried compiling to ePub instead of .movi, and still have the same problem.

I have attached a snapshot of the css code from the ePub file. It shows the first ‘paragraph with indent’ (which is the second paragraph in the chapter in reality) as having no indent.

The css content is not surprising in that it is what I see when displaying the file. The surprise is that it should compile that way. You can see that there is also a ‘paragraph without indent’ style a bit lower down. That is what is used for the first paragraph in each chapter.

And another update. Surprisingly, at least to me, changing the 0rem to 1.5rem in the css does not fix the problem… It still displays without an indent in the first indented (=second) paragraph. So the setting is happening somewhere else.

Workaround is to edit all the css lines with .body-text-with-indent; that worked. But of course it does not solve my underlying problem.

Still have not found a cause or solution for this. Ideas welcome.

Possible to share a sample project (with lorem ipsum) showing the issue?

Slàinte mhòr.

Well one thing worth pointing out is that you’re taking a more complicated route to the indent problem than you probably need to. The compiler is designed so that you don’t have to carefully apply styles to each and every paragraph in order to get a good result.

If I drop some bulk un-styled text into an editor and compile an ePub file with the default “Ebook” settings, I get exactly what you’re trying to achieve, but with a fraction of the effort. I might need to tweak the indent settings if I modify how the format works, and I might even need to dip into CSS to solve problems not anticipated by the hard-coded methods—but for a basic linear sequence of paragraphs where the first in the stack isn’t indented, this is default behaviour.

So let’s try and figure precisely why your method is conflicting with how it works normally.

A good method for figuring out why things aren’t doing what you think they should is to use a browser’s HTML/CSS analysis tools in conjunction with Scrivener’s testing output:

  1. From the compile format designer, hold down the Option key and click the Test HTML… button, which will appear in the lower left corner of the panel.
  2. Export that to a convenient location, and navigate there with Finder. Use Quick Look to find a good sample .xhtml file from one of the “body#.xhtml” files. When you have a good candidate, load it into your browser.
  3. Here instructions diverge depending on your browser. I use Vivaldi, which is a Chromium-based browser, so these instructions should work for Chrome. Right-click on the paragraph and select “Inspect”. With some browsers you may need to open “developer tools” from a menu.
  4. You may need to open a CSS pane to examine all of the selectors and CSS attributes being applied or overridden by other rules. Here is what I get with a simple test that seems to be set up the way you’re working, again with default “Ebook” settings:

As you can see, I have the first .body-text-with-indent paragraph selected. We have the CSS you noted as well as some defaults further down that are being overridden. These are defaults that would have formatted things correctly for you, had there not been a style here.

You rightly ask why text-indent: is set to 0rem by default. The answer to that question is in the Text Layout compile format pane.

  1. The default settings for Remove first line indents is: From all paragraphs following other elements. All paragraphs means all paragraphs! That includes styled paragraphs. The idea here is that if one did style every single paragraph with “body” or something, then they would get proper first-paragraph indent suppression no matter. This is working against you because you have two different style streams going on, and to the perspective of the logic, the first paragraph in your chapter is “another element”.

Scrivener presumes a semantic approach to styling. You have body text, as a concrete thing that is unlike, say, a chapter heading. In formatting terms there should not be a semantic difference between paragraph one and two. There is a formatting difference, but we should be able to affect that formatting within one semantic block.

  1. Theory aside, since you are handling indents fully manually, if we turn off all of the automation then you should get the desired result. So I disable every indent-related checkbox in this pane.
  2. Hold down Option and generate an update to the HTML test folder, overwriting the previous. You can switch back to your browser and hit Refresh to update both the viewer and the developer tool window:

With the indent automation removed, the default text-indent: setting for .body-text-with-indent is now 2.36rem (from the project’s definition of the style, in this case, I don’t have it added to the Format’s style list). You’ll also notice the generic default CSS that we had before, for indent handling, is gone. The only thing being overridden now is the compiler’s indent setting of 1.5rem.

And if you click on subsequent paragraphs, you’ll note the .body-text-with-indent + .body-text-with-indent selector is no longer in use.

So I believe you can find a working solution, but hopefully you can find an easier way to do this without the styles.

Thanks for the advice on this. Removing the styles did indeed fix it for the Kindle version. It does slightly screw up my intention to have a single file for both print and Kindle. My brother is much more of a CSS expert than I am and he is going through the CSS suggestions.

Depending on how you had set things up for PDF, it should work out fine. The way indent suppression works is different than eBooks, as of course there is no CSS with PDF. But all of these differences are stored in the compile Format. With PDF, indent control is found in the Settings tab in the Section Layouts pane. Each type of layout can have its own indent policy, as opposed to ePub/Kindle, where you select a policy centrally.