• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a way to filter a TOC?

New Here ,
Aug 01, 2023 Aug 01, 2023

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:

1.JPG

 

This is the current setup of the TOC:

2.JPG

 

Cheers,

TOPICS
How to

Views

298

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Create another toc based on different styles. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

And how this will help? 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 02, 2023 Aug 02, 2023

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?

 

Para Styles used for the TOC SettingsPara Styles used for the TOC Settings

Capture d’écran 2023-08-02 à 11.12.20.png


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:

 

Capture d’écran 2023-08-02 à 11.18.26.png

(^/)  The Jedi

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

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... 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

… As (s)he will have to remeber to "update the TOC"!  😉

 

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2023 Aug 02, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

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.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.0 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Exactly my point - "set and forget". 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

LATEST

It works with a book of course.

 

For more, contact me in private!

 

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

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.

Mike Witherell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

quote

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.


┋┊ InDesign to Kindle (& EPUB): A Professional Guide, v3.0 ┊ (Amazon) ┊┋

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Sort of, by sorting out styles and filtering them yourself.

 

  • Get your Selection/Arrow tool, with no text selected.
  • Go to your Paragraph Styles panel and select the style you use for your table header. Click once on it to highlight the style.
  • Go to the Flyaway Menu at the upper right of the panel and select the Duplicate Style... flyaway menu command.
  • When the Duplicate Paragraph Style dialog box appears, name it [Whatever your style name is] - No ToC.
  • Unless you choose to change something, all other style attributes will be unaffected. Click the OK button.
  • Now, tag all your ToC offenders with your No ToC style.

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Already mentioned... 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 02, 2023 Aug 02, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines