Home Download Buy Blog Forum Support

Bracket Matching broken in Latex math mode

Bracket Matching broken in Latex math mode

Postby judecrot on Sat Jun 30, 2012 10:40 pm

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?

Posts: 8
Joined: Sat Jun 30, 2012 10:28 pm

Re: Bracket Matching broken in Latex math mode

Postby ph03 on Tue Jul 24, 2012 9:09 pm

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
Posts: 3
Joined: Tue Jul 24, 2012 9:07 pm

Re: Bracket Matching broken in Latex math mode

Postby AGS on Wed Oct 10, 2012 4:08 pm

Any luck on solving this problem? Not only does highlighting not work between "$ $", it doesn't work in equation/align either.
Posts: 32
Joined: Mon Aug 20, 2012 5:58 pm

Re: Bracket Matching broken in Latex math mode

Postby kragol on Mon Jun 24, 2013 6:00 pm

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.
Posts: 2
Joined: Tue Sep 04, 2012 5:27 pm

Re: Bracket Matching broken in Latex math mode

Postby ambs on Thu Nov 28, 2013 7:56 pm


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

Any known fix?

Posts: 5
Joined: Thu Nov 28, 2013 7:52 pm

Return to General Discussion

Who is online

Users browsing this forum: dpiche, Dragonmaster Lou, Google [Bot], madn3ss75, Yahoo [Bot] and 46 guests