[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] Emacs tricks with beamer + auctex

From: Stephen Eglen
Subject: [AUCTeX] Emacs tricks with beamer + auctex
Date: Fri, 13 Jan 2006 14:58:41 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

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

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

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:

 ... point somewhere in here 

   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.
I'd be happy to share that if people want it.

best wishes, Stephen

(eval-after-load "tex"
  '(TeX-add-style-hook "beamer" 'my-beamer-mode))

(setq TeX-region "regionsje")
(defun my-beamer-mode ()
  "My adds on for when in beamer."

  ;; when in a Beamer file I want to use pdflatex.
  ;; Thanks to Ralf Angeli for this.
  (TeX-PDF-mode 1)                      ;turn on PDF mode.

  ;; 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)
  (set (make-local-variable 'reftex-section-levels)
       '(("lecture" . 1) ("frametitle" . 2)))

  ;; 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."
  (let (beg)
      (search-backward "\\begin{frame}")
      (setq beg (point))
      (forward-char 1)
      (TeX-pin-region beg (point))
      (letf (( (symbol-function 'TeX-command-query) (lambda (x) "LaTeX")))

(defun beamer-template-frame ()
  "Create a simple template and move point to after \\frametitle."
  (LaTeX-environment-menu "frame")
  (insert "\\frametitle{}")
  (backward-char 1))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]