emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alexander Gogl <gogl.alexander@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [FR] Please add custom command variable to org-latex-footnote-reference
Date: Wed, 17 Apr 2024 21:32:02 +0200	[thread overview]
Message-ID: <m2v84fhj9u.fsf@gmail.com> (raw)
In-Reply-To: <87o7a8arjt.fsf@localhost>

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

Dear Ihor,

thank's for your advice! Here is the updated patch. Now it works.

......................................................................
ox-latex: New option to customize LaTeX footnote command

Some LaTeX classes define their own footnote commands. For example,
kaobook
(https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
has \footnotes and \sidenotes, whereby sidenotes (notes are put into the
outter margin) are the dominant form of putting notes in kaobook. It
would be great if you could make the footnote command in the footnote
function customizable. My proposal is in the attachment.
......................................................................


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-added-option-to-customize-latex-footnote-command-in-.patch --]
[-- Type: text/x-patch, Size: 2964 bytes --]

From 1c7bee53ac91a8296c144f157ab8646b1a7a6595 Mon Sep 17 00:00:00 2001
From: Alexander Gogl <gogl.alexander@gmail.com>
Date: Wed, 17 Apr 2024 16:00:41 +0200
Subject: [PATCH 1/2] added option to customize latex footnote command in
 export

---
 etc/ORG-NEWS     |  4 ++++
 lisp/ox-latex.el | 14 ++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e61bd6988..a579260f5 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -999,6 +999,10 @@ even though it does not have its own ID.  By giving files top-level id
 properties, links to headlines in the file can also be made more
 robust by using the file id instead of the file path.
 
+*** New option ~latex-default-footnote-command~
+
+This new option allows you to define the LaTeX command the  org-mode footnotes are converted to (for example ~\\sidenote{%s%s}~).
+
 ** New features
 *** =colview= dynamic block now writes column width specifications
 
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5c19e1fe7..b45d13ca2 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -135,6 +135,9 @@
     (:latex-default-table-environment nil nil org-latex-default-table-environment)
     (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
     (:latex-default-table-mode nil nil org-latex-default-table-mode)
+    ;; TODO implement options variable
+    (:latex-default-footnote-command "\\footnote{%s%s}" nil org-latex-default-footnote-command)
+    ;;
     (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format)
     (:latex-engraved-options nil nil org-latex-engraved-options)
     (:latex-engraved-preamble nil nil org-latex-engraved-preamble)
@@ -667,6 +670,14 @@ The function result will be used in the section format string."
 
 ;;;; Footnotes
 
+(defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
+  "Default command used to insert footnotes.
+  Customize this command if the LaTeX class provides a different notation command like `\\sidenote{%s%s}' that you want to use."
+  :group 'org-export-latex
+  :version "24.4"  ;; FIXME enter correct version
+  :package-version '(Org . "9.7")
+  :type 'string)
+
 (defcustom org-latex-footnote-separator "\\textsuperscript{,}\\,"
   "Text used to separate footnotes."
   :group 'org-export-latex
@@ -780,7 +791,6 @@ default we use here encompasses both."
   :group 'org-export-latex
   :type 'string)
 
-
 ;;;; Tables
 
 (defcustom org-latex-default-table-environment "tabular"
@@ -2239,7 +2249,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
       (t
        (let ((def (org-export-get-footnote-definition footnote-reference info)))
 	 (concat
-	  (format "\\footnote{%s%s}" (org-trim (org-export-data def info))
+	  (format org-latex-default-footnote-command (org-trim (org-export-data def info))
 		  ;; Only insert a \label if there exist another
 		  ;; reference to def.
 		  (cond ((not label) "")
-- 
2.41.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-ox-latex-New-option-to-customize-LaTeX-footnote-comm.patch --]
[-- Type: text/x-patch, Size: 4117 bytes --]

From 12d211a5f0c56faf1b829fef26f788f210a31382 Mon Sep 17 00:00:00 2001
From: Alexander Gogl <gogl.alexander@gmail.com>
Date: Wed, 17 Apr 2024 21:22:51 +0200
Subject: [PATCH 2/2] ox-latex: New option to customize LaTeX footnote command

* lisp/ox-latex.el (org-export-define-backend): Add option.
(org-latex-default-footnote-command): New custom variable.
(org-latex-footnote-reference): Replace string "\\footnote{%s%s}"
with custom variable.

* etc/ORG-NEWS (New and changed options): Add description to option.

Some LaTeX classes define their own footnote commands. For example,
kaobook (https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
has \footnotes and \sidenotes, whereby sidenotes (notes are put into
the outter margin) are the dominant form of putting notes in
kaobook. It would be great if you could make the footnote command in
the footnote function customizable. My proposal is in the attachment.

Modified from a feature request by Alexander Gogl.

TINYCHANGE
---
 etc/ORG-NEWS     | 12 ++++++++++--
 lisp/ox-latex.el | 12 ++++++------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a579260f5..571ab3c98 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -999,9 +999,17 @@ even though it does not have its own ID.  By giving files top-level id
 properties, links to headlines in the file can also be made more
 robust by using the file id instead of the file path.
 
-*** New option ~latex-default-footnote-command~
+*** New option ~latex-default-footnote-command~ to customize the LaTeX footnote command
 
-This new option allows you to define the LaTeX command the  org-mode footnotes are converted to (for example ~\\sidenote{%s%s}~).
+This new option allows you to define the LaTeX command the Org mode
+footnotes are converted to (for example ~\sidenote{%s%s}~ instead of
+the default ~\footnote{%s%s}~).
+
+The option can be customized either by
+
+a) setting the global variable in the ~org-export-latex~ customization
+   group or
+b) by setting the file local variable ~LATEX_FOOTNOTE_COMMAND~
 
 ** New features
 *** =colview= dynamic block now writes column width specifications
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b45d13ca2..058b5a31a 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -135,9 +135,7 @@
     (:latex-default-table-environment nil nil org-latex-default-table-environment)
     (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
     (:latex-default-table-mode nil nil org-latex-default-table-mode)
-    ;; TODO implement options variable
-    (:latex-default-footnote-command "\\footnote{%s%s}" nil org-latex-default-footnote-command)
-    ;;
+    (:latex-default-footnote-command "LATEX_FOOTNOTE_COMMAND" nil org-latex-default-footnote-command t)
     (:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format)
     (:latex-engraved-options nil nil org-latex-engraved-options)
     (:latex-engraved-preamble nil nil org-latex-engraved-preamble)
@@ -672,9 +670,11 @@ The function result will be used in the section format string."
 
 (defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
   "Default command used to insert footnotes.
-  Customize this command if the LaTeX class provides a different notation command like `\\sidenote{%s%s}' that you want to use."
+  Customize this command if the LaTeX class provides a different
+  command like `\sidenote{%s%s}' that you want to use.
+%s
+"
   :group 'org-export-latex
-  :version "24.4"  ;; FIXME enter correct version
   :package-version '(Org . "9.7")
   :type 'string)
 
@@ -2249,7 +2249,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
       (t
        (let ((def (org-export-get-footnote-definition footnote-reference info)))
 	 (concat
-	  (format org-latex-default-footnote-command (org-trim (org-export-data def info))
+	  (format (plist-get info :latex-default-footnote-command) (org-trim (org-export-data def info))
 		  ;; Only insert a \label if there exist another
 		  ;; reference to def.
 		  (cond ((not label) "")
-- 
2.41.0


[-- Attachment #4: Type: text/plain, Size: 3968 bytes --]



Best

Alexander

PS: I have a hard time to setup an environment to test the patch because
my Spacemacs configuration conflicts with the Org mode development
version. Can anyone provide me a link to a ressource that describes the
procedure?

Ihor Radchenko <yantar92@posteo.net> --- 2024-04-17 Mi 16:21:

> Alexander Gogl <gogl.alexander@gmail.com> writes:
>
>> I completed the patch (see attachment). Please let me know if I made any mistake in the patch or if I should send the patch to another E-Mail-Address.
>
> Thanks! We use Org mailing list (public) to send patches and discuss Org
> mode development.
>
> I added Org mailing list to CC in this email.
> You can simply use "Reply All" to send the next version of the patch.
>
>> Reason for patch
>>
>> Some LaTeX classes define their own footnote commands. For example, kaobook
>> (https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
>> has \footnotes and \sidenotes, whereby sidenotes (notes are put into the
>> outter margin) are the dominant form of putting notes in kaobook. It would be
>> great if you could make the footnote command in the footnote function
>> customizable. My proposal is in the attachment.
>
> You can put this description in the commit message.
> Also, if you can, please add changelog entries, as described in
> https://orgmode.org/worg/org-contribute.html#commit-messages
>
>> Subject: [PATCH] added option to customize latex footnote command in export
>
> What about
>
> ox-latex: New option to customize LaTeX footnote command
>
> My version (1) clearly states which library the patch is changing; (2)
> Uses imperative tone as we usually do in commit messages.
>
>> +*** New option ~latex-default-footnote-command~
>> +
>> +This new option allows you to define the LaTeX command the  org-mode footnotes are converted to (for example ~\\sidenote{%s%s}~).
>
> We use "Org mode" to name Org mode.
> Also, we fill the text to default `fill-column' value of 70.
>
>> diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
>> index 5c19e1fe7..b45d13ca2 100644
>> --- a/lisp/ox-latex.el
>> +++ b/lisp/ox-latex.el
>> @@ -135,6 +135,9 @@
>>      (:latex-default-table-environment nil nil org-latex-default-table-environment)
>>      (:latex-default-quote-environment nil nil org-latex-default-quote-environment)
>>      (:latex-default-table-mode nil nil org-latex-default-table-mode)
>> +    ;; TODO implement options variable
>
> May you explain the purpose of this TODO?
>
>> +    (:latex-default-footnote-command "\\footnote{%s%s}" nil org-latex-default-footnote-command)
>
> "\\footnote{%s%s}" makes no sense in this context. The format of export
> options is described in the docstring of `org-export-options-alist':
>
>     The key of the alist is the property name, and the value is a list
>     like (KEYWORD OPTION DEFAULT BEHAVIOR) where:
>     
>     KEYWORD is a string representing a buffer keyword, or nil.
>     OPTION is a string that could be found in an #+OPTIONS: line.
>     DEFAULT is the default value for the property.
>     BEHAVIOR determines how Org should handle multiple keywords for
>
> You placed "\\footnote{%s%s}" in KEYWORD slot, which is not right.
> KEYWORD slot is what defines how to set the value locally. For example,
> "AUTHOR" in (:author "AUTHOR" nil user-full-name parse) means that
> :author export option can be set as
>
> #+AUTHOR: value
>
>> +(defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
>> +  "Default command used to insert footnotes.
>> +  Customize this command if the LaTeX class provides a different notation command like `\\sidenote{%s%s}' that you want to use."
>
> Please explain what is the meaning of each %s in the value in the
> docstring.
>
> Also, please re-fill the docstring to avoid long lines.
>
>> +  :group 'org-export-latex
>> +  :version "24.4"  ;; FIXME enter correct version
>
> :version is not needed. It is obsolete keyword we no longer use in the
> new customizations.


      reply	other threads:[~2024-04-17 19:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 14:00 [FR] Please add custom command variable to org-latex-footnote-reference Alexander Gogl
2023-12-08 22:16 ` Ihor Radchenko
     [not found]   ` <m2msuhdnt4.fsf@pc75-c847.uibk.ac.at>
     [not found]     ` <87y1chwmut.fsf@localhost>
     [not found]       ` <m25xzk8h8q.fsf@gmail.com>
     [not found]         ` <875xzig0jy.fsf@localhost>
     [not found]           ` <m27cgw3wvx.fsf@gmail.com>
2024-04-17 16:21             ` Ihor Radchenko
2024-04-17 19:32               ` Alexander Gogl [this message]

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=m2v84fhj9u.fsf@gmail.com \
    --to=gogl.alexander@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --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).