How can I see list of labels?

When one defines a new label it is better to see the list of already defined labels to avoid problems with references. Does this option exist In TexMacs?

As far as I know there isn’t. I agree that it would be nice.
As partial workaround, you can look for duplicate labels:

The “Duplicate labels” options under the search lens menu become active if there are duplicate labels; the disadvantage is that you have first to define the label, and only then you can see if it exists already or not.
Another possibility is to “cycle through all of the tags” (the “up” and “down” buttons at the bottom of the tool ribbons); here the disadvantage is that it takes more time than having a list under your eyes.

1 Like

Thank you for your reply. I already found these two possibilities. I worked with Latex many years by using TexMaker and TexStudio (fork of the TexMaker). In those programs there is very useful tool for works.
The same for command \cite . How suggest this idea for maintainers?

Joris van der Hoeven reads the mailing list, so you could try there.
You could try also submitting the request through the bug tracker of Savannah: start from, you must have a Savannah account and be logged in. Under “Item group” you can classify your posting as “Wishlist”.

When you are editing a reference and press the Tab key to autocomplete a list of possible completions appears in the footer:

1 Like

Perhaps a popup menu, like in the figure of @JoePass, is more handy: when the completions are many the footer will be too small.
TeXmacs has widgets, that can be implemented through Scheme, and so by users, without recompiling the program (manual I have a feeling that widgets could be a good way to have the list; the first step to do it would be to figure out where the completion information is (I do not promise that I am going to do it but I am curious enough that I will look more into it).

It seems you can get a list of labels by doing

(search-labels (buffer-tree))

From Scheme manual, 6.3. Displaying lists and trees
So one gets the list in a widget

(tm-widget (test-enum-labels) 
  (enum (display* "label " answer "\n") 
(map cadr (map tree->stree (search-labels (buffer-tree)))) "labels ..." "12em")))

and then

(show test-enum-labels)

Now I would have to get this widget (perhaps in slightly larger form) to appear when the user right-clicks inside the reference field. In place of (display* "label " answer “\n”) we want a command to insert the label at the place where the user clicked. I have to postpone, but it feels possible.

1 Like

I have written the following

(tm-widget (enum-labels) 
  (enum (insert answer) 
(map cadr (map tree->stree (search-labels (buffer-tree)))) "labels ..." "24em"))

(tm-menu (texmacs-popup-menu)
  (:require (and 
             (tree-is? (focus-tree) 'reference) 
             (tree-is? (tree-outer (focus-tree)) 'inactive)))
      ("Show labels ..." (show enum-labels)))

They work when I execute them from Scheme.and also when I put them in the personal initialization file.
Right click inside an inactive reference and you will get as the last item in the popup-menu the entry “Show labels …”; click on that and the list of labels will appear. Choose a label, and it is inserted inside the reference markup.

I cannot yet close automatically the widget once I have clicked on a choice (I have tried close and delete, which do something else, and hide, which does not exist).

  • I am not confident that the references to the tree (focus-tree) are correct, they work in my tests.
  • The detection of “being in a reference” works if there is only text in the reference field (usual). If there are other environments, it will fail. A more complex construct would succeed (checking the outer trees), but since usually in the reference fields one does put only text, perhaps it is ok).

Said this, @JoePass, could you please check if it works for you?

1 Like

Yes, they appeared in the footer. But I can not select references by clicking ref in the footer, and sometimes I have 50 or more references.

Sorry @pireddag, please tell me, in which file I have to put this code. What is a " personal initialization file"? My system is Linux Mint 20. Personal files are in the folder .TeXmacs.


Create the file if it does not exist.

Sorry, I have found it. Excellent, it works. Couple remarks. 1) I have label eq:m<mu. In the list of references, it has form eq:mmu. I use the Russian version and I have a Russian word “меньше” instead of “smaller”. 2) Also, in the list the references for literature appear but with the additional bib. I have a paper in the literature with the name blah-blah. In the list, it has the form bib-blah-blah. Maybe possible make code that makes the difference between \ref and \cite commands? For \ref, the list of references appears, and for \cite the list if citations appear? 3) This code does not work for \eqref command, but for \ref only.

For command \cite, the problem is already solved the right click gives “search in database”.

Here I have to figure out how (search-labels (buffer-tree)) works. Maybe I will succeed. Please give me some time.

Here I think I know what you mean (at least approximately) but I am too far away from understanding the code to be able to answer. Maybe one of the developers can help (we have to invoke them: @mgubi).

In any way, thank you very much. I’m sure that it will be much better to include this option in the future versions of the Texmacs.

TeXmacs is reasonably easy to extend by users. In my opinion, it takes now some documented and well-guided examples so that more people will write extensions. I hope that the blog at will help as a place where people can write small tutorials and also document/publicize good extensions that they write.

For this example, I will need to learn a bit more to be able to write about it: I have “hacked” it rather than “programmed” it. But: step by step.

Thank you for your reference. I made as noted in that cite " To automatically regenerate all the web pages use Tools->Web->Create/Update web site within TeXmacs and choose src/ as source and docs/ as destination directories. Once the repository is pushed on github it becomes visible." But I do not understand how to use these notes in TeXmacs.

If I understand well your question: I did not give the link to the website so that you may find in it something to use for writing references, but to say that I hope that with time it may become a collection of user-written extensions. In this way one would not have to always ask the developers for features (like in this case the list of labels), but could find them in the extensions written by users.
Of course this is my way of seeing things.

I re-read your initial post and modified the code. Now the contextual menu has an entry for label search when you are writing a label as well. Here is the code (pls. substitute it in place of the one I wrote above in this thread):

(tm-widget (enum-labels) 
  (enum (insert answer) 
(map cadr (map tree->stree (search-labels (buffer-tree)))) "Choose label ..."

(tm-menu (texmacs-popup-menu)
  (:require (or
	      (tree-is? (focus-tree) 'reference) 
	      (tree-is? (tree-outer (focus-tree)) 'inactive))
	     (tree-is? (focus-tree) 'label)
	     (tree-is? (tree-outer (focus-tree)) 'inactive))))
  ("Show labels ..." (show enum-labels)))

I did not yet figure out how to exclude the labels of the bibliography entries from the list. I will let you know what happens.

1 Like