Table of content does not like org-roam link in header

Hi all,
In some bigger notes I use an auto-generated table-of-content to list my headers.
If a header contains a link to another note in its string then when I click on the table-of-content’s link to that particular header I get the message

No match - create this as a new heading? (y
or n)

even though the heading already exists! (If I press ‘y’ then it creates a copy of the header without the org-roam link to the other note)

How do I fix this please?

What are examples of headers that misbehave and those that behave as expected?

How do you auto-generate a table of contents?

:PROPERTIES: [...]
#+title: test
#+filetags:

* Table of Contents
     :TOC_5_gh:noexport:
  - i love ELECTRONICS
  - i also love file:../data/
  - my favorite https://org-roam.discourse.group

* i love ELECTRONICS

* i also love file:../data/test.jpg

* my favorite https://org-roam.discourse.group

I added a screenshot to see the links more clearly. ELECTRONICS is a link to another note.
When I click on the i love ELECTRONICS link on the table of contents then instead of just jumping to it I get a message: No match - create this as a new heading? (y or n)
All other links in the table of contents when clicked on just put the cursor on the correct heading even if those headings have other links in their string (here I put a link to a file and to an URL as examples of what works)

If you do M-x org-toggle-link-display, what do the links “electronics” and “i love electronics” look like?

It looks like to be able to work the auto-generated table of contents needs to have the electronics note id in it (which is not the case). How do we do that?

org-roam-node-insert can be used, I think.

I just tried and you can’t edit the auto-generated table of contents and insert the link. As soon as you save the file the table of contenfs ditches it. Plus that defeats the purpose of an auto-generated table of contents I’m afraid.

The package used is toc-org https://github.com/snosov1/toc-org

In fact I can reproduce it in this simpler manner using an internal link:

test #electronics

  • electronics

With org-toggle-link-display

test [[#electronics]]

  • [[id:b9173060-6293-4551-8a03-474c351639cd][electronics]]

When I click on the link after the word “test” on the first line I get the message No match - create this as a new heading? (y or n)

This is not a link that Org-roam uses, so the behavior you see is expected.

Then this means this package does not support Org-roam, I believe. You may need to talk with its developer as a feature request, perhaps?

Org-roam does not have a feature that lets you create a TOC automatically. Instead, typically, you would create an index node (or “map of concepts”) and create a link from a node to it. This way, if you see the backlinks from the index node, you will see all the nodes relevant to the index.

1 Like