emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: [BUG] CUSTOM_id ignored on blocks by ox-beamer
Date: Sun, 15 Jan 2023 14:57:25 +0100	[thread overview]
Message-ID: <m2tu0ruchm.fsf@m4x.org> (raw)
In-Reply-To: <m2lemd56yy.fsf@m4x.org>

[-- 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 --]

  reply	other threads:[~2023-01-15 13:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-01-19 10:21     ` Ihor Radchenko
2023-02-09  9:14       ` Alan Schmitt
2023-02-10 10:57         ` 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=m2tu0ruchm.fsf@m4x.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    /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).