auctex
[Top][All Lists]
Advanced

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

[AUCTeX] Useful to me, maybe to others: preview beamer frame


From: Mirko Vukovic
Subject: [AUCTeX] Useful to me, maybe to others: preview beamer frame
Date: Wed, 10 Nov 2010 10:21:29 -0500

Hi,

I use the following elisp code to preview beamer frames in ghostview.  So, unlike the preview mode, the frame preview is viewed in an external application.  I find it easier to view the preview while I am typing in the corrections to the source buffer.

I am sure this code can be cleaned up considerably using proper elisp and auctex constructs.  So, I am looking forward to corrections :-)  Also, this can be included into auctex' beamer support.

(defun mirko/beamer-frame-to-file ()
  "Copy preamble and current frame into _frame_.tex"
  (interactive)
  (save-excursion
    (save-window-excursion
      (save-match-data
    (widen)

    ;; These two are to enable me to return where I started from
    (let ((here (point))
          (doc-buffer (current-buffer)))

      ;; set-up file _frame_.tex and copy current frame into it
      (copy-region-as-kill (search-backward "\\begin{frame}")
                   (search-forward "\\end{frame}"))
      (when (buffer-exists-p "_frame_.tex")
        (kill-buffer "_frame_.tex"))
      (when (file-exists-p "_frame_.tex")
        (delete-file "_frame_.tex"))
      (set-buffer (generate-new-buffer "_frame_.tex"))
      (set-visited-file-name "_frame_.tex" t)
      (yank)

      ;; copy preamble to _frame_.tex
      (set-buffer doc-buffer) (goto-char (point-min))
      (copy-region-as-kill (point-min)
                   (re-search-forward "^\\\\begin{document}"))
      (set-buffer "_frame_.tex")
      (goto-char (point-min))
      (open-line 2)
      (yank)

      ;; append \end document and save file
      (goto-char (point-max))
      (open-line 1)
      (forward-line)
      (insert "\\end{document}")
      (save-buffer))))))




 
(defun mirko/beamer-preview-frame ()
  "Save frame into _frame_.tex file and run TeX on it using the
same TeX-command as in the parent file - I use a special format file
for my beamer presentations."
  (interactive)
  (let ((frame-TeX-command-default TeX-command-default))
    (mirko/beamer-frame-to-file)
    (set-buffer "_frame_.tex")
    (setq TeX-command-default frame-TeX-command-default)
    (TeX-command-master)))

Mirko

reply via email to

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