[texworks] \begin{document} in colour

Stefan Löffler st.loeffler at gmail.com
Wed Jan 20 19:04:36 CET 2010


On 2010-01-20 18:39, kap4lin wrote:
> On Wed, Jan 20, 2010 at 7:05 AM, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> 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.
> Yeah, I realized that. I was thrilled at first with the regex usage
> but it was too good to be so simple ;(

Mind you, in theory it would be possible to simply apply the regexp to
the whole text (i.e., not line-wise). This would, however, require a
huge overhead. Imagine a document with hundreds (if not thousands) of
lines. You type one additional line (which you want highlighted). And
then the app hangs for a few seconds in the attempt to match every
regexp in your syntax-patterns to the whole document.
Therefore, syntax highlighting is done line-wise. This is actually part
of Qt, which calls the highlighter line-wise. Of course you could also
look at adjacent lines, but then you run into the problem of how many
lines you want to look at...

> On Mon, Jan 18, 2010 at 9:17 AM, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> Support for showing the text in bold (e.g. inside \textbf) has been
>> added recently.
> Thus, I am interested in seeing how \textbf has been incorporated. The
> logical idea would be, whenever you see the string '\textbf{' you will
> have to look for the first unpaired un-escaped closing brace, '}'.

I think you misunderstood me here. What was implemented was that syntax
highlighting specifications can now set simple font-related flags for
the properties bold, italic, and underlined. There is currently no
implementation of actually showing the content of \textbf in bold. All I
meant to say was, as an example, that one could define a regexp to show
the content of \textbf (or any other command, for that matter) in bold -
with all the limitations that were discussed previously (namely the
problem of line breaks and of the first closing brace).


More information about the texworks mailing list