Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:10:47+00:00 2026-06-17T21:10:47+00:00

I am trying to configure the TeXWorks editor to use the same syntax coloring

  • 0

I am trying to configure the TeXWorks editor to use the same syntax coloring as TeXMaker. However, TexWorks uses regexes to specify what should be coloured. Unfortunately it doesn’t have a default setting for math.

I want to match everything between $ and $,
everything between \[ and \],
everything between \( and \),
everything between $$ and $$. The latter is not very necessary because it’s rarely used in LaTeX documents.

It can also be more than one regexes to match all cases.

Of course \$ is escaped so I don’t want to match that, nor \\[ etc.

Then I also want to match everything between \begin{equation} and \end{equation}, but that is simple.

‘It cannot be done’ is a possible answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:10:49+00:00Added an answer on June 17, 2026 at 9:10 pm

    Try this PCRE regex:

    (?<!\\)    # negative look-behind to make sure start is not escaped 
    (?:        # start non-capture group for all possible match starts
      # group 1, match dollar signs only 
      # single or double dollar sign enforced by look-arounds
      ((?<!\$)\${1,2}(?!\$))|
      # group 2, match escaped parenthesis
      (\\\()|
      # group 3, match escaped bracket
      (\\\[)|                 
      # group 4, match begin equation
      (\\begin\{equation\})
    )
    # if group 1 was start
    (?(1)
      # non greedy match everything in between
      # group 1 matches do not support recursion
      (.*?)(?<!\\)
      # match ending double or single dollar signs
      (?<!\$)\1(?!\$)|  
    # else
    (?:
      # greedily and recursively match everything in between
      # groups 2, 3 and 4 support recursion
      (.*(?R)?.*)(?<!\\)
      (?:
        # if group 2 was start, escaped parenthesis is end
        (?(2)\\\)|  
        # if group 3 was start, escaped bracket is end
        (?(3)\\\]|     
        # else group 4 was start, match end equation
        \\end\{equation\}
      )
    ))))
    

    See this regex in action: https://regex101.com/r/wP2aV6/25

    Since this regex uses recursion it will handle nested mathematical expressions correctly.

    This works only on PCRE compatible regex engines. It requires some advanced features of regex engines, like negative lookbehind, conditional expressions and recursion which are not present in all regex engines.

    Unless you need something really simple then I would advise against using this regex and instead using a proper LaTeX parser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to configure log4j to use 2 appenders. Debug info should be
I'm trying to configure a PHP installation (5.4.3) with MYSQL (5.0.91) for use with
Trying to configure tigase to use hsqldb (hsqldb-1.8.0.9-1jpp.2) instead of derby (don't ask why,
I'm trying to configure my Rack app to use Memcache for sessions with Rack::Session::Memcache
I'm trying to configure a web application that can use client-side JavaScript for localization
I'm trying to configure Apache Tomcat to use SSL connection with client authentication (two
I am trying to configure cruisecontrol to use Tomcat rather than Jetty as its
I am trying configure a Django application to use mysql. I want to use
Iam trying to configure nutch for running multi-threaded crawling. However , Iam facing an
In trying to configure ServiceStack.net to use Ninject as its IOC, I am getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.