auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] Re: creating a new evironment command


From: Ryan Krauss
Subject: Re: [AUCTeX] Re: creating a new evironment command
Date: Wed, 7 Jun 2006 11:44:14 -0400

Thanks Stephen.  That seems to be working well.

Ryan

On 6/7/06, Stephen Eglen <address@hidden> wrote:
"Ryan Krauss" <address@hidden> writes:

> I am using AUCTeX with beamer (a great Latex package for
> presentations), and I need to create a new custom command sort of like
> inserting a figure environment.  Each frame in a presentation has the
> form
>
> \frame{
> \frametitle{Title}
>
> contents
>
> }
>
> How can I set up a command like the one used to insert a figure that
> prompts me for the frametitle and then puts the cursor in the contents
> area?

Dear Ryan,
Here's what I use (nb it doesn't prompt you for the title, but leaves
you in the right spot for it).

Stephen


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


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

(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)))
  (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))
        )
      ))



_______________________________________________
auctex mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/auctex





reply via email to

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