Re: Line number macro?

From: Philip Spaelti (spaelti@SHOIN.AC.JP)
Date: Sun Jan 14 2001 - 02:11:41 AEDT


On Sat, 13 Jan 2001 10:47:51 +0100 Kirk McElhearn wrote...
>Does anyone have an idea how I can add line numbers to a document, in the
>following manner: this is a long poem, and I would like to have a number
>every 5 lines. I can't use the built-in line numbers, since I want to
>export this to HTML.

Since this a poem I assume that the lines all have hard returns (or at least soft-returns). This would be a good thing since it would be much harder to do the line numbers otherwise.

Do the following:

- Set the main ruler for your poem such that the the margin is far enough left to leave space for the line numbers. Put a tab where you want the lines to start, and put a tab at the beginning of every line.

- Use autonumbers to number the lines. First choose one of the numbers, e.g. Custom A. Then open the Define Numbers dialog for Custom A, and set it to start at 5, and increase by 5. (Note: For HTML you will probably want hard numbers. But you can convert the Autonumbers to hard numbers when you're done.)

- Now insert line numbers every fifth line. If you want continuous numbering through the whole poem that is very easy with a find expression like the following:

Replace All "\(^.+\r.+\r.+\r.+\r\)\(.+\r\)" "\1\2" "oO-SA-wt-Gg"

Where the character between "\1" and "\2" is the desired custom number.

- If you want the numbers to restart on every page, things are a bit trickier. You can use the above find expression, changing it to "Replace in Selection", and going through the poem page by page. If that's too tedious for you, you'll need to write a macro. The simplest thing I can think of is the following. This macro inserts hard numbers, but it is easy enough to change that.

//=============================
// Macro Line numbers
// written by philip spaelti
//=============================
// go the beginning
Jump "1"
// Count every line
lineCount = 1
IncLine:
lineCount = lineCount + 1
clipboard = lineCount
Jump:To Line '\CC'
// Quit when we reach the end
if (charnum == endcharnum) exit
// On every 5th line paste the number
if (PageLineNum mod 5) goto IncLine
clipboard = PageLineNum; macropaste
goto IncLine
// * end macro*

Hope this helps
--------------------------------------
Philip Spaelti
Kobe Shoin Women's University
spaelti@shoin.ac.jp
--------------------------------------



This archive was generated by hypermail 2b29 : Thu Jan 18 2001 - 23:01:54 AEDT