Hi,
attached is a patch for the reported and confirmed bug.
Best, /PA
On 21/04/2026 15:42, Samuel W. Flint wrote:
Hello!
I have a number of custom entries for org-latex-classes, and I noticed
that (as of the most recent commit to Org's main branch), part of my
configuration appears to be ignored. In particular, this entry seems to
produce broken input
("handout"
"\\documentclass[paper=letter,twoside,parskip=half,mpinclude=true]
{scrartcl}\n\\setlength{\\marginparwidth}{1.75\
\marginparwidth}\n[DEFAULT-PACKAGES]\n[PACKAGES]\n[EXTRA]\n\
\usepackage[footnote=true]{snotez}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
In particular, on export, the class options I declare are omitted:
\documentclass{scrartcl}
\setlength{\marginparwidth}{1.75\marginparwidth}
I would expect:
\documentclass[paper=letter,twoside,parskip=half,mpinclude=true]{scrartcl}
\setlength{\marginparwidth}{1.75\marginparwidth}
The org file I am using is as follows:
#+title: Test Export File
#+date: [2026-04-17 Fri 10:18]
#+latex_class: handout
#+options: toc:nil num:t arch:nil todo:nil stat:nil inline:nil
#+latex_header: \setcounter{secnumdepth}{-\maxdimen}
I don't see any obvious changes in ORG-NEWS, and I'm wondering if I've
missed something. Any help would be appreciated.
Thanks,
Sam
--
Sagen's Paradeiser! (ORF: Als Radiohören gefährlich war) => write BE!
2nd year of the New Koprocracy
From f58bc3cabc8c2673392af693fa171f51fabd2ef4 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <[email protected]>
Date: Tue, 21 Apr 2026 19:38:14 +0200
Subject: [PATCH] ox-latex.el: Fix bug which deleted class options
lisp/ox-latex.el: (org-latex--mk-options) return the argument if it is
nil or an empty string. This way, (not class-options)
in (org-latex-make-preamble) will handle the document correctly with
unset #+LATEX_CLASS_OPTIONS:
testing/lisp/test-ox-latex.el: New
test (test-ox-latex/latex-class-options3) to check that when no LaTeX
class options are defined in the document options, any options set in
(org-latex-classes) are not overwritten or deleted.
Reported by: [email protected] in
https://lists.gnu.org/archive/html/emacs-orgmode/2026-04/msg00338.html
---
lisp/ox-latex.el | 4 ++--
testing/lisp/test-ox-latex.el | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index b8e4ff172..a54ac5a3b 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2021,10 +2021,10 @@ The default behaviour is to typeset with the Roman font family."
(defun org-latex--mk-options (str)
"Make STR be enclosed in [ ] or return an empty string if nil or empty.
-If STR is nil or an empty string, return an empty string.
+If STR is nil or an empty string, return STR.
If STR is a traditional LATEX_CLASS_OPTIONS enclosed in [ ], return it as is.
If the square brackets are missing, return STR enclosed in square brackets."
- (if (or (not str) (length= str 0)) ""
+ (if (or (not str) (length= str 0)) str
(save-match-data ; just in case it is used in a search/replace context
(let ((str (concat "[" str "]"))) ; make sure it is enclosed in []
(replace-regexp-in-string ; remove excess [ at the beginning
diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el
index e99aac3c4..7db371d31 100644
--- a/testing/lisp/test-ox-latex.el
+++ b/testing/lisp/test-ox-latex.el
@@ -401,6 +401,18 @@ Fake test document
(goto-char (point-min))
(should (search-forward "\\documentclass[a4paper,12pt]{article}" nil t))))
+(ert-deftest test-ox-latex/latex-class-options3 ()
+ "Don't overwrite class options in class template"
+ (let ((org-latex-classes '(("my-letter" "\\documentclass[a4paper,12pt]{letter}"))))
+ (org-test-with-exported-text
+ 'latex
+ "#+LATEX_CLASS: my-letter
+
+Fake test letter
+"
+ (goto-char (point-min))
+ (should (search-forward "\\documentclass[a4paper,12pt]{letter}" nil t)))))
+
(ert-deftest test-ox-latex/latex-default-example-with-options ()
"Test #+ATTR_LATEX: :options with custom environment."
--
2.43.0