Skip to main content
PrintHouse
Inspiring
April 24, 2018
Question

TOC without 'A' and 'The' determiners?

  • April 24, 2018
  • 4 replies
  • 1324 views

Hello,

Is it possible to exclude both 'A' and 'The' determiners from a generated table of contents?

Fore example, titles in a book might be:

'A Guide to Programming in JavaScript', 'A Very Merry Christmas', 'The Meaning of Life', 'Big Bang Theory'

I would love to have a TOC looking like this (in alphabetical order):

Big Bang Theory ........................... 24

Guide to Programming in JavaScript, A ..... 75

Meaning of Life, The ...................... 12

Very Merry Christmas, A ................... 56

Is there a clever way to do it (semi) automatically?

This topic has been closed for replies.

4 replies

Peter Kahrel
Community Expert
Community Expert
April 24, 2018

Index is the way to go. What Ariel suggests (if I understand him correctly) is to move any articles to the end of qualifying entries, generate the toc, then move any articles back. That produces a correctly sorted toc with articles after the entries. But it looks like a risky undertaking, especially compared with Jongware's index method. Besides, what Printhouse showed looks more like an index than a toc, and maybe Printhouse, like so many people, simply confused toc and index.

By the way, Theunis, interesting match() you have there:

.match('^'+articles+' ', 'i')

didn't know you could do things like that.

PrintHouse
Inspiring
April 24, 2018

Thanks, I haven't confused anything I'm using a TOC because there are several similar TOCs in different places in the book based on different categories of titles. Some in alphabetical order, some not. Besides, I believe you can have just one index per document, so that won't cut it. Don't ask why, that's how the book was designed before dawn of time. I'm just trying to ease my pain of putting it all together

Having said that, I now think I should have a script that I would use to update a TOC instead using the menu command. That script would: update a TOC, run GREP on it to find The, A, An like so ^(The) ((?<=^The ).*?(?=\t)) and move them before TAB like so $2, $1, then (optionally) sort the whole TOC alphabetically.

What do you think?

TᴀW
Legend
April 24, 2018

Perhaps the solution is to generate the TOC once, modify as needed once, and convert all the page numbers to live cross-references which will update automatically?

That way you will not need to worry about losing your manual work and the page numbers will always be correct.

(And if that is it, then check out my [not free] https://www.id-extras.com/products/livetoc), which does just that.)

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Jongware
Community Expert
Community Expert
April 24, 2018

There is – at least for an index, not for a table o' contents. If you are referring to a table of contents after all, then this will not work.

Before generating the index, run this short JavaScript. It modifies your current Index Entries in place, moving definite and indefinite articles at the start of each topic to the end. Then, generate your index as usual.

indexTopics = app.activeDocument.indexes[0].topics.everyItem().getElements();

articles = ['the','a','an'];

for (i=0; i<indexTopics.length; i++)

{

for (j=0; j<articles.length; j++)

{

  if (indexTopics.name.match('^'+articles+' ', 'i'))

  {

   indexTopics.name = indexTopics.name.substring(articles.length+1)+', '+indexTopics.name.substring(0,articles.length);

   break;

  }

}

}

Result: left, an index generated before running the script. Right, when afterwards.

vinny38
Legend
April 24, 2018

Looks more like a job for the Index feature than for a TOC.

Hiding the determiners is not difficult using grep style (see example below), but placing them at the end can't be achieved using TOC, afaik...

PrintHouse
Inspiring
April 24, 2018

Thanks.

I've got about 400 titles, so any manual marking of words in titles is a no-no. Same for hiding the determiners – the would still sort wrong.

I'm growing to think it's a job for a script: find determiners with GREP, move them before Tab with added comma in TOC and apply sorting afterwards.

TᴀW
Legend
April 24, 2018

You could save a GREP query (not a GREP style) that would move "a" and "the" from the beginning of an entry to before the tab in the entry, adding the a comma and space.

Then, whenever you update the TOC, just run that GREP query. Wouldn't take more than a few moments, but you'd need to remember to do it.

Ariel

id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
vladan saveljic
Inspiring
April 24, 2018

for begeening take a look here

Create an index in InDesign

...

To change the way an entry is sorted in the final index, use the Sort By boxes. For example, to sort the topic de la Vega under V (instead of D), you would type Vega in the Sort By box and de la Vega in the Topic Level box.

....