[TxMt] Latex Bundle grammar

Alain Matthes alain.matthes at mac.com
Tue Sep 11 17:00:16 UTC 2007


Le 11 sept. 07 à 13:23, Charilaos Skiadas a écrit :

> 3) The LaTeX grammar is the basic grammar. It includes the TeX  
> grammar and adds all the LaTeX specific stuff. In particular, it  
> adds the \[ ... \] and \( ... \) math modes, and hence needs direct  
> access to the TeX Math bundle, which it includes at those points.  
> (This is why we could not simply have TeX Math as a repository in  
> the TeX grammar, because then the LaTeX grammar couldn't call it.)

Firstly, Thanks for this answer. You understand exactly my problem

I need some precisions about patterns and include:

include = 'text.tex'; i understand this one but the next are not very  
clear for me

  include = '$self';

include = '$base';

> 4) For specialized document classes, at this point in time, we  
> simply create a new grammar that includes the LaTeX grammar and  
> adds its own specific stuff. (This might become simpler/better in  
> TM 2.0). Examples of this are the Beamer and Memoir grammars.

Perhaps I need to wait for TM 2 !

Questions about Beamer

1) In text.tex.latex we have : firstLineMatch = '^\\documentclass(?!.* 
\{beamer\})';

and in 'text.tex.latex.beamer : firstLineMatch = '^\\documentclass(\ 
[.*\])?\{beamer\}';
>
> 5) For commands in particular packages, we typically would add  
> those to the LaTeX grammar.

I'm not sure that's a good way because i don't use listings (pb with  
utf8) and I prefer pgf/tikz to pstricks.
I would like to know if it's possible to enable or disable some  
parts. I'm not sure but I think that's a big and long grammar is not  
good for the speed to match a long text. That is why , I made a  
remark about "listings" because it's not "pure" latex.

There is now an excellent way for the preferences with a panel, we  
can imagine a panel for the grammar package to add :
beamer, memoir, xcolor, listings, pstricks, tikz, amsmath etc...  and  
for the author : calc ifthen etex multido

Or a file in the preferences

> Just make the additions you want to the grammar and send it to us,  
> and we would add them. (Or consult with us on what changes you  
> think are needed.). So for adding specific package commands, this  
> is the option you should aim for.

for text.tex.latex

I've make somme additions :

{name = 'meta.preamble.latex';
contentName = 'support.class.latex';
begin = '((\\)(?:usepackage|documentclass|RequirePackage| 
usetikzlibrary))(?:(\[)([^\]]*)(\]))?(\{)';

and some modifications

		{name = 'constant.numeric.math.latex';
		match = '((\+|-)?)(([0-9]*[\.][0-9]+)|[0-9]+)';

because There is constant.numeric.math.tex and no  
onstant.numeric.math.latex and i want the sign + or - in the same  
color !

for text.tex

With keyword.control.tex, I've a problem with some terms like  
\if at tkz@visible or  \ifTKZ at tkzInit@NO . The symbol @ is a problem and  
in a package author there a lot of terms with @.

I add name = 'keyword.operator.tex'

with begingroup, endgroup, global def edef xdef gdef expandafter  
newbox newdimen newcount advance multiply divide etc...

but i'm not sure like keyword.control.tex ( with if else fi) that's  
necessary to a classic user of TeX.

When you include text.tex in text.tex.latex, it's not a good thing.  
there are good package to avoid the use of if etc...
for example ifthen

A latex user must use \ifthenelse  \newboolean \setboolean \isodd  
\whiledo \equal \lengthtest all these macros are in Latex and not in  
tex.

Important keywords in LaTex are newcommand, renewcommand, newcounter,  
setcounter, newlength, setlength, addtolength and some keywords tex  
are also necessary : advance multiply divide etc...

  I'm sorry because a lot of ideas are not in a good order.

Regards Alain




More information about the textmate mailing list