2

I have found a code to make typing equations in LaTeX in a simpler and faster way. Instead of typing

\begin{equation}
\end{equation}

I can now type

\be
\ee

It works great and I am happy with it. The code, found in this document (p. 13), is

\makeatletter
\newcommand{\be}{\begingroup
\setlength{\arraycolsep}{2pt}
\eqnarray%
\@ifstar{\nonumber}{}%
}
\newcommand{\ee}{\endeqnarray\endgroup}
\makeatother

My problem is that I use emacs, and it doesn't recognise those math delimiters and hence it doesn't give the face the proper math colour. I have tried to customise this by using the command M-x customize-apropos to try and find something I could use, but the closest I got were the variables

  1. 'font-latex-math-environments', which I don't think is what I am after since from what I can see I can only type the name of the command which goes inside the curly brackets in \begin{} and \end{}

  2. 'font-latex-make-built-in-keywords', which would require more knowledge from me than I have, and I don't even know whether it would work.

What I would like to know, thus, is how to set up Emacs so that whenever I used the pair \be and \ee it would give the face the same colour as I set up for math. I imagine this would require an emacs lisp code, which would be great so I could modify it to include other things if so I wished.

Can anyone help me getting this done?

Drew
  • 29,895
  • 7
  • 74
  • 104
Vivi
  • 4,070
  • 6
  • 29
  • 44
  • 3
    General FYI: [Avoid eqnarray!](http://tex.stackexchange.com/questions/196/eqnarray-vs-align) [Avoid eqnarray!](http://www.tug.org/pracjourn/2006-4/madsen/) [Avoid eqnarray!](http://texblog.net/latex-archive/maths/eqnarray-align-environment/) [Avoid eqnarray!](http://www.math.uiuc.edu/~hildebr/tex/displays.html) Use [align or equation or something else from amsmath instead](http://tex.stackexchange.com/questions/1166/which-command-should-i-use-for-displayed-equations-really). – ShreevatsaR May 22 '11 at 12:39
  • @ShreevatsaR I actually use align normally, but that is irrelevant for the question... – Vivi May 22 '11 at 19:39

1 Answers1

7

This is not really an answer to your question, but if it's just about saving keystrokes for writing an equation environment, you might want to try the following.

From the tags under your question, I assume you're using AUCTeX mode. With that, instead of typing

\begin{equation}

\end{equation}

every time, use the following shortcut to have AUCTeX insert an environment interactively: C-c C-e. This will prompt your for the name of the environment ("equation") which you can type using tab-completion.

So you do save a couple of keystrokes, the result is syntactically correct, you don't need the additional \be and \ee commands, and what's best is that this approach is generic, i.e., it works for all LaTeX environments, not just equation.

Thomas
  • 17,016
  • 4
  • 46
  • 70
  • 2
    Also, if `equation` is what you used most recently, then hitting `C-c C-e` gives `equation` as the default prompt, so you just have to hit Enter. – ShreevatsaR May 22 '11 at 12:44
  • I knew that, though I will confess I don't use it and it sort of solves some of my problems. The thing is, I would like to know how I can get Emacs to colour some of my custom made commands, and I thought that if I found a solution to the question above, I would be able to figure out how to do the other things I want to by understanding the code and then changing it slightly to fit my other needs. – Vivi May 23 '11 at 00:56