[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [New Exporter] org-export-latex-after-initial-vars-hook

From: Michael Bach
Subject: Re: [O] [New Exporter] org-export-latex-after-initial-vars-hook
Date: Thu, 6 Jun 2013 12:48:10 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

> Is there a hook that is run before actual LaTeX export of a given
> org-mode buffer in the new exporter engine?

For reference:
I got it to work by adapting the snippet from Bruno Tavernier[1]:
#+begin_src emacs-lisp
(defun my-auto-tex-cmd (backend)
    "When exporting from .org with latex,
    automatically run latex, pdflatex, or xelatex as appropriate,
    using latexmk."
    (let ((texcmd))
      (setq texcmd "latexmk -pdf %f")
      (if (string-match "LATEX_CMD: pdflatex" (buffer-string))
          (setq texcmd "latexmk -pdflatex=pdflatex -pdf %f"))
      (if (string-match "LATEX_CMD: pdflatex-shell-escape" (buffer-string))
          (setq texcmd "latexmk -pdflatex=pdflatex --shell-escape -pdf %f"))
      (if (string-match "LATEX_CMD: xelatex" (buffer-string))
          (setq texcmd "latexmk -pdflatex=xelatex -pdf %f"))
      (setq org-latex-pdf-process (list texcmd))))
  (add-hook 'org-export-before-parsing-hook 'my-auto-tex-cmd)

One thing that tripped me up initially was the requirement for the function to 
accept exactly one argument (unused in this case).

[1] http://lists.gnu.org/archive/html/emacs-orgmode/2010-10/msg00218.html

reply via email to

[Prev in Thread] Current Thread [Next in Thread]