* CUSTOM_id ignored on blocks by ox-beamer
@ 2023-01-04 11:52 alan.schmitt
2023-01-05 9:26 ` [BUG] " Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: alan.schmitt @ 2023-01-04 11:52 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 644 bytes --]
Hello,
I’m writing course slides in org-mode (exported currently to beamer, but
I want to also have html export in the long run), and I have trouble
linking blocks (for theorems or definitions), as the CUSTOM_ID property
is ignored by ox-beamer on blocks.
I see this issue has already been raised on the list
(https://list.orgmode.org/87lflg9ts2.fsf@nicolasgoaziou.fr/T/), and
looking at the code it seems that it still needs to be modified.
Unfortunately the code for org-beamer--format-block is quite complex and
I do not see how to change it to add a label. Could someone on the list
please give me a hand?
Best,
Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [BUG] CUSTOM_id ignored on blocks by ox-beamer
2023-01-04 11:52 CUSTOM_id ignored on blocks by ox-beamer alan.schmitt
@ 2023-01-05 9:26 ` Ihor Radchenko
2023-01-08 16:25 ` Alan Schmitt
0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2023-01-05 9:26 UTC (permalink / raw)
To: alan.schmitt; +Cc: emacs-orgmode
Confirmed.
alan.schmitt@polytechnique.org writes:
> I’m writing course slides in org-mode (exported currently to beamer, but
> I want to also have html export in the long run), and I have trouble
> linking blocks (for theorems or definitions), as the CUSTOM_ID property
> is ignored by ox-beamer on blocks.
>
> I see this issue has already been raised on the list
> (https://list.orgmode.org/87lflg9ts2.fsf@nicolasgoaziou.fr/T/), and
> looking at the code it seems that it still needs to be modified.
> Unfortunately the code for org-beamer--format-block is quite complex and
> I do not see how to change it to add a label. Could someone on the list
> please give me a hand?
If you look inside `org-beamer--format-block', it uses
`org-beamer-environments-default' and `org-beamer-environments-extra' to
format the blocks. See docstring for the latter for details.
The code responsible for LaTeX block generation is
(when (nth 2 env-format) ; when we non-column block
(concat
(org-fill-template ...) ; opening \begin lines
contents ; block body
... ; block closing \end lines
)
org-fill-template is using the template from the
`org-beamer-environments-*' replacing %-chars as described in the
docstring.
In order to handle CUSTOM_ID property, you can
(1) Introduce a new %-substitude to be handled in org-fill-template
call. It will insert block ID. (for example, using
`org-beamer--get-label')
(2) modify `org-beamer-environments-default' to insert label
appropriately.
Patches welcome!
--
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] 7+ messages in thread
* Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
2023-01-05 9:26 ` [BUG] " Ihor Radchenko
@ 2023-01-08 16:25 ` Alan Schmitt
2023-01-15 13:57 ` Alan Schmitt
2023-01-19 10:21 ` Ihor Radchenko
0 siblings, 2 replies; 7+ messages in thread
From: Alan Schmitt @ 2023-01-08 16:25 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 1123 bytes --]
Hello,
On 2023-01-05 09:26, Ihor Radchenko <yantar92@posteo.net> writes:
> If you look inside `org-beamer--format-block', it uses
> `org-beamer-environments-default' and `org-beamer-environments-extra' to
> format the blocks. See docstring for the latter for details.
>
> The code responsible for LaTeX block generation is
>
> (when (nth 2 env-format) ; when we non-column block
> (concat
> (org-fill-template ...) ; opening \begin lines
> contents ; block body
> ... ; block closing \end lines
> )
>
> org-fill-template is using the template from the
> `org-beamer-environments-*' replacing %-chars as described in the
> docstring.
>
> In order to handle CUSTOM_ID property, you can
> (1) Introduce a new %-substitude to be handled in org-fill-template
> call. It will insert block ID. (for example, using
> `org-beamer--get-label')
> (2) modify `org-beamer-environments-default' to insert label
> appropriately.
>
> Patches welcome!
Thank you for the detailed instructions. Here is my attempt at this.
I’ve tested it and it works.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-labels-to-latex-export-of-beamer-blocks.patch --]
[-- Type: text/x-patch, Size: 2114 bytes --]
>From 1747786c7106d0d90d9e8752e361552afacb2d4d Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
Date: Sun, 8 Jan 2023 17:20:31 +0100
Subject: [PATCH] Add labels to latex export of beamer blocks
A new option %l is available to be used in `org-beamer-environments-*'
to insert the label of the current block, obtained using
`org-babel--get-label'
---
lisp/ox-beamer.el | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 689bf1559..3518a0f50 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -178,10 +178,10 @@ through `org-beamer-environments-extra' variable.")
("quotation" "q" "\\begin{quotation}%a %% %h" "\\end{quotation}")
("quote" "Q" "\\begin{quote}%a %% %h" "\\end{quote}")
("structureenv" "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
- ("theorem" "t" "\\begin{theorem}%a[%h]" "\\end{theorem}")
- ("definition" "d" "\\begin{definition}%a[%h]" "\\end{definition}")
- ("example" "e" "\\begin{example}%a[%h]" "\\end{example}")
- ("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
+ ("theorem" "t" "\\begin{theorem}%a[%h]%l" "\\end{theorem}")
+ ("definition" "d" "\\begin{definition}%a[%h]%l" "\\end{definition}")
+ ("example" "e" "\\begin{example}%a[%h]%l" "\\end{example}")
+ ("exampleblock" "E" "\\begin{exampleblock}%a{%h}%l" "\\end{exampleblock}")
("proof" "p" "\\begin{proof}%a[%h]" "\\end{proof}")
("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
"Environments triggered by properties in Beamer export.
@@ -578,6 +578,7 @@ used as a communication channel."
(cons "O" (or raw-options ""))
(cons "h" title)
(cons "r" raw-title)
+ (cons "l" (format "\\label{%s}" (org-beamer--get-label headline info)))
(cons "H" (if (equal raw-title "") ""
(format "{%s}" raw-title)))
(cons "U" (if (equal raw-title "") ""
--
2.39.0
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
Best,
Alan
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
2023-01-08 16:25 ` Alan Schmitt
@ 2023-01-15 13:57 ` Alan Schmitt
2023-01-19 10:21 ` Ihor Radchenko
1 sibling, 0 replies; 7+ messages in thread
From: Alan Schmitt @ 2023-01-15 13:57 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3611 bytes --]
Hello,
Please let me know if there is something I should do to help integrate
this patch.
Best,
Alan
On 2023-01-08 17:25, Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hello,
>
> On 2023-01-05 09:26, Ihor Radchenko <yantar92@posteo.net> writes:
>
>> If you look inside `org-beamer--format-block', it uses
>> `org-beamer-environments-default' and `org-beamer-environments-extra' to
>> format the blocks. See docstring for the latter for details.
>>
>> The code responsible for LaTeX block generation is
>>
>> (when (nth 2 env-format) ; when we non-column block
>> (concat
>> (org-fill-template ...) ; opening \begin lines
>> contents ; block body
>> ... ; block closing \end lines
>> )
>>
>> org-fill-template is using the template from the
>> `org-beamer-environments-*' replacing %-chars as described in the
>> docstring.
>>
>> In order to handle CUSTOM_ID property, you can
>> (1) Introduce a new %-substitude to be handled in org-fill-template
>> call. It will insert block ID. (for example, using
>> `org-beamer--get-label')
>> (2) modify `org-beamer-environments-default' to insert label
>> appropriately.
>>
>> Patches welcome!
>
> Thank you for the detailed instructions. Here is my attempt at this.
> I’ve tested it and it works.
>
>>From 1747786c7106d0d90d9e8752e361552afacb2d4d Mon Sep 17 00:00:00 2001
> From: Alan Schmitt <alan.schmitt@polytechnique.org>
> Date: Sun, 8 Jan 2023 17:20:31 +0100
> Subject: [PATCH] Add labels to latex export of beamer blocks
>
> A new option %l is available to be used in `org-beamer-environments-*'
> to insert the label of the current block, obtained using
> `org-babel--get-label'
> ---
> lisp/ox-beamer.el | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
> index 689bf1559..3518a0f50 100644
> --- a/lisp/ox-beamer.el
> +++ b/lisp/ox-beamer.el
> @@ -178,10 +178,10 @@ through `org-beamer-environments-extra' variable.")
> ("quotation" "q" "\\begin{quotation}%a %% %h" "\\end{quotation}")
> ("quote" "Q" "\\begin{quote}%a %% %h" "\\end{quote}")
> ("structureenv" "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
> - ("theorem" "t" "\\begin{theorem}%a[%h]" "\\end{theorem}")
> - ("definition" "d" "\\begin{definition}%a[%h]" "\\end{definition}")
> - ("example" "e" "\\begin{example}%a[%h]" "\\end{example}")
> - ("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
> + ("theorem" "t" "\\begin{theorem}%a[%h]%l" "\\end{theorem}")
> + ("definition" "d" "\\begin{definition}%a[%h]%l" "\\end{definition}")
> + ("example" "e" "\\begin{example}%a[%h]%l" "\\end{example}")
> + ("exampleblock" "E" "\\begin{exampleblock}%a{%h}%l" "\\end{exampleblock}")
> ("proof" "p" "\\begin{proof}%a[%h]" "\\end{proof}")
> ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
> "Environments triggered by properties in Beamer export.
> @@ -578,6 +578,7 @@ used as a communication channel."
> (cons "O" (or raw-options ""))
> (cons "h" title)
> (cons "r" raw-title)
> + (cons "l" (format "\\label{%s}" (org-beamer--get-label headline info)))
> (cons "H" (if (equal raw-title "") ""
> (format "{%s}" raw-title)))
> (cons "U" (if (equal raw-title "") ""
> --
> 2.39.0
>
>
> Best,
>
> Alan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
2023-01-08 16:25 ` Alan Schmitt
2023-01-15 13:57 ` Alan Schmitt
@ 2023-01-19 10:21 ` Ihor Radchenko
2023-02-09 9:14 ` Alan Schmitt
1 sibling, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2023-01-19 10:21 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>> (2) modify `org-beamer-environments-default' to insert label
>> appropriately.
>>
>> Patches welcome!
>
> Thank you for the detailed instructions. Here is my attempt at this.
> I’ve tested it and it works.
Thanks!
>>From 1747786c7106d0d90d9e8752e361552afacb2d4d Mon Sep 17 00:00:00 2001
> From: Alan Schmitt <alan.schmitt@polytechnique.org>
> Date: Sun, 8 Jan 2023 17:20:31 +0100
> Subject: [PATCH] Add labels to latex export of beamer blocks
>
> A new option %l is available to be used in `org-beamer-environments-*'
> to insert the label of the current block, obtained using
> `org-babel--get-label'
Please add a changelog entry detailing the definitions where the changes
happened. See https://orgmode.org/worg/org-contribute.html#commit-messages
> - ("theorem" "t" "\\begin{theorem}%a[%h]" "\\end{theorem}")
> - ("definition" "d" "\\begin{definition}%a[%h]" "\\end{definition}")
> - ("example" "e" "\\begin{example}%a[%h]" "\\end{example}")
> - ("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
> + ("theorem" "t" "\\begin{theorem}%a[%h]%l" "\\end{theorem}")
> + ("definition" "d" "\\begin{definition}%a[%h]%l" "\\end{definition}")
> + ("example" "e" "\\begin{example}%a[%h]%l" "\\end{example}")
> + ("exampleblock" "E" "\\begin{exampleblock}%a{%h}%l" "\\end{exampleblock}")
Please document the new %l option in the docstring of
`org-beamer-environments-extra' and add a notice to etc/ORG-NEWS file.
--
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] 7+ messages in thread
* Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
2023-01-19 10:21 ` Ihor Radchenko
@ 2023-02-09 9:14 ` Alan Schmitt
2023-02-10 10:57 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: Alan Schmitt @ 2023-02-09 9:14 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 395 bytes --]
Hello Ihor,
On 2023-01-19 10:21, Ihor Radchenko <yantar92@posteo.net> writes:
> Please add a changelog entry detailing the definitions where the changes
> happened. See https://orgmode.org/worg/org-contribute.html#commit-messages
>
...
> Please document the new %l option in the docstring of
> `org-beamer-environments-extra' and add a notice to etc/ORG-NEWS file.
Here is an updated patch.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ox-beamer.el-add-labels-to-latex-export.patch --]
[-- Type: text/x-patch, Size: 3560 bytes --]
>From c480b26f9cb536b68b00930a19d59485f9221ef7 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
Date: Sun, 8 Jan 2023 17:20:31 +0100
Subject: [PATCH] lisp/ox-beamer.el: add labels to latex export
* ox-beamer.el (org-beamer-environments-default): add label escape to
some environments
(org-beamer--format-block): generate label string for label escape
(org-beamer-environments-extra): document label escape
A new escape %l is available to be used in `org-beamer-environments-*'
to insert the label of the current block, obtained using
`org-babel--get-label'
---
etc/ORG-NEWS | 5 +++++
lisp/ox-beamer.el | 10 ++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c5e9cd568..47806484e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -79,6 +79,11 @@ document header:
The face ~org-agenda-calendar-daterange~ is used to show entries with
a date range in the agenda. It inherits from the default face in
order to remain backward-compatible.
+*** New escape in ~org-beamer-environments-extra~ for labels in Beamer export
+The escape ~%l~ in ~org-beamer-environments-extra~ inserts the label
+obtained from ~org-beamer--get-label~. This is added to the default
+environments "theorem", "definition", "example", and "exampleblock" in
+~org-beamer-environments-default~.
** New features
*** ~org-metaup~ and ~org-metadown~ now act on headings in region
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 689bf1559..5df78d5a4 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -116,6 +116,7 @@ open The opening template for the environment, with the following escapes
%r the raw headline text (i.e. without any processing)
%H if there is headline text, that raw text in {} braces
%U if there is headline text, that raw text in [] brackets
+ %l the label, obtained from `org-beamer--get-label'
close The closing string of the environment."
:group 'org-export-beamer
:version "24.4"
@@ -178,10 +179,10 @@ through `org-beamer-environments-extra' variable.")
("quotation" "q" "\\begin{quotation}%a %% %h" "\\end{quotation}")
("quote" "Q" "\\begin{quote}%a %% %h" "\\end{quote}")
("structureenv" "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
- ("theorem" "t" "\\begin{theorem}%a[%h]" "\\end{theorem}")
- ("definition" "d" "\\begin{definition}%a[%h]" "\\end{definition}")
- ("example" "e" "\\begin{example}%a[%h]" "\\end{example}")
- ("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
+ ("theorem" "t" "\\begin{theorem}%a[%h]%l" "\\end{theorem}")
+ ("definition" "d" "\\begin{definition}%a[%h]%l" "\\end{definition}")
+ ("example" "e" "\\begin{example}%a[%h]%l" "\\end{example}")
+ ("exampleblock" "E" "\\begin{exampleblock}%a{%h}%l" "\\end{exampleblock}")
("proof" "p" "\\begin{proof}%a[%h]" "\\end{proof}")
("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
"Environments triggered by properties in Beamer export.
@@ -578,6 +579,7 @@ used as a communication channel."
(cons "O" (or raw-options ""))
(cons "h" title)
(cons "r" raw-title)
+ (cons "l" (format "\\label{%s}" (org-beamer--get-label headline info)))
(cons "H" (if (equal raw-title "") ""
(format "{%s}" raw-title)))
(cons "U" (if (equal raw-title "") ""
--
2.39.1
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
Best,
Alan
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
2023-02-09 9:14 ` Alan Schmitt
@ 2023-02-10 10:57 ` Ihor Radchenko
0 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2023-02-10 10:57 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Here is an updated patch.
Thanks!
Applied, onto main. I changed quoting style of some terms in ORG-NEWS
and moved the new item to the top as we usually do for new items (last
comes first).
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=666a61bcc
--
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] 7+ messages in thread
end of thread, other threads:[~2023-02-10 10:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 11:52 CUSTOM_id ignored on blocks by ox-beamer alan.schmitt
2023-01-05 9:26 ` [BUG] " Ihor Radchenko
2023-01-08 16:25 ` Alan Schmitt
2023-01-15 13:57 ` Alan Schmitt
2023-01-19 10:21 ` Ihor Radchenko
2023-02-09 9:14 ` Alan Schmitt
2023-02-10 10:57 ` 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.