emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>,
	Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [BUG] Re: The orgframe construct in the Beamer exporter as a default needs a rethink
Date: Tue, 12 Mar 2024 20:32:13 +0000	[thread overview]
Message-ID: <87plvzqjhv.fsf@t14.reltub.ca> (raw)
In-Reply-To: <87bk7jeik8.fsf@localhost> (Ihor Radchenko's message of "Tue, 12 Mar 2024 12:33:11 +0000")

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

On Tue, Mar 12 2024, Ihor Radchenko <yantar92@posteo.net> wrote:

> Pedro Andres Aranda Gutierrez <paaguti@gmail.com> writes:
>
>> Jup, of course. If you look in org-lint.el, one of the cases that would
>> trigger a message is when the frame environment uses "frame" directly and
>> there is a \begin{frame} in the org.
>> Line 1522 onwards in org-lint.el
>
> (1)
> Sure, but we should not demand users to run org-lint. Ideally, exporting
> any valid Org file should work.
> The fact that the presence of \begin{frame} breaks beamer is a technical
> detail users should better not be bothered with. That's why we added the
> orgframe construct.
>
> (2)
> On the other hand, it is clear that Org mode users are unwilling to
> tolerate too much of machine generated latex output. So, going further
> and trying to generate unique orgframe environments might not be ideal.
>
> The current approach is a balance between the above considerations.
>
> AFAIU, what you propose is reverting the orgframe code; that goes
> against the first point.

Current git HEAD allows a user like Pedro to effectively turn off the
orgframe code via

(setq org-beamer-frame-environment "frame")

or an equivalent. 

>
> What I proposed is to reduce the amount of machine-generated code by
> using `org-beamer-frame-environment' only when strictly necessary.

Attached is a patch that limits the use of
`org-beamer-frame-environment' to those frames that contain either
\begin{frame} or \end{frame} in their body.

This has the nice side-effect that one can include example frames
generated by Org without causing an error (previously, Org exported
latex that would not compile). See the attachments.

Leo


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

From cab7cd149868be86f80d2c7bb52e2c09c028d4b1 Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Tue, 12 Mar 2024 15:11:27 -0500
Subject: [PATCH] lisp/ox-beamer.el: constrain use of
 org-beamer-frame-environment

* lisp/ox-beamer.el (org-beamer--format-frame): Only use
`org-beamer-frame-environment' when a frame is marked as fragile and
the frame's contents include either \begin{frame} or \end{frame}.

Refs: https://list.orgmode.org/orgmode/87bk7jeik8.fsf@localhost/
https://list.orgmode.org/87a5nux3zr.fsf@t14.reltub.ca/T/
---
 lisp/ox-beamer.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 4fad37b59..f7e39dde4 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -429,7 +429,10 @@ used as a communication channel."
 	  ;; 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 (or (and fragilep
+                         (or (string-search "\\begin{frame}" contents)
+                             (string-search "\\end{frame}" contents))
+                         org-beamer-frame-environment)
                     "frame")))
     (concat "\\begin{" frame "}"
 	    ;; Overlay specification, if any. When surrounded by
-- 
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: 569 bytes --]

#+startup: beamer
#+LaTeX_CLASS: beamer

* A frame with =orgframe= sample code
#+begin_example
\begin{orgframe}
  Here is a beamer frame.
\end{orgframe}
#+end_example
This is exported in a =frame= environment, although it is marked as fragile.

* A frame with =frame= sample code
#+begin_example
\begin{frame}
  Here is a beamer frame.
\end{frame}
#+end_example
This is exported in an =orgframe= environment, since contains =\begin{frame}= and =\end{frame}=.

* An ordinary frame
\[ z^n = x^n + y^n \]
This is exported in a =frame= environment.


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

% Created 2024-03-12 Tue 15:28
% Intended LaTeX compiler: pdflatex
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\newenvironment<>{orgframe}[1][]{\begin{frame}#2[environment=orgframe,#1]}{\end{frame}}
\usetheme{default}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 29.1 (Org mode 9.7-pre)}, 
 pdflang={English}}
\begin{document}

\begin{frame}{Outline}
\tableofcontents
\end{frame}

\begin{frame}[label={sec:org5fbeeef},fragile]{A frame with \texttt{orgframe} sample code}
 \begin{verbatim}
\begin{orgframe}
  Here is a beamer frame.
\end{orgframe}
\end{verbatim}
This is exported in a \texttt{frame} environment, although it is marked as fragile.
\end{frame}
\begin{orgframe}[label={sec:org500e0c5},fragile]{A frame with \texttt{frame} sample code}
 \begin{verbatim}
\begin{frame}
  Here is a beamer frame.
\end{frame}
\end{verbatim}
This is exported in an \texttt{orgframe} environment, since contains \texttt{\textbackslash{}begin\{frame\}} and \texttt{\textbackslash{}end\{frame\}}.
\end{orgframe}
\begin{frame}[label={sec:orga2d3f31},fragile]{An ordinary frame}
 \[ z^n = x^n + y^n \]
This is exported in a \texttt{frame} environment.
\end{frame}
\end{document}

[-- Attachment #5: customize-frame.pdf --]
[-- Type: application/pdf, Size: 35719 bytes --]

  reply	other threads:[~2024-03-12 20:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 11:33 The orgframe construct in the Beamer exporter as a default needs a rethink Pedro Andres Aranda Gutierrez
2024-03-01 16:03 ` Fraga, Eric
2024-03-01 16:17   ` Pedro Andres Aranda Gutierrez
2024-03-01 17:23   ` Pedro Andres Aranda Gutierrez
2024-03-01 23:11 ` [BUG] " Leo Butler
2024-03-02  6:24   ` Pedro Andres Aranda Gutierrez
2024-03-02  6:39     ` Pedro Andres Aranda Gutierrez
2024-03-02  8:25       ` Pedro Andres Aranda Gutierrez
2024-03-02 12:22         ` Ihor Radchenko
2024-03-02 19:03           ` Pedro Andres Aranda Gutierrez
2024-03-04 11:10             ` Ihor Radchenko
2024-03-09  8:33               ` Pedro Andres Aranda Gutierrez
2024-03-12 12:33                 ` Ihor Radchenko
2024-03-12 20:32                   ` Leo Butler [this message]
2024-03-13  7:16                     ` Pedro Andres Aranda Gutierrez
2024-03-13 13:12                       ` Ihor Radchenko
2024-03-14 15:49                         ` Leo Butler
2024-03-15 14:02                           ` Ihor Radchenko
2024-03-16 13:12                             ` Leo Butler
2024-03-16 23:24                               ` Leo Butler
2024-03-17  9:53                                 ` Ihor Radchenko
2024-03-17 13:18                                   ` Leo Butler
2024-03-17 14:36                                     ` Ihor Radchenko
2024-03-02 12:21       ` Ihor Radchenko
2024-03-02 12:20   ` 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=87plvzqjhv.fsf@t14.reltub.ca \
    --to=leo.butler@umanitoba.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=paaguti@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).