Numbers for Paragraphs


I know there is the feature showing the line numbers, but this includes also headlines etc… But is there any feature to number only paragraphs (e.g. 01, 02 etc.).


While the feature is simpler than what you are looking for, there is the point to be made that Scrivener is designed to better work with outlines producing headings, rather than having headings typed into the text editor itself. So adopting that design goal would essentially dodge the problem.

I’d understand if you’d rather carry on as you have though! But that’s not the only feature that you may encounter slight awkwardness with, when trying to put multiple topics of content into one section.

1 Like

Well, you could create a Section Layout for paragraphs and auto-number them by putting in a <$n> placeholder in the Title Options tab Title Prefix text box and then removing the title.
But you’d have to file all paragraphs as separate binder items, which doesn’t look like that’s what you want.
Because hat would involve marking each paragraph with a token you could use to Import and Split a section in separate paragraphs using (buggy) Regular Expressions, then Compile to Word, only to Import and split the document to separate paragraphs.

So, I think the short answer is: no.

I think you can also use the Replacements compile pane to replace the beginning of each paragraph “^” with a numbering placeholder like "<$n:paragraph> " (check the REGEX checkbox to make that work), but it gets a little trickier if you want to restart the numbers at 1 every chapter or section break.

1 Like

Gets me to this:

Issues with the first and the last paragraph: You need an empty line before the first and you don’t need the last at all. Is there a better RegEx to solve those issues?

Do you want the numbers to be their own paragraphs like that, or do you want them to be placed on the same line at the start of the paragraph text?
I’m pretty sure that the caret symbol (^) will work better than \n, as it doesn’t translate as a replacement of the newline character but rather as the location of the beginning of a line/paragraph.

If you want to prevent it from adding numbers to blank lines, but you don’t want to remove those lines, then you’ll have to get a bit more fancy with parentheses to store found text and then either \1 or $1 in the replacement column to put it back rather than replacing it. So something like…

Replace with:
<$n:paragraph> \1

The (\w) will capture the first visible character of the paragraph, and so shouldn’t match to a blank line with no “word” characters on it.

The \1 (or alternately $1) will put it back in place, preceded by the auto-number token and a space.

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.


      (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.


Thanks for all your answer. Since I need it before compiling, I will try AntoniDel’s suggestion. Sounds promising.

But… all my suggestions make use of Compilation.
Sorry, there’s no functionality to show numbers before paragraph in the Editor, ASAIF.

Actually, there is a way to number your paragraphs inside Scrivener: The menu View->Text Editing->Show Line Numbers. However, it just numbers whatever is visible in the editor, starting at paragraph #1, and will also number titles that are part of a Scrivenings session. It’s not going to be consistent if you select different combinations of documents, nor will it come out during the compile process.

I’ve never understood what use the feature would be, but I’m sure someone has a use for it, or Keith wouldn’t have bothered putting it in.

1 Like

Is there a compile setting available so that I can include the “line” numbers in the compiled document according to the Scrivener editor’s “line” numbering?

(I use quotations around line because Scrivener actually counts carriage returns not lines. As a result, Scrivener’s numbering does not match Word nor Pages nor any other software that I know of that actually numbers the lines themselves!)

I’ve moved your post to an existing discussion on how to do this. I provide a detailed checklist and sample project above.

1 Like