Sublime Forum

Bracket Matching broken in Latex math mode

#1

Hi everybody,

I noticed that bracket matching is not working in LaTeX math mode (for example between $…$).
I guess this is connected to the fact that math mode is a sub-scope of string (string.other.math.tex)…
however math mode has very different “use-cases” than strings.
I could just go in the language definition and change the scope assignment but I do not know if this could break other things.
Any ideas on the best way of solving the problem? What would a better substitute for string as a scope?

Thanks!

0 Likes

#2

I have run into the same problem like you and I’m wondering if there is a fix
for this coming anytime soon?

Greets Janick

0 Likes

#3

Any luck on solving this problem? Not only does highlighting not work between “$ $”, it doesn’t work in equation/align either.

0 Likes

#4

Sorry to exhume such an old thread but this problem really annoyed me and I did not see any update on it.

judecrot’s suggestion to change the scope type in the tmLanguage files does work but breaks compatibility with other packages such as LaTeXTools.

A safer solution is to use the BracketHighlighter package. Since version 2 basic bracket highlighting in math mode is built-in. However it will by default (in the current latest version) only work in math environments such as “equation” “align” ,etc. It will not work in simple math mode delimited by $…$. The easy fix is to modify the settings file for the package and replace every occurrence of “string.other.math.block.environment.latex” by “string.other.math”.

It is also fairly easy to adapt the bracket matching to LaTeX cases where sequences such as “{” should be ignored, or to add highlighting for \begin{…} \end{…} constructs.

0 Likes

#5

Hey

Just got bitten by this in Sublime 3 :imp:
Not good for someone that got convinced just yesterday to buy it :frowning:

Any known fix?

Thanks
Alberto

0 Likes