[texworks] \begin{document} in colour

Stefan Löffler st.loeffler at gmail.com
Wed Jan 20 13:05:01 CET 2010


Am 2010-01-20 01:44, schrieb kap4lin:
> On Mon, Jan 18, 2010 at 9:17 AM, Stefan Löffler <st.loeffler at gmail.com> wrote:
>   
>> [...]
> 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.
>   

Yeah, the code is based on regexps applied to one line ATM (similar to
sed). And yes, it was designed for LaTeX style keywords, AFAIK.

> 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.
>   

I agree that the usage is limited. Feel free to open a new issue on GC
so we don't forget.
However, the current approach is the simplest one (some would say it's
not so simple at all with the complex regexp syntax and all) possible.
Any other approach would probably require considerable amount of code
and would also make the style definitions more complicated. But if
anyone has a clever idea how this could be improved we'd all be happy ;).

Regards,
Stefan


More information about the texworks mailing list