Skip to main content
Bedazzled532
Inspiring
December 24, 2024
Answered

How to make a tabular TOC (Table of Contents) automatically in Adobe Indesign

  • December 24, 2024
  • 2 replies
  • 1838 views

How do I make a TOC automatically like the one attached in the screenshot ?

Thanks

This topic has been closed for replies.
Correct answer Robert at ID-Tasker

@Robert at ID-Tasker I tried you method. Its great but the only problem would be when I make any update on the TOC. I will have to do the steps again.  Any suggestions using post toc steps using script ? Thanks


@Bedazzled532 

 

Not saying that I'm (very) good in JavaScript'ing 😉 but "yes, I can" 😉

 

app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
app.findTextPreferences.findWhat = "^p";
app.changeTextPreferences.changeTo = "^t";
app.findTextPreferences.appliedParagraphStyle  = "TOC Chapter";
app.selection[0].parentStory.changeText();
app.selection[0].parentStory.paragraphs.itemByRange(app.selection[0].parentStory.paragraphs[1],app.selection[0].parentStory.paragraphs[-1]).convertBulletsAndNumberingToText();
app.selection[0].parentStory.paragraphs.itemByRange(app.selection[0].parentStory.paragraphs[1],app.selection[0].parentStory.paragraphs[-1]).convertToTable();

 

After you refresh your TOC - you need to select its TextFrame and run the above script. It works on the ParentStory - so you don't have to reflow it in case there is an overset.

There is no error checking - code would be few times longer - but there aren't many trip hazards.

 

Attached is your INDD file with my modifications - so you can check TOC setting and get ParaStyles.

 

 

 

And here is a sample Task for my ID-Tasker - pretty much the same steps as you would've to do manually and what script above is doing - but you don't have to be a coder:

 

 

2 replies

Dave Creamer of IDEAS
Community Expert
Community Expert
December 26, 2024

I would take a simplier approach, being simple minded myself...

Just build a regular TOC with paragraph rules and put the verticle rules manually behind it. The verticle rules might have to be adjusted for height, but that wouldn't be hard based on the example. 

 

David Creamer: Community Expert (ACI and ACE 1995-2023)
Robert at ID-Tasker
Legend
December 26, 2024
quote

I would take a simplier approach, being simple minded myself...

Just build a regular TOC with paragraph rules and put the verticle rules manually behind it. The verticle rules might have to be adjusted for height, but that wouldn't be hard based on the example. 

 

By @Dave Creamer of IDEAS

 

Yes, but in this case - TOC is build from two Paragraphs - so some post-processing is needed anyway.

 

Even if you mean to use the formatting already created by OP - and just add vertical lines to simulate table look - then their height would have to be adjusted every time number of entries change or their length.

 

Dave Creamer of IDEAS
Community Expert
Community Expert
December 26, 2024
quote

- then their height would have to be adjusted every time number of entries change or their length.


By @Robert at ID-Tasker

I think that is what I said. 😁

David Creamer: Community Expert (ACI and ACE 1995-2023)
Willi Adelberger
Community Expert
Community Expert
December 24, 2024
  1. Make a toc based on paragraph styles.
  2. Convert the toc into a a table. 

To make it faster, save the table style to reapply it after changes. You have to generate it again and apply these steps after any change. 

Bedazzled532
Inspiring
December 24, 2024

@Willi Adelberger Thanks for the reply. If you notice the TOC  entry has following format:

SlNo.      Chapter Name     Chapter Author      Page Number.

Serial number will not be a problem. I have made Numbering para style for TOC entry. How do I include "Chapter Author" in the same line ? Currently I have given a separate style to Chapter Author and changed its leading to 0.

Bedazzled532
Inspiring
December 24, 2024

@Willi Adelberger I have reached 98% close to the example. I just need a vertical line next to the serial number. This will make this TOC 98% automatic. No need to convert it to table.

 

After generating the toc, will have to run grep shown in the screenshot.

 

I have shared the toc idml and current screenshot.