Files
.emacs.d/lisp/init-tex.el

62 lines
2.1 KiB
EmacsLisp
Raw Normal View History

;; -*- lexical-binding: t; -*-
2025-12-14 09:04:11 +11:00
(use-package latex
:ensure (auctex :pre-build (("./autogen.sh")
("./configure" "--without-texmf-dir" "--with-lispdir=.")
("make")))
:mode (("\\.tex\\'" . LaTeX-mode))
2026-02-08 20:12:13 +11:00
:hook prettify-symbols-mode
:hook visual-line-mode
:hook turn-on-reftex
2025-12-14 09:04:11 +11:00
:bind (:map LaTeX-mode-map
2026-02-08 20:12:13 +11:00
("C-S-e" . latex-math-from-calc))
:custom
(TeX-parse-self t)
(TeX-PDF-mode t)
(TeX-DVI-via-PDFTeX t)
2025-12-14 09:04:11 +11:00
:config
2026-02-08 23:44:31 +11:00
(setq-default TeX-command-default "LaTeXMk")
2025-12-14 09:04:11 +11:00
;; Format math as a Latex string with Calc
2026-02-08 20:12:13 +11:00
(add-hook 'LaTeX-mode-hook #'eglot-ensure)
2025-12-14 09:04:11 +11:00
(defun latex-math-from-calc ()
"Evaluate `calc' on the contents of line at point."
(interactive)
(cond ((region-active-p)
(let* ((beg (region-beginning))
(end (region-end))
(string (buffer-substring-no-properties beg end)))
(kill-region beg end)
(insert (calc-eval `(,string calc-language latex
calc-prefer-frac t
calc-angle-mode rad)))))
(t (let ((l (thing-at-point 'line)))
(end-of-line 1) (kill-line 0)
(insert (calc-eval `(,l
calc-language latex
calc-prefer-frac t
2026-02-08 20:12:13 +11:00
calc-angle-mode rad)))))))
(setq TeX-view-program-selection '((output-pdf "PDF Tools")))
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '((LaTeX-mode latex-mode) "texlab")))
)
2025-12-14 09:04:11 +11:00
(use-package cdlatex
:ensure t
:hook (LaTeX-mode . turn-on-cdlatex)
:bind (:map cdlatex-mode-map
2025-12-22 15:57:17 +11:00
("<tab>" . cdlatex-tab))
:config
(setq cdlatex-math-symbol-alist '((?f ("\\varphi" "\\phi"))
(?i ("\\iota"))
))
(setq cdlatex-math-modify-alist '((?f "\\mathbb" nil t nil nil)))
(cdlatex-reset-mode))
2025-12-16 01:58:26 +11:00
(use-package texpresso
:defer nil
:load-path "~/.emacs.d/lisp/packages/")
(provide 'init-tex)