简体   繁体   中英

Setting up AUCTeX: LaTeX-mode-hook does not work

I have a strange problem. When I set up my AUCTeX configuration for Latex like this

(require 'tex)
(TeX-global-PDF-mode t)

it works for me.

But when I alter the code by putting in a lambda function

(add-hook LaTeX-mode-hook (lambda ()
    (require 'tex)
    (TeX-global-PDF-mode t)
))

it won't work.

Could someone help me? Thank you.

Try adding a ' to the immediate left of LaTeX-mode-hook . Also, you need to (require 'tex) before using the LaTeX-mode-hook .

Because the library AUCTeX defines the variable LaTeX-mode-hook (ie, brings it into existence), placing (require 'tex) inside a hook that does not yet exist will not work. [See line 5017 of ~/.emacs.d/elpa/auctex-11.87.3/latex.el )

(require 'tex)

(add-hook 'LaTeX-mode-hook (lambda ()
  (TeX-global-PDF-mode t)
  ))

Normally, I see this used: (setq TeX-PDF-mode t) . However, the original poster is correct regarding the existence of a function named TeX-global-PDF-mode -- see line 1729 of ~/.emacs.d/elpa/auctex-11.87.3/tex.el .


例
(source: lawlist.com )

Delete following line if you have in your "init.el".

(load "preview-latex.el" nil t t)

Although the line is suggested in"auctex-reademe.txt", I think following is more appropriate.

(load "preview" nil t t)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM