Compile to line numbered document

It would be great if there was an ability to generate a line-numbered, compiled document (rtf,docx,pdf) like this:
It would be helpful for documents that need to be presented and discussed in live public setting where people involved need to be able to very quickly find in common a line in a document.
I don’t think this is really a feature that one would impose in styles or document formatting. Instead, it seems like an option one might turn on or off for any format that simple would line number in the left margin or not when a document was compiled. If it were to be a more sophisticated implementation, then maybe line numbers would optional reset at chosen levels of a document’s hierarchy.
If there is someone who has an approach to doing this that lets them add line numbering to documents after they have been compiled that would be helpful to learn from you.

LibreOffice Writer
Tools / Line numbering

You can compile to RTF, do this in LO (which is opensource / free to use), then export it in the format you need.

If you number paragraphs instead of lines, you can have them correspond to what Scrivener can display with this function :


There may be a Scrivener way but as I do this infrequently but when I do I simply compile to a Word document, and then set line numbering on in Word to print and/or make a PDF. Less than a minute.

1 Like

There is.
But the way I know of involves using styles everywhere.
And it doesn’t number lines. Only paragraphs.

Compile format / styles panel :

If you use Scrivener’s MMD compiler format, Pandoc allows you to use an ODT/DOCX template file, so you enable line numbering in the template, then use Scrivener’s post-processing to use it and without any fuss you have a finished document with line numbering enabled (and any other customisations to styles, page formatting etc.)


Otherwise yes, for me who works a lot with printouts and has to maneuver to have a numbering that matches between my printout and what Scrivener displays on screen, to be able to automatically number lines or paragraphs (paragraphs in my case) would be an awesome addition.
I mean something simple. As in a checkbox.

I think Scrivener could really benefit from the same trick Pandoc uses. Both ODT and DOCX are actually open containers, so you can take an e.g. DOCX, and inject in your actual document, preserving the other document properties like page setup, styles, and all the other features of those programs. Scrivener could use an optional template for these formats natively (a setting in the compiler), and it would save a bunch of explicit implementation for things like line-numbers…

Are you sure that would work ?
As I show below, the numbering is in the margin (once) in LO.
It is neither in the text zone nor selectable.
image . . image

Yes, the MMD compile generates “proper” line numbering without the need for any custom styles or fiddling in a word processor. Here is the vanilla output:

Using this compile setting (with macOS file paths):

The template.odt should be placed in the same folder that you are compiling to. You will notice the line numbers have even been styled (along with things like the blockquote, customised headers etc.), all of this comes from template.odt itself, there is no magic from Scrivener or markdown involved…

A sample Scrivener project and the template.odt is attached below (you obviously need to have Pandoc and LibreOffice installed, the sample template uses fonts available on my system etc.). The workflow is identical if you want to do this with Word (make a template.docx and use that)… (124.8 KB)