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
The documentation where to change the exporter for source code can be found in the documentation for org-export-format-source-code-or-example
, C-h f org-export-format-source-code-or-example
:
...
Check if a function by name
"org--format-source-code-or-example" is bound. If yes, use it
as the custom formatter. Otherwise, use the default formatter. Default
formatters are provided for docbook, html, latex and ascii backends.
For example, use `org-html-format-source-code-or-example' to provide a
custom formatter for export to "html".
...
An example export function can be found here (l. 2635). Modified to match your requierments:
(defun org-html-format-source-code-or-example
(lines lang caption textareap cols rows num cont rpllbl fmt)
(setq lines
(concat
"<pre name=\"code\" class=\"" lang "\">\n"
(cond
(textareap
(concat
(format "<p>\n<textarea cols=\"%d\" rows=\"%d\">"
cols rows)
lines "</textarea>\n</p>\n"))
(t
(with-temp-buffer
(insert lines)
(goto-char (point-min))
(while (re-search-forward "[<>&]" nil t)
(replace-match (cdr (assq (char-before)
'((?&."&")(?<."<")(?>.">"))))
t t))
(buffer-string))))
"</pre>\n"))
(unless textareap
(setq lines (org-export-number-lines lines 1 1 num cont rpllbl fmt)))
lines)
After evaluation (copy to *scratch* and run M-x eval-buffer
, or place in your .emacs and restart) html export exports
#+BEGIN_SRC java
public class UserBuilder
{
private string _firstName;
private string _lastName;
}
#+END_SRC
as
<pre name="code" class="java">
public class UserBuilder
{
private string _firstName;
private string _lastName;
}
</pre>
(Had to switch languages in the example because my emacs doesn't know c# but it works for all languages).
Best Answer
Short Answer: Does not look to be easily accomplished to modify the structure dramatically. There are some export-options suggested like
org-export-plist-vars
but I personally have not played with them.Digging for the Answer: When you call C-c C-e t, you are invoking the org-mode function
org-insert-export-options-template
. I did a quick help on the function (C-h f) and didn't see any helping text or options to pass to it, so I had to look at the source of the function (M-xfind-function
ENTERorg-insert-export-options-template
ENTER>).Reading through the
org-insert-export-options-template
function, I see that it is acquiring the text to insert viaorg-get-current-options
. No help on configuring it's behavior in it's description, so off to view it's source as well. There you will see the familiar full bodied paragraph of template information that is inserted into the text when you callorg-insert-export-options-template
. The values populate are from various other org variables, buffer name, etc.Recommendation: What I personally have done is spent some time deciding which options I'd like and copied those from other org files when I start a new one. I have also thought about using AutoInsertMode to auto-populate a new org file for me but have put it off.