"Freezing" paragraph numbers: possible, or not?

Everything related to our flagship word processor.
Post Reply
BobHughes
Posts: 15
Joined: 2012-09-21 13:04:20
Location: Oxford, UK

"Freezing" paragraph numbers: possible, or not?

Post by BobHughes »

Daft question probably, but...

I've numbered the paragraphs in the draft of my book that's with my editor (using "Show paragraph numbers..." from the View menu) and have made copious notes referring to these numbers, for incorporation in the next draft.

Is there any way of fixing these numbers (perhaps attaching them to the ends of their current paragraphs), so that they can still be found, when I start inserting new stuff and rearranging the current draft? Paragraphs would then get new auto-allocated numbers, but their old ones would still be there, at the end.

I've read last year's interesting correspondence on 'freezing' paragraph numbers, but the originator very sensibly allocated his via stylesheet - which alas I didn't:

http://nisus.com/forum/viewtopic.php?f= ... paragraphs

All the best,

Bob Hughes

martin
Official Nisus Person
Posts: 4738
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: "Freezing" paragraph numbers: possible, or not?

Post by martin »

Hi Bob,

If you only have a single section in your document, and thus only one sequence of paragraph numbers, this isn't difficult at all. Because the menu View > Line Numbers > Show Paragraph Numbers This Section simply counts paragraphs, we can very easily reproduce that sequence with a macro:

Code: Select all

# visit the end of each paragraph in the document
Select Document Start
While Find Next '$', 'E-W', '-am'
	# insert a paragraph number
	$selected = TextSelection.active
	$text = $selected.text
	
	If $text.length > 0
		If $selected.location < $text.length
			$paragraphCharIndex = $selected.location
		Else
			$paragraphCharIndex = $text.length - 1
		End
	
		$paragraphNum = $text.paragraphNumberAtIndex($paragraphCharIndex)
		If $paragraphNum
			Type Text " [$paragraphNum]"
		End
	End
	
	# move to the start of the next paragraph
	Find Next '^', 'E-W', '-am'
End
You can run the macro on your document once, and then turn off the View menu (or keep it on if you want both).

The macro inserts numbers using the form [1], [2], [3], etc, but you can adjust that by editing the string " [$paragraphNum]" in the macro. You can use any characters there that you like, as long as you keep the double-quote marks and $paragraphNum variable intact.

BobHughes
Posts: 15
Joined: 2012-09-21 13:04:20
Location: Oxford, UK

Re: "Freezing" paragraph numbers: possible, or not?

Post by BobHughes »

Fabulous. Thanks very much Martin.

B

Post Reply