[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inserting beamer frames
From: |
Greg Bognar |
Subject: |
Re: Inserting beamer frames |
Date: |
Fri, 14 Jan 2022 18:03:41 +0100 |
[...]
> > But when I try to write a function to use in LaTeX-after-insert-env-hook, I
> > stumble. [...]
> > I'm probably making some elementary mistake...
>
> No, it was me. I had a brief look at beamer.el as I made that
> suggestion. Looking closer, beamer.el defines:
>
> '("frame" (lambda (env &rest ignore)
> (let ((title (TeX-read-string "(Optional) Title: " nil
> 'LaTeX-beamer-frametitle-history)))
> (LaTeX-insert-environment env)
> (unless (zerop (length title))
> (save-excursion
> (LaTeX-find-matching-begin)
> (end-of-line)
> (LaTeX-newline)
> ;; Indent the next macro insertion and don't
> ;; rely on the fill-function to do it:
> (indent-according-to-mode)
> (insert (format "\\frametitle{%s}" title))
> ;; This works because \frametitle is a
> ;; paragraph command.
> (when auto-fill-function
> (backward-char)
> (LaTeX-fill-paragraph)))))))
>
> `LaTeX-after-insert-env-hook' is called at the end of
> `LaTeX-insert-environment', \frametitle is inserted afterwards. Alas,
> any function added to `LaTeX-after-insert-env-hook' doesn't see that
> later insertion and would fail. Therefore the functions above.
Yes, I suspected something like this was happening. I ended up adopting
Mandar's suggestion of writing a beamer.el file and placing it in my
TeX-style-private directory (I think that's the one I need). This has the
advantage that I can format the frame insertion the way I want and don't need to
issue any commands to fix the formatting.
Thanks everyone!
Re: Inserting beamer frames, Mandar Mitra, 2022/01/11