[texworks] \begin{document} in colour

kap4lin kap4lin at gmail.com
Wed Jan 20 01:44:36 CET 2010


Hi,

On Mon, Jan 18, 2010 at 9:17 AM, Stefan Löffler <st.loeffler at gmail.com> wrote:
> Hi,
>
> Am 2010-01-18 08:09, schrieb kap4lin:
>> Not to hijack the thread but, I guess this is part of a bigger wish
>> list - syntax highlighting - is it possible to show the text inside
>> \textbf{...} in bold, is it possible to show anything inside
>> \textcolor{blue}{...} in actually blue, .... the later one can
>> actually be very useful in collaborative editing. I guess, I have
>> auctex in mind ;)
>>
>
> Syntax highlighting in principle is available for ages. It's available
> from the "Format -> Syntax Colouring" menu for each individual file or a
> default value can be set in the preferences. ATM, only schemes for LaTeX
> and ConTeXt are available in the sources, though. But it's fairly easy
> to define some of your own. Just take a look at the file
> configuration/syntax-patterns.txt inside your Tw config folder.
>
> Support for showing the text in bold (e.g. inside \textbf) has been
> added recently. The color for \textcolor commands is more difficult, as
> the styling currently can't depend on the text that is highlighted. But
> you could of course add style rules for your favorite colors individually.

This is great, although very limited in the sense that it "makes
sense" only for latex keywords. What I mean is this:

If there is a line break or a '}' in the _text_ then the font
style/color specification breaks down. And you don't expect either of
these in the keywords ;) I guess the styling/coloring works like sed -
one line at a time.

Example:

With the following definition in syntax-patterns.txt:
red         Y \\textcolor\s*\{red\}\s*\{[^}]*\}

The following works:
\textcolor{red}{This is in red}

But the following two don't:
(1)
\textcolor{red}{This should have been (line break here)
in red}

(2)
\textcolor{red}{This also should have been in red: $\{a,b\}$}


I think these situations are too common and unfortunately cannot be
handled by regex. Hence the usage is very limited.

-- 
Regards
Kap4Lin
--------------------------------------
http://counter.li.org  #402424



More information about the texworks mailing list