Pedro Andres Aranda Gutierrez <[email protected]> writes:

> Subject: [PATCH] ox-beamer.el: New Beamer LaTeX prelude sequence
>
> * doc/org-manual.org: (*** Beamer specific export settings): Add note
> about theme information in org-latex-classes.
> * etc/ORG-NEWS: Announce new place of theme information in LaTeX prelude as
> (potentially) breaking change.
> * lisp/ox-beamer.el (org-beamer--insert-theme): New function to insert
> theme information in header for document class beamer.  Will leave header
> unaltered if it contains theme configuration or the class is not beamer.
> (org-beamer-template):  Use (org-beamer--insert-theme) to add the theme
> information to the LaTeX preamble.
> * testing/lisp/test-ox-beamer.el (test-ox-beamer/beamer-theme-keep): New
> test to check that the theme information in the class header provided by
> (org-latex-classes) takes precedence over the BEAMER_... keywords.
> Document class options are inserted correctly in all cases.
> ---
>  doc/org-manual.org             |  5 ++++-
>  etc/ORG-NEWS                   | 18 ++++++++++++++++++
>  lisp/ox-beamer.el              | 30 ++++++++++++++++++++++--------
>  testing/lisp/test-ox-beamer.el | 34 ++++++++++++++++++++++++++++++++++
>  4 files changed, 78 insertions(+), 9 deletions(-)
>
> diff --git a/doc/org-manual.org b/doc/org-manual.org
> index cd8903a7e..cab2f200d 100644
> --- a/doc/org-manual.org
> +++ b/doc/org-manual.org
> @@ -13159,9 +13159,12 @@ Beamer output.  These keywords work similar to the 
> general options
>  settings (see [[*Export Settings]]).
>
>  #+texinfo: @noindent
> -*Note:* Theme-related =BEAMER_...= keywords do not apply to =ltx-talk=
> +*Note 1:* Theme-related =BEAMER_...= keywords do not apply to =ltx-talk=
>  and will be ignored.
>
> +*Note 2:* Theme-related =BEAMER_...= keywords will be ignored in the
> +=beamer= class definition in ~org-latex-classes~ defines the Beamer theme.

Maybe "Theme-related =BEAMER_...= keywords will be ignored *if* the
=beamer= class definition in ~org-latex-classes~ contains =\usetheme{...}="


> +(defun org-beamer--insert-theme (header theme-info)
> +  "Insert THEME-INFO right after `\\usepackage..{beamer}' in HEADER.

*documentclass

> +Return the resulting HEADER.
> +
> +If the class is not \"beamer\" or the header contains a theme declaration,
> +return HEADER unaltered."
> +  (save-match-data
> +    ;; this is only match beamer... will not do anything for ltx-talk(!)
> +    (when (string-match "\\documentclass\\(\\[.+?]\\)?{beamer}\n" header)
> +      (let ((document-class (match-string 0 header)))
> +        (unless  (string-match-p "\\usetheme\\(\\[.+?]\\)?{[^]]+}\n" header)
> +          (setq header
> +                (string-replace document-class
> +                                (concat document-class theme-info) ;; 
> theme-info ends with '\n'
> +                                header))))))
> +  header)
> +
> ...
> +     ;; Document class, theme and packages.
> +     (org-beamer--insert-theme
> +      (org-latex-make-preamble info)
> +      (org-beamer--theme-header info))

org-latex-make-preamble will create the full preamble, including
#+LATEX_HEADER. So, something like
#+LATEX_HEADER: \usetheme{Madrid}
will also trigger #+BEAMER_... keywords being ignored.
Is it intentional?

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to