# emacs ORG-mode “headless” export-as commands?

When I use org-export-as-latex or org-export-as-html orgmode turns my buffer into a .tex file or .html file. But I don't want all the extra junk that it adds to the file: I want to handle the documentclass and everything myself and just \input the org mode generated file. (Or the analogous things for html with php).

So if my org file just has:

* Section
- Stuff
- Things


I want the org mode command to output just

\section{Section}
\begin{itemize}
\item Stuff
\item Things
\end{itemize}


Without any of the extra \tableofcontents junk that ORG adds to it. I know I could define my own kind of #+LaTeX_CLASS that could add the packages I want and so on, but I don't want to do things that way (and that wouldn't remove the \maketitle or the spurious \vspace* that ORG insists on inserting.

Is there a command to do this "headless" parsing and converting? I had a look but it's not obvious from the documentation. Presumably some low level ORG command is doing the parsing and converting I want, but I couldn't find what it was called from looking at the docs and C-h pages...

This is not a question about HTML or LaTeX but about emacs ORG mode. So don't kick it off to some other site...

-
Check the prototype and documentation for org-export-as-latex. There is a flag called body-only which will do part of the job. You can also pass a property list for overriding default settings. – Juancho Jun 20 '11 at 18:52
Also, if you need real minimalism, have a look at the generic exporter at orgmode.org/worg/org-contrib/org-export-generic.html – Juancho Jun 20 '11 at 18:56
@Juancho could you explain how to pass a flag to a command? Maybe as part of an answer to this question? – Seamus Jun 20 '11 at 23:45
Just for trying, M-: then enter (org-export-as-latex nil nil nil nil t) (the last t means true for the body-only parameter). You'll get a message indicating the tex buffer created. If you like the result, you can make a command or keybinding to call this. – Juancho Jun 21 '11 at 1:13
@Juancho I get "trailing garbage following expression" and no output... – Seamus Jun 21 '11 at 9:54

For LaTeX output, here are some options for getting cleaner output:

The function org-export-as-latex actually takes several parameters, one of which is a flag called BODY-ONLY.

The prototype for this function is (org-export-as-latex ARG &optional HIDDEN EXT-PLIST TO-BUFFER BODY-ONLY PUB-DIR) for OrgMode 7.5.

You can try the output by evaluating the LISP call explicitly:

M-: (org-export-as-latex nil nil nil nil t) RET


where the t symbol indicates the body-only option. This will create a new buffer with the LaTeX output. (RET means pressing the return key)

A shortcut for the above is to call org-export-region-as-latex. This is an interactive function which you can call with M-x. Its only argument is the body-only flag.

For example, you can select the whole buffer (via C-x h), then call this function with a prefix argument (to give a non-nil value to body-only):

C-u M-x org-export-region-to-latex RET


Now you'll have a new buffer selected with the LaTeX output and no header / footer / titles / TOC added.

This idea works also with org-export-region-as-html.

There is also a contributed package org-export-generic that lets you define an exporter completely: http://orgmode.org/worg/org-contrib/org-export-generic.html

P.S. I'm using the latest development version of OrgMode 7.5

-