Number lines in documents using Pages
How to number each line in a legal document
How to number each line in a legal document
Hi J,
Line numbering is not a supported feature in Pages.
You can, though, create a tall, narrow text box to contain a list of numbers, set to the same line spacing as your document.
To control line spacing, I set up the body text style first (16pt Georgia, 1.5line spacing), then placed the insertion point in the formatted paragraph and pressed option-command-C to copy the format.
Then I clicked in the text box to place the insertion point there, and pressed option-command-V to paste the format into the (empty) text stream in the box.
I also set the text alignment in the box to aligned right, to align the numbers vertically as shown.
Each page will require separate box.
Regards,
Barry
One can kludge line numbers in a Pages document, but it does not account for white space in the document content where you may want to skip the number sequence on empty lines. Either the free LibreOffice Writer or MS Word can handle this automatically for you, and that would be my recommendation.
The following AppleScript, when copied and pasted into the Script Editor, (Dock:Launchpad:Other:Script Editor), and the compile button clicked, and the script run, will deposit a slim text box with a number sequence in it into the Pages document.
If Pages is not running, and the script is run, then it will launch Pages and expect you to choose the template in 10 ten seconds. If you do, the Pages document will open and the text box is automatically inserted. Otherwise, if there is already an open Pages document, then it will just insert the Text box.
The Pages v8.1 scripting dictionary does not provide the ability to change Text Wrap to None, align the Text box content right, or set the Line Spacing. All will have to be done manually. For a line spacing of 1.5, and using 12 pt font, you want line spacing set to exactly 18 pt in both this text box, and your main document content so that the numbers align.
AppleScript:
-- autobox.applescript
-- automatically generates a narrow text box with right-aligned, space padded numerals
-- Due to Pages v8.1 scripting dictionary limitations, the following must be set
-- manually after the box appears in the Pages document.
-- 1) In the arrange tab, set Text Wrap to None
-- 2) Select the Text box and click the right align button in Format
-- 3) Set line spacing to 1.5, or for 12 pt, exactly at 18 pt.
-- No provision for omitting line numbers for spaces in legal document. If you
-- require white space, then use LibreOffice Writer, or MS Word.
-- Adapted from: https://iworkautomation.com/pages/text-item.html
-- VikingOSX, 2019-08-16, Apple Support Communities
use scripting additions
set theFont to "Georgia"
set theFontSize to 12
set theFontColor to "red"
-- set theFontColor to "black"
-- for next page's number box, make these adjustments
-- set boxLowRange to boxHighRange + 1 and boxHighRange to 2 * boxHighRange + 1
set boxLowRange to 1
set boxHighRange to 35
tell application "Pages"
activate
if not (exists document 1) then delay 10
tell front document
tell current page
set lineNo to (do shell script "seq -f '%4g' " & boxLowRange & space & boxHighRange)
set textBox to make new text item with properties {height:648, width:32, position:{72, 72}}
set object text of textBox to lineNo
tell object text of textBox
set properties to {font:theFont, size:theFontSize, color:theFontColor}
end tell
end tell
end tell
end tell
The hosting software is not going to let me upload the screen capture of the full, or even partial result of the Pages document, but Barry's example should suffice.
Number lines in documents using Pages