Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

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
share|improve this answer

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.

share|improve this answer

Unfortunately, according to the Pages 09 User Guide and another site, the TOC collects only paragraph styles. This means you cant generate an entry for text in the middle of a paragraph, which is what most index entries refer to. You can theoretically mark your intended index entries–for example with white {curly brackets}, replace the brackets with paragraph marks in a style that goes into the TOC, create a TOC-that-looks-like-an-index, save it, and revert.

In practice, using find and replace to change a styled character into a styled paragraph break seems to turn both the preceding and the following text into the new TOC-recorded style. In ten minutes I couldn't make this replacement scheme work right, and then I realized: turning indexed words into paragraphs is going to be pushing later indexed words further down the page count, so except with a very short document or a very sparse index, you'll end up with TOC entries that give the wrong page.

What all of us word processor and spreadsheet users need is for Apple to design the interface, and Microsoft to engineer the functionality.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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