让 Emacs 识别自定义数学分隔符,以便相应地为脸部着色

发布于 2024-11-09 03:05:54 字数 1029 浏览 7 评论 0原文

我找到了一个代码,可以在 LaTeX 中以更简单、更快的方式输入方程式。 打字,而不是

\begin{equation}
\end{equation}

我现在可以

\be
\ee

打字。它工作得很好,我对此很满意。代码可在文档中找到(第 13 页),

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

我的问题是我使用 emacs,它无法识别那些数学分隔符,因此它不会为脸部提供正确的数学颜色。我尝试使用命令 Mxcustomize-apropos 来自定义它,以尝试找到我可以使用的东西,但我得到的最接近的是变量

  1. 'font-latex-math -环境', 我不认为我就是这样的人 从我所见之后 只能输入名称 进入卷曲内部的命令 \begin{}\end{}

    中的括号
  2. 'font-latex-make-built-in-keywords', 这需要更多的知识 来自我的比我拥有的,我没有 甚至知道它是否有效。

因此,我想知道的是如何设置 Emacs,以便每当我使用 \be\ee 对时,它都会为脸部提供与我为数学做好了准备。我想这需要一个 emacs lisp 代码,这会很棒,所以如果我愿意,我可以修改它以包含其他内容。

谁能帮我完成这件事吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此生挚爱伱 2024-11-16 03:05:54

这并不是您问题的真正答案,但如果只是为了节省编写equation环境的击键,您可能想尝试以下操作。

从您问题下的标签来看,我假设您正在使用 AUCTeX 模式。这样,您就不必

\begin{equation}

\end{equation}

每次都键入内容,而是使用以下快捷方式让 AUCTeX 以交互方式插入环境:Cc Ce。这将提示您输入环境名称(“方程”),您可以使用制表符补全键输入该名称。

因此,您确实节省了几次击键,结果在语法上是正确的,您不需要额外的 \be\ee 命令,最好的是这种方法是通用的,即它适用于所有 LaTeX 环境,而不仅仅是equation

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文