Basti's Scratchpad on the Internet

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
#+LATEX_HEADER: }

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: nurullah@nakkaya.com

You can't have papers without figures, images,

#+CAPTION: Arduino Duemilanove
#+ATTR_LaTeX: scale=0.75
[[./img/arduino-duemilanove.jpeg]]

or pre-formatted text,

#+BEGIN_EXAMPLE
 Some example from a text file.
#+END_EXAMPLE

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

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
      (quote
       ("/path/to/default.bib")))

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

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

and add,

\bibliographystyle{plain}
\bibliography{refs}{}

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,

reftex-citation

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

Other posts
comments powered by Disqus