all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] beamer export
@ 2022-09-28 19:46 Leo Butler
  2022-09-29  2:45 ` Ihor Radchenko
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2022-09-28 19:46 UTC (permalink / raw)
  To: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 66 bytes --]

The following Org document shows a bug in the beamer exporter.


[-- Attachment #2: beamer bug.org --]
[-- Type: text/plain, Size: 2840 bytes --]

#+TITLE:     Writing Beamer presentations in org-mode
#+AUTHOR:    Eric S Fraga
#+AUTHOR:    (bug report by Leo Butler)
#+EMAIL:     e.fraga@ucl.ac.uk
#+DATE:      2010-03-30 Tue
#+DESCRIPTION: 
#+KEYWORDS: 
#+LANGUAGE:  en
#+OPTIONS:   H:2 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:https://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+HTML_LINK_UP:
#+HTML_LINK_HOME:
#+LATEX_COMPILER: lualatex
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) %4BEAMER_col(Col) %10BEAMER_extra(Extra)


* A Bug Report about the Beamer Tutorial

** 
#+begin_src elisp :exports both
(org-version)
#+end_src

#+RESULTS:
: 9.5.2

** The bug
The [[https://orgmode.org/worg/exporters/beamer/tutorial.html][Beamer tutorial by Eric Fraga]]
([[https://orgmode.org/worg/exporters/beamer/tutorial.html]]) has an
example that shows how to create a two column frame using org. The
first column is not identified, though.

** The Org code
Here is the org code.
\tiny
#+begin_src org :exports code
  ,** Two columns
  ,*** A block                                           :B_ignoreheading:BMCOL:
      :PROPERTIES:
      :BEAMER_env: ignoreheading
      :BEAMER_col: 0.4
      :END:
      - this slide consists of two columns
      - the first (left) column has no heading and consists of text
      - the second (right) column has an image and is enclosed in an
	@example@ block

  ,*** A screenshot                                            :BMCOL:B_example:
      :PROPERTIES:
      :BEAMER_col: 0.6
      :BEAMER_env: example
      :END:
      ,#+ATTR_LaTeX: :width \textwidth
      [[./a-simple-slide.png]]
#+end_src

** The \LaTeX{} code
Here is the generated \LaTeX{} code. I needed to add comment characters (%) to each line due to a bug in the =verbatim= environment.\pause
\tiny
#+begin_src latex :exports code
  % \begin{frame}[label={sec:orgcc0ebff}]{Two columns}
  % \begin{itemize}
  % \item this slide consists of two columns
  % \item the first (left) column has no heading and consists of text
  % \item the second (right) column has an image and is enclosed in an
  % @example@ block
  % \end{itemize}

  % \begin{column}{0.6\columnwidth}
  % \begin{example}[A screenshot]
  % \begin{center}
  % \includegraphics[width=\textwidth]{./a-simple-slide.png}
  % \end{center}
  % \end{example}
  % \end{column}
  % \end{columns}
  % \end{frame}
#+end_src
\pause\normalsize
The first =itemize= environment should have been wrapped by a =column= environment inside the =columns= environment.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2022-09-28 19:46 [BUG] beamer export Leo Butler
@ 2022-09-29  2:45 ` Ihor Radchenko
  2022-09-29 18:43   ` Daniel Fleischer
  2024-01-20 14:56   ` Ihor Radchenko
  0 siblings, 2 replies; 18+ messages in thread
From: Ihor Radchenko @ 2022-09-29  2:45 UTC (permalink / raw)
  To: Leo Butler, Daniel Fleischer; +Cc: Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

> The following Org document shows a bug in the beamer exporter.

Confirmed on main.

There are two bugs reported here:
1. ox-latex export bug for src blocks containing direct LaTeX when
   org-latex-src-block-backend is set to its default 'verbatim value
2. ox-beamer export bug as described in the attached org file

Daniel, can you please take a look at the first bug?
I suspect that \commands should be additionally escaped in verbatim
environment, similar to
https://stackoverflow.com/questions/3019774/how-write-this-in-verbatim-latex

-- 
Ihor Radchenko,
Org mode contributor,
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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2022-09-29  2:45 ` Ihor Radchenko
@ 2022-09-29 18:43   ` Daniel Fleischer
  2022-12-10 12:49     ` Ihor Radchenko
  2024-01-20 14:56   ` Ihor Radchenko
  1 sibling, 1 reply; 18+ messages in thread
From: Daniel Fleischer @ 2022-09-29 18:43 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Leo Butler, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 980 bytes --]

Hi, I'm on vacation for the next month. I can look at it when I'm back.

On Thu, Sep 29, 2022, 03:44 Ihor Radchenko <yantar92@gmail.com> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
> > The following Org document shows a bug in the beamer exporter.
>
> Confirmed on main.
>
> There are two bugs reported here:
> 1. ox-latex export bug for src blocks containing direct LaTeX when
>    org-latex-src-block-backend is set to its default 'verbatim value
> 2. ox-beamer export bug as described in the attached org file
>
> Daniel, can you please take a look at the first bug?
> I suspect that \commands should be additionally escaped in verbatim
> environment, similar to
>
> https://stackoverflow.com/questions/3019774/how-write-this-in-verbatim-latex
>
> --
> Ihor Radchenko,
> Org mode contributor,
> 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
>

[-- Attachment #2: Type: text/html, Size: 1801 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2022-09-29 18:43   ` Daniel Fleischer
@ 2022-12-10 12:49     ` Ihor Radchenko
  0 siblings, 0 replies; 18+ messages in thread
From: Ihor Radchenko @ 2022-12-10 12:49 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: Ihor Radchenko, Leo Butler, Org Mode Mailing List

Daniel Fleischer <danflscr@gmail.com> writes:

> Hi, I'm on vacation for the next month. I can look at it when I'm back.

There is no activity in this thread for over one month.
Bumping.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2022-09-29  2:45 ` Ihor Radchenko
  2022-09-29 18:43   ` Daniel Fleischer
@ 2024-01-20 14:56   ` Ihor Radchenko
  2024-01-23 16:58     ` Leo Butler
  1 sibling, 1 reply; 18+ messages in thread
From: Ihor Radchenko @ 2024-01-20 14:56 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Leo Butler, Daniel Fleischer, Org Mode Mailing List

Ihor Radchenko <yantar92@gmail.com> writes:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>> The following Org document shows a bug in the beamer exporter.
>
> Confirmed on main.

I investigated further.

> There are two bugs reported here:
> 1. ox-latex export bug for src blocks containing direct LaTeX when
>    org-latex-src-block-backend is set to its default 'verbatim value

This appears to be Beamer-specific problem with verbatim environments:
https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim

The solution might be to use [fragile] frame parameter, but that might
have its own drawbacks:
https://tex.stackexchange.com/questions/136240/drawbacks-of-using-fragile-frames-in-beamer

> 2. ox-beamer export bug as described in the attached org file

This is not a bug. When you specify ignoreheading environment, you imply
that the contents of the heading is to be included as is.
If you want the contents to become a column, you should specify column
environment.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-20 14:56   ` Ihor Radchenko
@ 2024-01-23 16:58     ` Leo Butler
  2024-01-24 16:06       ` Ihor Radchenko
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-01-23 16:58 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 2108 bytes --]

On Sat, Jan 20 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>>
>>> The following Org document shows a bug in the beamer exporter.
>>
>> Confirmed on main.
>
> I investigated further.

Thanks.

>
>> There are two bugs reported here:
>> 1. ox-latex export bug for src blocks containing direct LaTeX when
>>    org-latex-src-block-backend is set to its default 'verbatim value
>
> This appears to be Beamer-specific problem with verbatim environments:
> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>
> The solution might be to use [fragile] frame parameter, but that might
> have its own drawbacks:
> https://tex.stackexchange.com/questions/136240/drawbacks-of-using-fragile-frames-in-beamer

Yes, an *automatic* solution may create more problems than it solves.
Although, I do note that ox-beamer does mark some frames as fragile already.
I wonder how difficult it would be to add a property drawer to frames,
so (amongst other things), they could be marked fragile?

>
>> 2. ox-beamer export bug as described in the attached org file
>
> This is not a bug. When you specify ignoreheading environment, you imply
> that the contents of the heading is to be included as is.
> If you want the contents to become a column, you should specify column
> environment.

I see. That is not now the ignoreheading property is described. It says
[1]:

    ... As the text in the slide says, the left column is a list and the
    right one is an image. The left column's headline text is ignored,
    specified by =C-c C-b i= which tells org to *ignore* the headline
    text completely.

I think the documentation and example needs to be corrected. I have
attached a patch. I have also attached a revision of the original org
file with the bug report, and its export to pdf to demonstrate that the
revised example works as intended.

Best,
Leo

[1] worg/exporters/beamer/tutorial.org


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: beamer-bug.org --]
[-- Type: text/x-org; name="beamer-bug.org", Size: 3893 bytes --]

#+TITLE:     Writing Beamer presentations in org-mode
#+AUTHOR:    Eric S Fraga
#+AUTHOR:    (bug report by Leo Butler)
#+EMAIL:     e.fraga@ucl.ac.uk
#+DATE:      2010-03-30 Tue
#+DESCRIPTION: 
#+KEYWORDS: 
#+LANGUAGE:  en
#+OPTIONS:   H:2 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:https://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+HTML_LINK_UP:
#+HTML_LINK_HOME:
#+LATEX_COMPILER: lualatex
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) %4BEAMER_col(Col) %10BEAMER_extra(Extra)


* A Bug Report about the Beamer Tutorial

** 
:PROPERTIES:
:BEAMER_env: frame
:END:
#+begin_src elisp :exports both :results list
(list (emacs-version) (org-version))
#+end_src

#+RESULTS:
- GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0)
  of 2023-08-30, modified by Debian
- 9.6.10

** The bug
:PROPERTIES:
:BEAMER_env: frame
:END:
The [[https://orgmode.org/worg/exporters/beamer/tutorial.html][Beamer tutorial by Eric Fraga]]
([[https://orgmode.org/worg/exporters/beamer/tutorial.html]]) has an
example that shows how to create a two column frame using org. The example is incorrect, though, because it sets the =ignoreheading= property on the first column.

The following example removes that property and corrects a minor typo in the example.

** The Org code
:PROPERTIES:
:BEAMER_env: frame
:END:
Here is the org code.
\tiny
#+name: beamer-ex
#+begin_src org :exports both :results replace
  ,** Two columns
  ,*** A block                                          :BMCOL:
      :PROPERTIES:
      :BEAMER_col: 0.4
      :END:
      - this slide consists of two columns
      - the first (left) column has no heading and consists of text
      - the second (right) column has an image and is enclosed in an
	*example* block

  ,*** A screenshot                                            :BMCOL:B_example:
      :PROPERTIES:
      :BEAMER_col: 0.6
      :BEAMER_env: example
      :END:
      ,#+ATTR_LaTeX: :width \textwidth
      [[./a-simple-slide.png]]
#+end_src

#+RESULTS: beamer-ex
** Two columns
*** A block                                          :BMCOL:
    :PROPERTIES:
    :BEAMER_col: 0.4
    :END:
    - this slide consists of two columns
    - the first (left) column has no heading and consists of text
    - the second (right) column has an image and is enclosed in an
      *example* block

*** A screenshot                                            :BMCOL:B_example:
    :PROPERTIES:
    :BEAMER_col: 0.6
    :BEAMER_env: example
    :END:
    #+ATTR_LaTeX: :width \textwidth
    [[./a-simple-slide.png]]

** The \LaTeX{} code                                               :noexport:
Here is the generated \LaTeX{} code. I needed to add comment characters (%) to each line due to a bug in the =verbatim= environment.\pause
\tiny
#+begin_example
%\begin{frame}[label={sec:org8bc49cc}]{Two columns}
\begin{columns}
\begin{column}{0.4\columnwidth}
\begin{itemize}
\item this slide consists of two columns
\item the first (left) column has no heading and consists of text
\item the second (right) column has an image and is enclosed in an
\alert{example} block
\end{itemize}
\end{column}

\begin{column}{0.6\columnwidth}
\begin{example}[A screenshot]
\begin{center}
\includegraphics[width=\textwidth]{./a-simple-slide.png}
\end{center}
\end{example}
\end{column}
\end{columns}
%\end{frame}
#+end_example

\pause\normalsize
The first =itemize= environment should have been wrapped by a =column= environment inside the =columns= environment.

[-- Attachment #3: beamer-bug.pdf --]
[-- Type: application/pdf, Size: 100158 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-exporters-beamer-tutorial.org-fix-two-column-example.patch --]
[-- Type: text/x-diff; name="0001-exporters-beamer-tutorial.org-fix-two-column-example.patch", Size: 2456 bytes --]

From 77e2766f5fc5dda2118458f73a0b93ff1f1e6a38 Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Tue, 23 Jan 2024 10:49:21 -0600
Subject: [PATCH] exporters/beamer/tutorial.org: fix two column example

* exporters/beamer/tutorial.org: The ignoreheading environment causes
the column property to be ignored, which is opposite to the intent of
the Two columns example.  Remove that environment and the pertinent
comment in the paragraph following, so the example exports as
intended.  Fix a couple typos in the Org example itself.
---
 exporters/beamer/tutorial.org | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/exporters/beamer/tutorial.org b/exporters/beamer/tutorial.org
index fc32395f..f40425ed 100644
--- a/exporters/beamer/tutorial.org
+++ b/exporters/beamer/tutorial.org
@@ -198,31 +198,29 @@ column.  The following
 #+BEGIN_Example
 ,** Two columns
 
-,*** A block                                           :B_ignoreheading:BMCOL:
+,*** A block                                           :BMCOL:
     :PROPERTIES:
-    :BEAMER_env: ignoreheading
     :BEAMER_col: 0.4
     :END:
     - this slide consists of two columns
     - the first (left) column has no heading and consists of text
     - the second (right) column has an image and is enclosed in an
-      @example@ block
+      *example* block
 
 ,*** A screenshot                                            :BMCOL:B_example:
     :PROPERTIES:
     :BEAMER_col: 0.6
     :BEAMER_env: example
     :END:
-,    #+ATTR_LaTeX: :width \textwidth
-    [[file://../../images/org-beamer/a-simple-slide.png]]
+,#+ATTR_LaTeX: :width \textwidth
+[[file://../../images/org-beamer/a-simple-slide.png]]
 #+END_Example
 
 defines a two column slide.  As the text in the slide says, the left
 column is a list and the right one is an image.  The left column's
-headline text is ignored, specified by =C-c C-b i= which tells org to
-*ignore* the headline text completely.  The column on the right
-however is placed with an /example/ block (whose appearance will
-depend on the Beamer theme).
+headline text is ignored.  The column on the right however is placed
+with an /example/ block (whose appearance will depend on the Beamer
+theme).
 
 The columns also have widths.  By default, these widths are the
 proportion of the page width to use so I have specified 40% for the
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-23 16:58     ` Leo Butler
@ 2024-01-24 16:06       ` Ihor Radchenko
  2024-01-25 16:13         ` Leo Butler
  2024-01-25 22:29         ` Leo Butler
  0 siblings, 2 replies; 18+ messages in thread
From: Ihor Radchenko @ 2024-01-24 16:06 UTC (permalink / raw)
  To: Leo Butler; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

>>> 1. ox-latex export bug for src blocks containing direct LaTeX when
>>>    org-latex-src-block-backend is set to its default 'verbatim value
>>
>> This appears to be Beamer-specific problem with verbatim environments:
>> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>>
>> The solution might be to use [fragile] frame parameter, but that might
>> have its own drawbacks:
>> https://tex.stackexchange.com/questions/136240/drawbacks-of-using-fragile-frames-in-beamer
>
> Yes, an *automatic* solution may create more problems than it solves.
> Although, I do note that ox-beamer does mark some frames as fragile already.
> I wonder how difficult it would be to add a property drawer to frames,
> so (amongst other things), they could be marked fragile?

Hmm. Actually, that frame is already marked fragile.
Yet, it is not enough...
Apparently, LaTeX has really hard time processing verbatim code inside
beamer frames.

>>> 2. ox-beamer export bug as described in the attached org file
>>
>> This is not a bug. When you specify ignoreheading environment, you imply
>> that the contents of the heading is to be included as is.
>> If you want the contents to become a column, you should specify column
>> environment.
>
> I see. That is not now the ignoreheading property is described. It says
> [1]:
>
>     ... As the text in the slide says, the left column is a list and the
>     right one is an image. The left column's headline text is ignored,
>     specified by =C-c C-b i= which tells org to *ignore* the headline
>     text completely.
>
> I think the documentation and example needs to be corrected. I have
> attached a patch.

Thanks! Applied.
https://git.sr.ht/~bzg/worg/commit/aedea59f

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-24 16:06       ` Ihor Radchenko
@ 2024-01-25 16:13         ` Leo Butler
  2024-01-26 11:45           ` Ihor Radchenko
  2024-01-25 22:29         ` Leo Butler
  1 sibling, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-01-25 16:13 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 2812 bytes --]

On Wed, Jan 24 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>>>> 1. ox-latex export bug for src blocks containing direct LaTeX when
>>>>    org-latex-src-block-backend is set to its default 'verbatim value
>>>
>>> This appears to be Beamer-specific problem with verbatim environments:
>>> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>>>
>>> The solution might be to use [fragile] frame parameter, but that might
>>> have its own drawbacks:
>>> https://tex.stackexchange.com/questions/136240/drawbacks-of-using-fragile-frames-in-beamer
>>
>> Yes, an *automatic* solution may create more problems than it solves.
>> Although, I do note that ox-beamer does mark some frames as fragile already.
>> I wonder how difficult it would be to add a property drawer to frames,
>> so (amongst other things), they could be marked fragile?
>
> Hmm. Actually, that frame is already marked fragile.
> Yet, it is not enough...



> Apparently, LaTeX has really hard time processing verbatim code inside
> beamer frames.

I looked again at the solution here:

https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim

and it errors out with a recent version of pdflatex:

   This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex)

This is, apparently, a known problem:

https://github.com/josephwright/beamer/issues/360

The end of that issue report includes a work-around that we might apply
in org. I have attached a patch for your feedback. The example that
stimulated this discussion compiles with the patch and the testsuite
shows no errors related to it.

>
>>>> 2. ox-beamer export bug as described in the attached org file
>>>
>>> This is not a bug. When you specify ignoreheading environment, you imply
>>> that the contents of the heading is to be included as is.
>>> If you want the contents to become a column, you should specify column
>>> environment.
>>
>> I see. That is not now the ignoreheading property is described. It says
>> [1]:
>>
>>     ... As the text in the slide says, the left column is a list and the
>>     right one is an image. The left column's headline text is ignored,
>>     specified by =C-c C-b i= which tells org to *ignore* the headline
>>     text completely.
>>
>> I think the documentation and example needs to be corrected. I have
>> attached a patch.
>
> Thanks! Applied.
> https://git.sr.ht/~bzg/worg/commit/aedea59f

Thanks. I can see the commit on master in git, but the webpage seems to
be unchanged.

https://orgmode.org/worg/exporters/beamer/tutorial.html

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-beamer.el-randomize-the-beamer-frame-environ.patch --]
[-- Type: text/x-diff; name="0001-lisp-ox-beamer.el-randomize-the-beamer-frame-environ.patch", Size: 3216 bytes --]

From 9cb3489e3fe80fb2e3996b737f528aa4db9ba62d Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Thu, 25 Jan 2024 09:48:20 -0600
Subject: [PATCH] lisp/ox-beamer.el:  randomize the beamer frame environment

* lisp/ox-beamer.el (org-beamer--frame-environment): new 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.

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].

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 | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 82c8841aa..be3003835 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -36,11 +36,23 @@
 (require 'cl-lib)
 (require 'ox-latex)
 
+;; Needed to set-up Beamer export.
+(defconst org-beamer--frame-environment
+  (concat "orgframe" (org-id-uuid))
+  "Name of the beamer frame environment.
+This is randomized to prevent collisions.")
+
 ;; Install a default set-up for Beamer export.
 (unless (assoc "beamer" org-latex-classes)
   (add-to-list 'org-latex-classes
-	       '("beamer"
-		 "\\documentclass[presentation]{beamer}"
+	       `("beamer"
+		 ,(concat "\\documentclass[presentation]{beamer}\n"
+                          ;; Define an alias for the beamer frame environment
+                         "\\newenvironment<>{"
+                         org-beamer--frame-environment
+                         "}[1][]{\\begin{frame}[environment="
+                         org-beamer--frame-environment
+                         ",#1]}{\\end{frame}}")
 		 ("\\section{%s}" . "\\section*{%s}")
 		 ("\\subsection{%s}" . "\\subsection*{%s}")
 		 ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
@@ -414,7 +426,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 +493,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.
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-24 16:06       ` Ihor Radchenko
  2024-01-25 16:13         ` Leo Butler
@ 2024-01-25 22:29         ` Leo Butler
  2024-01-26 13:30           ` Ihor Radchenko
  1 sibling, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-01-25 22:29 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

On Wed, Jan 24 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>> I think the documentation and example needs to be corrected. I have
>> attached a patch.
>
> Thanks! Applied.
> https://git.sr.ht/~bzg/worg/commit/aedea59f

Attached is a second patch to de-lint the ox-beamer tutorial.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-exporters-beamer-tutorial.org-clean-lint-warnings.patch --]
[-- Type: text/x-diff; name="0001-exporters-beamer-tutorial.org-clean-lint-warnings.patch", Size: 2814 bytes --]

From 7a52949ce25c7576896785ba185f9bd6afc7f12b Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Tue, 23 Jan 2024 11:23:18 -0600
Subject: [PATCH] exporters/beamer/tutorial.org: clean lint warnings

* exporters/beamer/tutorial.org:  convert the informal footnote
markers to Org footnotes.
---
 exporters/beamer/tutorial.org | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/exporters/beamer/tutorial.org b/exporters/beamer/tutorial.org
index f40425ed..ae1ec751 100644
--- a/exporters/beamer/tutorial.org
+++ b/exporters/beamer/tutorial.org
@@ -33,7 +33,7 @@ keybindings]].
 
 * First steps
 ** The export template
-Starting with an empty file called =presentation.org= [1], say, the
+Starting with an empty file called =presentation.org= [fn:1], say, the
 first step is to insert the default org export template (=C-c C-e #=
 with the default keybindings). This will generate something that looks
 like this (some specific entries will vary):
@@ -74,7 +74,7 @@ Beamer specific options.  The following options are what I use:
 
 The first line enables the Beamer specific commands for org-mode (more
 on this below); the next two tell the LaTeX exporter to use the
-Beamer class and to use the larger font settings[2].  
+Beamer class and to use the larger font settings[fn:2].
 
 ** Outline levels for frames (slides)
 
@@ -178,7 +178,7 @@ org-mode has a special beamer sub-mode which provides an easy to use
 method for specifying block types (and columns as well, as we shall
 [[*Column view for slide and block customisation][see in the next section]]).
 
-To specify the type of block, you can type =C-c C-b= [3].  This brings up
+To specify the type of block, you can type =C-c C-b= [fn:3].  This brings up
 a keyboard driven menu in which you type a single letter to select the
 option you wish to apply to this headline.  For the above example, I
 typed =C-c C-b t=.  The options selected in this manner are also shown
@@ -348,10 +348,10 @@ changed easily.  Please read [[https://orgmode.org/manual/Beamer-Export.html#Bea
 
 * Footnotes
 
-[1] [[https://orgmode.org/worg/sources/org-tutorials/org-beamer/presentation.org][A previously created example presentation]] is available.
+[fn:1] [[https://orgmode.org/worg/sources/org-tutorials/org-beamer/presentation.org][A previously created example presentation]] is available.
 
-[2] I am a firm believer in using the largest font possible to
+[fn:2] I am a firm believer in using the largest font possible to
 encourage less text on slides. This is obviously a personal view.
 
-[3] org-beamer-mode must be turned on for this keybinding to be available.
+[fn:3] org-beamer-mode must be turned on for this keybinding to be available.
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-25 16:13         ` Leo Butler
@ 2024-01-26 11:45           ` Ihor Radchenko
  2024-01-26 20:54             ` Leo Butler
  0 siblings, 1 reply; 18+ messages in thread
From: Ihor Radchenko @ 2024-01-26 11:45 UTC (permalink / raw)
  To: Leo Butler; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

>> Apparently, LaTeX has really hard time processing verbatim code inside
>> beamer frames.
>
> I looked again at the solution here:
> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>
> and it errors out with a recent version of pdflatex:
>
>    This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex)
>
> This is, apparently, a known problem:
>
> https://github.com/josephwright/beamer/issues/360
>
> The end of that issue report includes a work-around that we might apply
> in org. I have attached a patch for your feedback. The example that
> stimulated this discussion compiles with the patch and the testsuite
> shows no errors related to it.

Thanks!
I have concerns about your approach though.

You are replacing all the frame environments with custom environment
unconditionally. However, custom environment has downsides. For example,
\againframe will stop working, as pointed earlier in the linked beamer
thread
https://github.com/josephwright/beamer/issues/360#issuecomment-708705250

Since the problem appears only when the frame contents contains
\end{frame}, it may be sufficient to replace the standard frame
environment with the workaround only in such scenario.

> +;; Needed to set-up Beamer export.
> +(defconst org-beamer--frame-environment
> +  (concat "orgframe" (org-id-uuid))
> +  "Name of the beamer frame environment.
> +This is randomized to prevent collisions.")

Please use constant name. (org-id-uuid) makes export randomized for no
good reason.

>  ;; Install a default set-up for Beamer export.
>  (unless (assoc "beamer" org-latex-classes)
>    (add-to-list 'org-latex-classes
> -	       '("beamer"
> -		 "\\documentclass[presentation]{beamer}"
> +	       `("beamer"
> +		 ,(concat "\\documentclass[presentation]{beamer}\n"
> +                          ;; Define an alias for the beamer frame environment
> +                         "\\newenvironment<>{"
> +                         org-beamer--frame-environment
> +                         "}[1][]{\\begin{frame}[environment="
> +                         org-beamer--frame-environment
> +                         ",#1]}{\\end{frame}}")

Please use `org-beamer-template' rather than modifying the class.
Modifying the class may confuse users.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-25 22:29         ` Leo Butler
@ 2024-01-26 13:30           ` Ihor Radchenko
  0 siblings, 0 replies; 18+ messages in thread
From: Ihor Radchenko @ 2024-01-26 13:30 UTC (permalink / raw)
  To: Leo Butler; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

> Attached is a second patch to de-lint the ox-beamer tutorial.

Thanks!
Applied, onto master.
https://git.sr.ht/~bzg/worg/commit/23c54e97

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-26 11:45           ` Ihor Radchenko
@ 2024-01-26 20:54             ` Leo Butler
  2024-01-29 21:36               ` Leo Butler
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-01-26 20:54 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 3864 bytes --]

On Fri, Jan 26 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>>> Apparently, LaTeX has really hard time processing verbatim code inside
>>> beamer frames.
>>
>> I looked again at the solution here:
>> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>>
>> and it errors out with a recent version of pdflatex:
>>
>>    This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex)
>>
>> This is, apparently, a known problem:
>>
>> https://github.com/josephwright/beamer/issues/360
>>
>> The end of that issue report includes a work-around that we might apply
>> in org. I have attached a patch for your feedback. The example that
>> stimulated this discussion compiles with the patch and the testsuite
>> shows no errors related to it.
>
> Thanks!
> I have concerns about your approach though.
>
> You are replacing all the frame environments with custom environment
> unconditionally. However, custom environment has downsides. For example,
> \againframe will stop working, as pointed earlier in the linked beamer
> thread
> https://github.com/josephwright/beamer/issues/360#issuecomment-708705250

The comment that you are citing shows how to define the custom
environment so that \againframe works correctly. See the attachment
`beamer-example-againframe.tex' and pdf. You can see that \againframe
works with the custom environment.

>
> Since the problem appears only when the frame contents contains
> \end{frame}, it may be sufficient to replace the standard frame
> environment with the workaround only in such scenario.

Yes, that might be true. But my feeling is that it would be simpler and
more robust to use the custom frame environment in most cases.

>
>> +;; Needed to set-up Beamer export.
>> +(defconst org-beamer--frame-environment
>> +  (concat "orgframe" (org-id-uuid))
>> +  "Name of the beamer frame environment.
>> +This is randomized to prevent collisions.")
>
> Please use constant name. (org-id-uuid) makes export randomized for no
> good reason.

There is a good reason to randomize (or at least make customize-able)
the environment name: so that beamer code generated by ox-beamer can be
safely inserted into org files and exported by ox-beamer. With a fixed
name for the environment, we will have just recreated the original
source of the bug report. As a compromise, in the attached patch, I have
made the environment name customize-able.

>
>>  ;; Install a default set-up for Beamer export.
>>  (unless (assoc "beamer" org-latex-classes)
>>    (add-to-list 'org-latex-classes
>> -	       '("beamer"
>> -		 "\\documentclass[presentation]{beamer}"
>> +	       `("beamer"
>> +		 ,(concat "\\documentclass[presentation]{beamer}\n"
>> +                          ;; Define an alias for the beamer frame environment
>> +                         "\\newenvironment<>{"
>> +                         org-beamer--frame-environment
>> +                         "}[1][]{\\begin{frame}[environment="
>> +                         org-beamer--frame-environment
>> +                         ",#1]}{\\end{frame}}")
>
> Please use `org-beamer-template' rather than modifying the class.
> Modifying the class may confuse users.

Ok, I have done so.

The docstring of `org-latex-classes' says:

    The HEADER-STRING is the header that will be inserted into the
    LaTeX file.  It should contain the \documentclass macro, and
    anything else that is needed for this setup.

From that, I figured that would be the correct place to put that
\newenvironment command. I have moved it, as requested.

Please see the revised patch. I believe that I have taken into account
your suggestions.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: beamer-example-againframe.tex --]
[-- Type: text/x-tex; name="beamer-example-againframe.tex", Size: 764 bytes --]

% Created 2024-01-26 Fri 11:42
% Intended LaTeX compiler: lualatex
\documentclass[bigger]{beamer}
\newenvironment<>{OrgFrame}[1][]{\begin{frame}[environment=OrgFrame,#1]}{\end{frame}}
\usetheme{default}

\begin{document}
\begin{OrgFrame}[label=repeatit,fragile]{Verbatim inside a Special Frame Environment}
\tiny
\begin{verbatim}
\begin{frame}[label={sec:org8bc49cc}]{Two columns}
\begin{columns}
\begin{column}{0.4\columnwidth}
\begin{itemize}
\item this slide consists of two columns
\item the first (left) column has no heading and consists of text
\item the second (right) column has an image and is enclosed in an
\alert{example} block
\end{itemize}
\end{column}
\end{verbatim}
\end{OrgFrame}

\againframe<2>{repeatit}
\end{document}

[-- Attachment #3: beamer-example-againframe.pdf --]
[-- Type: application/pdf, Size: 11872 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch --]
[-- Type: text/x-diff; name="0001-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch", Size: 3477 bytes --]

From bfd182b9ca86c2db5cd514cad0a11fd3f5bd8934 Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
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}"))))
 
-
 \f
 ;;; 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"))
+
 \f
 ;;; 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: A MWE that fails with existing ox-beamer.org --]
[-- Type: text/org; name="customize-frame.org", Size: 167 bytes --]

#+startup: beamer
#+LaTeX_CLASS: beamer

* A frame with =verbatim= contents
#+begin_example
\begin{frame}
  Here is a beamer frame.
\end{frame}
#+end_example

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-26 20:54             ` Leo Butler
@ 2024-01-29 21:36               ` Leo Butler
  2024-02-01 15:04                 ` Ihor Radchenko
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-01-29 21:36 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 2303 bytes --]

On Fri, Jan 26 2024, Leo Butler <Leo.Butler@umanitoba.ca> wrote:

> On Fri, Jan 26 2024, Ihor Radchenko <yantar92@posteo.net> wrote:
>
>> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>>
>>>> Apparently, LaTeX has really hard time processing verbatim code inside
>>>> beamer frames.
>>>
>>> I looked again at the solution here:
>>> https://tex.stackexchange.com/questions/140719/verbatim-in-beamer-showing-error-file-ended-while-scanning-use-of-xverbatim
>>>
>>> and it errors out with a recent version of pdflatex:
>>>
>>>    This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex)
>>>
>>> This is, apparently, a known problem:
>>>
>>> https://github.com/josephwright/beamer/issues/360
>>>
>>> The end of that issue report includes a work-around that we might apply
>>> in org. I have attached a patch for your feedback. The example that
>>> stimulated this discussion compiles with the patch and the testsuite
>>> shows no errors related to it.
>>
>> Thanks!
>> I have concerns about your approach though.
>>
>> You are replacing all the frame environments with custom environment
>> unconditionally. However, custom environment has downsides. For example,
>> \againframe will stop working, as pointed earlier in the linked beamer
>> thread
>> https://github.com/josephwright/beamer/issues/360#issuecomment-708705250
>
> The comment that you are citing shows how to define the custom
> environment so that \againframe works correctly. See the attachment
> `beamer-example-againframe.tex' and pdf. You can see that \againframe
> works with the custom environment.
>
>>
>> Since the problem appears only when the frame contents contains
>> \end{frame}, it may be sufficient to replace the standard frame
>> environment with the workaround only in such scenario.
>
> Yes, that might be true. But my feeling is that it would be simpler and
> more robust to use the custom frame environment in most cases.

Replying to self: Attached is a patch that adds a property,
BEAMER_FRAME, that lets the frame environment name be set on a
frame-by-frame basis. In addition, it typesets any fragile frame in the
`orgframe' environment. I am not sure if the latter is really needed,
given the former.

Comments?

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch --]
[-- Type: text/x-diff; name="0002-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch", Size: 5384 bytes --]

From d0117ca35405654c6adc003252eff5a1f629b67a Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
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): A new customize
variable that contains the name of an environment that serves as an
alias for the beamer frame environment.

(org-beamer--format-frame): Introduce the new property, :BEAMER_FRAME.
If set in the headline, use that as name of the frame environment.
Otherwise, in frames marked as fragile, the name of the frame
environment is taken from `org-beamer--frame-environment'.  In all
other frames, the default name is frame.  Unless the frame name is
"frame", the name is added to the list
`org-beamer--frame-environments'.

(org-beamer--frame-environments): New variable and function.  The
variable holds a list of names of frame environments found while
formatting frames.  The function generates the LaTeX code to define
each new frame environment.

(org-beamer-template): Add a call to `org-beamer--frame-environments'
to insert the environment definitions into the beamer document.

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 via the :BEAMER_FRAME property.

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 | 44 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 82c8841aa..4a1e09b85 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -149,9 +149,17 @@ 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"))
+
 \f
 ;;; Internal Variables
 
+(defvar org-beamer--frame-environments '()
+  "List of beamer frame environments.")
+
 (defconst org-beamer-column-widths
   "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
   "The column widths that should be installed as allowed property values.")
@@ -409,12 +417,17 @@ used as a communication channel."
   "Format HEADLINE as a frame.
 CONTENTS holds the contents of the headline.  INFO is a plist
 used as a communication channel."
-  (let ((fragilep
-	 ;; FRAGILEP is non-nil when HEADLINE contains an element
-	 ;; among `org-beamer-verbatim-elements'.
-	 (org-element-map headline org-beamer-verbatim-elements 'identity
-			  info 'first-match)))
-    (concat "\\begin{frame}"
+  (let* ((fragilep
+	  ;; FRAGILEP is non-nil when HEADLINE contains an element
+	  ;; among `org-beamer-verbatim-elements'.
+	  (org-element-map headline org-beamer-verbatim-elements 'identity
+			   info 'first-match))
+         (frame (or (org-element-property :BEAMER_FRAME headline)
+                    (and fragilep org-beamer-frame-environment)
+                    "frame")))
+    (unless (string= frame "frame")
+      (add-to-list 'org-beamer--frame-environments frame))
+    (concat "\\begin{" frame "}"
 	    ;; Overlay specification, if any. When surrounded by
 	    ;; square brackets, consider it as a default
 	    ;; specification.
@@ -481,7 +494,7 @@ used as a communication channel."
 	    ;; output.
 	    (if (not fragilep) contents
 	      (replace-regexp-in-string "\\`\n*" "\\& " (or contents "")))
-	    "\\end{frame}")))
+	    "\\end{" frame "}")))
 
 (defun org-beamer--format-block (headline contents info)
   "Format HEADLINE as a block.
@@ -805,6 +818,21 @@ contextual information."
 	  (org-export-get-reference radio-target info)
 	  text))
 
+;;;; Frame Environments
+;;
+;; Define any needed frame environments.
+
+(defun org-beamer--frame-environments ()
+  "Define beamer frame environments.
+This function is called once from `org-beamer-template'.  As a
+side-effect, it resets `org-beamer--frame-environments' to nil."
+  (prog1
+      (string-join
+       (mapcar
+        #'(lambda(frame)
+            (format "\\newenvironment<>{%s}[1][]{\\begin{frame}[environment=%s,#1]}{\\end{frame}}\n" frame frame))
+        org-beamer--frame-environments))
+    (setq org-beamer--frame-environments '())))
 
 ;;;; Template
 ;;
@@ -825,6 +853,8 @@ holding export options."
      (org-latex--insert-compiler info)
      ;; Document class and packages.
      (org-latex-make-preamble info)
+     ;; Define the frame environments, if needed.
+     (org-beamer--frame-environments)
      ;; Insert themes.
      (let ((format-theme
 	    (lambda (prop command)
-- 
2.43.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: customize-frame.org --]
[-- Type: text/org; name="customize-frame.org", Size: 625 bytes --]

#+startup: beamer
#+LaTeX_CLASS: beamer

* A frame with =verbatim= contents
#+begin_example
\begin{frame}
  Here is a beamer frame.
\end{frame}
#+end_example

This is typeset in an =orgframe= environment, since it is marked as fragile.

* An ordinary frame
\[ z^n = x^n + y^n \]

This is typeset in a =frame= environment.

* A frame with =:BEAMER_FRAME= property set
:PROPERTIES:
:BEAMER_FRAME: special-frame
:END:
#+begin_example
\begin{orgframe}
  Here is a beamer orgframe.
\end{orgframe}
#+end_example

This is typeset in a =special-frame= environment, otherwise a LaTeX error will be thrown.

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-01-29 21:36               ` Leo Butler
@ 2024-02-01 15:04                 ` Ihor Radchenko
  2024-02-14 16:13                   ` Leo Butler
  0 siblings, 1 reply; 18+ messages in thread
From: Ihor Radchenko @ 2024-02-01 15:04 UTC (permalink / raw)
  To: Leo Butler; +Cc: Ihor Radchenko, Daniel Fleischer, Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

>       The docstring of `org-latex-classes' says:
>
>	   The HEADER-STRING is the header that will be inserted into the
>	   LaTeX file.  It should contain the \documentclass macro, and
>	   anything else that is needed for this setup.
>
>       From that, I figured that would be the correct place to put that
>       \newenvironment command. I have moved it, as requested.

Yes, but org-latex-classes is a custom option. If user accidentally
deletes the \newenvironment command, things will not compile.

We generally prefer to keep things that we expect to remain constant out
of customizations.

> Replying to self: Attached is a patch that adds a property,
> BEAMER_FRAME, that lets the frame environment name be set on a
> frame-by-frame basis. In addition, it typesets any fragile frame in the
> `orgframe' environment. I am not sure if the latter is really needed,
> given the former.

Thanks!

> Comments?

I am not a big fan of introducing a new BEAMER_FRAME option.
We already have BEAMER_ENV.

However, BEAMER_ENV is somewhat tricky for frame headings - ox-beamer
allows special values of frame and fullframe (the latter is not fully
documented) to allow frames nesting different from
`org-beamer-frame-level'.

What about not adding BEAMER_FRAME, but instead adding org-lint checker
that will detect when frame text contains the problematic \end{orgframe}?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-02-01 15:04                 ` Ihor Radchenko
@ 2024-02-14 16:13                   ` Leo Butler
  2024-02-19  9:42                     ` Ihor Radchenko
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-02-14 16:13 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

On Thu, Feb 01 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>> Replying to self: Attached is a patch that adds a property,
>> BEAMER_FRAME, that lets the frame environment name be set on a
>> frame-by-frame basis. In addition, it typesets any fragile frame in the
>> `orgframe' environment. I am not sure if the latter is really needed,
>> given the former.
>
> Thanks!
>
>> Comments?
>
> I am not a big fan of introducing a new BEAMER_FRAME option.
> We already have BEAMER_ENV.
>
> However, BEAMER_ENV is somewhat tricky for frame headings - ox-beamer
> allows special values of frame and fullframe (the latter is not fully
> documented) to allow frames nesting different from
> `org-beamer-frame-level'.

I experimented with BEAMER_ENV, but my impression is that that the code
for extracting a label is quite brittle. I may re-visit this option, but
not at this time.

>
> What about not adding BEAMER_FRAME, but instead adding org-lint checker
> that will detect when frame text contains the problematic \end{orgframe}?

Ok, thanks for your feedback. I have modified the patch along the lines
you suggested. It is attached.

Best,
Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch --]
[-- Type: text/x-diff; name="0001-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch", Size: 6733 bytes --]

From cc3e1572e354d18ce57c6a7b89b7fdd96b7fe1a8 Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
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): A new customize
variable.  It contains the name of an environment that serves as an
alias for the beamer frame environment.

(org-beamer--format-frame): Introduce the new property, :BEAMER_FRAME.
If set in the headline, use that as name of the frame environment.
Otherwise, in frames marked as fragile, the name of the frame
environment is taken from `org-beamer--frame-environment'.  In all
other frames, the default name is frame.  Unless the frame name is
"frame", the name is added to the list
`org-beamer--frame-environments'.

(org-beamer--frame-environments): New variable and function.  The
variable holds a list of names of frame environments found while
formatting frames.  The function generates the LaTeX code to define
each new frame environment.

(org-beamer-template): Add a call to `org-beamer--frame-environments'
to insert the environment definitions into the beamer document.

* lisp/org-lint.el (org-lint-beamer-frame): Check the body of each
frame for an occurrence of \begin{orgframe} or \end{orgframe}, or
whatever environment name is in `org-beamer-frame-environment' [4].

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].

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/
[4] https://list.orgmode.org/orgmode/87il38i5tb.fsf@localhost/T/
---
 lisp/org-lint.el  | 15 +++++++++++++++
 lisp/ox-beamer.el | 43 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index f68aeab01..7248f687d 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -1446,6 +1446,17 @@ AST is the buffer parse tree."
          ((memq (org-element-property :type deadline) '(inactive inactive-range))
           (list (org-element-begin planning) "Inactive timestamp in DEADLINE will not appear in agenda."))
          (t nil))))))
+
+(defun org-lint-beamer-frame (ast)
+  "Check for occurrences of begin or end frame."
+  (org-with-point-at ast
+    (goto-char (point-min))
+    (let (result)
+      (while (re-search-forward
+              (concat "\\\\\\(begin\\|end\\){" org-beamer-frame-environment "}") nil t)
+        (push (list (match-beginning 0) "Beamer frame name may cause error when exporting.") result))
+      result)))
+
 \f
 ;;; Checkers declaration
 
@@ -1711,6 +1722,10 @@ AST is the buffer parse tree."
   "Report $ that might be treated as LaTeX fragment boundary."
   #'org-lint-LaTeX-$-ambiguous
   :categories '(markup) :trust 'low)
+(org-lint-add-checker 'beamer-frame
+  "Report that frame text contains beamer frame environment."
+  #'org-lint-beamer-frame
+  :categories '(export) :trust 'low)
 (org-lint-add-checker 'timestamp-syntax
   "Report malformed timestamps."
   #'org-lint-timestamp-syntax
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 82c8841aa..65d8b06ef 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -149,9 +149,17 @@ 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"))
+
 \f
 ;;; Internal Variables
 
+(defvar org-beamer--frame-environments '()
+  "List of beamer frame environments.")
+
 (defconst org-beamer-column-widths
   "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
   "The column widths that should be installed as allowed property values.")
@@ -409,12 +417,16 @@ used as a communication channel."
   "Format HEADLINE as a frame.
 CONTENTS holds the contents of the headline.  INFO is a plist
 used as a communication channel."
-  (let ((fragilep
-	 ;; FRAGILEP is non-nil when HEADLINE contains an element
-	 ;; among `org-beamer-verbatim-elements'.
-	 (org-element-map headline org-beamer-verbatim-elements 'identity
-			  info 'first-match)))
-    (concat "\\begin{frame}"
+  (let* ((fragilep
+	  ;; FRAGILEP is non-nil when HEADLINE contains an element
+	  ;; among `org-beamer-verbatim-elements'.
+	  (org-element-map headline org-beamer-verbatim-elements 'identity
+			   info 'first-match))
+         (frame (or (and fragilep org-beamer-frame-environment)
+                    "frame")))
+    (unless (string= frame "frame")
+      (add-to-list 'org-beamer--frame-environments frame))
+    (concat "\\begin{" frame "}"
 	    ;; Overlay specification, if any. When surrounded by
 	    ;; square brackets, consider it as a default
 	    ;; specification.
@@ -481,7 +493,7 @@ used as a communication channel."
 	    ;; output.
 	    (if (not fragilep) contents
 	      (replace-regexp-in-string "\\`\n*" "\\& " (or contents "")))
-	    "\\end{frame}")))
+	    "\\end{" frame "}")))
 
 (defun org-beamer--format-block (headline contents info)
   "Format HEADLINE as a block.
@@ -805,6 +817,21 @@ contextual information."
 	  (org-export-get-reference radio-target info)
 	  text))
 
+;;;; Frame Environments
+;;
+;; Define any needed frame environments.
+
+(defun org-beamer--frame-environments ()
+  "Define beamer frame environments.
+This function is called once from `org-beamer-template'.  As a
+side-effect, it resets `org-beamer--frame-environments' to nil."
+  (prog1
+      (string-join
+       (mapcar
+        #'(lambda(frame)
+            (format "\\newenvironment<>{%s}[1][]{\\begin{frame}[environment=%1$s,#1]}{\\end{frame}}\n" frame))
+        org-beamer--frame-environments))
+    (setq org-beamer--frame-environments '())))
 
 ;;;; Template
 ;;
@@ -825,6 +852,8 @@ holding export options."
      (org-latex--insert-compiler info)
      ;; Document class and packages.
      (org-latex-make-preamble info)
+     ;; Define the frame environments, if needed.
+     (org-beamer--frame-environments)
      ;; Insert themes.
      (let ((format-theme
 	    (lambda (prop command)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-02-14 16:13                   ` Leo Butler
@ 2024-02-19  9:42                     ` Ihor Radchenko
  2024-02-20 20:41                       ` Leo Butler
  0 siblings, 1 reply; 18+ messages in thread
From: Ihor Radchenko @ 2024-02-19  9:42 UTC (permalink / raw)
  To: Leo Butler; +Cc: Ihor Radchenko, Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

>> What about not adding BEAMER_FRAME, but instead adding org-lint checker
>> that will detect when frame text contains the problematic \end{orgframe}?
>
> Ok, thanks for your feedback. I have modified the patch along the lines
> you suggested. It is attached.

Thanks!
It looks like you left over some parts from the previous patch version.

> (org-beamer--format-frame): Introduce the new property, :BEAMER_FRAME.

... like this.

> (org-beamer--frame-environments): New variable and function.  The
> variable holds a list of names of frame environments found while
> formatting frames.  The function generates the LaTeX code to define
> each new frame environment.
> (org-beamer-template): Add a call to `org-beamer--frame-environments'
> to insert the environment definitions into the beamer document.

And since we only have a single alternative environment in this version
of the patch, `org-beamer--frame-environments' does not appear to be
necessary.

> +(defcustom org-beamer-frame-environment "orgframe"
> +  "Name of the beamer frame environment."
> +  :group 'org-export-beamer
> +  :type '(string :tag "Beamer frame"))

It would be nice to provide a mode detailed explanation about the
purpose of this custom option.

> +(defun org-lint-beamer-frame (ast)
> +  "Check for occurrences of begin or end frame."
> +  (org-with-point-at ast
> +    (goto-char (point-min))
> +    (let (result)
> +      (while (re-search-forward
> +              (concat "\\\\\\(begin\\|end\\){" org-beamer-frame-environment "}") nil t)
> +        (push (list (match-beginning 0) "Beamer frame name may cause error when exporting.") result))
> +      result)))

... and to link this org-lint warning to the
`org-beamer-frame-environment' docstring.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-02-19  9:42                     ` Ihor Radchenko
@ 2024-02-20 20:41                       ` Leo Butler
  2024-02-21 10:51                         ` Ihor Radchenko
  0 siblings, 1 reply; 18+ messages in thread
From: Leo Butler @ 2024-02-20 20:41 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Ihor Radchenko, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 2245 bytes --]

On Mon, Feb 19 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>>> What about not adding BEAMER_FRAME, but instead adding org-lint checker
>>> that will detect when frame text contains the problematic \end{orgframe}?
>>
>> Ok, thanks for your feedback. I have modified the patch along the lines
>> you suggested. It is attached.
>
> Thanks!
> It looks like you left over some parts from the previous patch version.
>
>> (org-beamer--format-frame): Introduce the new property, :BEAMER_FRAME.
>
> ... like this.
>
>> (org-beamer--frame-environments): New variable and function.  The
>> variable holds a list of names of frame environments found while
>> formatting frames.  The function generates the LaTeX code to define
>> each new frame environment.
>> (org-beamer-template): Add a call to `org-beamer--frame-environments'
>> to insert the environment definitions into the beamer document.
>
> And since we only have a single alternative environment in this version
> of the patch, `org-beamer--frame-environments' does not appear to be
> necessary.
>
>> +(defcustom org-beamer-frame-environment "orgframe"
>> +  "Name of the beamer frame environment."
>> +  :group 'org-export-beamer
>> +  :type '(string :tag "Beamer frame"))
>
> It would be nice to provide a mode detailed explanation about the
> purpose of this custom option.
>
>> +(defun org-lint-beamer-frame (ast)
>> +  "Check for occurrences of begin or end frame."
>> +  (org-with-point-at ast
>> +    (goto-char (point-min))
>> +    (let (result)
>> +      (while (re-search-forward
>> +              (concat "\\\\\\(begin\\|end\\){" org-beamer-frame-environment "}") nil t)
>> +        (push (list (match-beginning 0) "Beamer frame name may cause error when exporting.") result))
>> +      result)))
>
> ... and to link this org-lint warning to the
> `org-beamer-frame-environment' docstring.

Thanks for your comments.

I think the attached patch addresses each of your points. It's not clear
to me what you mean by "link(ing) this org-lint warning to the
`org-beamer-frame-environment' docstring", but I have expanded the
warning include mention of this variable.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch --]
[-- Type: text/x-diff; name="0001-lisp-ox-beamer.el-customize-the-beamer-frame-environ.patch", Size: 5594 bytes --]

From 70262bc2469536eeb3aaec926ec71530cfaeca79 Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
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): A new customize
variable.  It contains the name of an environment that serves as an
alias for the beamer frame environment.

(org-beamer-template): Add a call to `org-beamer--frame-environments'
to insert the environment definitions into the beamer document.

* lisp/org-lint.el (org-lint-beamer-frame): Check the body of each
frame for an occurrence of \begin{orgframe} or \end{orgframe}, or
whatever environment name is in `org-beamer-frame-environment' [4].
The warning includes advice to see `org-beamer-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].

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/
[4] https://list.orgmode.org/orgmode/87il38i5tb.fsf@localhost/T/
---
 lisp/org-lint.el  | 15 +++++++++++++++
 lisp/ox-beamer.el | 28 ++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 4d2a55d15..91ee2eb2a 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -1507,6 +1507,17 @@ AST is the buffer parse tree."
          ((memq (org-element-property :type deadline) '(inactive inactive-range))
           (list (org-element-begin planning) "Inactive timestamp in DEADLINE will not appear in agenda."))
          (t nil))))))
+
+(defun org-lint-beamer-frame (ast)
+  "Check for occurrences of begin or end frame."
+  (org-with-point-at ast
+    (goto-char (point-min))
+    (let (result)
+      (while (re-search-forward
+              (concat "\\\\\\(begin\\|end\\){" org-beamer-frame-environment "}") nil t)
+        (push (list (match-beginning 0) "Beamer frame name may cause error when exporting.  See `org-beamer--frame-environment'.") result))
+      result)))
+
 \f
 ;;; Checkers declaration
 
@@ -1787,6 +1798,10 @@ AST is the buffer parse tree."
   "Report $ that might be treated as LaTeX fragment boundary."
   #'org-lint-LaTeX-$-ambiguous
   :categories '(markup) :trust 'low)
+(org-lint-add-checker 'beamer-frame
+  "Report that frame text contains beamer frame environment."
+  #'org-lint-beamer-frame
+  :categories '(export) :trust 'low)
 (org-lint-add-checker 'timestamp-syntax
   "Report malformed timestamps."
   #'org-lint-timestamp-syntax
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 571b9c239..c65166e61 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -148,6 +148,14 @@ 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 alternative beamer frame environment.
+In frames marked as fragile, this environment is used in place of
+the usual frame environment.  This permits insertion of a beamer
+frame inside example blocks."
+  :group 'org-export-beamer
+  :type '(string :tag "Beamer frame"))
+
 \f
 ;;; Internal Variables
 
@@ -408,12 +416,14 @@ used as a communication channel."
   "Format HEADLINE as a frame.
 CONTENTS holds the contents of the headline.  INFO is a plist
 used as a communication channel."
-  (let ((fragilep
-	 ;; FRAGILEP is non-nil when HEADLINE contains an element
-	 ;; among `org-beamer-verbatim-elements'.
-	 (org-element-map headline org-beamer-verbatim-elements 'identity
-			  info 'first-match)))
-    (concat "\\begin{frame}"
+  (let* ((fragilep
+	  ;; FRAGILEP is non-nil when HEADLINE contains an element
+	  ;; among `org-beamer-verbatim-elements'.
+	  (org-element-map headline org-beamer-verbatim-elements 'identity
+			   info 'first-match))
+         (frame (or (and fragilep org-beamer-frame-environment)
+                    "frame")))
+    (concat "\\begin{" frame "}"
 	    ;; Overlay specification, if any. When surrounded by
 	    ;; square brackets, consider it as a default
 	    ;; specification.
@@ -480,7 +490,7 @@ used as a communication channel."
 	    ;; output.
 	    (if (not fragilep) contents
 	      (replace-regexp-in-string "\\`\n*" "\\& " (or contents "")))
-	    "\\end{frame}")))
+	    "\\end{" frame "}")))
 
 (defun org-beamer--format-block (headline contents info)
   "Format HEADLINE as a block.
@@ -814,7 +824,6 @@ contextual information."
 	  (org-export-get-reference radio-target info)
 	  text))
 
-
 ;;;; Template
 ;;
 ;; Template used is similar to the one used in `latex' backend,
@@ -834,6 +843,9 @@ holding export options."
      (org-latex--insert-compiler info)
      ;; Document class and packages.
      (org-latex-make-preamble info)
+     ;; Define the alternative frame environment.
+     (format "\\newenvironment<>{%s}[1][]{\\begin{frame}[environment=%1$s,#1]}{\\end{frame}}\n"
+             org-beamer--frame-environment)
      ;; Insert themes.
      (let ((format-theme
 	    (lambda (prop command)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [BUG] beamer export
  2024-02-20 20:41                       ` Leo Butler
@ 2024-02-21 10:51                         ` Ihor Radchenko
  0 siblings, 0 replies; 18+ messages in thread
From: Ihor Radchenko @ 2024-02-21 10:51 UTC (permalink / raw)
  To: Leo Butler; +Cc: Ihor Radchenko, Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

> Thanks for your comments.
>
> I think the attached patch addresses each of your points. It's not clear
> to me what you mean by "link(ing) this org-lint warning to the
> `org-beamer-frame-environment' docstring", but I have expanded the
> warning include mention of this variable.

Thanks!
Applied, onto main; with amendments:
- adjusted the commit message, removing the mention of
  `org-beamer--frame-environments'.
- fixed typos using incorrect variable name
  `org-beamer--frame-environment'.
- added etc/ORG-NEWS entry
- fixed compiler warnings
- re-worded org-lint warning, suggesting customizing
  `org-beamer-frame-environment'
- added :package-description and :safe keywords to defcustom

Fixed.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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>


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-02-21 15:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-28 19:46 [BUG] beamer export Leo Butler
2022-09-29  2:45 ` Ihor Radchenko
2022-09-29 18:43   ` Daniel Fleischer
2022-12-10 12:49     ` Ihor Radchenko
2024-01-20 14:56   ` Ihor Radchenko
2024-01-23 16:58     ` Leo Butler
2024-01-24 16:06       ` Ihor Radchenko
2024-01-25 16:13         ` Leo Butler
2024-01-26 11:45           ` Ihor Radchenko
2024-01-26 20:54             ` Leo Butler
2024-01-29 21:36               ` Leo Butler
2024-02-01 15:04                 ` Ihor Radchenko
2024-02-14 16:13                   ` Leo Butler
2024-02-19  9:42                     ` Ihor Radchenko
2024-02-20 20:41                       ` Leo Butler
2024-02-21 10:51                         ` Ihor Radchenko
2024-01-25 22:29         ` Leo Butler
2024-01-26 13:30           ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.