[Tex/LaTex] Exporting from Org-mode without LaTeX preamble

emacsorg-modepreview

Is it possible to export an *.org file to LaTeX file, without the usual preamble of \documentclass[...]{article} and a number of \usepackage[]{xyz}, yet take advantage of LaTeX and org-mode's math and calculation power?

I have EMACS+AUCTeX and TexLive 2013 installed on a 32-bit Windows 7 machine.

Best Answer

Edit

I was wrong, you can do this with normal org mode commands.

C-c C-e will invoke org-export-dispatch

This brings up the Export Dispatcher buffer. You'll notice the option for Body Only at the top, which is toggled with C-b. Set it to On, and then complete your export with l l (or whatever you like).

I'll leave my original, though now unnecessary, pandoc solution below.

Original answer using pandoc

An inelegant solution using pandoc. From the command line, the following provides the org -> latex conversion without producing any header text:

pandoc -o file_name.tex file_name.org

This assumes your file is called "file_name.org". A bit of elisp to call this function from within Emacs, while you're visiting the file you wish to export:

(defun my-export-to-tex ()
  "Export this buffer from org to latex."
  (interactive)
  (async-shell-command 
   (concatenate "pandoc -o "
                (file-name-base buffer-file-name)
                ".tex " buffer-file-name)))