From 46e13c3ebd32f685080914b4d6a5574296ef73cc Mon Sep 17 00:00:00 2001 From: Alexander Gogl Date: Wed, 17 Apr 2024 16:00:41 +0200 Subject: [PATCH] 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. Link: https://list.orgmode.org/m2v84fhj9u.fsf@gmail.com/T/#m71809443a3b328ed704712ba53e6bb78282249cc TINYCHANGE --- etc/ORG-NEWS | 12 ++++++++++++ lisp/ox-latex.el | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index dbf849422..fc2ff9e00 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -999,6 +999,18 @@ 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~ 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}~ instead of +the default ~\footnote{%s%s}~). + +The option can be customized either by + +1. setting the global variable in the ~org-export-latex~ customization + group or +2. by setting the file local keyword =LATEX_FOOTNOTE_COMMAND= + ** New features *** ~org-paste-subtree~ now handles =C-u= and =C-u C-u= prefix arguments specially diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 5c19e1fe7..cdbf65cf6 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -135,6 +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) + (:latex-default-footnote-command "LATEX_FOOTNOTE_COMMAND" 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 +668,17 @@ 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 +command like \"\\sidenote{%s%s}\" that you want to use. +The value will be passed as an argument to `format' as the following + (format org-latex-default-footnote-command + footnote-description footnote-label)" + :group 'org-export-latex + :package-version '(Org . "9.7") + :type 'string) + (defcustom org-latex-footnote-separator "\\textsuperscript{,}\\," "Text used to separate footnotes." :group 'org-export-latex @@ -780,7 +792,6 @@ default we use here encompasses both." :group 'org-export-latex :type 'string) - ;;;; Tables (defcustom org-latex-default-table-environment "tabular" @@ -2239,7 +2250,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 (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) "")