Add Asymptote and better org-mode LaTeX export
This commit is contained in:
parent
668400d339
commit
40d8c92ebb
84
init.el
84
init.el
|
@ -481,6 +481,15 @@
|
||||||
:config
|
:config
|
||||||
(pdf-tools-install))
|
(pdf-tools-install))
|
||||||
|
|
||||||
|
(use-package auctex)
|
||||||
|
|
||||||
|
(use-package asy-mode
|
||||||
|
:mode "\\.asy\\'"
|
||||||
|
:init
|
||||||
|
(with-eval-after-load 'latex-mode
|
||||||
|
(require 'asy-mode)
|
||||||
|
(asy-insinuate-latex-globally)))
|
||||||
|
|
||||||
(defun my-double-space-sentence ()
|
(defun my-double-space-sentence ()
|
||||||
(setq-local sentence-end-double-space t))
|
(setq-local sentence-end-double-space t))
|
||||||
|
|
||||||
|
@ -502,18 +511,87 @@
|
||||||
(ruby . t)
|
(ruby . t)
|
||||||
(python . t)
|
(python . t)
|
||||||
(shell . t)
|
(shell . t)
|
||||||
(C . t)))
|
(C . t)
|
||||||
|
(asymptote . t)))
|
||||||
(org-agenda-files '("~/Agenda"))
|
(org-agenda-files '("~/Agenda"))
|
||||||
;; NixOS minimal LaTeX setup
|
;; NixOS minimal LaTeX setup
|
||||||
(org-latex-compiler "lualatex")
|
(org-latex-compiler "lualatex")
|
||||||
(org-preview-latex-default-process 'dvisvgm)
|
(org-preview-latex-default-process 'lua-dvisvgm)
|
||||||
(org-latex-src-block-backend 'engraved)
|
(org-latex-src-block-backend 'engraved)
|
||||||
:config
|
:config
|
||||||
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.1)
|
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.3)
|
||||||
org-modules (append '(org-tempo org-habit) org-modules))
|
org-modules (append '(org-tempo org-habit) org-modules))
|
||||||
|
;; Preview with lualatex to prevent errors when trying to load fontspec and
|
||||||
|
;; others with pdflatex
|
||||||
|
(add-to-list
|
||||||
|
'org-preview-latex-process-alist
|
||||||
|
'(lua-dvisvgm :programs ("dvilualatex" "dvisvgm")
|
||||||
|
:description "dvi > svg"
|
||||||
|
:message "you need to install the programs: lualatex and dvisvgm"
|
||||||
|
:image-input-type "dvi"
|
||||||
|
:image-output-type "svg"
|
||||||
|
:image-size-adjust (1.0 . 1.0)
|
||||||
|
:latex-compiler ("dvilualatex -interaction nonstopmode -output-directory %o %f")
|
||||||
|
:image-converter ("dvisvgm %f --no-fonts --exact-bbox --scale=%S --output=%O")))
|
||||||
|
(with-eval-after-load 'ox-latex
|
||||||
|
(add-to-list 'org-latex-classes
|
||||||
|
'("apa6"
|
||||||
|
"\\documentclass{apa6}"
|
||||||
|
("\\section{%s}" . "\\section*{%s}")
|
||||||
|
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||||
|
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||||
|
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
||||||
|
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
|
||||||
|
;; HACK: apply the value of #+LATEX_CLASS to previews as well
|
||||||
|
(defun my--org-latex-make-preamble-change-class (args)
|
||||||
|
(if-let* (((> (length args) 1))
|
||||||
|
(template (nth 1 args)))
|
||||||
|
(let* ((info (car args))
|
||||||
|
(class (plist-get info :latex-class))
|
||||||
|
(class-options (plist-get info :latex-class-option))
|
||||||
|
(header (nth 1 (assoc class (plist-get info :latex-classes))))
|
||||||
|
(processed-header
|
||||||
|
(if class-options
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
|
||||||
|
class-options header t nil 1)
|
||||||
|
header)))
|
||||||
|
(cl-list* info
|
||||||
|
(string-replace "\\documentclass{article}" processed-header template)
|
||||||
|
(cddr args)))
|
||||||
|
args))
|
||||||
|
(advice-add #'org-latex-make-preamble
|
||||||
|
:filter-args #'my--org-latex-make-preamble-change-class))
|
||||||
(with-eval-after-load 'catppuccin-theme
|
(with-eval-after-load 'catppuccin-theme
|
||||||
(face-spec-set 'org-block `((t (:foreground ,(catppuccin-get-color 'text)))))))
|
(face-spec-set 'org-block `((t (:foreground ,(catppuccin-get-color 'text)))))))
|
||||||
|
|
||||||
|
(use-package ob-asymptote
|
||||||
|
:config
|
||||||
|
(defun org-babel-execute:asymptote (body params)
|
||||||
|
"Execute a block of Asymptote code.
|
||||||
|
This function is called by `org-babel-execute-src-block'."
|
||||||
|
(let* ((out-file (cdr (assq :file params)))
|
||||||
|
(format (or (file-name-extension out-file)
|
||||||
|
"pdf"))
|
||||||
|
(cmdline (cdr (assq :cmdline params)))
|
||||||
|
(in-file (org-babel-temp-file "asymptote-"))
|
||||||
|
(cmd
|
||||||
|
(concat "asy "
|
||||||
|
(if out-file
|
||||||
|
(concat
|
||||||
|
"-globalwrite -f " format
|
||||||
|
" -o " (org-babel-process-file-name
|
||||||
|
(file-name-sans-extension out-file)))
|
||||||
|
"-V")
|
||||||
|
" " cmdline
|
||||||
|
" " (org-babel-process-file-name in-file))))
|
||||||
|
(with-temp-file in-file
|
||||||
|
(insert (org-babel-expand-body:generic
|
||||||
|
body params
|
||||||
|
(org-babel-variable-assignments:asymptote params))))
|
||||||
|
(message cmd) (shell-command cmd)
|
||||||
|
nil)))
|
||||||
|
|
||||||
(use-package org-alert
|
(use-package org-alert
|
||||||
:init
|
:init
|
||||||
(when (daemonp)
|
(when (daemonp)
|
||||||
|
|
Loading…
Reference in a new issue