diff options
| author | tslil clingman <> | 2019-09-11 19:18:14 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2019-09-11 19:18:14 -0400 |
| commit | ac1a4884d03fc0495c773500d8a13f84b695fa43 (patch) | |
| tree | 29e5ec49e0ce957d80d8f11a155b47840c74f488 /emacs/inits/24-latex.el | |
Init
Diffstat (limited to 'emacs/inits/24-latex.el')
| -rw-r--r-- | emacs/inits/24-latex.el | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/emacs/inits/24-latex.el b/emacs/inits/24-latex.el new file mode 100644 index 0000000..98eb70c --- /dev/null +++ b/emacs/inits/24-latex.el @@ -0,0 +1,146 @@ +;; Time-stamp: <2019-05-27 11:22:10 (tslil@basingstoke)> + +(defvar latex-template-dir (expand-file-name "~/academic/typeset/latex-templates")) +(defun prompt-latex-file-template () + "Check if tex file does not exist or the command was called +interactively. If neither, prompt to insert from a template +populated from the directory *latex-template-dir*" + (interactive) + (when (and (if (file-exists-p (buffer-file-name)) + (called-interactively-p 'interactive) + t) + (yes-or-no-p "Insert template?")) + (let* ((tfiles (directory-files latex-template-dir nil "\\.tex")) + (template (ivy-read "Select template: " tfiles))) + (when template + (goto-char (point-min)) + (insert-file-contents (concat latex-template-dir "/" template)) + (search-forward "begin{document}") + (forward-line) + (save-buffer))))) + +;; Why does this not work? +;; (use-package cdm-mode +;; :functions cdm-mode +;; :defer t +;; :load-path "~/.emacs.d/scripts/") +(autoload 'cdm-mode "cdm-mode" nil t) + +(use-package company-auctex :ensure t :defer t) + +(use-package latex + :ensure auctex + :bind (:map LaTeX-mode-map + ("'" . better-TeX-insert-single-quote) + ("TAB" . LaTeX-indent-line)) + :hook (LaTeX-mode . (lambda () + (require 'company-auctex) + (electric-pair-local-mode -1) + (flyspell-mode) + (turn-on-auto-fill) + (cdlatex-mode t) + (company-auctex-init) + (siege-mode 1) + (cdm-mode) + (prompt-latex-file-template))) + :init + (defun better-TeX-insert-single-quote () + (interactive) + (let ((old-open TeX-open-quote) + (old-close TeX-close-quote)) + (unwind-protect (progn + (setq TeX-open-quote "`" + TeX-close-quote "'") + (call-interactively 'TeX-insert-quote)) + (setq TeX-open-quote old-open + TeX-close-quote old-close)))) + + :config + (add-to-list 'LaTeX-indent-environment-list + '("diagram")) + (add-to-list 'LaTeX-indent-environment-list + '("diagram*")) + + + (add-to-list 'TeX-command-list '("XeLaTeX" "xelatex %t" TeX-run-TeX nil + (latex-mode doctex-mode) + :help "Run XeLaTeX")) + + (setq TeX-electric-sub-and-superscript t + TeX-electric-math '("$" . "$") + TeX-electric-escape nil + LaTeX-electric-left-right-brace t) + + (setq-default TeX-master nil) + (setq TeX-auto-save t + TeX-parse-self t + TeX-PDF-mode t + TeX-source-correlate-mode nil + TeX-view-program-selection '( ((output-dvi style-pstricks) "dvips and gv") + (output-dvi "xdvi") + (output-pdf "Zathura") + (output-html "xdg-open")))) + + +(use-package cdlatex + :ensure t + :bind (:map cdlatex-mode-map + ("(" . nil) + ("{" . nil) + ("[" . nil) + ("|" . nil) + ("<" . nil) + ("$" . nil) + ("'" . nil) + ("TAB" . nil) + ;; ("TAB" . cdlatex-tab) + ("C-c e" . cdlatex-environment) + ("~" . cdlatex-math-modify) + ("`" . cdlatex-math-symbol)) + :init + (setq cdlatex-math-modify-prefix ?~ + cdlatex-math-symbol-prefix ?` + cdlatex-math-modify-alist '((?a "\\mathbb" nil t nil nil) + (?c "\\mathcal" "\\textsc" t nil nil) + (?t "\\trm" "\\trm" t nil nil) + (?y "\\ty" "\\ty" t nil nil) + (?v "\\texttt" "\\texttt" t nil nil) + (?u "\\tyu" "\\tyu" t nil nil) + (?k "\\mathfrak" nil t nil nil) + (?` nil "`'" t nil nil) + (?- "\\overline" nil t nil nil) + (?_ "\\underline" nil t nil nil)) + cdlatex-math-symbol-alist '((?% ("\\widehat{?}" "\\hat{?}")) + (?' ("^{\\prime}" "\\prime")) + (?* ("\\times" "\\otimes" "\\star")) + (?+ ("+" "\\oplus")) + (?- ("\\vdash" "\\setminus" "\\triangle")) + (?. ("\\sq" "\\circ" "\\cdot")) + (?0 ("\\emptyset" "\\circ")) + (?\; ("\\col")) + (?< ("\\leftarrow" "\\leftharpoonup" "\\xleftarrow")) + (?> ("\\to" "\\rightharpoonup" "\\xrightarrow")) + (?B ("\\bullet")) + (?C ("\\widecheck{?}" "\\check{?}")) + (?F ("\\Phi" "\\Varphi")) + (?M ("\\begin{bsmallmatrix}?\\end{bsmallmatrix}")) + (?P ("\\Prod{?}" "\\Pi" "\\partial")) + (?S ("\\Sum{?}" "\\Sigma" "\\arcsin")) + (?\"("^{\\prime\\prime}" "\\prime\\prime")) + (?a ("\\alpha" "\\cap" "\\sqcap")) + (?c ("\\cat{?}" "\\catn{?}")) + (?e ("\\varepsilon" "\\epsilon" "\\exp{?}")) + (?i ("\\iota" "\\in")) + (?j ("{\\id^{h}}_{?}" "{\\id^{v}}_{?}")) + (?r ("\\rho" "\\varrho" "\\restrict{?}")) + (?u ("\\upsilon" "\\cup" "\\sqcup")) + (?{ ("\\subseteq" "\\subsetneq")) + (?} ("\\supseteq" "\\supsetneq")) + ))) + +(use-package doc-view + :defer t + :functions doc-view-mode + :hook (doc-view-mode . auto-revert-mode) + :config (setq doc-view-resolution 300 + doc-view-continuous t)) |
