From 8247947aa6141cde9c58205e0266f0e674226f95 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sun, 10 Oct 2021 21:20:31 -0700 Subject: [PATCH] org.el: Allow customizing overlay-put scale factor * lisp/org.el (org-latex-fragment-scale): Add customizable variable that is equal to or evaluates to a scale factor used to scale inline latex fragments. (org--make-preview-overlay): Adjust latex fragment overlay generation to account for the new custom scale factor. --- lisp/org.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index dbc288a3c..f5e9ff8d1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -388,6 +388,15 @@ text." :type '(symbol function integer) :group 'org) +(defcustom org-latex-fragment-scale 1.0 + "Scaling factor used for LaTeX image fragments. +This can either be a number or a function that takes the image +data and image type as parameters and evaluates to a number. The +function can be useful for context-aware scaling, such as setting +the scale factor to be consistent with the surrounding text size." + :type '(number function) + :group 'org) + ;;; Version (org-check-version) @@ -16007,7 +16016,13 @@ as a string. It defaults to \"png\"." (delete-overlay o)))) (overlay-put ov 'display - (list 'image :type imagetype :file image :ascent ascent))))) + (list 'image + :type imagetype + :file image + :ascent ascent + :scale (if (functionp org-latex-fragment-scale) + (funcall org-latex-fragment-scale image imagetype) + org-latex-fragment-scale)))))) (defun org-clear-latex-preview (&optional beg end) "Remove all overlays with LaTeX fragment images in current buffer. -- 2.31.1