Does anyone have a syntax pattern for TeXworks’s syntax-patterns.txt that will correctly highlight Expl3 code? I.e., something that will recognize that the entirety of \cs_new:Npn is a command sequence—although highlighting the :Npn suffix differently might not be a bad idea.


1 Answer 1


I use a colour scheme based loosely on that from WinEdt's DTX submode (I used to use WinEdt). This is for editing .dtx files, and nowadays includes support for l3docstrip's @@ convention:


# comments
red        Y    \^\^A.*

# Guards
orange         N    %<(?:[A-Za-z0-9!\|]+|.)>
limegreen      N    %<\*(?:[A-Za-z0-9!\|]+|.)>
crimson        N    %</(?:[A-Za-z0-9!\|]+|.)>
darkviolet     N    %<@@=(?:[A-Za-z]+|.)>

# special characters
darkred        N    \^\^\^\^\^[0-9a-z]{5}
darkred        N    \^\^\^\^[0-9a-z]{4}
darkred        N    \^\^\^[0-9a-z]{3}
darkred        N    \^\^[0-9a-z]{2}
darkred        N    [$#^_{}&]
gray        N    ^%%.*
gray        N    ^%

# Macrocode
green        N    \\(?:begin|end)\{macrocode\}

# LaTeX environments
darkgreen    N    \\(?:begin|end)\s*\{[^}]*\}

# control sequences
blue        N    \\(?:[A-Za-z@:_]+|.)

The key line here is the last one, which does the highlighting request. Of course, this is just a case of getting the regular expression right (if only this were easy!).

  • I’d been using a version of this (without the @@-highlighting) based on an earlier answer of yours, and didn’t realize it already covered expl3. Thank you! Aug 5, 2012 at 4:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .