emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer


From: Alan Schmitt
Subject: Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
Date: Sun, 08 Jan 2023 17:25:25 +0100

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: signature.asc
Description: PGP signature

>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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]