From d28a3a9e611efd94637742939c4f2b6c89c6ba97 Mon Sep 17 00:00:00 2001 From: Lars Tveito Date: Tue, 7 Apr 2015 21:18:31 +0200 Subject: [PATCH] Updated LaTeX section to include org mode export. Also this includes a new LaTeX class to org mode. --- init.el | 40 +++++++++++++++++++++++++++++++--------- init.org | 46 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/init.el b/init.el index afaf6c5..813c1e2 100644 --- a/init.el +++ b/init.el @@ -883,13 +883,17 @@ given, the duplicated region will be commented out." (add-hook 'asm-mode-hook 'asm-setup) -;; LaTeX +;; LaTeX and org-mode LaTeX export ;; =.tex=-files should be associated with =latex-mode= instead of ;; =tex-mode=. (add-to-list 'auto-mode-alist '("\\.tex\\'" . latex-mode)) +;; Use ~biblatex~ for bibliography. + +(setq-default bibtex-dialect 'biblatex) + ;; I like using the [[https://code.google.com/p/minted/][Minted]] package for source blocks in LaTeX. To make org ;; use this we add the following snippet. @@ -903,17 +907,35 @@ given, the duplicated region will be commented out." ;; Tex- and LaTeX-mode, we can add the flag with a rather dirty statement ;; (if anyone finds a nicer way to do this, please let me know). -(eval-after-load 'ox-latex - '(setq org-latex-pdf-process - (mapcar - (lambda (str) - (concat "pdflatex -shell-escape " - (substring str (string-match "-" str)))) - org-latex-pdf-process))) - (eval-after-load 'tex-mode '(setcar (cdr (cddaar tex-compile-commands)) " -shell-escape ")) +;; When exporting from Org to LaTeX, use ~latexmk~ for compilation. + +(eval-after-load 'ox-latex + '(setq org-latex-pdf-process + '("latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -pdf -f %f"))) + +;; For my thesis, I need to use our university's LaTeX class, this snippet +;; makes that class available. + +(eval-after-load "ox-latex" + '(progn + (add-to-list 'org-latex-classes + '("ifimaster" + "\\documentclass{ifimaster} +[DEFAULT-PACKAGES] +[PACKAGES] +[EXTRA] +\\usepackage{babel,csquotes,ifimasterforside,url,varioref}" + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + (custom-set-variables '(org-export-allow-bind-keywords t)))) + ;; Markdown ;; I sometimes use a specialized markdown format, where inline math-blocks diff --git a/init.org b/init.org index 0e7f755..892dc1f 100644 --- a/init.org +++ b/init.org @@ -1106,7 +1106,7 @@ (add-hook 'asm-mode-hook 'asm-setup) #+END_SRC -** LaTeX +** LaTeX and org-mode LaTeX export =.tex=-files should be associated with =latex-mode= instead of =tex-mode=. @@ -1115,6 +1115,12 @@ (add-to-list 'auto-mode-alist '("\\.tex\\'" . latex-mode)) #+END_SRC + Use ~biblatex~ for bibliography. + + #+BEGIN_SRC emacs-lisp + (setq-default bibtex-dialect 'biblatex) + #+END_SRC + I like using the [[https://code.google.com/p/minted/][Minted]] package for source blocks in LaTeX. To make org use this we add the following snippet. @@ -1131,18 +1137,40 @@ (if anyone finds a nicer way to do this, please let me know). #+BEGIN_SRC emacs-lisp - (eval-after-load 'ox-latex - '(setq org-latex-pdf-process - (mapcar - (lambda (str) - (concat "pdflatex -shell-escape " - (substring str (string-match "-" str)))) - org-latex-pdf-process))) - (eval-after-load 'tex-mode '(setcar (cdr (cddaar tex-compile-commands)) " -shell-escape ")) #+END_SRC + When exporting from Org to LaTeX, use ~latexmk~ for compilation. + + #+BEGIN_SRC emacs-lisp + (eval-after-load 'ox-latex + '(setq org-latex-pdf-process + '("latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -pdf -f %f"))) + #+END_SRC + + For my thesis, I need to use our university's LaTeX class, this snippet + makes that class available. + + #+BEGIN_SRC emacs-lisp + (eval-after-load "ox-latex" + '(progn + (add-to-list 'org-latex-classes + '("ifimaster" + "\\documentclass{ifimaster} + [DEFAULT-PACKAGES] + [PACKAGES] + [EXTRA] + \\usepackage{babel,csquotes,ifimasterforside,url,varioref}" + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}") + ("\\paragraph{%s}" . "\\paragraph*{%s}") + ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) + (custom-set-variables '(org-export-allow-bind-keywords t)))) + #+END_SRC + ** Markdown I sometimes use a specialized markdown format, where inline math-blocks