From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Ihor Radchenko <yantar92@gmail.com>,
Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [BUG] beamer export
Date: Tue, 20 Feb 2024 20:41:46 +0000 [thread overview]
Message-ID: <87a5nux3zr.fsf@t14.reltub.ca> (raw)
In-Reply-To: <877cj0hjtb.fsf@localhost> (Ihor Radchenko's message of "Mon, 19 Feb 2024 09:42:08 +0000")
[-- 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
next prev parent reply other threads:[~2024-02-20 20:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-02-21 10:51 ` Ihor Radchenko
2024-01-25 22:29 ` Leo Butler
2024-01-26 13:30 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5nux3zr.fsf@t14.reltub.ca \
--to=leo.butler@umanitoba.ca \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@gmail.com \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).