Re: [BUG] beamer export

2024-02-21 Thread Ihor Radchenko
Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2024-02-20 Thread Leo Butler
On Mon, Feb 19 2024, Ihor Radchenko  wrote:

> Leo Butler  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

From 70262bc2469536eeb3aaec926ec71530cfaeca79 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): 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)))
+
 
 ;;; 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
 

Re: [BUG] beamer export

2024-02-19 Thread Ihor Radchenko
Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2024-02-14 Thread Leo Butler
On Thu, Feb 01 2024, Ihor Radchenko  wrote:

> Leo Butler  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

From cc3e1572e354d18ce57c6a7b89b7fdd96b7fe1a8 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): 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)))
+
 
 ;;; 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 

Re: [BUG] beamer export

2024-02-01 Thread Ihor Radchenko
Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2024-01-29 Thread Leo Butler
On Fri, Jan 26 2024, Leo Butler  wrote:

> On Fri, Jan 26 2024, Ihor Radchenko  wrote:
>
>> Leo Butler  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

From d0117ca35405654c6adc003252eff5a1f629b67a 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): 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"))
+
 
 ;;; 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 

Re: Re: [BUG] beamer export

2024-01-27 Thread Pedro Andres Aranda Gutierrez
Hi

CAVEAT EMPTOR: Although it’s some years that I have been using org to create my 
slides, I never needed this… Interesting to learn new things ;-) 

I personally would not oppose to have a customizable org-frame-environment 
variable, with its default value being “frame”. 
Then, when actually emitting the code, add something like:

(unless (string= org-frame-environment “frame”
 …)

Which would create the code most of us would expect (i.e. 
\begin{frame}…\end{frame}) in almost any case except when you really need the 
`newenvironment’ construct.

My .02 cents, /PA

> El 27 ene 2024, a las 18:00, emacs-orgmode-requ...@gnu.org escribió:
> 
> Message: 2
> Date: Fri, 26 Jan 2024 20:54:17 +
> From: Leo Butler mailto:leo.but...@umanitoba.ca>>
> To: Ihor Radchenko mailto:yanta...@posteo.net>>
> Cc: Ihor Radchenko mailto:yanta...@gmail.com>>, Daniel 
> Fleischer
>   mailto:danfl...@gmail.com>>, Org Mode Mailing List 
> mailto:emacs-orgmode@gnu.org>>
> Subject: Re: [BUG] beamer export
> Message-ID: <87wmrvlsso@t14.reltub.ca 
> <mailto:87wmrvlsso@t14.reltub.ca>>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> On Fri, Jan 26 2024, Ihor Radchenko  <mailto:yanta...@posteo.net>> wrote:
> 
>> Leo Butler mailto:leo.but...@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
>>>  
>>> <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 
>>> <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 
>> <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&qu

Re: [BUG] beamer export

2024-01-26 Thread Leo Butler
On Fri, Jan 26 2024, Ihor Radchenko  wrote:

> Leo Butler  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

% 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}


beamer-example-againframe.pdf
Description: beamer-example-againframe.pdf
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 

Re: [BUG] beamer export

2024-01-26 Thread Ihor Radchenko
Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2024-01-26 Thread Ihor Radchenko
Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2024-01-25 Thread Leo Butler
On Wed, Jan 24 2024, Ihor Radchenko  wrote:

> Leo Butler  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

From 7a52949ce25c7576896785ba185f9bd6afc7f12b Mon Sep 17 00:00:00 2001
From: Leo Butler 
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



Re: [BUG] beamer export

2024-01-25 Thread Leo Butler
On Wed, Jan 24 2024, Ihor Radchenko  wrote:

> Leo Butler  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

From 9cb3489e3fe80fb2e3996b737f528aa4db9ba62d 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:  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}")
 		 

Re: [BUG] beamer export

2024-01-24 Thread Ihor Radchenko
Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2024-01-20 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Leo Butler  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 .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2022-12-10 Thread Ihor Radchenko
Daniel Fleischer  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 .
Support Org development at ,
or support my work at 



Re: [BUG] Beamer export fails with async export [9.5.3 (9.5.3-g4197fc @ /home/thomas/.emacs.d/straight/build/org/)]

2022-10-21 Thread Ihor Radchenko
Thomas Freeman  writes:

> When exporting a LaTeX beamer presentation as an asynchronous process
> (by using C-a prior to selecting the export option), the export fails with 
> the following error:
>
> (error "Unknown \"nil\" back-end: Aborting export")

Could you please provide detailed steps how to reproduce the problem
together with a sample beamer presentation file?
See https://orgmode.org/manual/Feedback.html#Feedback

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] beamer export

2022-09-29 Thread Daniel Fleischer
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  wrote:

> Leo Butler  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
>


Re: [BUG] beamer export

2022-09-28 Thread Ihor Radchenko
Leo Butler  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



Re: [BUG] beamer export -- text inside section, before next headline, has no frame [9.5.2 (9.5.2-ge7ea95 @ /home/hugo/.config/emacs/straight/build/org/)]

2022-02-04 Thread Eric S Fraga
Dear Hugo,

On Thursday,  3 Feb 2022 at 17:26, Hugo Heagren wrote:
> I have org-beamer-frame-level set to 2, so when exporting to beamer,
> top-level headlines become sections, and second-level headlines become
> frames. I often want to include a short explanation/intro of the
> section, before moving onto the more specific slide (I have found this
> is good for complex lectures).

But if you want that short explanation to be on a slide, simply use a
second level heading, e.g. "** Introduction to the section"?  Beamer
does not have a distinction in "levels" of slides/frames and it would
not make sense to have top level (section) text be a slide.

-- 
: Eric S Fraga, with org release_9.5.2-364-ge7ea95 in Emacs 29.0.50