1
0
Fork 0
mirror of https://github.com/Horhik/dotfiles.git synced 2024-11-27 18:41:31 +00:00

fix latex preview svgm zoom

This commit is contained in:
Horhik 2022-10-12 16:51:15 +03:00
parent bb82175d18
commit a6787157ab
2 changed files with 56 additions and 4 deletions

View file

@ -241,8 +241,8 @@
;; Increase the size of various headings
(set-face-attribute 'org-document-title nil :font "Vollkorn" :weight 'bold :height 1.3)
(dolist (face '((org-level-1 . 1.1)
(org-level-2 . 1.0)
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1)
(org-level-3 . 1.0)
(org-level-4 . 1.0)
(org-level-5 . 1.0)
@ -753,6 +753,32 @@
:config
(add-hook 'org-mode-hook 'org-cdlatex-mode)
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.3))
(setq org-preview-latex-default-process 'dvisvgm) ;No blur when scaling
(defun my/text-scale-adjust-latex-previews ()
"Adjust the size of latex preview fragments when changing the
buffer's text scale."
(pcase major-mode
('latex-mode
(dolist (ov (overlays-in (point-min) (point-max)))
(if (eq (overlay-get ov 'category)
'preview-overlay)
(my/text-scale--resize-fragment ov))))
('org-mode
(dolist (ov (overlays-in (point-min) (point-max)))
(if (eq (overlay-get ov 'org-overlay-type)
'org-latex-overlay)
(my/text-scale--resize-fragment ov))))))
(defun my/text-scale--resize-fragment (ov)
(overlay-put
ov 'display
(cons 'image
(plist-put
(cdr (overlay-get ov 'display))
:scale (+ 1.0 (* 0.25 text-scale-mode-amount))))))
(add-hook 'text-scale-mode-hook #'my/text-scale-adjust-latex-previews)
)
#+end_src
** Live Preview

View file

@ -176,8 +176,8 @@
;; Increase the size of various headings
(set-face-attribute 'org-document-title nil :font "Vollkorn" :weight 'bold :height 1.3)
(dolist (face '((org-level-1 . 1.1)
(org-level-2 . 1.0)
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1)
(org-level-3 . 1.0)
(org-level-4 . 1.0)
(org-level-5 . 1.0)
@ -599,6 +599,32 @@
:config
(add-hook 'org-mode-hook 'org-cdlatex-mode)
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.3))
(setq org-preview-latex-default-process 'dvisvgm) ;No blur when scaling
(defun my/text-scale-adjust-latex-previews ()
"Adjust the size of latex preview fragments when changing the
buffer's text scale."
(pcase major-mode
('latex-mode
(dolist (ov (overlays-in (point-min) (point-max)))
(if (eq (overlay-get ov 'category)
'preview-overlay)
(my/text-scale--resize-fragment ov))))
('org-mode
(dolist (ov (overlays-in (point-min) (point-max)))
(if (eq (overlay-get ov 'org-overlay-type)
'org-latex-overlay)
(my/text-scale--resize-fragment ov))))))
(defun my/text-scale--resize-fragment (ov)
(overlay-put
ov 'display
(cons 'image
(plist-put
(cdr (overlay-get ov 'display))
:scale (+ 1.0 (* 0.25 text-scale-mode-amount))))))
(add-hook 'text-scale-mode-hook #'my/text-scale-adjust-latex-previews)
)
(use-package org-fragtog
:straight t