branch: externals/org
commit 329c47a63c0a3d09dd95525ebafed755e9585797
Author: Pedro A. Aranda <[email protected]>
Commit: Ihor Radchenko <[email protected]>
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.
(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: Four tests for `org-latex-use-sans'
- Default: don't use sans
- Set through `org-latex-use-sans' variable
- Set through :latex-use-sans OPTION
- Overriding `org-latex-use-sans' from OPTIONS
* doc/org-manual.org: Document the new option.
* etc/ORG-NEWS: Announce `org-latex-use-sans'.
---
doc/org-manual.org | 12 ++++++++++
etc/ORG-NEWS | 7 ++++++
lisp/ox-latex.el | 16 ++++++++++++-
testing/lisp/test-ox-latex.el | 56 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 90 insertions(+), 1 deletion(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index bcb02cba0e..17ca72e9b4 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -14412,6 +14412,18 @@ This would produce in LaTeX (with the actual
=polyglossia= syntax):
\setotherlanguage{french}
#+end_example
+#+vindex: org-latex-use-sans
+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 6467c7f7f4..966eafab4c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -498,6 +498,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 844591a434..994feb72b0 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?)
+ (plist-get info :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 419cbf0799..4c05aadb56 100644
--- a/testing/lisp/test-ox-latex.el
+++ b/testing/lisp/test-ox-latex.el
@@ -272,6 +272,62 @@ 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/use-sans-override ()
+ "Test `org-latex-use-sans' overriding variable."
+ (let ((org-latex-use-sans t))
+ (org-test-with-exported-text 'latex
+ "#+TITLE: Test no sans fonts
+#+OPTIONS: latex-use-sans:nil
+
+* 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