Org Mode

Table of Contents

1 Structure

1.1 Drawer

The heading can have a drawer, meaning it is hidden by default. Under a headline, use :DRAWERNAME: and :END: to denote the beginning and end. C-c C-x d also creates drawer easily. If region is active, move the region to a drawer.

1.2 Footnote

Footnote can be of these format:

  • [fn:1] some text
  • [fn:name]
  • [fn:: anonymous inline footnote!]
  • [fn:name: named inline footnote that can be referenced from elsewhere]

There should be two empty lines after the footnote definition.

C-c C-x f inserts a footnote (at the end of page); C-c C-c jump to definition or back to reference; C-c ' :: edit the footnote in a seperate buffer.

1.3 Headings

Moving around
C-c C-n :: next heading C-c C-p :: previous heading C-c C-f :: next heading same level C-c C-b :: previous heading same level C-c C-u :: parent heading C-c C-j :: jump to some node. Direct type to navigate, and tab to expand.
Editing
Use the command org-promote-subtree and org-demote-subtree to adjust the heading level. M-h marks current tree. It is very useful to narrow the subtree using C-x n s and widen it back by C-x n w.

2 Agenda

It is very convenient to use org-capture to quickly write down a task to a pre-specified org file, and return from this interruption. After that, use org-refile (C-c C-w) to organize the entries inside the file, into different top-level headings. When a job is done, use org-archive-subtree to move it to the archive file, defaults to xxx_archive (C-c C-x C-s)in the same directory.

org-capture-goto-target will goto the file associated with template entry. org-capture-goto-last-stored goes directly to the last stored file.

Creating
A TODO keyword in the beginning of a heading mark it as a TODO item, or simply M-S-<RET> to create one.
Attributes
You can add a schedule or deadline for such an item, by C-c C-s and C-c C-d respectively. Time-stamp is normally inserted C-c . inserts or modifies time stamp. It can recognize a variety of format. Also, in the interactive calendar and in the org buffer, use M-<ARROW> to move. An item can have a priority within A to C, set by C-c ,.
Operations
There're a lot of operations on the entries. In the org buffer, C-c t will rotate TODO state. For a list that is not a heading, you can pre-pend the list with [ ], and C-c C-c toggles it. A task can be clocked. Clock in via C-c C-x C-i and clock out via C-c C-x C-o. C-c ^ can sort the lists, based on many attributes such as todo status, time, priority.
Agenda View

It is better to view the TODO lists in a dedicated buffer. Org keeps the variable org-agenda-files for the global agenda files. You can add current file by C-c [. The global agenda has different view method, namely C-c a a for the week view, C-c a t for all todo items, and C-c a L for the timeline of current file. In side the buffer, <ENTER> enter the org file while <TAB> display the org file in another window.

In the agenda view, d,w,vm,vy change the range to day, week, month, year respectively. E to show the entry text (text inside the heading), R show the clock report. s saves all buffers, f, b and . go to next, previous week and today respectively.

As always g to refresh. It is easier to operate in such a buffer: you don't usually need the C-c prefix. t changes TODO status, , set the priority, with + and - to raise or lower it. You can still set deadline and schedule using the same binding. Clocking in and out becomes I and O, and cancel with X.

3 Tags

Tags can be the variable name plus @ is available. Every heading can have tags at the end of it. Use :tag1:tag2: syntax. Tags will be inherited by default for the subtrees. C-c C-c :: at the heading, set the tags.

4 Properties

Similar to tags, we can also set the property, the key value pairs. It is inside the PROPERTY drawer. Each line is a property, where key is surrounded with :, and value after it. Property is not inherited by default.

5 Exporting

5.1 bibliography

Normally you only need:

bibliographystyle:plain
bibliography:/home/hebi/github/bibliography/hebi/tools.bib

It remains to be seen how to put a set of default bib file instead of specifying this ugly file.

5.2 Latex Exporting

5.2.1 doc class & options

 #+LATEX_CLASS: fse
 #+OPTIONS: toc:nil author:nil

 #+BIBLIOGRAPHY: slicing plain
 #+INCLUDE: "appendix.org" :minlevel 1

5.2.2 appendix

 #+LaTeX: \appendix

 #+INCLUDE: "appendix-todo.org" :minlevel 1
 #+INCLUDE: "appendix-context.org" :minlevel 1
 #+INCLUDE: "appendix-helium-guard.org" :minlevel 1
 #+INCLUDE: "appendix-valgrind-exp.org" :minlevel 1

5.2.3 code listing

#+ATTR_LATEX: :options frame=shadowbox

5.3 Beamer

The header setup:

#+STARTUP: beamer
#+AUTHOR: Hebi Li
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [presentation]
#+BEAMER_THEME: Madrid
#+OPTIONS: H:2 toc:t num:t

The above configuration define "H" to be 2, meaning the frame is the second level heading (**). The top level heading (*) can be used to organize the presentation. To show the current section, add this just after every top level heading.

#+TOC: headlines [currentsection]

There's an automatic way to add table of contents before each section:

#+latex_header: \AtBeginSection[]{\begin{frame}<beamer>\frametitle{Topic}\tableofcontents[currentsection]\end{frame}}

The *** will becomes block. These blocks can utilize the horizontal space.

#+BEGINEXAMPLE

5.3.1 Octave code   BMCOL B_block

5.3.2 The output   BMCOL B_block

#+ENDEXAMPLE

6 Table

#+TBLFM: $4=$2/10
#+TBLFM: $4=$2*100/$3
#+TBLFM: $4=(round $4)

7 Image

[[./image]]

  • org-toggle-inline-image
  • org-display-inline-image
  • org-redisplay-inline-image
  • org-remove-inline-image

The width is defined by org-image-actual-width

  • t: actual width
  • 300: 300px

Use #+ATTR_HTML: :width 300px to set the html export size.

8 org-ref

8.0.1 Commands

  • C-c ]: insert citation, typically with helm: org-ref-helm-insert-cite-link
8.0.1.1 Navigation in the bib file
M-n
next entry
M-p
previous entry