[TxMt] How to include private additions to syntax coloring?

Holger Frauenrath mail at frauenrath.com
Fri Dec 22 08:34:12 UTC 2006

Hi Haris and everybody else,

I split up my different questions into different emails.

>> So, for example, let's say I have a custom command for including  
>> scheme and figures, and I would like to have that command colored  
>> in a specific way; what would be the best and most forward- 
>> compatible way of doing it? If I understand things correctly,  
>> then, if I change the LaTeX language file directly, future updates  
>> to the bundle are going to be ignored (overwritten by my changed  
>> file). I guess, it would be better to put those personal additions  
>> into an extra file. But what is the correct/optimal way to call/ 
>> include it in the LaTeX language file?
> I don't know what you mean about including scheme. Do you mean  
> scheme code via the lstlistings environment or something like that?  
> Then we should add those to the official bundle. As for figure  
> environments, they should be already targeted by the scope  
> mechanism, so you should be able to assign them colors as is, I  
> think. Unless I misunderstand what you want to do. Both of these  
> two you should also be able to do by creating your own bundle and  
> including the latex grammar. However there is one tricky bit: The  
> rules that match environments match the spaces before the \begin,  
> so that they match from the beginning of the line (for coloring the  
> background more nicely). So if your rule matches only from the  
> \begin part, it does not matter whether it appears first or not,  
> since the built-in rule matches EARLIER. So you would need to be  
> matching those spaces as well. (I've been bitten by this myself ;) ).

Sorry for choosing a potentially confusing example. What I meant to  
say is that I have a custom command for including schemes and  
figures: \includescheme{scale}{name}{caption} which inserts a  
centered figure environment, inserts file <name> at scale <scale>,  
creates a label <name>, and inserts the caption <caption>. So, it is  
not targeted by the scope mechanism ... But this just served as a  
specific example.

My question was more general. In case I have a custom LaTeX command  
(any command) that I want to have a syntax colored, i.e., or in case  
I want to change an existing syntax color behavior, *what is the best  
way to do it*?

I just don't understand yet how to do it so that it does not break  
forward compatibility. I assume, it would be best to put my own  
private additions/changes to the syntax coloring into a separate  
language file, e.g. "LaTeX HF", instead of just writing them into the  
"LaTeX" language file itself. Is that correct? But, then, how do I  
either call/include it from the LaTeX file or vice versa? How do I  
set up such a separate file for my private additions?



Eidgenössische Technische Hochschule Zürich (ETH Zürich)
Department of Materials
Wolfgang-Pauli-Str. 10, HCI H515
CH-8093 Zürich

Phone: (+41) 1 633 6474
Fax:   (+41) 1 633 1390
Email: frauenrath at mat.ethz.ch
Web:   http://www.polychem.mat.ethz.ch/frauenrath/

More information about the textmate mailing list