[Adapted from following posting: Newsgroups: gmane.comp.tex.latex.beamer.general, gmane.emacs.auctex.general Subject: Emacs tricks with beamer + auctex Date: Fri, 13 Jan 2006 14:58:41 +0000 & further updated 2010-03-16. & updated 2014-04-15. ] I'm happily using beamer (thanks Till!), together with auctex and emacs. I thought I'd share a couple of tricks with the beamer mail list, and would be interested to hear other people's. This code does several things (at least for me with Emacs from CVS repository). 1. Turn on PDF mode when editing beamer files (Thanks Ralf). 2. Recognise \lecture{} and \frametitle as section commands, so that reftex-toc (C-c =) allows you to see/navigate easily through your frames. 3. When cursor is within a frame, M-C-x runs pdflatex on the current frame, assuming that the frame is defined with the frame environment: \begin{frame} ... point somewhere in here \end{frame} the resulting pdf file will be called X.pdf where X is the value of TeX-region ("regionsje" in my code below) 4. C-c f generates a simple template for a new frame. To make 3 really useful, it is good to have a viewer looking at X.pdf that can automatically refresh when the pdf is updated. In this way you quickly get to see what your frame looks like. Does anyone know of a good viewer? gv has the "watch file" facility, but it doesn't seem to work, since during the file update, gv reports something like: --- **** Unrecoverable error in xref! Error: /rangecheck in resolveR --- xpdf has an option for reloading a file by using the -remote and -reload flags, so I've hacked an awful perl script around xpdf so that the script notifies xpdf to reload when X.pdf has finished changing. See http://www.damtp.cam.ac.uk/user/sje30/wxpdf ---------------------------------------------------------------------- (require 'cl) ;; needed for letf below (eval-after-load "tex" '(TeX-add-style-hook "beamer" 'my-beamer-mode)) (setq TeX-region "regionsje") ;;; From http://thread.gmane.org/gmane.emacs.auctex.general/718 (add-hook 'LaTeX-mode-hook (lambda () (when (member "beamer" TeX-active-styles) (TeX-add-style-hook "beamer" (lambda () (TeX-PDF-mode 1)))))) (defun my-beamer-mode () "My adds on for when in beamer." ;; Tell reftex to treat \lecture and \frametitle as section commands so that ;; C-c = gives you a list of frametitles and you can easily navigate around ;; the list of frames. ;; If you change reftex-section-level, reftex needs to be reset so that ;; reftex-section-regexp is correctly remade. (require 'reftex) ;; frametitle normally 2. (set (make-local-variable 'reftex-section-levels) '(("lecture" . 1) ("section" . 2) ("frametitle" . -3))) (reftex-reset-mode) ;; add some extra functions. (define-key LaTeX-mode-map "\C-cf" 'beamer-template-frame) (define-key LaTeX-mode-map "\C-\M-x" 'tex-frame) ) (defun tex-frame () "Run pdflatex on current frame. Frame must be declared as an environment." (interactive) (let (beg) (save-excursion (search-backward "\\begin{frame}") (setq beg (point)) (forward-char 1) (LaTeX-find-matching-end) (TeX-pin-region beg (point)) (letf (( (symbol-function 'TeX-command-query) (lambda (x) "LaTeX"))) (TeX-command-region)) ) )) (defun beamer-template-frame () "Create a simple template and move point to after \\frametitle." (interactive) (LaTeX-environment-menu "frame") (insert "\\frametitle{}") (backward-char 1))