在Emacs init文件中添加一个TeX符号 [英] Add a TeX symbol in the Emacs init file

查看:215
本文介绍了在Emacs init文件中添加一个TeX符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将以下代码添加到我的 .emacs init文件中:

I am trying to add the following code to my .emacs init file:

(TeX-add-symbols '("eqref" TeX-arg-ref))

但是我不能让它工作。在运行 emacs t.tex t.tex 在这里是一个示例文本文件)时,我收到以下错误命令行:

But I cannot get it to work. I get the following error when running emacs t.tex (t.tex is here a sample text file) from the command line:

Warning (initialization): An error occurred while loading `.emacs':
Symbol's function definition is void: TeX-add-symbols

我在Ubuntu 12.04上使用GNU Emacs版本23.3.1。我的 .emacs init文件看起来像

I am using GNU Emacs version 23.3.1 on Ubuntu 12.04. My .emacs init file looks like

(setq TeX-auto-parse t)
(setq TeX-electric-escape t)
(setq reftex-label-alist '((nil ?e nil "~\\eqref{%s}" nil nil)))
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(TeX-add-symbols '("eqref" TeX-arg-ref))

如果我输入 ESC-: (即运行命令 eval-expression ),然后输入
(TeX-add-symbols' eqrefTeX-arg-ref))在提示符下工作正常。 (这是运行这个之后,我可以在缓冲区中输入 \eqref ,并且按预期工作。但是这不是一个很好的解决方案,必须手动输入这个代码每次我编辑一个文件..这就是为什么我试图在 .emacs 文件中设置它的原因..)

If I enter ESC-: (i.e. running the command eval-expression) and enter (TeX-add-symbols '("eqref" TeX-arg-ref)) at the prompt it works fine. (That is after running this, I can enter \eqref in the buffer and it works as expected.. But this is not a good solution, having to enter this code manually each time I edit a file.. That is the reason why I try to set it up in the .emacs file..)

此问题的背景信息:

我使用AucTeX样式 amsmath有问题。 el ..似乎在我的机器上没有正确加载..有关详细信息,请参阅使用\eqref与RefTeX

I have a problem with using the AucTeX style amsmath.el.. it seems that it is not loaded properly on my machine.. For more information, see Using \eqref with RefTeX.

推荐答案

你必须在 LaTeX模式被激活,否则你会收到错误符号的函数定义为void:TeX-add-symbols 。您可以将该功能添加到 LaTeX模式的钩子中。为了覆盖可能的其他 eqref 宏定义,您应该添加一个虚拟的(忽略)到宏的定义。这个代码,在你的 .emacs 中,这个诀窍:

You have to evaluate the code after LaTeX-mode is activated, otherwise you get the error Symbol's function definition is void: TeX-add-symbols. You can add that function to the hook of LaTeX-mode. In order to override possible other eqref macro definitions, you should add a dummy (ignore) to the definition of the macro. This code, in your .emacs, does the trick:

(add-hook 'LaTeX-mode-hook
      '(lambda ()
         (TeX-add-symbols '("eqref" TeX-arg-ref (ignore)))))

这篇关于在Emacs init文件中添加一个TeX符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆