You can also define your rules for syntax highliting in a syntax-patterns.txt file in your TeXworks\configuration folder. After that you choose your syntax coloring from the top menu: Format -> Syntax Coloring<br><br>Below are some examples of what I have in mine syntax-patterns.txt. You can use some of these as a base for new ones or just to see how it works. And setting colors is of course up to you as well :)<br>
<br><br>[LaTeX_Gralcio]<br># special characters<br>darkred N [#^_{}&]<br><br># LaTeX refs<br>cyan/black;B N \\(?:ref|eqref)\s*\{[^}]*\}<br><br># LaTeX cite<br>purple/lavender N \\cite\s*\{[^}]*\}<br>
<br># LaTeX footnotes<br>black/lavender N \\footnote\s*\{[^}]*\}<br><br># LaTeX begin/end document<br>red/black;B N \\(?:begin|end)\s*\{document\}<br><br># LaTeX environments<br>black/moccasin;B N \\(?:begin|end)\s*\{[^}]*\}<br>
<br># LaTeX sections <br>black/red;B N \\chapter\s*(?:\[[^]]*\]\s*)?\{[^}]*\}<br><br># LaTeX sections <br>yellow/brown;B N \\(?:section|subsection|subsubsection)\s*\{[^}]*\}<br><br># LaTeX labels<br>greenyellow/black;B N \\(?:label)\s*\{[^}]*\}<br>
<br># LaTeX packages<br>black/moccasin;B N \\usepackage\s*(?:\[[^]]*\]\s*)?\{[^}]*\}<br><br># LaTeX definitions<br>black/cyan;B N \\(?:def|let|newcommand|renewcommand)\s*\\[^{^[]*<br><br># LaTeX commands\environments' renewals<br>
black/cyan;B N \\(?:re|)new(?:command|environment|theorem)\s*\{[^}]*\}<br><br># control sequences<br>mediumblue N \\(?:[A-Za-z@]+|.)<br><br># Math Inline <br>darkmagenta;B N \$[^$]*\$<br><br># comments<br>
steelblue;I Y %.* <br><br><br><br>Cheers,<br>G<br><br><br><div class="gmail_quote">2011/7/14 Paul A Norman <span dir="ltr"><<a href="mailto:paul.a.norman@gmail.com">paul.a.norman@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Apologies I should have pasted that - green will not show properly<br>
with black, try<br>
<br>
Black/LawnGreen;B n EVIDENCE<br>
<br>
or<br>
<br>
Black/LawnGreen;B y ^.*EVIDENCE.*$<br>
<br>
Also you can use this yet to be completeed dialogue,<br>
<br>
<a href="http://twscript.paulanorman.com/downloads/?InsertColour" target="_blank">http://twscript.paulanorman.com/downloads/?InsertColour</a><br>
<br>
For your colour names (use SVG only).<br>
<font color="#888888"><br>
Paul<br>
</font><div><div></div><div class="h5">On 14 July 2011 13:11, Paul A Norman <<a href="mailto:paul.a.norman@gmail.com">paul.a.norman@gmail.com</a>> wrote:<br>
> Hi Carlo,<br>
><br>
> "Try activating the following menu item: `Window->Show->Tags`. This<br>
> will add a sidebar that will allow you to jump around to the<br>
> sections/subsections/etc of your document. Hopefully it provides some<br>
> of the functionality you are looking for."<br>
><br>
> In your editing document you can put:--<br>
><br>
> %: Evidence One starts here<br>
> EVIDENCE One<br>
><br>
> and "Evidence One starts here" will show in the tag window that<br>
> Charlie has pointed you to.<br>
><br>
> Its the %: at the beginning of the line that makes that manual kind of<br>
> entry show in your tag window, but not in your output (pdf).<br>
><br>
> % tells TeX to ignore the rest of the information on that line, so you<br>
> can write comments to your self. %: makes the remarks appear in your<br>
> tag window.<br>
><br>
> Clicking on entries in the Tag Window jumps you to the area of the editor.<br>
><br>
> You can get other things to automatically show in your Tag windows by<br>
> using regular expressions in<br>
> tag-patterns.txt (back up the file first)<br>
> have a look in it to see how the tag-patterns are done.<br>
><br>
> It can be got to from your<br>
> Scripts menu, choose "Scripting Tex Works" / Show Scripts Folder, go<br>
> up one directory,<br>
> then into the directory called configuration.<br>
><br>
> Also highlighting and colour changes and styling: bold, italic, and<br>
> underlining, can be achieved by editing<br>
> syntax-patterns.txt<br>
> in the same folder as described above.<br>
><br>
> You will notice sections there, e.g. [Latex]<br>
><br>
> You can either put things in [Latex] section or make a new section at<br>
> the end of another section, perhaps [Thesis] and write your<br>
> syntax-patterns in there - then choose which scheme you want to use in<br>
> your editing document under the menu on Format/ Syntax Colouring.<br>
><br>
> I'd recommend considering using the existing [Latex] section for what<br>
> you are doing. But remember to backup these files before changing any<br>
> of them, so that you can revert back to them if necessary (if things<br>
> go badly wrong in your editing of them :)<br>
><br>
> Put any often repeated things, or regular expressions for patterns of<br>
> text that you want highlighted/coloured/styled the same way.<br>
><br>
> For example you could add a line<br>
><br>
> Black/Yellow;B n ^[^\s]*:<br>
><br>
> Which would at least highlight anything that starts as one word and<br>
> ends with a colon: (i.e. with no spaces in it).<br>
><br>
> Black - foreground colour<br>
> /Yellow - background-colour<br>
> ;B - bold<br>
> n - No spell checking inside described area (y for spell checking)<br>
> ^ start of string (in Tw editor context - here a line)<br>
> [^\s] here the ^ inside [] means essentially anything but \s which<br>
> means a space or a tab etc<br>
> * any number of the immediately preceding - here meaning any number of<br>
> non space items<br>
> : a literal colon<br>
><br>
> Try just the following it might be enough<br>
><br>
> Black/Green;B n EVIDENCE<br>
><br>
> or<br>
><br>
> Black/Green;B y ^.*EVIDENCE.*$<br>
><br>
> For a whole line, with EVIDENCE in it, at a time. with spell checking.<br>
><br>
> Afaik, none of the changes that you might make to either<br>
> tag-patterns.txt or syntax-patterns.txt will take effect until you<br>
> completely restart TeXworks, which is a bit difficult for testing!<br>
><br>
> Regular expressions are a bit to get your head around unless your<br>
> brain is naturally wired for that kind of thing, but you can get there<br>
> with trial and patience, and then its just like when learning a<br>
> foreign language, it all suddenly starts to click into place.<br>
><br>
> Regular expressions are also used for searches as an optional and<br>
> sometimes optimal way of finding things in many computer applications<br>
> (and in TeXworks), so they are worth learning to some extent,<br>
> depending upon your needs<br>
><br>
> Alain Delmotte and Stefan Löffler, and others have made a real effort<br>
> to give people a kick start in the TeXworks manual, which you can open<br>
> form your Help menu. In there you will find introductions and more<br>
> information on many of these things (and more!), and pointers to<br>
> TeXworks wiki entries for more information.<br>
><br>
> For regular expressions, even help information based around web pages<br>
> will be of help, or use testing modules provided on the web to try<br>
> out your regular expressions first.<br>
><br>
> Paul<br>
><br>
> On 14 July 2011 10:27, Herbert Schulz <<a href="mailto:herbs@wideopenwest.com">herbs@wideopenwest.com</a>> wrote:<br>
>><br>
>> On Jul 13, 2011, at 4:40 PM, Carlo Marmo wrote:<br>
>><br>
>>> Thank you.<br>
>>> Last question, I promise. Where can I find some examples of syntax<br>
>>> highlighting, in order to figure out what kind of problems it is design to<br>
>>> solve?<br>
>>> Carlo<br>
>><br>
>> Howdy,<br>
>><br>
>> Open any latex file and see what it does.<br>
>><br>
>> Good Luck,<br>
>><br>
>> Herb Schulz<br>
>> (herbs at wideopenwest dot com)<br>
>><br>
>><br>
>><br>
>><br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Z powa¿aniem,<br>Grzegorz Popek<br><a href="mailto:grzegorz.popek@pwr.wroc.pl">grzegorz.popek@pwr.wroc.pl</a><br>Instytut Informatyki (I-32)<br>Politechnika Wroc³awska<br>