Empty line above titles after compiling?

@AmberV
I was able to partially answer my question on my own, by overriding my styles’ name to a single identical name…
image

That could somewhat be functional (although it is getting close to as much trouble as to fixing the bug manually, at this point) but it leaves “no style” as a third style once in LO…

(I personally just reached the point where I’m thinking “Meh. Screw it. I’ll deal with it by hand, hopefully the bug will be fixed soon enough.”)

Still, I have to say that should I not be using so much styles in the early phases of composition, the solution you pointed to would be ideal.
(At the early stage of my composition process, I kind of only compile so that I can further work a chapter/document in a printout form. My current solution is to compile and print a single document at a time. I am ok with that. Else, the bug ain’t a real problem in that context. I can totally live with the unwanted extra line. It’ll only cost me a few extra blank sheets a year. (Perhaps none, even, since when I get a paragraph alone on the last page, I usually play with the header and footer size to fit it on the previous page.) Nothing to sob over. – Once I am done with the composition process, my project is down to only two or three styles, so then again, not a problem.)

I have reproduced and analyzed the problem with the supposed “page breaks” during compilation several times.

In fact Scrivener does not insert page breaks when compiling to Word (docx) as claimed everywhere in Scrivener’s user interface and documentation. There is also no extra paragraph.

Scrivener inserts a section break (not a page break!) at the end of the paragraph between the text and the paragraph marker. The section break forces a new page. This moves the paragraph marker itself to the new page, creating a blank paragraph and (normally) preserving the paragraph’s formatting attributes from the previous section. A section break, unlike a page break, means that various properties (such as header, footer, column count) are (or can be) reset for subsequent pages.

Scrivener’s procedure is equivalent to manually inserting a section break at the end of a paragraph in Word by a user. With manual insertion, the user must then either edit and reformat or delete this “new” paragraph. Unfortunately, inserting a page break at the end of the paragraph would not change the problem either, because exactly the same thing happens (a “new” paragraph is created by separating the paragraph with a section or a page break).

It remains irrelevant at which point of a paragraph a section break or a page break is inserted. The paragraph is always separated, even if it is only the paragraph marker that is moved to the new page/section. Remedy could be possible at compile only if first the page break or section break is inserted at the end of the paragraph and then the paragraph marker is deleted. But presumably this deletion of the paragraph marker will not be possible?

1 Like

Thanks for the detailed explanation (sorry, my second comment overlapped with your explanation). To sum up for me, Scrivener offers many possibilities for “formatting” (like section breaks or headers/footers) - but that they really should not be used at all. Which raises the question for me, why Scrivener offers possibilities that only lead to errors (or let’s say “weaknesses”) which one should avoid with procedures with further software.

For me, I’ll continue to work on the current book with Scrivener’s weaknesses for now and just ignore extra blank paragraphs in between. At the end I will then look at whether it is worth applying a template in Word or whether I am then not faster overall with a one-time manual overhaul.

In fact Scrivener does not insert page breaks when compiling to Word (docx) as claimed everywhere in Scrivener’s user interface and documentation. There is also no extra paragraph.

That is correct, the technical formatting command that it inserts under most circumstances is a Section Break, not a pure/simple Page Break. I use the latter in common discussions to describe both, because on the surface they achieve very similar effects and that is how the software describes them.

It is possible to have Scrivener generate simple page breaks, but you would need to disable all features that require mid-document data changes like header/footer setups, front matter using different page numbering, and so on.

Scrivener’s procedure is equivalent to manually inserting a section break at the end of a paragraph in Word by a user.

So the problem that we have is that the toolkit itself handles things that way, given how it organises data in memory and then generates output from that structure. We would have to override how it handles text data at a fairly deep level to fix this. But yes, the details aside, the end result is as you describe: a user inserting a break incorrectly and then not fixing it.

On achieving best-practices output from Scrivener...

To sum up for me, Scrivener offers many possibilities for “formatting” (like section breaks or headers/footers) - but that they really should not be used at all…

100%! If I were a word processor user I would use one of these two routes:

  1. I would stick with how I write currently, with Markdown in Scrivener, and use Pandoc to generate the DOCX/ODT file—which is enormously cleaner and better conforming to best practices and conventional behaviours (MultiMarkdown’s ODT isn’t bad either). That workflow is almost exactly like what I describe doing manually in the other thread: you design a document template and then Pandoc handles the creation of the raw styled formatting and injects it into the template for you, skipping the step of importing the text yourself.

    So it’s a very clean, efficient and quite powerful workflow if you need a good word processing document. I do have some quibbles with how it works—and in some areas it feels like a WIP. For example I’d rather see proper image floats with dedicated captions rather than a “Caption” paragraph underneath an inline image, but one big advantage to using Markdown to write is that our documents get better as the years go by. Stuff that I wrote back in 2008, when Markdown was in its infancy with regards to complex documentation creation, creates much better documents now, without me having to change anything about the source.

    The emphasis here is that Scrivener can produce well-formed documents right now, out of the box—and writing with Markdown is probably a whole lot less about writing with Markdown than you think it might be, considering how the compiler has an RTF to Markdown conversion engine built-in. Many wouldn’t even need to see much, if any, syntax in the editor. The user manual PDF for instance, which does a lot more formatting than native Scrivener can even dream of doing, is a Markdown project—but in most sections of the source project you probably wouldn’t even notice or realise that.

  2. If I were to abandon Markdown for some unholy reason, and use rich text formatting as a basis for how I write in Scrivener, then I would do what you are saying. In fact when I started playing with this and creating a proof-of-concept some months ago, I created a compile format that very deliberately avoids as much of Scrivener’s formatting as possible. You can’t avoid all of it, but I got it down to the point where everything about the look and feel of the document could be overridden by the template I inject the compiled .odt file into. So that absolutely is the route I would take if I had to work this way. For me, what comes out of the compiler would look almost nothing like the final product, and would be intended more as raw data.

    I wouldn’t though, because even that workflow has limitations that I do not have with Markdown, such as being unable to cross-reference to figures properly (with Scrivener the best you can do essentially boils down to using markup in the editor anyway, so… might as well just use a mature and broadly supported markup rather than something that only works in one tool and produces static text instead of field references and dynamic numbering).

…Which raises the question for me, why Scrivener offers possibilities that only lead to errors (or let’s say “weaknesses”) which one should avoid with procedures with further software.

It’s a good question. Why is it this way? Mainly because it has grown organically and gradually over the course of nearly 17 years now, most of which during that time it had no proper stylesheet support at all (true, the Windows version is younger than that, but it’s core design comes from that legacy). These kinds of brute force tactics I describe above are the only way to do most of these things if the output is oblivious to styles. While styles were finally implemented, they were really only implemented at a shallow level. They are applied to text, but not even by default in Section Layouts (owing to other design corners and Catch-22s). It was, you might say, a “phase one” implementation of stylesheet support.

It’s also worth bearing in mind that for many years this was all good enough, too. Most people were handing off a Courier or TNR manuscript and it’s okay for such documents to be technically sloppy. Publishing houses have piles of macros to fix author sloppiness because authors often have no clue how to use a word processor beyond typing—hitting tab to make indents, etc. But as more people are now doing their own design, or handing their work over to freelancers that may not have decades of helpful macros in their tool-chest, the importance of having a well-formed output is more relevant today than it was when Scrivener started out.

So yeah, if one is doing things the right way and wants a best-practices document, either of the methods I described above, are the best ways to use Scrivener, hands down. If you’re not doing thorough design or embarking on a collaborative or institutional workflow that requires well-formed documents, and are just hoping for the best (maybe even using PDF then)… then whatever. “WYSIWYG” works even if what you see is “wrong” from a best-practices standpoint. :slight_smile: It works if all you are doing is opening the output in a word processor and using its better layout engine to create a superior PDF than what Scrivener can create natively.

These factors are probably why this is not more of an issue. Most of the people that would even notice Scrivener’s output are, like I say, in a workflow designed to strip out sloppiness anyway.

This does not mean we shouldn’t improve, but that is deep level overhaul territory for some point in the future.

3 Likes

Thank you very much for your detailed explanation. I now better understand how and why one should work with Scrivener when wanting to have control of most of the process. For me I produce a document that goes straight to the publisher who does all the layout and formatting. The compiled output of Scrivener mainly serves two purposes for me:

  1. It is the overall written product (text, no pics, no tocs, no footnotes etc.) where I can scan through it and get an impression how the whole thing would “somehow” look.

  2. After all writing and editing it’s the interface I hand over to the publisher.

After that the rest of editing with corrections (grammar, stylish etc.) will be done in a document I get from the publisher.

So for summing up: I will work with the output Scrivener compiles. At the end I will overhaul that output, only changing as little as possible (like the empty paragraphs) and send it to publisher. For me Scrivener is a very good research and writing tool. With now knowing more detailed about the Scrivener workflow and techniques I accept that little flaw. Because no workflow is perfect but needs to be as good as necessary. For my workflow it’s the optimal tool.

2 Likes

Perfect, then in that case you may not even need to clean the empty lines as they’ll probably do that for you. But if you wish to, that’s another thing!

1 Like

So, after spending hours poring over the Scrivener docs, assuming that I was misunderstanding how the compile settings worked, I finally looked through the forums here and discovered that this whole inserting-blank-line-after-page-break problem is actually a bug. Given that it’s a well-known bug of apparently long standing, and not addressed recently, it would be REALLY REALLY nice to have some kind of note in the documentation about the problem. Seriously. It would be a much better user experience.

Here is a method to create a Word Macro that deletes the paragraph mark above a specific style in Word. I create a style in Scrivener called Chapter Title and assign it in the compile settings to the section title before compiling. Then I add the VBA macro below to my Word document and run it and voila! All the blank lines above my chapter titles are gone.

Below is a VBA macro that you can use in Word to find every instance of a specific style and delete the paragraph (line) just before it. Please replace "YourStyleName" with the actual name of the style you’re targeting:

vbCopy code

Sub DeleteParagraphBeforeStyledText()
    Dim oPara As Paragraph
    Dim sStyle As String

    ' Set the style name you're looking for
    sStyle = "YourStyleName"

    ' Loop through all paragraphs in the document
    For Each oPara In ActiveDocument.Paragraphs
        ' Check if the paragraph style matches the specified style
        If oPara.Style = sStyle Then
            ' Check if there is a previous paragraph
            If Not oPara.Previous Is Nothing Then
                ' Delete the entire previous paragraph
                oPara.Previous.Range.Delete
            End If
        End If
    Next oPara
End Sub

Here’s how you can add and run this macro in Word:

  1. Press Alt + F11 to open the VBA editor.
  2. In the Project window, find your document’s name and right-click on it. Choose Insert > Module to create a new module.
  3. In the new module window, paste the code provided above.
  4. Replace "YourStyleName" with the name of the style you want to target. Make sure the name matches exactly, including capitalization.
  5. Close the VBA editor.
  6. You can now run the macro by pressing Alt + F8, selecting DeleteParagraphBeforeStyledText from the list, and clicking Run.

Note that this will delete the paragraph before every instance of the specified style throughout the entire document.

3 Likes

Just want to chime in here. This bug has been in Scrivener for years. There’s no way (that I know of) during compile to prevent the stupid blank lines on the top – however, I have conjured this VB macro scripts to fix it. They are located here: Fix Scrivener Longlasting Stupidity · GitHub

The first few lines in the link explain how to enable developer options and add the macros. If you do the line removing, it will take a few seconds (or longer for really long documents) to update.

Yes I felt my heart sinking as I scrolled through this long section from last year. (I assume there are entries for 2024 and they will be “more of the same”). I’ve tried maybe a dozen different compile configurations. Now I’m getting Chapter titles and hashtags and NO TEXT. Let’s face it the visual clues in the compile window are very confusing; the terminology seems inconsistent (“Chapter” v “section” v “headed” or not v. “blank lines” or not). Too bad “compile” is such a bummer for many many people.
How about REDO compile and or include a gallery of mistakes; "When your compiled project looks like this [ – ] return to Compile and do this [–]. Right now the Compile problem has people chasing isolated examples what it requires is Scrivenor fixing the problem.
I am thinking about carefully moving my text into a non-fiction template and not change the binder layout. Another idea is to move the text to a word processer and print a decent document pronto. It will cost more but the compile crisis is costing a lot of writing time.
Poggio

Great that compuaid has the advanced computer skills and knowledge to do this! Good to learn from jjxtra that this has been a bug for years. I thought it was just me!!
Poggio

To reiterate on the status, here is the last update. To be clear for those not aware of how programming works: nobody except eccentric people make software from scratch. We use frameworks that are the result of decades of refinement. This is how we get things like scroll bars, buttons, text editors, dialogue boxes and so on.

If the bug is in the framework you use to make software, our relationship with that is almost a bit like your relationship with Scrivener. Can you fix the bug in Scrivener? You might find a way to dodge around it with features, but no you can’t.

Often for us it is much the same, we have to find ways to dodge around a bug that is one step deeper than Scrivener. Sometimes we can do so successfully, but it is not always easy. This one is not easy, unfortunately, otherwise we would have fixed it back when we looked at doing so.

I just felt that needed reiteration, and perhaps clarification, since there still seems to be some confusion over why we haven’t fixed something that isn’t actually in Scrivener.

To round up the fixes that have been shared:

1 Like

RE: Using best practices instead of Scrivener’s basic formatting](Empty line above titles after compiling? - #66 by AmberV). Under ideal circumstances this shouldn’t be a problem, in my opinion, because unless you just need a quick and dirty output where empty lines like this actually do not matter one bit (a proofing copy for example, or a manuscript you’re sending off to a publisher that will clean it all up anyway), you shouldn’t be using quick and dirty formatting tools like manual page/section breaks, but letting the template’s stylesheet drive almost all formatting. That post goes into the details.
So “Under ideal circumstances this shouldn’t be a problem” unless “Scrivener’s basic formatting” IS the problem.
Poggio

This was the first question I asked myself when dealing with Separators in compile and it still bugs me today.
Wouldn’t adding a “None” or “No Action” option to the “Separators before section” list sort out the Windows dilemma that results in a carriage return at the top line of the of the next section, which in effect is a new sections starting a line below where they should on Scrivener for Windows?

The option to have no separator at all has been asked about before. In most cases it wouldn’t be terribly useful and would result in the last paragraph of one section merging with the first paragraph of the next. There are certainly some edge cases (e.g. you could have a sequence of binder items that are one-liners and have them merged into a paragraph) where it could be seen as useful, but not broadly enough to add what would for most cases be a confusing option.

That aside, I don’t see how a setting like that would help since it would no longer be inserting a page break. Even so, that isn’t something Scrivener is doing, it’s a bug in the Qt exporter that is too deep for us to get at easily.

2 Likes

Alright. It was unclear to me why a Single Return is necessary at the start of a new section, when the prior section is already set to Break.

In another post, I pointed out that if the prior section ends with text in a table cell, Qt doesn’t act unnaturally in the new section.

I don’t know if that’s more of a headache for the developer or a consideration to explore.