This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

emacs latex config

By: a guest on Nov 10th, 2012  |  syntax: Lisp  |  size: 4.85 KB  |  views: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;hooks
  2. (add-hook 'LaTeX-mode-hook 'TeX-fold-mode)
  3. (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
  4. ;(add-hook 'LaTeX-mode-hook 'reftex-mode)
  5. ;(add-hook 'LaTeX-mode-hook 'rainbow-delimiters-mode)
  6. ;; (add-hook 'LaTeX-mode-hook 'ac-l-setup)
  7. ;;Syntax Higlight
  8. (add-hook 'LaTeX-mode-hook 'turn-on-font-lock)
  9. ;; Mathe Modus
  10. (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
  11. ;; Reftex einflechten und laden
  12. (setq reftex-plug-into-AUCTeX t)
  13. (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
  14.  
  15. ; configure auctex
  16. (setq TeX-auto-save t)
  17. (setq TeX-parse-self t)
  18. (setq TeX-PDF-mode t) ;; .pdf statt .dvi per default:
  19. (setq-default TeX-master nil)
  20. (setq TeX-electric-escape nil)
  21. (setq predictive-latex-electric-environments t)
  22.  
  23. ;; Satzende ". " statt ". ". " f¨r M-k: loeschen bis Satzende usw.
  24. (setq sentence-end "[.?!][]\"')}]*\\($\\| \\| \\)[;;]*") ;; Da ist ein "Newline in der Zeile!"
  25. (setq sentence-end-double-space nil)
  26.  
  27. ;; Nur benutzen falls Auctex > 11.81 mit preview-latex:
  28. (load "preview-latex.el" nil t t)
  29.  
  30. ;; Zeile kommentieren, falls nicht installiert:
  31. (setq-default ispell-program-name "aspell")
  32. ;; Deutsche Rechtschreibung falls \usepackage{ngerman}
  33. ;; oder german benutzt wird
  34. (add-hook 'TeX-language-de-hook
  35. (function (lambda () (ispell-change-dictionary "german8"))))
  36.  
  37. ;; some new key-bindings for auctex math-mode
  38. (setq LaTeX-math-list nil)
  39. (add-to-list 'LaTeX-math-list '(?\C-f "varphi"))
  40. (add-to-list 'LaTeX-math-list '(?\C-j "vartheta"))
  41. (add-to-list 'LaTeX-math-list '(?\C-e "varepsilon"))
  42. (add-to-list 'LaTeX-math-list '(?\C-v "vec"))
  43. (add-to-list 'LaTeX-math-list '(?\C-d "dot"))
  44. (add-to-list 'LaTeX-math-list '(?\C-r "varrho"))
  45. (add-to-list 'LaTeX-math-list '(?\/ "frac"))
  46. (add-to-list 'LaTeX-math-list '(?\C-p "partial"))
  47.  
  48. ;; stuff for reftex-mode
  49. (setq reftex-label-alist
  50.       '(("section" ?s "sec:" "~\\ref{%s}"  nil ("Kapitel" "Kap." "Abschnitt" "Abs."))
  51.         ("eqnarray" ?e "eq:" "~(\\ref{%s})"  nil ("Gleichung" "Gl."))
  52.         ("eqnarray*" ?e "eq:" "~(\\ref{%s})"  nil ("Gleichung" "Gl."))
  53.         ("align" ?e "eq:" "~(\\ref{%s})"  nil ("Gleichung" "Gl."))
  54.         ("align*" ?e "eq:" "~(\\ref{%s})"  nil ("Gleichung" "Gl."))
  55.         ("table" ?t "tab:" "~\\ref{%s}"  nil ("Tabelle" "Tab."))
  56.         ("figure" ?f "fig:" "~\\ref{%s}"  nil ("Abbildung" "Abb."))))
  57. (setq reftex-insert-label-flags '(nil t))
  58.  
  59. ;; german quotes an auctex
  60. (setq TeX-open-quote "\"`")
  61. (setq TeX-close-quote "\"'")
  62.  
  63. ;; default floating argument
  64. (setq LaTeX-float "!h")
  65.  
  66.  
  67. ;; shell escape is needed for minted package
  68. (eval-after-load "tex"
  69.   '(setcdr (assoc "LaTeX" TeX-command-list)
  70.           '("%`%l%(mode) -shell-escape%' %t"
  71.           TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX")
  72.     )
  73.   )
  74.  
  75. ; left-right braces stuff
  76. (defun lr-brace ()
  77.  (interactive "*")
  78.  (insert "\\left( \\right)")
  79.  (backward-char 8)
  80. )
  81. (defun lr-sq-brace ()
  82.  (interactive "*")
  83.  (insert "\\left[ \\right]")
  84.  (backward-char 8)
  85. )
  86. (defun lr-crl-brace ()
  87.  (interactive "*")
  88.  (insert "\\left\{ \\right\}")
  89.  (backward-char 9)
  90. )
  91.  
  92. ;; moarr latex keybindings
  93. (add-hook 'LaTeX-mode-hook
  94.           (lambda ()
  95.             (define-key LaTeX-mode-map (kbd "C-c e") 'LaTeX-find-next-item)
  96.             (define-key LaTeX-mode-map (kbd "C-c s") 'LaTeX-find-next-section)
  97.             (define-key LaTeX-mode-map (kbd "<tab>") 'yas/expand)
  98.             (define-key LaTeX-mode-map (kbd "<C-tab>") 'cdlatex-tab)
  99.             ))
  100.  
  101. ;; ========== goto undef ref ========== ;;
  102. (defalias 'my-latex-goto-undefref (read-kbd-macro
  103. "C-s undefined M-e M-b M-@ <C-end> C-x o M-g <f10> RET"))
  104.  
  105.  
  106. (defun LaTeX-compile-metapost ()
  107.   "compiles (using mpost) all files ending in \"mp\" in the current file's directory"
  108.   (interactive)
  109.   (shell-command "find . -name "*.mp" -exec mpost '{}' \; "))
  110.  
  111.  
  112. ;; lets get another minor LaTeX mod, disabled atmo
  113. (autoload 'cdlatex-mode "cdlatex" "CDLaTeX Mode" t)
  114. (autoload 'turn-on-cdlatex "cdlatex" "CDLaTeX Mode" nil)
  115. (add-hook 'LaTeX-mode-hook 'turn-on-cdlatex)   ; with AUCTeX LaTeX mode
  116. (add-hook 'latex-mode-hook 'turn-on-cdlatex)   ; with Emacs latex mode
  117.  
  118.  
  119. ;; flyspell
  120. (add-hook 'LaTeX-mode-hook 'flyspell-mode)   ; with AUCTeX LaTeX mode
  121. (add-hook 'latex-mode-hook 'flyspell-mode)   ; with Emacs latex mode
  122.  
  123. ;; (require 'tex-mode)
  124. ;; (add-hook 'LaTeX-mode-hook
  125. ;;           (lambda ()
  126. ;;             (set (make-local-variable 'syntax-propertize-function)
  127. ;;                  (syntax-propertize-rules latex-syntax-propertize-rules))
  128. ;;             (latex-electric-env-pair-mode 1)))
  129.  
  130. (require 'tex-mode)
  131. (defconst my-latex-syntax-propertize-function
  132.   (with-temp-buffer (latex-mode) syntax-propertize-function))
  133.  
  134. (add-hook 'LaTeX-mode-hook
  135.           (lambda ()
  136.             (set (make-local-variable 'syntax-propertize-function)
  137.                  my-latex-syntax-propertize-function)
  138.             (latex-electric-env-pair-mode 1)))
  139.  
  140. (provide 'setup-latex)
clone this paste RAW Paste Data