From bfd182b9ca86c2db5cd514cad0a11fd3f5bd8934 Mon Sep 17 00:00:00 2001 From: Leo Butler Date: Thu, 25 Jan 2024 09:48:20 -0600 Subject: [PATCH] lisp/ox-beamer.el: customize the beamer frame environment name * lisp/ox-beamer.el (org-beamer-frame-environment): new customize variable that contains the name of an environment that serves as an alias for the beamer frame environment. The environment's definition is appended to the set-up for beamer export. (org-beamer--format-frame): Replace the occurrence of \begin{frame} and \end{frame} with the new environment's name. (org-beamer-template): Add LaTeX code to define the new frame environment. Rationale: Code with \begin{frame} or \end{frame} cannot be embedded in a verbatim environment inside a beamer frame due to a design decision made by the beamer developers [1]. As suggested in that report, defining an alias for the beamer frame environment will allow such verbatim examples to compile correctly [2]. Since the frame environment name is customize-able, beamer code generated by ox-beamer can be included inside the verbatim environment, simply by changing the frame environment name. This solution also works with instances of \againframe. Refs: [1] https://github.com/josephwright/beamer/issues/360 [2] https://github.com/josephwright/beamer/issues/360#issuecomment-708705250 [3] https://list.orgmode.org/orgmode/87le8eg1hs.fsf@localhost/T/ --- lisp/ox-beamer.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index 82c8841aa..bab9ae089 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -45,7 +45,6 @@ ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) - ;;; User-Configurable Variables @@ -149,6 +148,11 @@ which is replaced with the subtitle." :package-version '(Org . "8.3") :type '(string :tag "Format string")) +(defcustom org-beamer-frame-environment "orgframe" + "Name of the beamer frame environment." + :group 'org-export-beamer + :type '(string :tag "Beamer frame")) + ;;; Internal Variables @@ -414,7 +418,7 @@ used as a communication channel." ;; among `org-beamer-verbatim-elements'. (org-element-map headline org-beamer-verbatim-elements 'identity info 'first-match))) - (concat "\\begin{frame}" + (concat "\\begin{" org-beamer-frame-environment "}" ;; Overlay specification, if any. When surrounded by ;; square brackets, consider it as a default ;; specification. @@ -481,7 +485,7 @@ used as a communication channel." ;; output. (if (not fragilep) contents (replace-regexp-in-string "\\`\n*" "\\& " (or contents ""))) - "\\end{frame}"))) + "\\end{" org-beamer-frame-environment "}"))) (defun org-beamer--format-block (headline contents info) "Format HEADLINE as a block. @@ -825,6 +829,12 @@ holding export options." (org-latex--insert-compiler info) ;; Document class and packages. (org-latex-make-preamble info) + ;; Define the frame environment. + "\\newenvironment<>{" + org-beamer-frame-environment + "}[1][]{\\begin{frame}[environment=" + org-beamer-frame-environment + ",#1]}{\\end{frame}}\n" ;; Insert themes. (let ((format-theme (lambda (prop command) -- 2.43.0