Org mode syntax
Quick reference card
Table of Contents
Source | https://github.com/fniessen/refcard-org-mode |
1 Summary
This document is expected to be helpful when you are interested in composing a document like this document itself. It serves as an example template and reference of the Org-mode document. This document is available as a README.org which is in text format and can be edited in a text editor (usually GNU Emacs). This Document is also available as a README.html, which is exported as HTML from README.org. HTML file stylesheet based on org.css.
See https://sbr.pm/articles/sandbox.html (ditaa) and https://github.com/elmarlee/org-mode-template/blob/master/org-mode-template.org for more examples.
2 Headings
* Biggest heading New chapter. ** Bigger heading New section. *** Big heading New sub-section.
3 Biggest heading
New chapter.
3.1 Bigger heading
New section.
3.1.1 Big heading
New sub-section.
4 Paragraphs
4.1 Line breaks
By entering two consecutive backslashes, \\ you can force a line break without starting a new paragraph.
By entering two consecutive backslashes,
you can force a line break
without starting a new paragraph.
4.2 Horizontal rules
For an horizontal line, insert at least 5 dashes: this is some text above an horizontal rule ----- and some text below it.
For an horizontal line, insert at least 5 dashes: this is some text above an horizontal rule
and some text below it.
5 Formatting text
Text effects.
5.1 Bold and italic
/Emphasize/ (italics), *strongly* (bold), and */very strongly/* (bold italics). Markup elements can be nested: This is /italic text which contains _underlined text_ within it/, whereas _this is normal underlined text_. Markup can span across multiple lines, by default *no more than 2*: *This is not bold.* Org mode does not interpret a marker surrounded by alphanumeric characters as an emphasis marker. So, you can't (easily) emphasize just part of a word: Not feas*ible*.
Emphasize (italics), strongly (bold), and very strongly (bold italics).
Markup elements can be nested:
This is italic text which contains underlined text within it, whereas this is normal underlined text.
Markup can span across multiple lines, by default no more than 2:
*This is not bold.*
Org mode does not interpret a marker surrounded by alphanumeric characters as an emphasis marker. So, you can’t (easily) emphasize just part of a word:
Not feas*ible*.
5.2 Monospace, superscript and subscript
Other elements to use sparingly are:
- monospaced typewriter font for
inline code
- monospaced typewriter font for verbatim text
deleted text(vs. inserted text)- text with superscript, such as 210
- text with subscript, such as H2O
5.3 Smart punctuation
If =#+OPTIONS: ':t= is specified, or alternatively =(setq org-export-with-smart-quotes t)= in Emacs configuration file, Org mode will produce typographically correct output, converting straight 'single quotes' and "straight quotes" to their respective curly/smart quotes, --- to em-dashes, -- to en-dashes, ... to ellipses and ' to typographic apostrophe.
If #+OPTIONS: ':t is specified, or alternatively (setq org-export-with-smart-quotes t) variable in Emacs configuration file, Org mode will produce typographically correct output, converting straight ’single quotes’ and “straight quotes” to their respective curly/smart quotes, — to em-dashes, – to en-dashes, … to ellipses and ’ to typographic apostrophe.
6 Lists
Org markup allows you to create bulleted or numbered lists. It allows any combination of the two list types.
6.1 Unordered lists
Itemized lists are marked with bullets. Create them with a minus or a plus sign.
They are convenient to organize data, and make the document prettier, and easier to read.
- Item with some lengthy text wrapping hopefully across several lines. We add a few words to really show the line wrapping. - Bullet. + Bullet. * Bullet.
- Item with some lengthy text wrapping hopefully across several lines. We add a few words to really show the line wrapping.
- Bullet.
- Bullet.
- Bullet.
- Bullet.
6.2 Checklists
- [X] Checked. - [-] Half-checked. - [ ] Not checked. - Normal list item.
[X]
Checked.[-]
Half-checked.[ ]
Not checked.- Normal list item.
6.3 Ordered lists
Enumerated lists are marked with numbers or letters like a., A., a) and A), but requires to (setq org-list-allow-alphabetical t) in Emacs configuration file.
1. Arabic (decimal) numbered list item. We add a few words to show the line wrapping. A. Upper case alpha (letter) numbered list item. a. Lower alpha. b. Lower alpha. B. Upper alpha. 2. Number.
- Arabic (decimal) numbered list item. We add a few words to show the line
wrapping.
- Upper case alpha (letter) numbered list item.
- Lower alpha.
- Lower alpha.
- Upper alpha.
- Upper case alpha (letter) numbered list item.
- Number.
You can have ordered lists with jumping numbers:
2. [@2] We start with point number 2. 3. Automatically numbered item.
- We start with point number 2.
- Automatically numbered item.
6.4 Definition lists
Labeled, multi-line lists.
- First term to define :: Definition of the first term. We add a few words to show the line wrapping, to see what happens when you have long lines. - Second term :: Explication of the second term with *inline markup*. In many paragraphs.
- First term to define
- Definition of the first term. We add a few words to show the line wrapping, to see what happens when you have long lines.
- Second term
Explication of the second term with inline markup.
In many paragraphs.
6.5 Separating lists
Adjacent lists sometimes like to fuse. To force the start of a new list, offset the two lists by an empty line comment:
- apples
- oranges
- bananas
# Comment.
- carrots
- tomatoes
- celery
- apples
- oranges
- bananas
- carrots
- tomatoes
- celery
7 Tables
Tables are one of the most refined areas of the Org mode syntax. They are very easy to create and to read.
7.1 Simple table
| Cell in column 1, row 1 | Cell in column 2, row 1 | | Cell in column 1, row 2 | Cell in column 2, row 2 |
Cell in column 1, row 1 | Cell in column 2, row 1 |
Cell in column 1, row 2 | Cell in column 2, row 2 |
Org tables have cells of at most one line long: there is no such thing as a multi-line table cell in Org.
7.2 Column formatting
Columns are automatically aligned:
- Number-rich columns to the right, and
- String-rich columns to the left.
7.2.1 Table with aligned cells
If you want to override the automatic alignment, use <r>
, <c>
or <l>
.
Table with aligned columns | <r> | <c> | <l> | | 1 | 2 | 3 | | Right | Center | Left | | Cell in column 1, row 3 | Cell in column 2, row 3 | Cell in column 1, row 3 |
1 | 2 | 3 |
Right | Center | Left |
Cell in column 1, row 3 | Cell in column 2, row 3 | Cell in column 3, row 3 |
7.3 Header row
You can create tables with an header row (by using an horizontal line of dashes to separate it from the rest of the table).
Table with an header row | Name of column 1 | Name of column 2 | Name of column 3 | |------------------+------------------+------------------| | Top left | Top middle | | | | | Right | | Bottom left | Bottom middle | |
Name of column 1 | Name of column 2 | Name of column 3 |
---|---|---|
Top left | Top middle | |
Right | ||
Bottom left | Bottom middle |
7.4 A very long table
To test “sticky table headers”…
| Name of column 1 | Name of column 2 | Name of column 3 | |------------------+------------------+------------------| | Top left | Top middle | | | 2 | | | | 3 | | | | 4 | | | | 5 | | | | 6 | | | | 7 | | | | 8 | | | | 9 | | | | 10 | | | | 11 | | | | 12 | | | | 13 | | | | 14 | | | | 15 | | Right | | 16 | | | | 17 | | | | 18 | | | | 19 | | | | 20 | | | | 21 | | | | 22 | | | | 23 | | | | 24 | | | | 25 | | | | 26 | | | | 27 | | | | 28 | | | | 29 | | | | Bottom left | Bottom middle | |
Name of column 1 | Name of column 2 | Name of column 3 |
---|---|---|
Top left | Top middle | |
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
10 | ||
11 | ||
12 | ||
13 | ||
14 | ||
15 | Right | |
16 | ||
17 | ||
18 | ||
19 | ||
20 | ||
21 | ||
22 | ||
23 | ||
24 | ||
25 | ||
26 | ||
27 | ||
28 | ||
29 | ||
Bottom left | Bottom middle |
7.5 Table placement
| a | b | | 1 | 2 |
a | b |
1 | 2 |
XXX Different from the following:
| a | b | | 1 | 2 |
a | b |
1 | 2 |
7.6 Align tables on the page
7.6.1 Left
Here is a table on the left side:
,#+LATEX: \noindent ,#+ATTRLATEX: :center nil
a | b | c |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
,#+LATEX: \hfill
The noindent
just gets rid of the indentation of the first line of a paragraph
which in this case is the table. The hfill
adds infinite stretch after the
table, so it pushes the table to the left.
7.6.2 Center
Here is a centered table:
a | b | c |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
7.6.3 Right
And here’s a table on the right side:
a | b | c |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
Here the hfill
adds infinite stretch before the table, so it pushes the table
to the right.
7.7 Table size
Cell in column 1, row 1 | Cell in column 2, row 1 |
Cell in column 1, row 2 | Cell in column 2, row 2 |
7.8 CSV
You can fill a table from a CSV file using R commands.
8 Links
8.1 External links
See http://www.pirilampo.org (automatic!) and the Org mode Web site.
8.1.1 Relative links
8.1.2 Email links
8.2 Internal links
8.2.1 Inline anchors
8.2.2 Internal cross references
See:
- Location cross reference.
8.3 Extensions that define new hyperlinks targets
9 Images
9.1 Inline picture
Figure 1: Org mode logo
Click to see the Unicorn picture.
9.2 Image alignment (using positioning)
Books usually align/float images on the right/left of the contents.
9.2.1 Image is left aligned
9.2.2 Image is right aligned
9.2.3 Image is centered
9.3 Image attributes and values
XXX Available HTML image tags include …
Attribute | Value(s) |
---|---|
:alt |
Alternate text |
:height |
|
:width |
User defined size in pixels |
:align |
|
:border |
|
:bordercolor |
|
:hspace |
|
:vspace |
|
:title |
User defined text |
Place images side by side: XXX
9.4 Figures
To define images that will be treated as book illustrations (figures) and automatically labeled and numbered, use XXX.
10 Videos
11 Admonitions
Admonitions (contextual backgrounds) are statements taken out of the content’s flow and labeled with a title.
Common admonitions are:
note
warning
tip
caution
important
(Most themes style only note
and warning
specially.)
11.1 Base admonitions
11.1.1 Note
A note box is displayed as follows:
#+begin_note This is a useful note. #+end_note
This is a useful note.
11.1.2 Warning
A warning box is displayed as follows:
#+begin_warning Be careful! Check that you have... #+end_warning
Be careful! Check that you have…
11.1.3 Tip
A tip box is displayed as follows:
#+begin_tip Try doing it this way... #+end_tip
Try doing it this way…
11.1.4 Caution
#+begin_caution Caution #+end_caution
Caution
11.1.5 Important
#+begin_important Important #+end_important
Important
11.2 Additional admonitions
11.2.1 Attention
#+begin_attention Attention #+end_attention
Attention
11.2.2 Hint
#+begin_hint Hint #+end_hint
Hint
11.2.3 Error
#+begin_error Error #+end_error
Error
11.2.4 Danger
#+begin_danger Danger #+end_danger
Danger
12 Centered text
#+begin_left This text is \\ aligned to the left! #+end_left
This text is
aligned to the left!
#+begin_center This text is \\ centered! #+end_center
This text is
centered!
#+begin_right This text is \\ aligned to the right! #+end_right
This text is
aligned to the right!
13 Prose excerpts
13.1 Quote
Use the quote
block for content that doesn’t require the preservation of line
breaks.
#+begin_quote Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. Such an author, with thesaurus in hand, chooses the names of variables carefully and explains what each variable means. He or she strives for a program that is comprehensible because its concepts have been introduced in an order that is best for human understanding, using a mixture of formal and informal methods that reinforce each other. -- Donald Knuth #+end_quote
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. Such an author, with thesaurus in hand, chooses the names of variables carefully and explains what each variable means. He or she strives for a program that is comprehensible because its concepts have been introduced in an order that is best for human understanding, using a mixture of formal and informal methods that reinforce each other.
– Donald Knuth
A short one:
#+begin_quote Everything should be made as simple as possible, but not any simpler. -- Albert Einstein #+end_quote
Everything should be made as simple as possible, but not any simpler. – Albert Einstein
13.2 Verse
In a verse
environment, there is an implicit line break at the end of each line,
and indentation is preserved:
#+begin_verse Everything should be made as simple as possible, but not any simpler. -- Albert Einstein #+end_verse
Everything should be made as simple as possible,
but not any simpler. – Albert Einstein
Another example: Typically used for quoting passages of an email message:
>> The meeting has been postponed to next Friday.
>
> Has the deadline for the report been moved too?
Yes. And chekout http://www.doodle.com/ for rescheduling the meeting.
In the text body,
indentation is
preserved.
13.3 Block quote with optional attribution line
epigraph
13.4 Block quotes with their own class attribute
highlights
pull-quote
Blockquote
13.5 Non-breaking space
Insert the Unicode character 00A0
to add a non-breaking space.
FIXME Or add/use an Org entity? Or use tilde?
14 Substitutions
14.1 General replacements
{{{longtext}}} wherever required.Insert
Insert this very very long text wherever required.
Emacs comes with these built in macros:
{{{title}}} {{{author}}} {{{email}}} {{{date}}} {{{date(FORMAT)}}} {{{time(FORMAT)}}} {{{modification-time(FORMAT, VC)}}} {{{property(PROPERTY-NAME)}}} {{{property(PROPERTY-NAME,SEARCH-OPTION)}}} {{{n}}} {{{n(NAME)}}} {{{n(NAME,ACTION)}}}
Org mode syntax
Tuomas Pyyhtiä
asdf@asdf.com
FORMAT
FORMAT
1
1
1
14.2 Styled references
{{{color(blue, This text is colored in blue.)}}} {{{color(red, This other text is in red.)}}}
This text is colored in blue.
This other text is in red.
Other macros from https://github.com/fniessen/org-macros e.g.:
Keyboard macro:
Use {{{kbd(C-c a a)}}} to launch the agenda.
Use C-c a a to launch the agenda.
Bgcolor Macro: {{{bgcolor(red, This information is important.)}}} {{{bgcolor(#E0E0E0, This other isn’t.)}}} Common color names are supported by most Org exporters (HTML, LaTeX): {{{bgcolor(red, red)}}} {{{bgcolor(orange, orange)}}} {{{bgcolor(yellow, yellow)}}} {{{bgcolor(green, green)}}} {{{bgcolor(blue, blue)}}} {{{bgcolor(purple, purple)}}} {{{bgcolor(violet, violet)}}} You can also use hexadecimal color codes: {{{bgcolor(#FF0000, #FF0000)}}} {{{bgcolor(#00FF00, #00FF00)}}} {{{bgcolor(#0000FF, #0000FF)}}}
Common color names are supported by most Org exporters (HTML, LaTeX):
You can also use hexadecimal color codes:
Color macro: {{{color(red, This information is important.)}}} {{{color(#E0E0E0, This other isn’t.)}}} Common color names are supported by most Org exporters (HTML, LaTeX): {{{color(red, red)}}} {{{color(orange, orange)}}} {{{color(yellow, yellow)}}} {{{color(green, green)}}} {{{color(blue, blue)}}} {{{color(purple, purple)}}} {{{color(violet, violet)}}} You can also use hexadecimal color codes: {{{color(#FF0000, #FF0000)}}} {{{color(#00FF00, #00FF00)}}} {{{color(#0000FF, #0000FF)}}}
This information is important. This other isn’t.
Common color names are supported by most Org exporters (HTML, LaTeX):
red orange yellow green blue purple violet
You can also use hexadecimal color codes:
#FF0000 #00FF00 #0000FF
fixme macro:
{{{fixme}}} Delete this…
FIXME Delete this…
Highlight macro: {{{hl(This information is important.)}}} {{{highlight(red, red)}}} {{{highlight(orange, orange)}}} {{{highlight(yellow, yellow)}}} {{{highlight(green, green)}}} {{{highlight(blue, blue)}}} {{{highlight(purple, purple)}}} {{{highlight(violet, violet)}}}
This information is important.
red orange yellow green blue purple violet
Lorem Ipsum macro:
{{{loremipsum}}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
14.3 Special characters
We also use substitutions to include some of the widely used Unicode characters (like ©, converted from text characters to its typographically correct entity).
14.3.1 Accents
- \Agrave \Aacute
- À Á
14.3.2 Punctuation
- Dash: \ndash \mdash - Marks: \iexcl \iquest - Quotations: \laquo \raquo - Miscellaneous: \para \ordf
- Dash: – —
- Marks: ¡ ¿
- Quotations: « »
- Miscellaneous: ¶ ª
14.3.3 Commercial symbols
- Property marks: \copy \reg - Currency: \cent \EUR \yen \pound
- Property marks: © ®
- Currency: ¢ € ¥ £
14.3.4 Greek characters
The Greek letters \alpha, \beta, and \gamma are used to denote angles.
The Greek letters α, β, and γ are used to denote angles.
14.3.5 Math characters
- Science: \pm \div - Arrows: \to \rarr \larr \harr \rArr \lArr \hArr - Function names: \arccos \cos - Signs and symbols: \bull \star
- Science: ± ÷
- Arrows: → → ← ↔ ⇒ ⇐ ⇔
- Function names: arccos cos
- Signs and symbols: • *
14.3.6 Misc
- Smilies: \smiley \sad - Suits: \clubs \spades
- Smilies: ☺ ☹
- Suits: ♣ ♠
15 Source code
15.1 Inline code
You can also evaluate code inline as follows: 1 + 1 is 1 + 1
.
15.2 Code blocks (with syntax highlighting)
The source code blocks support syntax highlighting:
/* * Application that displays a "Hello" message to the standard output. */ int main(int arc, char **argv) { printf("Hello, %s!\n", (argc>1) ? argv[1] : "World"); return 0; }
You need htmlize.el in your load-path
, for the HTML export.
15.3 Source mode
The following language strings are currently recognized:
ABC, Asymptote, Awk, C, C++, Calc, Clojure, comint, Coq, CSS, D, Ditaa, Dot (Graphviz), ebnf, Emacs Lisp, Forth, Fortran, Gnuplot, Haskell, Io, J, Java, Javascript, LaTeX, Ledger, Lilypond, Lisp, Make, Matlab, Maxima, Mscgen, Objective Caml, Octave, Org, Perl, Picolisp, PlantUML, Processing, Python, R, Ruby, Sass, Scala, Scheme, Screen, Sed, shell, Shen, SQL, SQLite, Stan, Vala, Contributed, Language, Eukleides, Fomus, Groovy, Julia, Mathematica, Mathomatic, OZ, Stata, Tcl, Emacs Package, Language, Axiom, HTML, Neo4j, Elixir, http request, iPython, Kotlin, Lisp Flavored Erlang, MongoDB, Prolog, rec, Standard ML, Google Translate and Typescript.
16 Math
16.1 Inline math expressions
For inline math expressions, use the parentheses notation \(...\)
:
The formula \(a^2 + b^2 = c^2\) has been discovered by Pythagoras. Let \(a=\sin(x) + \cos(x)\). Then \(a^2 = 2\sin(x)\cos(x)\) because \(\sin^2x + \cos^2x = 1\).
The formula \(a^2 + b^2 = c^2\) has been discovered by Pythagoras.
Let \(a=\sin(x) + \cos(x)\). Then \(a^2 = 2\sin(x)\cos(x)\) because \(\sin^2x + \cos^2x = 1\).
16.2 Math expressions in display mode
For mathematical expressions which you want to make stand out, centered on their
own lines, use \[...\]
:
The /Euler theorem/: \[ \int_0^\infty e^{-x^2} dx = {{\sqrt{\pi}} \over {2}} \] LaTeX allows to inline such ~\[...\]~ constructs (/quadratic formula/): \[ \frac{-b \pm \sqrt{b^2 - 4 a c}}{2a} \]
16.3 Include Org files
You can include another Org file and skip its title by using the :lines
argument
to #+INCLUDE
:
File inclusion, through INCLUDE keywords, is an export-only feature.
17 Useful extensions
17.1 Todo extension
17.1.1 Dates
Timestamps:
and .17.1.2 TODO We need to achieve…
17.1.3 DONE Buy GTD book online
By default, DONE
actions will be collapsed.
Note that I should probably implement that default behavior only for ARCHIVE
’d
items.
17.1.4 TODO Read GTD book
By default, all (active) entries will be expanded at page load, so that their contents is visible.
That can be changed by adding such a line (into your Org document):
17.1.5 TODO Apply GTD methodoloy
This section will be collapsed when loading the page because the entry has the
value hsCollapsed
for the property :HTML_CONTAINER_CLASS:
.
Powerful, no?
17.1.6 Some note computer write
You can add tags to any entry, and hightlight all entries having some specific tag by clicking on the buttons made accessible to you in the “Dashboard”.
17.1.7 Weekly review computer
Now, you can even make your weekly review in the HTML export… Press the r
key
to start entering the “review mode” where all but one active entry are
collapsed, so that you can really focus on one item at a time!
17.2 Bigblow extension
The string fixme
(in upper case) gets replaced by a “Fix Me!” image:
FIXME Delete this...
FIXME Delete this…
18 Citations
Cross-referenced to bibliography.
19 Appendix
Special sections.
19.1 Index
Index (or list of acronyms).
- Write index entries
Note that multi-entry terms generate separate index entries.
- Place the index at the desired location
- Produce the index by updating
org-latex-pdf-process
19.2 Bibliography
The bibliography…
- Eric Steven Raymond. The Art of Unix Programming. Addison-Wesley. ISBN 0-13-142901-9.
19.3 Glossary
- A glossary term
- The corresponding (indented) definition.
- A second glossary term
- The corresponding (indented) definition.
Footnotes:
Extensively used in large documents.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.