Skip to main content
James Gifford—NitroPress
Brainiac
April 16, 2022
Answered

Identifying/Mapping TOC text anchors

  • April 16, 2022
  • 2 replies
  • 3173 views

Is there any straightforward way to identify the automatically generated text anchor for any TOC entry? I generate a TOC that works fine for both the print edition and the EPUB/Kindle side TOC. It creates 120-odd text anchors of the name style '_idTOCAnchor-34'.

 

In theory, I can do internal references using these anchors... but in practice, the order and numbering seem to be almost random. ...Anchor-1, for example, goes to the last section heading in the document, and I haven't been able to make any sense out of the numeric order.

 

So if I want to link to a section titled "End Material" on page 195, without going and setting a specific text anchor of known name, how do I identify that heading's TOC anchor number? (It seems with all the various menus and palettes and such, this should be much easier... but I'm stumped.)

 

This topic has been closed for replies.
Correct answer Peter Kahrel

The order is probably not random. The anchors must be added from back to front, and they are numbered ascending, so they appear to be in reverse order.

You can use this script to map anchors:

https://creativepro.com/files/kahrel/indesign/text_anchors.html

P.

2 replies

Community Expert
March 6, 2023

 a way to modify the script so that it can automatically rename the anchors based on the text of the paragraph they are anchored to

 

A separate script would make more sense.

 

that portion of the script doesnt seem to prompt

 

Not sure I understand what you mean here. What kind of prompt were you thinking of?

Inspiring
March 7, 2023

Sorry, i think i misread his post and thought a second dialog would pop up after selecting which TOC style you want.

Peter KahrelCorrect answer
Community Expert
April 16, 2022

The order is probably not random. The anchors must be added from back to front, and they are numbered ascending, so they appear to be in reverse order.

You can use this script to map anchors:

https://creativepro.com/files/kahrel/indesign/text_anchors.html

P.

New Participant
September 16, 2023

@Peter Kahrel 

Thank you for sharing the script. I downloaded and installed it. It worked beautifully the first time!

However, each successive time after that, something appears to "shift" in the window the script opens. First time, all the buttons on the right were missing.

Second time, the space above the labels increased (marked in green in the attached png).

Any idea what's going on? How to fix it?

New Participant
September 21, 2023

I sometimes get reports about problems with the interface, though I never see those myself. I notice that I updated the script (slightly), and I have now uploaded that update. (I can't remember what changed, must have been something minor.)

 

If the problem persists, first try to resize the script's window to something very small. Click and drag from the bottom-right up and left. That way you force the window to redraw, which may fix the problem.

 

If taht doesn't work, delete the text_anchors.txt file. It sits next to the jsx file in the Scripts panel.

 

I hope that either of these suggestions helps.


@Peter Kahrel:

Downloaded the script ... thank you.

The issue of window shifting occurs repeatedly after the first time. The solution that has worked so far is clicking & dragging from the bottom-right to the left. In the process, the window does get resized and appears as-expected.

Thank you for the script & the suggestion.