-(defun my-auto-tex-cmd ()
- "When exporting from .org with latex, automatically run latex,
- pdflatex, or xelatex as appropriate, using latexmk."
- (let ((texcmd)))
- ;; default command: pdflatex
- (setq texcmd "latexmk -pdflatex='pdflatex -synctex=1 --shell-escape --' -pdf %f")
- ;; pdflatex -> .pdf
- (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
- (setq texcmd "latexmk -pdflatex='pdflatex -synctex=1 --shell-escape' -pdf %f"))
- ;; xelatex -> .pdf
- (if (string-match "LATEX_CMD: xelatex" (buffer-string))
- (setq texcmd "latexmk -pdflatex='xelatex -syntex=1 --shell-escape' -bibtex -use-make -pdf %f"))
- ;; LaTeX compilation command
- (setq org-latex-to-pdf-process (list texcmd)))
-
-(add-hook 'org-latex-after-initial-vars-hook 'my-auto-tex-cmd)