Copy link to clipboard
Copied
Hey all!
Quick question... is there a way to 'filter' a TOC?
I have a list of figures set up at the back of my current project that is listing all figures throughout the document. This has been set up using paragrah styles.
Currently, I'm using a custom TOC formated to show the list of figures divided by what heading they fall under. The trouble is the TOC is also listing chapters of the document that don't contain any figures. Is there a funtion that will allow me to filter any headings without figures from showing? ie, have the TOC only show chapter headings that have figures?
This is how my TOC currently looks. I don't want any headings with the 'x' from showing as these chapters contain no figures:
This is the current setup of the TOC:
Cheers,
Copy link to clipboard
Copied
As the TOC is generated automatically - there is no direct way to filter what will be created.
I think the only way would be if you use a different ParaStyle for the Chapter's title that doesn't have any Figures.
Copy link to clipboard
Copied
Create another toc based on different styles.
Copy link to clipboard
Copied
And how this will help?
Copy link to clipboard
Copied
"As the TOC is generated automatically …" is totally false: an InDesign TOC is generated by a click (menu or K-shortcut).
So the good question would be: What click do you prefer?
1 click:
/*
_FRIdNGE-0740_UpdateTOC.jsx
Script written by Michel Allio [02/08/2023]
*/
var myDoc = app.activeDocument;
var myStories = myDoc.stories, S = myStories.length, s;
for ( s = 0; s < S; s++ ) {
if ( myStories[s].storyType == StoryTypes.TOC_STORY ) {
myStories[s].textContainers[0].select();
app.menuActions.itemByID(71442).invoke();
// Grep 1
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "^.+\\r(?=.)";
app.findGrepPreferences.appliedParagraphStyle = "Chapter_Toc";
app.changeGrepPreferences.changeTo = "";
myDoc.changeGrep( );
// Grep 2
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "^.+\\z";
app.findGrepPreferences.appliedParagraphStyle = "Chapter_Toc";
app.changeGrepPreferences.changeTo = "";
myDoc.changeGrep( );
app.findGrepPreferences = app.changeGrepPreferences = null;
app.selection = null;
}
}
alert ( "TOC Updated! …" )
Result:
(^/) The Jedi
Copy link to clipboard
Copied
"Automatically" by InDesign based on the selected Styles.
And OP will have to remember to run your script every time there are some changes in the document...
Copy link to clipboard
Copied
… As (s)he will have to remeber to "update the TOC"! 😉
(^/)
Copy link to clipboard
Copied
Thank you!
I'm keen to give this a try at work tomorrow. One small issue... How do I use the script? 😆
Also, would this script work with a book?
Cheers
Copy link to clipboard
Copied
Using different styles for the headings you want to include and exclude is much simpler and more 'organic,' IMVHO. You can set everything up so that normal TOC generation — which, yes, I'd classify as 'automatic' — will create a clean, new TOC including just the headings you want, while leaving the variant headings apparently identical for all other purposes.
Not every task requires an effing script.
Copy link to clipboard
Copied
Exactly my point - "set and forget".
Copy link to clipboard
Copied
It works with a book of course.
For more, contact me in private!
(^/)
Copy link to clipboard
Copied
Two things continue to catch and trip up the new user of the ToC generator:
1. More Options should be clicked to open it up
and
2. ToC presets are still called styles, which confuses the user in a dialog box where you choose *styles* to apply another *style* which might also make some auto-generated *styles* and save the whole thing as a ToC *style* but which is actually a named preset.
This continues to be confusing to new learners and experienced users alike.
Copy link to clipboard
Copied
2. ToC presets are still called styles, which confuses the user in a dialog box where you choose *styles* to apply another *style* which might also make some auto-generated *styles* and save the whole thing as a ToC *style* but which is actually a named preset.
This, in spades and with flashing neon pointers. TOCs are an entire schema in themselves, one dependent on careful assignment of several actual styles, and viewing each setup as a "style" is a self-defeating situation.
Copy link to clipboard
Copied
Sort of, by sorting out styles and filtering them yourself.
When you run your next ToC for the document(s), the No ToC style won't make the trip. Easy Peasy.
Hope this helps,
Randy
Copy link to clipboard
Copied
Already mentioned...
Copy link to clipboard
Copied
But not with a step-by-step process to accomplish the task ... as it is above.
Sometimes just do that thang isn't a sufficient answer.