Question

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.

Was it helpful?

Solution

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)

OTHER TIPS

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top