I want to create a document of a few hundred pages, where continuous line numbers appear on the left and right of the page. Below is an example of what I want to achieve (although I want to specify a different starting number than 1). How can I do this in Libre Office writer? Can I do this natively, or is there a macro that would work?
You can certainly do it left or right side (or inner or outer). Both sides is not listed as a possibility in Tools > Line Numbering. You might need a macro
Do you have an example of a macro that I could use?
Here is a way you can do it.
- From Styles drop down, click on More Styles, then expand Index category
- Right click on User Index 1 and select Modify.
- Under Fill Character, select None
- Apply Style.
Here is a macro to generate the lines.
Sub twoColNums Dim i, s Do i = inputbox("How many lines you require?","Line Count") s = inputbox("Starting number?","Starting number") loop Until isNumeric(i) AND isNumeric(s) Dim oText oText = ThisComponent.Text Dim n s = cLng(s) i = cLng(i) For n = s To s+i oText.insertString(oText.getEnd(), CHR$(13) & n & CHR$(9) & n , false) Next n Print "Done!" End Sub
Thank you very much for the macro, it works well to generate the numbers, but the two sets of number colums are very close together (see picture below). How can the script be changed to space the two columns further apart?
Secondly, what would change on the script if I only wanted one column of numbers instead of two - I was thinking about this for another project that I have.
The issue with the numbers close together sounds like a style issue. Did you select and apply the style to the entire text? I suggest you play around with the style settings to get the desired look. As for single column, remove the either one of the two
& n in the
insertString command to get what you want.
Many thanks Caveman. I played around with the styles and it solved things. Just one more question, is it possible to specify the starting number? Say if I want it to start with number 36 instead of number 1. What would need to be changed in the script?
No problemo! See updated answer. Ooops fixed code issue. Should work fine now.
I just changed the n value to start at any number I want and it works great. Thanks so much.