[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: |
Tue, 11 Jan 2022 12:39:51 +0100 |
> > Yes, that's what I thought. Is there a way to, say, copy and modify that
> > definition and add it as a new environment? E.g., calling `myframe' that
> > inserts the frame with the customized formatting?
>
> Yes, you could do that, but I suggest to write a function which searches
> back in the environment for \frametitle and then deletes any white
> spaces/newlines to get the desired result. You could the add that
> function to `LaTeX-after-insert-env-hook' in your init file like this:
>
> (with-eval-after-load "beamer"
> (add-hook 'LaTeX-after-insert-env-hook #'your-function t))
>
> Do you feel comfortable to write a `your-function'?
Thanks for the suggestions. I wanted to try Arash's idea first. But I'm very
incompetent in emacs-lisp.
I can write an interactive function that seems to work:
(defun my-frame-title-fix ()
"Fix the formatting of Beamer frame titles."
(interactive)
(save-excursion
(previous-line)
(forward-char)
(when (string-equal "frametitle" (thing-at-point 'word 'no-properties))
(join-line)
(delete-horizontal-space))))
But when I try to write a function to use in LaTeX-after-insert-env-hook, I
stumble.
(defun my-hook-frame-title-fix (env start end)
"Fix the formatting of Beamer frame titles."
(save-excursion
(goto-char start)
(forward-to-indentation 1)
(forward-char)
(what-cursor-position) ;this shows we got to the right place, over "f"
))
But this does not work:
(defun my-hook-frame-title-fix (env start end)
"Fix the formatting of Beamer frame titles."
(save-excursion
(goto-char start)
(forward-to-indentation 1)
(forward-char)
(when (string-equal "frametitle" (thing-at-point 'word 'no-properties))
(join-line)
(delete-horizontal-space))))
I'm probably making some elementary mistake...
All the best,
Greg
Re: Inserting beamer frames, Mandar Mitra, 2022/01/11