Hi final version of the patch. Best, /PA
PS: Trying to move to new git is being a roller-coaster... On Sun, 25 Jan 2026 at 19:18, Ihor Radchenko <[email protected]> wrote: > Pedro Andres Aranda Gutierrez <[email protected]> writes: > > > Version 2 with the requested addition (documented) > > > + (:latex-use-sans nil "latex-use-sans" org-latex-use-sans) > > ... > > - (plist-get info :latex-header-extra))) > > + (plist-get info :latex-header-extra)) > > + (and (not snippet?) > > + org-latex-use-sans > > + > "\\renewcommand*\\familydefault{\\sfdefault}")) > > You should check :latex-use-sans rather than directly consulting the > custom option here. Just as it is done for :latex-header-extra. > > > -- > 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> > -- 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 1 of the New Koprocracy
From af0d5ec797f27a1033d9c64f7e9a3aa98fa8e446 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <[email protected]> Date: Mon, 26 Jan 2026 08:18:15 +0100 Subject: [PATCH] New option (org-latex-use-sans): Control using Sans as default font This is the second version, providing for #+OPTION: latex-use-sans:t in addition to configuring through variables. * lisp/ox-latex.el: (org-latex-use-sans) : new defcustom :options-alist: include new option :latex-use-sans (org-latex-make-preamble): add command to typeset using the Sans family after LATEX_HEADER_EXTRA if not a snippet and (org-latex-use-sans) is not nil or requested through OPTIONS * testing/lisp/test-ox-latex.el: Three tests for (org-latex-use-sans) - Default: don't use sans - Set through (org-latex-use-sans) variable - Set through :latex-use-sans OPTION * doc/org-manual.org: document (org-latex-use-sans) * etc/ORG-NEWS: announce (org-latex-use-sans) --- doc/org-manual.org | 11 ++++++++++ etc/ORG-NEWS | 7 ++++++ lisp/ox-latex.el | 16 +++++++++++++- testing/lisp/test-ox-latex.el | 40 +++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 8f917a57e..10010f0df 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -14409,6 +14409,17 @@ This would produce in LaTeX (with the actual =polyglossia= syntax): \setotherlanguage{french} #+end_example +The LaTeX backend normally exports using the Roman font family +specified in the document class or by the user in the +=LATEX_HEADER=. Setting the option ~org-latex-use-sans~ to =t= will +force the LaTeX compiler to use the Sans font as default. You can also +include it in the document options with: + +#+begin_example +#+OPTIONS: latex-use-sans:t +#+end_example + + *** Quoting LaTeX code :PROPERTIES: :DESCRIPTION: Incorporating literal @LaTeX{} code. diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 2e1f79f8c..45b0760b2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -485,6 +485,13 @@ the suffix of =:file= is the primary determinant, and =:file-ext= secondary. Header arguments =:pdf= and =:eps= are supported for backwards compatibility. Default output type is still PNG. +*** New option ~org-latex-use-sans~ + +This option specifies the PDF should be typeset using the Sans font +specified in the document class (or the user) instead of the default +font (i.e. the Roman font). + + ** New functions and changes in function arguments # This also includes changes in function behavior from Elisp perspective. diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index a63013adf..82a16234a 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -170,6 +170,7 @@ (:latex-title-command nil nil org-latex-title-command) (:latex-toc-command nil nil org-latex-toc-command) (:latex-compiler "LATEX_COMPILER" nil org-latex-compiler) + (:latex-use-sans nil "latex-use-sans" org-latex-use-sans) ;; Redefine regular options. (:date "DATE" nil "\\today" parse))) @@ -1978,6 +1979,15 @@ INFO is a plist used as a communication channel." (member (or compiler "") org-latex-compilers) (format org-latex-compiler-file-string compiler)))) +(defcustom org-latex-use-sans nil + "Whether to typeset the document with the Sans font family. + +The default behaviour is to typeset with the Roman font family." + :group 'org-export-latex + :package-version '(Org . "9.8") + :type 'boolean + :safe #'booleanp) + ;;; Filters @@ -2032,7 +2042,11 @@ specified in `org-latex-default-packages-alist' or (mapconcat #'org-element-normalize-string (list (plist-get info :latex-header) (and (not snippet?) - (plist-get info :latex-header-extra))) + (plist-get info :latex-header-extra)) + (and (not snippet?) + (or (plist-get info :latex-use-sans) org-latex-use-sans) + "\\renewcommand*\\familydefault{\\sfdefault}")) + "")))) info) info))) diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el index 64ab7d467..003ee5aa3 100644 --- a/testing/lisp/test-ox-latex.el +++ b/testing/lisp/test-ox-latex.el @@ -272,6 +272,46 @@ is suppressed (should (search-forward "} \\addcontentsline{toc}{section}{Section 3}"))))) +(ert-deftest test-ox-latex/use-sans () + "Test `org-latex-use-sans' set to t." + (let ((org-latex-use-sans t)) + (org-test-with-exported-text 'latex + "#+TITLE: Test sans fonts +* Test + +Fake test document +" + (goto-char (point-min)) + (should (search-forward "\\renewcommand*\\familydefault{\\sfdefault}" nil t)) + (should (search-forward "\\begin{document}" nil t))))) + +(ert-deftest test-ox-latex/use-sans-option () + "Test latex-use-sans in OPTIONS set to t." + (org-test-with-exported-text 'latex +"#+TITLE: Test sans fonts +#+OPTIONS: latex-use-sans:t + +* Test + +Fake test document +" + (goto-char (point-min)) + (should (search-forward "\\renewcommand*\\familydefault{\\sfdefault}" nil t)) + (should (search-forward "\\begin{document}" nil t)))) + +(ert-deftest test-ox-latex/use-sans-default () + "Test `org-latex-use-sans' default setting." + (org-test-with-exported-text 'latex + "#+TITLE: Test no sans fonts +* Test + +Fake test document +" + (goto-char (point-min)) + (should-not (search-forward "\\renewcommand*\\familydefault{\\sfdefault}" nil t)) + (goto-char (point-min)) + (should (search-forward "\\begin{document}" nil t)))) + (ert-deftest test-ox-latex/math-in-alt-title () "Test math wrapping in ALT_TITLE properties." (org-test-with-exported-text -- 2.43.0
