Numbers for Paragraphs

If it is a matter of compiling with numbered paragraphs, I would take a different approach from regular expressions, as those can be blind to text type (would you want images and their captions numbered, and would that avoid headings as they request?), and use styles instead.

The basic ingredients to understand are:

  • When compiling, you can apply a style to normal text in the project, as well as reformatting it.
  • Styles can be prefixed with text, which includes placeholders.
  • Any text already styled (such as an image caption or heading) will not have its style overwritten by this process.

The attached project is a proof of concept, using the “Modern” compile Format as a basis for modification: Compiling Numbered Paragraphs - Example (171.0 KB)

If you compile that with the given settings, you should see each “normal” paragraph in the test project has been numbered, and that the number resets at each chapter. The number is also “hanging” outside of the standard flush left margin, which is in fact a slight of hand since Scrivener can’t actually put stuff outside of the margin area.

So to achieve this look we do the following:

  1. In the editor, nothing. If I switch to Manuscript (Times) Format and compile, there will be no numbers.

  2. In the compiler, the Format is edited, and in the Styles pane, I modify the supplied “Body” style in the following ways:

    • Copy and paste the following in the Paragraph Prefix field. I need to do this because there are tab stops before and after the placeholder, which we will use to format the hanging indent, and I don’t think at the moment there is a way of typing those in here.

      	<$n:para>.	
      

      (Triple-click to select the above, with tabs.)

    • The ruler is modified to: 0cm first-line; 0.8cm left indent; 0.6cm right-tab; 0.8cm left tab.

    • I then went through all of the other styles, and where relevant, offset their left and first-line indent settings by +0.8cm, to in effect push everything over to what is now the new flush left.

  3. In the Page Settings pane, reduce the left margin from 2.5cm to 1.7cm to make our +0.8 offset now mathematically 2.5cm again. The numbers are now “outside” the margin, so to speak.

  4. Lastly, we need to make these styles do something, since by default they are inert. In Section Layouts, change the “Chapter Title” heading line to “Heading 1”. I then change the section title on the second line to a “Heading 1 Subtitle” style I created earlier. In the “Title Options” tab, I set the Title Suffix to <$rst_para>. The n:para counter is what we are using to number paragraphs, so this will make the numbering start over at 1 whenever there is a chapter break.

  5. In the “Section Text” layout, the sample text has the “Body” style applied to it.

As you can see, it looks a little weird in the preview because the numbers are not added yet, nor the tabs, but it will all work out in the end.

Compiled example of hanging indent numbered paragraphs.

2 Likes