Do the sites with the table of contents have any matching url parts? Like for example /blog? Then you could filter the trigger so it only fires when the anchors on pages that contain “specific-url-part” are clicked.
Another possibility would be if you name your event category or event action after a variable so the names are dynamically filled with whereever the anchor was clicked or what the attributed click text was. This looks like this in the tag configuration:
If Matomo can read those variables on your website, you should get an event report that could look like this.
Maybe this would also be a solution for you problem. With that, you could track on which page which anchor link was clicked.