Is it possible to make an index in an IWork Pages document?

By index I mean marking words as index worthy and at the end of the document having an alphabetical list of those words and the pages where they are mentioned. Much like any computer book out there.

link|improve this question

69% accept rate
feedback

2 Answers

I believe that this is possible, although not trivial to do with Applescript using Pages built in Applescript dictionary. It depends on exactly what sort of functionality / formatting etc. you need.

The following script might be a good starting point. In this case it searches for pages with the word "member" but you could change this to a dialogue, a list or whatever you found useful. The code is a little crude and not particularly quick but it does work.

set theSearchText to "member"
copy theSearchText to theOutputText
set theOutputText to theOutputText & "   "
set theCurrentPage to 0

tell application "Pages"
    tell document 1
        repeat with i from 1 to count of words
            set theText to text of word i
            if item 1 of theText is equal to "member" then
                set thePageNumber to the page number of the containing page of word i
                if thePageNumber is not equal to theCurrentPage then
                    copy thePageNumber to theCurrentPage
                    set theOutputText to theOutputText & ", " & thePageNumber as string
                end if
            end if
        end repeat
        return theOutputText
    end tell
end tell
link|improve this answer
feedback

I've never tried, but since index is associated with style, you can create a style called "word" that is identical to your body content style. Then you just have to create an index that list all the "word" content, and that's it.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.