[texworks] syntax pattern for inmath

Stefan Löffler st.loeffler at gmail.com
Tue Feb 2 18:49:48 CET 2010


Hi,

On 2010-02-02 18:14, Alain Delmotte wrote:
> I'd like to have syntax-pattern for inmath expressions like $e=mc^2$.
> I have this:
>    limegreen    N      \$.+\$
> but if there are more than one math expression, everything is coloured
> between the first $ (of the first expression) and the last $ (of the
> last expression).

I suppose the regex mechanism is greedy by default, i.e. it matches
everything from the first to the last $ in your line.
You could try something like "\$[^$]+\$" (or possibly "\$[^\$]+\$")
without the quotation marks. I haven't tried this myself, though, this
is just a guess.

> Also I'd like this for the display-math expressions "on several lines".
> I have :
>    limegreen    N      \\\[((.*)\n?)+\\\]
> this works for a one line expression
> \[e=mc^2\],
> but not for
> \[
>
> e=mc^2
>
> \]
>
>
> Is this possible?

AFAIK, not at the moment. The syntax highlighter (as provided by Qt) is
line-based. I.e., lines are treated independently and are highlighted
independently. It may be possible to remember states across lines
(technical: store user-data for each block - QSyntaxHighlighter supports
such caching, IIRC), but this is not implemented yet.

HTH
Stefan


More information about the texworks mailing list