A new version of the patch, including a test for the new
#+BEAMER_CLASS_OPTIONS

Best, /PA

On Tue, 8 Apr 2025 at 09:08, Pedro Andres Aranda Gutierrez <
paag...@gmail.com> wrote:

> Hmmm...
>
> Isn't it enough to it select with
> #STARTUP: beamer
>
> I have not used any alternative class to 'beamer' when using beamer...
> After all these years, I'd be 8-0 to learn you can use
> other latex classes to generate beamer presentations... but again, could
> be another instance of the proverb
> "you will never go to sleep without learning something new"
>
> And I'm always open to learning new stuff :-)
>
> Thx, /PA
>
> On Tue, 8 Apr 2025 at 07:29, David Masterson <dsmaster...@icloud.com>
> wrote:
>
>> Pedro Andres Aranda Gutierrez <paag...@gmail.com> writes:
>>
>> > Good point, maybe I didn't explain clearly enough.
>> > #+BEAMER_CLASS_OPTIONS: will only take effect when exporting to
>> > BEAMER.  It is enforced in (org-beamer-template) when and if
>> > present. You can always continue using #+LATEX_CLASS: and
>> > #+LATEX_CLASS_OPTIONS: for backward compatibility or other reasons.
>>
>> Should there be a #+BEAMER_CLASS to go with #+BEAMER_CLASS_OPTIONS ??
>>
>> --
>> David Masterson
>>
>
>
> --
> Fragen sind nicht da, um beantwortet zu werden,
> Fragen sind da um gestellt zu werden
> Georg Kreisler
>
> Sagen's Paradeiser, write BE!
> Year 1 of the New Koprocracy
>
>

-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Sagen's Paradeiser, write BE!
Year 1 of the New Koprocracy
From fcc09ae045806d18bc8534f690b368041c0ec0a5 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paag...@gmail.com>
Date: Tue, 8 Apr 2025 12:08:45 +0200
Subject: [PATCH] New BEAMER_CLASS_OPTIONS

* lisp/ox-beamer.el: Add #+BEAMER_CLASS_OPTIONS
(org-beamer-template) replace the class options with the
#+BEAMER_CLASS_OPTIONS, if defined.
* testing/lisp/test-ox-beamer.el: Add test for new
#+BEAMER_CLASS_OPTIONS
* doc/org-manual.org: Add entry explaining new
#+BEAMER_CLASS_OPTIONS

---
 doc/org-manual.org             | 12 ++++++++++++
 etc/ORG-NEWS                   | 11 +++++++++++
 lisp/ox-beamer.el              | 10 +++++++++-
 testing/lisp/test-ox-beamer.el | 14 ++++++++++++++
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 7561c0d62..5a6039ba1 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13064,6 +13064,18 @@ Beamer export backend has several additional keywords for customizing
 Beamer output.  These keywords work similar to the general options
 settings (see [[*Export Settings]]).

+- =BEAMER_CLASS_OPTIONS= ::
+
+  #+cindex: @samp{BEAMER_CLASS_OPTIONS}, keyword
+
+  The options to pass to the beamer class. It is the equivalent
+  to ~LATEX_CLASS_OPTIONS~ in the LaTeX exporter.  For example:
+
+  : #+BEAMER_CLASS_OPTIONS: [handout,12pt,t]
+
+  would produce a handout (as opposed to the slides) with 12pt fonts
+  and align the slide contents to the top of the contents space.
+
 - =BEAMER_THEME= ::

   #+cindex: @samp{BEAMER_THEME}, keyword
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 982bac4e9..8f6911a50 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -215,6 +215,17 @@ take the date as an argument, and generate a list of pairs for
 types of datetrees (e.g. for lunar calendars, academic calendars,
 retail 4-4-5 calendars, etc).

+*** New keyword ~#+BEAMER_CLASS_OPTIONS:~
+
+~#+BEAMER_CLASS_OPTIONS~ is a equivalent to ~#+LATEX_CLASS_OPTIONS~ for
+documents that are meant to be exported to LaTeX/beamer presentations.
+An example: add
+#+BEGIN_EXAMPLE
+#+BEAMER_CLASS_OPTIONS: [handout,t]
+#+END_EXAMPLE
+to produce a handout of the presentation with the items aligned at the
+top of the slide contents space.
+
 ** New and changed options

 # Changes dealing with changing default values of customizations,
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index e862da99d..2f72fa4e3 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -259,6 +259,7 @@ Return overlay specification, as a string, or nil."
   :options-alist
   '((:headline-levels nil "H" org-beamer-frame-level)
     (:latex-class "LATEX_CLASS" nil "beamer" t)
+    (:beamer-class-options "BEAMER_CLASS_OPTIONS" nil "[presentation]" t)
     (:beamer-subtitle-format nil nil org-beamer-subtitle-format)
     (:beamer-column-view-format "COLUMNS" nil org-beamer-column-view-format)
     (:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
@@ -872,7 +873,14 @@ holding export options."
      ;; LaTeX compiler
      (org-latex--insert-compiler info)
      ;; Document class and packages.
-     (org-latex-make-preamble info)
+     (let* ((preamble  (org-latex-make-preamble info))
+            (beamer-class-options (plist-get info :beamer-class-options)))
+       (if beamer-class-options
+           ;; modify the documentclass only
+           (replace-regexp-in-string "class\\[[^]]+\\]"
+                                     (concat "class " beamer-class-options)
+                                     preamble)
+       preamble))
      ;; Define the alternative frame environment, if needed.
      (when (plist-get info :beamer-define-frame)
        (format "\\newenvironment<>{%s}[1][]{\\begin{frame}#2[environment=%1$s,#1]}{\\end{frame}}\n"
diff --git a/testing/lisp/test-ox-beamer.el b/testing/lisp/test-ox-beamer.el
index f5743409f..53b80589d 100644
--- a/testing/lisp/test-ox-beamer.el
+++ b/testing/lisp/test-ox-beamer.el
@@ -106,5 +106,19 @@ Here is a second example:
      (should (search-forward (concat "\\end{frame}") nil t))
      (should (search-forward (concat "\\end{" org-beamer-frame-environment "}"))))))

+(ert-deftest ox-beamer/beamer-class-options ()
+  "Test that #+BEAMER_CLASS_OPTIONS is used."
+  (org-test-with-exported-text
+   'beamer
+   "#+OPTIONS: toc:nil
+#+BEAMER_CLASS_OPTIONS: [12pt,t]
+
+* A frame
+- Hola
+"
+   (goto-char (point-min))
+   (should (search-forward "\\documentclass [12pt,t]{beamer}"))))
+
+
 (provide 'test-ox-beamer)
 ;;; test-ox-beamer.el ends here
--
2.34.1

Reply via email to