;; Time-stamp: <2020-04-23 20:45:55 (tslil@bison)> (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 (completing-read "Select template: " tfiles nil t))) (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 unfill :ensure t) (use-package pdf-tools :demand :ensure t ;; :bind (:map pdf-view-mode-map ;; ("C-s" . isearch-forward)) :config (pdf-tools-install)) (use-package latex :ensure auctex :bind (:map LaTeX-mode-map ("'" . better-TeX-insert-single-quote) ("TAB" . LaTeX-indent-line) ("M-q" . unfill-paragraph) ("C-c C-g" . pdf-sync-forward-search)) :hook (LaTeX-mode . (lambda () (require 'company-auctex) (electric-pair-local-mode -1) (spell-fu-mode) (display-line-numbers-mode) (auto-fill-mode -1) (visual-line-mode) (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 (dolist (entry '(("diagram") ("vdiagram") ("diagram*") ("vsubdiagram") ("vsubdiagrams"))) (push entry LaTeX-indent-environment-list)) (setq TeX-command-list '(("XeLaTeX" "xelatex %t" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run XeLaTeX") ("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode context-mode) :help "Run BibTeX") ("View externally" "%V" TeX-run-discard-or-function t t :help "Run External Viewer") ("View" "(find-file \"%o\")" TeX-run-function nil t :help "Run Viewer") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command"))) (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 'synctex TeX-view-program-selection '( ((output-dvi style-pstricks) "dvips and gv") (output-dvi "xdvi") (output-pdf "Zathura") (output-html "xdg-open"))) (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)) (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")) (?- ("\\dashv" "\\vdash" "\\setminus")) (?. ("\\sq" "\\circ" "\\cdot")) (?0 ("\\emptyset" "\\circ")) (?< ("\\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))