Searching in the math mode does not find all instances

If I search a symbol in math expressions, I can find only some of the instances but not all of them in the document. Some symbols like the real part notation \Re can’t be found at all. Is this a known bug?

Hi @Jade, thanks for the report. I can’t reproduce this, I’m afraid, I can search for \Re in equations.
Could you provide some more details? What version of TeXmacs are you using on which OS? Does it happen always? It would be great if you could provide a sample document.

ALso, did you expand the search tool to a separate window? The search in the toolbar is much more limited.

I have expanded the search tool. I am running version 2.1 on Mac OS 12.0.1 with M1 MacBook Air. I tried the simplest example: the document has nothing but a single \Re. Then I can’t find it no matter it is in the text mode or in the math mode.

BTW, the right-click menu has scrambled text in my M1 MacBook and also iMac.

Do you start the search tool with the cursor inside math mode?

Yes, I started the search with the cursor inside the math mode.

This is not a bug, but an intended behavior being mode-dependent. See the user manual (https://www.texmacs.org/tmweb/help/book.en.html) section 8.2 the second paragraph.

I read that part of the manual. I am already inside the math mode when I start the searching. For example, with the cursor inside \Re a, I can find a but not \Re.

I deleted the .TexMacs directory and now I can find \Re (don’t know why). However, it remains to be a problem to find all instances of a math symbol or expression. After some exploration, I found a possible cause. I created the tm file from importing a latex file, and I have used my own definitions, such as \al for \alpha. Then I can’t find this \alpha. How to avoid this issue when importing latex file?

Yes, the search tool will give results for the tags in the document, so if you have \al, it won’t give a hit for \alpha.

You can use Search & Replace and replace all \al tags by \alpha.

1 Like

This works! So the importing will not expand the macros such as \newcommand{\al}{\alpha}? I found another problem. I can’t find a simple expression like f(x) if it’s imported from LaTeX. I did this experiment: create a LaTeX file with just one line: $f(x)$. Then import it to TeXmacs. Then I can’t find f(x)!. I can find f, x, but not f(x) or (x). So I typed f(x) directly in TeXmac in math mode and check the difference between these two. When I put the cursor just after x, I found a difference in the right corner of the window:

  • the imported one: math around x

  • the typed one: math around* x

Maybe that’s the reason I can’t find the imported one using the search tool. What’s the difference? How do we get around this issue when importing LaTeX?

around is the variant of parentheses that don’t scale with the size of the contents. You can switch between them with the icon showing two parentheses with an updownarrow inside.

They are imported as such because that’s how the standard LaTeX parentheses work. If you import $f\left(X\right)$, then you get the size-matching variant.

You could remove them by doing Search and Replace with wildcards. Go into the S&R tool type \around and Enter, then press Ctrl-1 to insert a wildcard. Then go to the replace field, enter parentheses and put the wildcard inside.

The \around tag works in the Search dialog (find the parentheses), but not in the S&R dialog (finds nothing, so the replace button does nothing).

PS: Since a document may contain both variants of the parentheses/brackets/braces, it would be nice if the search and S&R tool can find both variants if one enters (,[,{ in the dialog.

1 Like

Yes, it’s quite tricky to get the right \around tag into the S&R tool. I suggest to copy/paste it from the document.
More complex search and replace can be done using Scheme (e.g. using regular expressions, see Help->Scheme extensions -> TeXmacs extensions...->).

1 Like

It is doable in my setting. See the screenshot below

By the way, it also matches without around explicitly inputted. In both cases, you have to de-select both Enforce brackets to match and Use extensible brackets.

3 Likes