Numbers for Paragraphs

Hi,

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

Thanks
Nick

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

This:
image
Gets me to this:
image

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…

Find:
^(\w)
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.

      	<$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

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

Here’s what I want to do.

Take a scene: Number peragraphs.

Then paste this into a spelling and grammar checker, or use an AI and ask it for suggestions.

Or I’m sending it to a co-author for comment.

And they can reply, Move #17 to above 15. Take out 23-49…

And then I can make the changes.

Framemaker, back when I used it, had a “Lock Numbering” and “Lock Paging” option which allowed you to set these. If you added something that should have been numbered it got some kind of suffix.

e.g.

1 Foo

2 Bar

3 Baz

Then if you removed the Bar paragraph you were left with

1 Foo

3 Baz

And if you added something after Foo you got

1 Foo

1+a Flibbit

2 Bar

3 Baz

I would settle for additons being just unnumbered, and the rest of hte list not changing if I remove a line.

If you put a

Online Text Numbering Tool: Add Sequential Numbers Instantly

Compile and paste. (Or paste straight from your project.)
This should allow you to communicate with third party collaborators.
Keep the resulting text as a reference, but I personally wouldn’t bring it back in my project as the version I am working on. Scrivener’s paragraph numbering should match anyways (until you merge, move, add or delete a paragraph).

If you do paste it back in your project, use Paste and Match style and lose all of your formatting -!!- or suffer worse potential consequences later.
I am not joking. → I really advise you only use the resulting numbered text as a reference.

P.S. I have never used that online tool I just linked to. I don’t know what it is worth. I ran a quick test and it worked. So…

═════════════════════

Another thing you can do is to paste → [<$n>]space
at the beginning of each of your paragraphs. (In your project.)

→ (Use [<$n:para>]space if you are already numbering something else at compile. This will avoid any issues.)

→ (Using uncommon brackets would later allow you to use a RegEx to remove all of those numbering prefixes from your documents in one go, without risking deleting something else as well.) → ⸢..⸣ → ⸨..⸩

Start at the top of each concerned documents, paste the first prefix, and Ctrl+down-arrow will then move you to the beginning of the next paragraph.
So: Ctrl + V-Down-V-Down-V-Down-V-Down-V-Down- … you’ll be done in no time.

This will compile with numbers.

The result of this (if compiled to RTF) can be safely used in your project.

1 Like

I’ve merged your post into an existing discussion on this. Please refer to this post for a detailed demonstration of how you can add numbering dynamically, as a process of compiling.

That is the best you’ll be able to do. While Scrivener does have a line numbering feature, the one that is built into the text editor (View ▸ Text Editing ▸ Show Line Numbers) is dynamic—more like how a plain text editor would number lines.

But as noted above, the compiled result will be “hard coded” to those numbers, and thus remain useful as a reference. You could import it into the project for that purpose, not as a replacement for the original text, but as an editing reference.

The only difference I would take myself is to have the compiler insert the numbering rather than putting it directly into the text editor by hand (which is what the linked to post goes over). I would go that route perhaps if the numbering was intrinsic to the text, maybe, but even then I think I’d rather leave the “clutter” to the compile Format as a matter of taste.

1 Like

Ick. I really don’t want to do this for 200,000 words worth of paragraphs.

It may make a dozen trips back and forth.

In FrameMaker one of the options was to Lock Numbering.

When numbering was locked, adding a new anyting to a numbered list added as a decimal point.

So if you intitally had

=> 1. This is line 1 in the original document

=> 2. This is line 2 in the original document

=> 3. This is line 3 in the original dokument.

And then you inserted a line between 2 and 3, you get.

=> 1. This is line 1 in the original document

=> 2. This is line 2 in the original document

=>3. This line is inserted between 2 and 3.

=>4. This is line 3 in the original dokument.

***

So if I send off a numbered paragraph document to someone, I get comments back referencing paragraphs by number, as soon as I do anything that changes the numbering, their references the numbers I sent out no longer match.

Which in turn means, I have to keep two documents: The numbered version I sent out. They tell me I mis-spelled document in line 3, but earlier I did that insert. I have to look up what they think is line 3, figure out that it’s MY line 4, now, and fix the word.

***

What Locked Numbering did in FrameMaker

=> 1. This is line 1 in the original document

=> 2. This is line 2 in the original document

=> 2.1. This line is inserted between 2 and 3.

=> 4. This is line 3 in the original dokument.

FM allowed you to do this in page view too. So that if you did something that changed the page flow, the top of page 17 in version 1.2.7 was still the top of page 17 in 1.2.9. There may be now pages 16.1, 16.2…. or with editing, you may have blank pages if someone deleted everthing on a page.

A simple compile + 1 paste per document.
The word count is irrelevant.

Doesn’t each and every paragraph require that I paste the autonumber thing at the start of it?

That “NUMBERING” style doesn’t even have to exist in your project. Create it on the spot, in the compile format as above.
(Add any paragraph formatting style to the list, rename it, tweak it.)

Add brackets to <$n>. I didn’t, in my screenshot. – [<$n>]space
. . . . . .
Compile to RTF.

2 Likes

Just to reiterate, the post that I linked you to, from higher up in this thread, has a test project that demonstrates how to do this automatically, and goes over how it was created in great detail (down to the formatting adjustments).

Nobody should be getting from this thread that the answer to the problem is to manually number each paragraph by hand, or to have to put countering tokens in front of each paragraph in the text editor. That is the opposite of what a program like Scrivener is for. Granted it might not be as sophisticated as FrameMaker, but we do our best.

It’s very likely you’d be able to save the compile Format from that test project as a global format, and then use it in your own work with a little adjustment. The above screenshots posted by Vincent illustrate some of the steps I worked through, and should help describe the process. The format I built off of might be too casual for what you need, but this technique is easy to build into any of our formats, or the one you’re building yourself.

That aside, I would consider importing the compile copy into your binder as a reference. You might even turn on the compile option, in the General tab, to Insert links back to Scrivener in each section, for your own personal copy (i.e. compile one with, for you, and one without for your readers). These links will jump straight to the original binder item in the draft that the text came from, and thus make reference proofing copies far more useful.

It’s true, there is nothing like an ID number for each paragraph in Scrivener, like you describe, but having a physical copy you can work against, and easily look up the source for, is pretty close in capability, if not the workflow.

2 Likes