[texworks] HELP with Tw 0.4.3 syntax highlighting

Carlo Marmo carlo.marmo at gmail.com
Thu Jul 14 14:39:13 CEST 2011


Thanks Grzegorz, that's a very good starting point for me!
Carlo

2011/7/14 Grzegorz Popek <gralcio at gmail.com>

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


More information about the texworks mailing list