Last active
January 23, 2024 20:51
-
-
Save mrkgnao/d11cf6d785c86acc7544861ce6a36745 to your computer and use it in GitHub Desktop.
TikZ preview in Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; In Spacemacs, this sets up: | |
;; - LaTeX previews (in \(...\) or \[...\]) with `, T x` | |
;; - TikZ preview (inside #+BEGIN_LaTeX ... #+END_LaTeX blocks) with C-c C-c | |
;; | |
;; All previews and exports use AMS Euler, which I like, and a suitable text | |
;; font to go with it. | |
;; | |
;; Other libraries (xy and so on) should also work if you add them to the | |
;; org-latex-packages-alist lines below. | |
;; | |
;; People who don't use Spacemacs are assumed to have enough Emacs-fu to figure | |
;; out how to adapt this to their own setups. | |
;; | |
;; https://emacs.stackexchange.com/questions/31211/how-to-display-latex-image-in-org-mode/ | |
;; http://bnbeckwith.com/blog/org-mode-tikz-previews-on-windows.html | |
;; https://emacs.stackexchange.com/questions/16392/rendering-latex-code-inside-begin-latex-end-latex-in-org-mode-8-3-1 | |
(defun dotspacemacs/user-config () | |
(require 'ob-latex) | |
(with-eval-after-load 'org | |
(setq org-latex-create-formula-image-program 'imagemagick) | |
(setq org-latex-packages-alist | |
'(("" "newpxtext,newpxmath" t) | |
("" "tikz" t) | |
("" "tikz-cd" t) | |
("" "eulervm" t))) | |
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.6)) | |
(org-babel-do-load-languages | |
'org-babel-load-languages | |
'((latex . t))) | |
(eval-after-load "preview" | |
'(add-to-list 'preview-default-preamble "\\PreviewEnvironment{tikzpicture}" t)) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment