Background colouring in TeXworks

The current experimental builds of TeXworks now include the ability to alter the background colour of text, as well as the foreground. At the moment, you can’t do this in an additive fashion (varying the two independently). However, it does make it easy to have something a bit nicer than the default bright red for comments. I’ve altered my syntax-patterns.txt file for LaTeX to read

[LaTeX]
# special characters
darkred		N	[$#^_{}&]

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

# LaTeX packages
darkblue	N	\\usepackage\s*(?:\[[^]]*\]\s*)?\{[^}]*\}

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

# comments
black/lightgrey			Y	%.*

You’ll see that the last line includes two colours, so I get black on light grey for comments.

4 thoughts on “Background colouring in TeXworks

  1. Hi, thanks for the post that’s very helpful.
    But there is one thing I don’t understand. What do the Letters N or Y mean? Couldn’t find anything in the wiki.

  2. Hi, thanks for the post that’s very helpful.
    But there is one thing I don’t understand. What do the Letters N or Y mean? Couldn’t find anything in the wiki. I am asking because I would like to add something for “TODO” or “FIXME”.

  3. Hello David,

    This is a flag for spell-checking. So it’s turned on for comments (which will mainly be text), but off for command names and so on.

    Joseph

  4. At your hint, I made an extension of this file for emphasizing tasks. Perhaps it helps.

    Just add two lines before the comments line:

    # tasks
    red Y %TODO:.*

Leave a Reply