2
votes

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.

2

2 Answers

2
votes

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 (i.e., 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.


Example
(source: lawlist.com)

0
votes

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)