Hi, Attached is a patch adding a new option `org-latex-default-class-options'. The option can be set locally (file locally, buffer locally, etc.) to effect the options which are interpolated in LaTeX exports by default.
This might not seem terribly useful: if you want to have standard/common options set for a certain class (or even all classes) just specify them in the header string in `org-latex-classes'. This is usually sufficient, but not always. I have recently been using the LaTeX subfiles package a lot, with org mode. The package lets your compile multi-file projects in convenient ways, but (in order to do this) requires that: 1. each subfile uses the `subfile' class, 2. with the path of the master file passed as an argument My workflow is that I have a master file in LaTeX, which includes various other LaTeX files (which are exports from org files) as subfiles, thus: ,---- | /project-folder | ├ main.tex | ├ chapterOne | │ ├ chapterone.org | │ └ chapterone.tex (org export) | ├ chapterTwo | │ ├ chaptertwo.org | │ └ chaptertwo.tex (org export) | └ chapterThree | ├ chapterthree.org | └ chapterthree.tex (org export) `---- Whenever I edit one of the org files, I re-export it, thus updating the LaTeX subfiles source. So I need that export procedure to fulfil both 1 and 2 (or,if it doesn't, I have to fiddle with the exported LaTeX manually, which I don't want to). Fulfilling 1 is easy---I just set `org-latex-default-class' to "subfile" in .dir-locals in project-folder (and of course make sure that "subfile" has a valid class in in `org-latex-classes'). I want to fulfil 2, but I don't want to hardcode `../main.tex', into my `org-latex-classes', because I might have other projects where the main file is called something else (or even recursive subfile systems where different files are the 'main' file at different levels). At the moment, I solve this by putting: ,---- | #+latex_class_options: [../thesis.tex] `---- At the top of every org file, but since I do have to this for /every/ file in the hierarchy, it would be nice to get the same effect by just setting a variable. So: if I set the newly introduced `org-latex-default-class-options' in .dir-locals in project-folder, I'll get the right export behaviour every time and not have to edit the LaTeX manually, /or/ add the header to each org file manually. Someone seems to have shown interest in this sort of feature once before: <https://emacs.stackexchange.com/questions/29107/org-latex-export-set-default-options-for-documentclass> best, Hugo
From 64dce3c5c77eb90e59b73c293e15b96cd275855f Mon Sep 17 00:00:00 2001 From: Hugo Heagren <h...@heagren.com> Date: Fri, 10 Jan 2025 13:01:28 +0000 Subject: [PATCH] ox-latex.el: new custom var `org-latex-default-class-options' * lisp/ox-latex.el (org-latex-default-class-options): New option. (latex): Default to `org-latex-default-class-options'. --- lisp/ox-latex.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 782be244b..b99fae1df 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -121,7 +121,7 @@ (org-export-define-backend 'latex (:filter-verse-block . org-latex-clean-invalid-line-breaks)) :options-alist '((:latex-class "LATEX_CLASS" nil org-latex-default-class t) - (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t) + (:latex-class-options "LATEX_CLASS_OPTIONS" nil org-latex-default-class-options t) (:latex-header "LATEX_HEADER" nil nil newline) (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline) (:description "DESCRIPTION" nil nil parse) @@ -423,6 +423,12 @@ (defcustom org-latex-default-class "article" :group 'org-export-latex :type '(string :tag "LaTeX class")) +(defcustom org-latex-default-class-options "" + "The defailt options passed to the document class." + :group 'org-export-latex + :type '(string :tag "LaTeX class") + :safe #'stringp) + (defcustom org-latex-classes '(("article" "\\documentclass[11pt]{article}" -- 2.39.5