emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Bach <phaebz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [New Exporter] org-export-latex-after-initial-vars-hook
Date: Thu, 6 Jun 2013 12:48:10 +0000 (UTC)	[thread overview]
Message-ID: <loom.20130606T144108-886@post.gmane.org> (raw)
In-Reply-To: CAFbCY6hxjtvd40Mwc9+ToD-C13+RnEJFDQLNEnBxVV71J_n9yw@mail.gmail.com

> 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)
#+end_src

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	other threads:[~2013-06-06 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06  8:59 [New Exporter] org-export-latex-after-initial-vars-hook Michael Bach
2013-06-06 12:48 ` Michael Bach [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-06-06  8:38 Michael Bach
2013-04-29 15:46 Søren Mikkelsen
2013-04-29 17:16 ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20130606T144108-886@post.gmane.org \
    --to=phaebz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).