How to add sequential numbers to images in Pages
How do I add sequential numbers to images in Apple pages?
MacBook Pro 13″, macOS 15.7
How do I add sequential numbers to images in Apple pages?
MacBook Pro 13″, macOS 15.7
As noted, there's no built-in automatic way to do this.
However, it may be scriptable.
The followed script looks at the front document and iterates through all the images in that document, adding a new text box below with the simple caption "Image " and the image number.
There are several caveats - the results may vary depending on page-based vs. document-based, due to the way the images are placed, but it should give you a good start.
tell application "Pages"
-- here's the image counter
set image_counter to 1
-- get the front document
tell document 1
-- loop through the pages
repeat with page_num from 1 to (count pages)
tell page page_num
-- get the images on this page
set page_images to its images
-- and loop through them
repeat with i in page_images
tell i
-- get the image's position and dimensions so we can work out where to place the caption
set {x, y} to its {width, height}
set {loc_x, loc_y} to its position
end tell
-- make a new text box
set image_caption_box to make new text item
-- set the parameters of the box
tell image_caption_box
set object text to "Image " & image_counter
set position to {loc_x, loc_y + y}
set height to 24
end tell
-- and increment the counter
set image_counter to image_counter + 1
end repeat
end tell
end repeat
end tell
end tell
Paste this into a new Script Editor document and click Run (use a copy of your document first, just in case :) )
The comments should give you an idea of what the script is doing.
As noted, there's no built-in automatic way to do this.
However, it may be scriptable.
The followed script looks at the front document and iterates through all the images in that document, adding a new text box below with the simple caption "Image " and the image number.
There are several caveats - the results may vary depending on page-based vs. document-based, due to the way the images are placed, but it should give you a good start.
tell application "Pages"
-- here's the image counter
set image_counter to 1
-- get the front document
tell document 1
-- loop through the pages
repeat with page_num from 1 to (count pages)
tell page page_num
-- get the images on this page
set page_images to its images
-- and loop through them
repeat with i in page_images
tell i
-- get the image's position and dimensions so we can work out where to place the caption
set {x, y} to its {width, height}
set {loc_x, loc_y} to its position
end tell
-- make a new text box
set image_caption_box to make new text item
-- set the parameters of the box
tell image_caption_box
set object text to "Image " & image_counter
set position to {loc_x, loc_y + y}
set height to 24
end tell
-- and increment the counter
set image_counter to image_counter + 1
end repeat
end tell
end repeat
end tell
end tell
Paste this into a new Script Editor document and click Run (use a copy of your document first, just in case :) )
The comments should give you an idea of what the script is doing.
Pages does not support this capability. It is a manual effort.
Microsoft Word will automatically sequence inserted images with Figure 1, ... Figure n captions. Pages was never designed to be a Word clone, so your hoping for Apple to suddenly change course and do this would be a stretch.
That's a nice touch, Camelot.
Too bad Apple emaciated the Pages Scripting Dictionary so that one cannot select the image and its accompanying Text caption box, then group them for subsequent combined movement (if desired).
> Too bad Apple emaciated the Pages Scripting Dictionary so that one cannot select the image and its accompanying Text caption box, then group them for subsequent combined movement (if desired).
Yeah... that could be possible via AppleScript to trigger UI scripting of command-option-G, but it would be nice to be able to do directly.
🥺
lets hope it will be available in the new Apple studio 🫠
How to add sequential numbers to images in Pages