如何让 AucTeX 在自定义数学环境中自动完成 `\left[ \right]`、`\left( \right)`?

如何让 AucTeX 在自定义数学环境中自动完成 `\left[ \right]`、`\left( \right)`?

笔记:这可能是重复的,但我不知道正确的搜索词。如果您能发布原始问题的链接并关闭此问题,我将不胜感激。

我听从了建议这里,现在 AucTeX 具有正确的字体突出显示,并且在我的自定义数学环境中启用了数学模式。但是 AucTex 不会自动完成\left[ \right]\left( \right)在我的自定义数学环境中,这真的很不方便。

问题:在我的自定义数学环境中,如何更改我的.emacs文件以使 AucTeX 自动完成?\left[ \right]\left( \right)

作为参考,这是我的.emacs

(require 'package)
(package-initialize)
(require 'yasnippet)
(yas-global-mode 1)
(require 'auto-complete)
(add-to-list 'ac-modes 'latex-mode) 
(require 'ac-math) 
(defun my-ac-latex-mode () 
   (setq ac-sources
         (append '(;  again, I don't want unicode: ac-source-math-unicode
           ac-source-math-latex
           ac-source-latex-commands)
                 ac-sources)))
(add-hook 'LaTeX-mode-hook 'my-ac-latex-mode)
(ac-flyspell-workaround)
(add-to-list 'ac-modes 'org-mode)
(require 'auto-complete-config) 
(ac-config-default)
(setq ac-auto-start t)          
(setq ac-auto-show-menu t)
(global-auto-complete-mode t) 
(show-paren-mode 1)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(auto-fill-mode -1)
(remove-hook 'text-mode-hook #'turn-on-auto-fill)
(remove-hook 'text-mode-hook 'auto-detect-wrap)
'(text-mode-hook
  '((lambda nil (auto-fill-mode nil))
    smart-spacing-mode))
(auto-fill-mode nil)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse 't)
(setq scroll-step 1)
(setq mac-mouse-wheel-mode t)
(setq mac-mouse-wheel-smooth-scroll t)
(setq TeX-save-query nil)

(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(setq TeX-PDF-mode t)
(require 'smartparens-config)
(add-hook 'LaTeX-mode-hook #'smartparens-mode)

(add-hook 'LaTeX-mode-hook 'add-my-latex-environments)
(defun add-my-latex-environments ()
  (LaTeX-add-environments
   '("formulae" LaTeX-env-label)))

(custom-set-variables 
 '(font-latex-math-environments (quote  
     ("formulae"))) 
  '(TeX-insert-braces nil))

(setq reftex-label-alist 
  '(("formulae" ?e nil nil t))) 

答案1

尝试将以下命令添加到您的.emacs文件:

(setq LaTeX-electric-left-right-brace t)

相关内容