Answers inline and patch attached ...

On Sat, 4 Jul 2026 at 18:54, Ihor Radchenko <[email protected]> wrote:

> Pedro Andres Aranda Gutierrez <[email protected]> writes:
>
> >> That is org-latex--make-template-from-info?
> >>
> > Yup,  I have start to write a couple of helper functions for vc-dir.
> > I fear I trusted them blindly. We found a corner base...
>
> Sorry, I meant "What is ...".
> There is no such function in ox-latex.
>
Reiterate, corner case in my functions, I'm trying to find out where that
came from...
Anyhow, fixed.

>
> >> Why not simply org-latex-metadata?
> >>
> >
> > Because
> > \\DocumentMetadata <--> org-latex-doc-metadata
> > is an additional hint that might be useful in the future if more
> > metadata are introduced.
>
> Well. Then, why #+LATEX_METADATA and not #+LATEX_DOC_METADATA?
>
Done

>
> >> > +(defcustom org-latex-doc-metadata nil
> >> > +  "A string with the document metadata.
> >> > +
> >> > +These metadata can be used to add additional information in the PDF
> >>
> >> *This.
> >
> > Maybe a 'kleines Latinum' and too many years of writing research papers
> > make it impossible to think of "data" as a singular....
> >
> > And from https://english.stackexchange.com/a/6913
> >
> > So, choosing (2), "data are" is clearly your safest bet, and is what I
> > always do (and what I find nearly all of my colleagues do).
>
> Ok.
>
> > I came up with
> > "These metadata add accesibility information to the PDF
>
> *accessibility
>
Done

>
> > +(ert-deftest test-ox-latex/pdf-metadata ()
> > +  "Test that DocumentMetadaData are inserted *before* LATEX_CLASS_PRE."
>
> *DocumentMetaData
>
Done

>
> --
> Ihor Radchenko // yantar92,
> Org mode maintainer,
> 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>
>

Closing the window for today...

/PA

--
ox-beamer & ox-latex maintainer

Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

"Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE!
Year 2 of the New Koprocracy

This was produced by a human (implied virtues and weaknesses acknowledged)
I'd hate this being fed to any form of AS (sorry AI)...
From 3dedfaf8481494beca9dc237c2624a2e1d8e76a9 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <[email protected]>
Date: Sat, 04 Jul 2026 18:08:00 +0200
Subject: [PATCH] ox-latex.el: Add DocumentMetadata

* doc/org-manual.org: Document LATEX_DOC_METADATA keyword.
* etc/ORG-NEWS: Announce new LATEX_DOC_METADATA keyword.
* lisp/ox-latex.el: Add LATEX_DOC_METADATA to the LaTeX backend info
channel.
(org-latex-doc-metadata): New variable to hold the default document
metadata.
(org-latex-make-preamble): Check for valid class before
anything else.  Insert LATEX_DOC_METADATA before LATEX_CLASS_PRE.
* testing/lisp/test-ox-latex.el
(test-ox-latex/pdf-metadata):  Verify that the DocumentMetadata are
inserted; and that they inserted before LATEX_CLASS_PRE
---
 doc/org-manual.org            |  9 +++++++++
 etc/ORG-NEWS                  |  5 +++++
 lisp/ox-latex.el              | 14 ++++++++++++++
 testing/lisp/test-ox-latex.el | 21 +++++++++++++++++++++
 4 files changed, 49 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 9201a341a..96de73975 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -14286,6 +14286,15 @@ general options (see [[*Export Settings]]).
   #+cindex: @samp{LATEX_CLASS_PRE}, keyword
   Arbitrary lines to prepend before the LaTeX preamble.

+- =LATEX_DOC_METADATA= ::
+
+  #+cindex: @samp{LATEX_DOC_METADATA}, keyword
+  #+vindex: org-latex-doc-metadata
+  Arbitrary lines with document metadata. When you set
+  ~org-latex-doc-metadata~ or you use ~#+LATEX_DOC_METADATA~, the
+  value will be inserted as =\DocumentMetadata{<value>}=
+  at the beginning of the LaTeX preamble.
+
 - =KEYWORDS= ::

   #+cindex: @samp{KEYWORDS}, keyword
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 03057cbd0..6f5f7096b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -144,6 +144,11 @@ A current limitation is that export blocks and keywords are only
 implemented for events and todos, and not yet for calendar-wide
 properties.

+*** New variable ~org-latex-doc-metadata~ and keyword ~#+LATEX_DOC_METADATA:~
+
+The LaTeX exporter can include PDF metadata with the new variable
+~org-latex-doc-metadata~ and the new keyword ~#+LATEX_DOC_METADATA:~.
+
 ** New and changed options

 # Changes dealing with changing default values of customizations,
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 8e2f72209..b3919c74f 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -125,6 +125,7 @@ (org-export-define-backend 'latex
     (:latex-header "LATEX_HEADER" nil nil newline)
     (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline)
     (:latex-class-pre "LATEX_CLASS_PRE" nil nil newline)
+    (:latex-metadata "LATEX_DOC_METADATA" nil org-latex-doc-metadata newline)
     (:description "DESCRIPTION" nil nil parse)
     (:keywords "KEYWORDS" nil nil parse)
     (:subtitle "SUBTITLE" nil nil parse)
@@ -652,6 +653,19 @@ (defcustom org-latex-hyperref-template
 		 (string :tag "Format string"))
   :safe #'string-or-null-p)

+(defcustom org-latex-doc-metadata nil
+  "A string with the document metadata.
+
+These metadata add accesibility information to the PDF
+to make it usable by screen readers and similar applications.
+They will be inserted as \"\\DocumentMetadata{<metadata>}\"
+at the beginning of the generated LaTeX preamble."
+
+  :package-version '(Org . "10")
+  :type '(choice (const :tag "No metadata" nil)
+		 (string :tag "Metadata for the PDF output"))
+  :safe #'string-or-null-p)
+
 ;;;; Headline

 (defcustom org-latex-format-headline-function
diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el
index a804e281b..eaf3928fa 100644
--- a/testing/lisp/test-ox-latex.el
+++ b/testing/lisp/test-ox-latex.el
@@ -522,5 +522,26 @@ (ert-deftest test-ox-latex/subtree-export-with-language ()
        (should (search-forward "\\usepackage[utf8]{inputenc} \\usepackage[french, english]{babel}")))
      (kill-buffer export-buffer))))

+(ert-deftest test-ox-latex/pdf-metadata ()
+  "Test that DocumentMetadata are inserted *before* LATEX_CLASS_PRE."
+  (org-test-with-exported-text
+   'latex
+   "#+TITLE: PDF Metadata
+#+LANGUAGE: en-gb es
+#+OPTIONS: toc:nil H:3 num:nil
+#+LATEX_COMPILER: pdflatex
+#+LATEX_DOC_METADATA: tagging = on
+#+LATEX_CLASS_PRE: \\PassOptionsToPackage{dvipsnames}{xcolor}
+#+LATEX_CLASS: report
+* Testing
+
+Just to see that DocumentMetadata comes before PassOptions and documentclass
+"
+   ;; (message "pdf-metadata: %s" (buffer-string))
+   (goto-char (point-min))
+   (should (search-forward "\\DocumentMetadata{tagging = on}" nil t))
+   (should (search-forward "\\PassOptionsToPackage{dvipsnames}{xcolor}" nil t))
+   (should (re-search-forward "^\\\\documentclass\\[.+?]{report}" nil t))))
+
 (provide 'test-ox-latex)
 ;;; test-ox-latex.el ends here

Reply via email to