Inside a section, Org recognises elements by how their first line starts. Greater
elements can contain other elements; lesser elements contain only text and objects, or
nothing parsed at all. Anything that matches nothing else is a paragraph. Keywords such
as #+begin_src are case-insensitive.
Blocks
A block runs from #+begin_NAME to #+end_NAME.
| Block | After begin | Content | Kind |
|---|---|---|---|
center | – | Elements, centred on export. | greater |
quote | – | Elements, as a block quotation. | greater |
| any other name (special block) | parameters | Elements; exporters turn it into, for example, a div with that class or a LaTeX environment. | greater |
comment | – | Text left out of export. | lesser |
example | switches | Text shown as is, in a fixed-width font. | lesser |
export | a back-end name, required (html, latex…) | Raw text for that exporter only. | lesser |
src | language, switches, header arguments | Source code, which Org Babel can run. | lesser |
verse | – | Text with line breaks and indentation kept, objects parsed. | lesser |
In lesser blocks, a line starting with * or #+ must be
escaped with a leading comma (,* not a heading); Org removes it.
| Switch | Meaning (example and src blocks) |
|---|---|
-n [start] | Number the lines, from 1 or start. |
+n [step] | Number lines continuing from the previous block. |
-r | Remove the reference labels from the code. |
-l "format" | The label format, default (ref:%s). |
-i | Keep the block’s indentation. |
-k | Keep labels in the code. |
Source block header arguments start with a colon: :results,
:exports (code, results, both,
none), :session, :var, :dir,
:tangle, :noweb, :cache, :eval
and many more, defined by Babel and each language.
#+name: square
#+begin_src python :var x=4 :results value
return x * x
#+end_src
#+RESULTS: square
: 16
Dynamic blocks
#+begin: NAME PARAMETERS … #+end:. Org fills the content by
calling a function named after NAME, such as clocktable or
columnview. Dynamic blocks cannot nest.
Plain lists
| Part | Syntax |
|---|---|
| Bullet | -, +, or * if indented (an unindented * is a heading); or a counter 1., 1), a., a) (letters only with org-list-allow-alphabetical). |
| Counter set | [@5] after the bullet starts numbering at 5. |
| Checkbox | [ ] open, [X] done, [-] partly done (some children done). |
| Tag | TERM :: description makes a description list. |
The first item decides the list’s type: a counter makes it ordered, a tag makes it a description list, otherwise it is unordered. Items continue on lines indented more than the bullet; a list ends at a line indented less, or two blank lines.
- [X] Book flights
- [-] Packing [1/2]
1. [X] Passport
2. [ ] Adapter
- Lisbon :: three nights
Tables
- Org tables: lines starting with
|. A row is cells between bars; a line starting|-is a rule. Columns are aligned by Org as you type. #+TBLFM:lines after a table hold spreadsheet formulas: column formulas ($3=$1*$2), field formulas (@2$4=vsum(@2$1..@2$3)), ranges, and Calc or Emacs Lisp ('(…)) expressions, with format flags after a;.- A first column of
!,^,_,#,*,$or/marks rows for names, recalculation and export exclusion. - A cell
<10>or<l>,<c>,<r>in a row of its own sets a column’s width or alignment. - table.el tables: lines starting with
+-, kept as text and handled by Emacs’ table.el; they allow spanning cells.
| Item | Qty | Price | Total |
|-------+-----+-------+-------|
| Boxes | 10 | 3.5 | 35 |
#+TBLFM: $4=$2*$3
Footnote definitions
[fn:LABEL] contents at the start of an unindented line, where LABEL is
a number or a word. The definition runs to the next footnote definition, the next
heading, two blank lines or the end of the file. Footnotes are usually gathered under
a heading named Footnotes.
Affiliated keywords
Lines directly above an element (no blank line) that attach information to it:
| Keyword | Meaning |
|---|---|
#+CAPTION: | A caption; #+CAPTION[short]: long gives a short form for lists of figures. Several lines are joined. |
#+NAME: | A name, used to link to the element or to refer to a table or block from code. |
#+HEADER: | Extra header arguments for the source block below. |
#+RESULTS: | Marks the element as the result of a named block or call; may carry a hash. |
#+PLOT: | Gnuplot options for plotting a table. |
#+ATTR_BACKEND: | Attributes for one exporter: #+ATTR_HTML: :width 300, #+ATTR_LATEX: :float t. |
#+DATA: | An older synonym kept for compatibility (with LABEL, SRCNAME, TBLNAME, RESNAME, SOURCE, HEADERS, all read as NAME, HEADER or RESULTS). |
Other elements
| Element | Syntax | Meaning |
|---|---|---|
| Keyword | #+KEY: VALUE | An in-buffer setting. |
| Babel call | #+call: NAME[HEADER](ARGS)[HEADER] | Runs a named source block. |
| Comment | # then a space, or # alone | A line left out of export. |
| Fixed-width area | : then a space, or : alone | Lines shown as is, like an example block; used for results. |
| Horizontal rule | Five or more - | A rule. |
| Diary sexp | %%(…) in the first column | An Emacs diary expression, for agenda entries such as anniversaries. |
| LaTeX environment | \begin{NAME} … \end{NAME} | LaTeX passed to LaTeX export and rendered by others. |
| Clock | CLOCK: … | Time spent: see clock lines. |
| Paragraph | Anything else | Text with objects, ended by a blank line or another element. |