开发者

Getting Emacs to recognise custom math delimiters so it can colour the face accordingly

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜