Added the org-fragtog package to do inline latex edit/preview

This commit is contained in:
Louis Lacoste 2023-01-17 10:15:21 +01:00
parent 7e4a975ebf
commit 9c771d6796
2 changed files with 53 additions and 4 deletions

View file

@ -87,8 +87,13 @@
(dired-directory dired-directory "%b")))) (dired-directory dired-directory "%b"))))
(global-font-lock-mode t) (global-font-lock-mode t)
(custom-set-faces
'(flyspell-incorrect ((t (:inverse-video t))))) (custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(flyspell-incorrect ((t (:inverse-video t)))))
(line-number-mode 1) (line-number-mode 1)
(column-number-mode 1) (column-number-mode 1)
@ -321,7 +326,8 @@ A->B
(let* ((wanted-packages (let* ((wanted-packages
'(flycheck '(flycheck
company company
org-appear)) org-appear
org-fragtog))
(missing-wanted-packages (remove-if #'package-installed-p wanted-packages))) (missing-wanted-packages (remove-if #'package-installed-p wanted-packages)))
(when missing-wanted-packages (when missing-wanted-packages
(message "Missing wanted packages: %s" missing-wanted-packages) (message "Missing wanted packages: %s" missing-wanted-packages)
@ -339,4 +345,16 @@ A->B
(global-visual-line-mode 1) ; 1 for on & 0 for off (global-visual-line-mode 1) ; 1 for on & 0 for off
(add-hook 'org-mode-hook 'org-fragtog-mode)
(load-theme 'leuven t) (load-theme 'leuven t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(org-format-latex-options
'(:foreground default :background default :scale 1.5 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers
("begin" "$1" "$" "$$" "\\(" "\\[")))
'(package-selected-packages
'(org-fragtog org-appear magit htmlize flycheck ess company auctex)))

View file

@ -513,7 +513,8 @@ This often fails, yielding an ugly warning, and isn't of any use in Org-mode any
(let* ((wanted-packages (let* ((wanted-packages
'(flycheck '(flycheck
company company
org-appear)) org-appear
org-fragtog))
(missing-wanted-packages (remove-if #'package-installed-p wanted-packages))) (missing-wanted-packages (remove-if #'package-installed-p wanted-packages)))
(when missing-wanted-packages (when missing-wanted-packages
(message "Missing wanted packages: %s" missing-wanted-packages) (message "Missing wanted packages: %s" missing-wanted-packages)
@ -541,6 +542,36 @@ This mode makes the emphasis markers appear when the cursor is on it
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el
(global-visual-line-mode 1) ; 1 for on & 0 for off (global-visual-line-mode 1) ; 1 for on & 0 for off
#+end_src #+end_src
** Auto toggle the preview of LaTeX fragments
#+begin_src emacs-lisp :tangle init.el
(add-hook 'org-mode-hook 'org-fragtog-mode)
#+end_src
** Remote image display
This code was taken from https://emacs.stackexchange.com/questions/42281/org-mode-is-it-possible-to-display-online-images and makes use of the =org-yt= package.
#+begin_src emacs-lisp
(require 'org-yt)
(defun org-image-link (protocol link _description)
"Interpret LINK as base64-encoded image data."
(cl-assert (string-match "\\`img" protocol) nil
"Expected protocol type starting with img")
(let ((buf (url-retrieve-synchronously (concat (substring protocol 3) ":" link))))
(cl-assert buf nil
"Download of image \"%s\" failed." link)
(with-current-buffer buf
(goto-char (point-min))
(re-search-forward "\r?\n\r?\n")
(buffer-substring-no-properties (point) (point-max)))))
(org-link-set-parameters
"imghttp"
:image-data-fun #'org-image-link)
(org-link-set-parameters
"imghttps"
:image-data-fun #'org-image-link)
#+end_src
* Theme * Theme
** Activation du thème ** Activation du thème
#+begin_src emacs-lisp :tangle init.el #+begin_src emacs-lisp :tangle init.el