Writing Papers Using org-mode

With LaTeX, it seems like I am spending more time researching LaTeX itself then the topic I am working on, so for sometime now I dropped LaTeX in favor of Org-mode. I am posting this as a personal cheat sheet, it is much more easier to search this site then to dig through old papers to figure out how I did stuff.

Org-mode allows you to control certain things during export using export options, following sets the default font to Arial,

#+LATEX_HEADER: \renewcommand{\rmdefault}{phv} % Arial

and following gets rid of the red boxes drawn around the links.

#+LATEX_HEADER: \usepackage{hyperref}
#+LATEX_HEADER: \hypersetup{
#+LATEX_HEADER:     colorlinks,%
#+LATEX_HEADER:     citecolor=black,%
#+LATEX_HEADER:     filecolor=black,%
#+LATEX_HEADER:     linkcolor=blue,%
#+LATEX_HEADER:     urlcolor=black

For those who write in non English, babel package will translate, automatically generated text strings to the language you specify.

#+LATEX_HEADER: \usepackage[turkish]{babel}

For specifying date, author, and title of the paper you are writing,

#+TITLE: Writing Papers Using org-mode
#+AUTHOR: Nurullah Akkaya
#+EMAIL: [email protected]

You can't have papers without figures, images,

#+CAPTION: Arduino Duemilanove
#+ATTR_LaTeX: scale=0.75

or pre-formatted text,

 Some example from a text file.

for embedding source,

#+BEGIN_SRC lisp
(let [i (atom 0)]
  (defn generate-unique-id
    "Returns a distinct numeric ID for each call."
    (swap! i inc)))

If you want to listing to look like the fontified Emacs buffer you need to add these to your .emacs,

(setq org-latex-listings t)
(add-to-list 'org-latex-packages-alist '("" "listings"))
(add-to-list 'org-latex-packages-alist '("" "color"))

For adding citations to paper using reftex add the following snippet to your .emacs,

(setq-default TeX-master t)
(setq reftex-default-bibliography

(defun na-org-mode-reftex-setup ()
  (load-library "reftex")
  (and (buffer-file-name)
       (file-exists-p (buffer-file-name))

(add-hook 'org-mode-hook 'na-org-mode-reftex-setup)

and add,


to the end of the org file. It will look for refs.bib for bibtex references in the same folder as the org-file. Anytime you want to insert a reference use,


When generating the file, export to latex then manually call pdflatex then call bibtex org-file.aux and finally call pdflatex once more.