Org mode syntax
Quick reference card
Table of Contents
- 1. Summary
- 2. Reference card
- 3. Document header
- 4. Document settings
- 5. Section titles (headings)
- 6. Paragraphs
- 7. Formatting text
- 8. Lists
- 9. Tables
- 10. Links
- 11. Images
- 12. Videos
- 13. Admonitions
- 14. Centered text
- 15. Sidebar
- 16. Prose excerpts
- 17. Substitutions
- 18. Source code
- 19. Math
- 20. Miscellaneous effects
- 21. Footnotes
- 22. Useful extensions
- 23. Citations
- 24. Appendix
| Framework | Org mode 9 |
| Bug tracker | https://github.com/fniessen/refcard-org-mode/issues |
| Source | https://github.com/fniessen/refcard-org-mode |
1 Summary
This is an Org mode document, using the .org extension (supported by GitHub).
Org mode is an easy-to-write plain text formatting syntax for authoring notes, articles, LaTeX documents, books, Web pages, Beamer slide decks and much more!
This is a cheat sheet for Org mode 8 (because of some markup syntax changes since Org mode 7), using ReadTheOrg CSS.
Reading through all the documentation is highly recommended, but for the truly impatient, following are some quick steps to get started.
2 Reference card
Table of Contents
- 1. Summary
- 2. Reference card
- 3. Document header
- 4. Document settings
- 5. Section titles (headings)
- 6. Paragraphs
- 7. Formatting text
- 8. Lists
- 9. Tables
- 10. Links
- 11. Images
- 12. Videos
- 13. Admonitions
- 14. Centered text
- 15. Sidebar
- 16. Prose excerpts
- 17. Substitutions
- 18. Source code
- 19. Math
- 20. Miscellaneous effects
- 21. Footnotes
- 22. Useful extensions
- 23. Citations
- 24. Appendix
3 Document header
Title and author line:
#+TITLE: Org mode syntax examples #+AUTHOR: Fabrice Niessen My document provides...
It's a good practice to also include an email line following the author line.
#+EMAIL: john.doe@example.com
4 Document settings
4.1 Document description
4.2 Section numbering
4.3 Table of contents
Set the toc attribute to activate an auto-generated table of contents (limited
to its 2 first levels) at the top of document.
The ALT_TITLE property allows to set an alternate title (shorter, for example)
for a given headline in the table of contents and other running heads.
To locally insert the TOC at some random place, use the #+TOC: headlines [n]
feature; for example:
4.4 List of figures
#+TOC: figures is not implemented yet in the HTML backend.
4.5 List of tables
#+TOC: tables is already implemented in the HTML backend.
4.6 List of equations
5 Section titles (headings)
* Biggest heading (level 1)
New chapter.
** Bigger heading (level 2) New section. *** Big heading (level 3) New sub-section. **** Heading (level 4) New sub-sub-section.
5.1 Numbered headings
You can create numbered headings up to a certain level by setting an option:
6 Paragraphs
6.1 Line breaks
By entering two consecutive backslashes,
you can force a line break
without starting a new paragraph.
6.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.
7 Formatting text
Text effects.
7.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*.
7.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 super^{script}, such as 2^{10}
- text with sub_{script}, such as H_{2}O
7.3 Smart punctuation
If the XXX option is specified, Org mode will produce typographically correct
output, converting straight quotes to curly quotes, --- to em-dashes, -- to
en-dashes, and ... to ellipses.
8 Lists
Org markup allows you to create bulleted or numbered lists. It allows any combination of the two list types.
8.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.
- Bullet.
8.2 Checklists
[X]Checked.[-]Half-checked.[ ]Not checked.- Normal list item.
8.3 Ordered lists
Enumerated lists are marked with numbers or letters:
- 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.
- Number.
You can have ordered lists with jumping numbers:
- We start with point number 2.
- Automatically numbered item.
8.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.
8.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
- carrots
- tomatoes
- celery
9 Tables
Tables are one of the most refined areas of the Org mode syntax. They are very easy to create and to read.
9.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 |
Org tables have cells of at most one line long: there is no such thing as a multi-line table cell in Org.
9.2 Column formatting
Columns are automatically aligned:
- Number-rich columns to the right, and
- String-rich columns to the left.
9.2.1 Table with aligned cells
If you want to override the automatic alignment, use <r>, <c> or <l>.
,#+CAPTION: Table with aligned columns
| 1 | 2 | 3 |
| Right | Center | Left |
| xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx |
9.2.2 Table with column size adjusted
9.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).
| Name of column 1 | Name of column 2 | Name of column 3 |
|---|---|---|
| Top left | Top middle | |
| Right | ||
| Bottom left | Bottom middle |
9.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 |
9.5 Table placement
| a | b |
| 1 | 2 |
XXX Different from the following:
| a | b |
| 1 | 2 |
9.6 Align tables on the page
9.6.1 Left
Here is a table on the left side:
,#+LATEX: \noindent ,#+ATTR_LATEX: :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.
9.6.2 Center
Here is a centered table:
| a | b | c |
|---|---|---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
9.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.
9.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 |
9.8 CSV
You can fill a table from a CSV file using R commands.
10 Links
10.1 External links
See http://www.pirilampo.org (automatic!) and the Org mode Web site.
10.1.1 Relative links
10.1.2 Email links
10.2 Internal links
10.2.1 Inline anchors
10.2.2 Internal cross references
See:
- Location cross reference.
10.3 Extensions that define new hyperlinks targets
11 Images
11.1 Inline picture
Figure 1: Org mode logo
Click to see the Unicorn picture.
11.2 Image alignment (using positioning)
Books usually align/float images on the right/left of the contents.
11.2.1 Image is left aligned
11.2.2 Image is right aligned
11.2.3 Image is centered
11.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
11.4 Figures
To define images that will be treated as book illustrations (figures) and automatically labeled and numbered, use XXX.
12 Videos
13 Admonitions
Admonitions (contextual backgrounds) are statements taken out of the content's flow and labeled with a title.
Common admonitions are:
notewarningtipcautionimportant
(Most themes style only note and warning specially.)
13.1 Base admonitions
13.1.1 Note
A note box is displayed as follows:
#+begin_note This is a useful note. #+end_note
This is a useful note.
13.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…
13.1.3 Tip
A tip box is displayed as follows:
#+begin_tip Try doing it this way... #+end_tip
Try doing it this way…
13.1.4 Caution
#+begin_caution Caution #+end_caution
Caution
13.1.5 Important
#+begin_important Important #+end_important
Important
13.2 Additional admonitions
13.2.1 Attention
#+begin_attention Attention #+end_attention
Attention
13.2.2 Hint
#+begin_hint Hint #+end_hint
Hint
13.2.3 Error
#+begin_error Error #+end_error
Error
13.2.4 Danger
#+begin_danger Danger #+end_danger
Danger
14 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!
15 Sidebar
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.
#+begin_sidebar Org mode was first released by Carsten Dominik in 2004 as an outlining and project planning tool. Further development turned it into a general tool that can be used to author professional documents like LaTeX. #+end_sidebar
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi…
Phasellus ut libero. Nulla in libero non enim tristique sollicitudin. Ut tempor. Phasellus pellentesque augue eget ante. Mauris malesuada. Donec sit amet diam sit amet dolor placerat blandit. Morbi enim purus, imperdiet in, molestie sit amet, pellentesque eu, mauris. In vel erat vel ipsum bibendum commodo. Curabitur accumsan. Nam sed metus. Etiam tristique bibendum justo.
16 Prose excerpts
16.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
16.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.
16.3 Block quote with optional attribution line
epigraph
16.4 Block quotes with their own class attribute
highlights
pull-quote
Blockquote
16.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?
17 Substitutions
17.1 General replacements
Insert {{{longtext}}} wherever required.
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ä
first.last@domain.fi
FORMAT
FORMAT
1
1
1
17.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.
17.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).
17.3.1 Accents
- \Agrave \Aacute
- À Á
17.3.2 Punctuation
- Dash: \ndash \mdash - Marks: \iexcl \iquest - Quotations: \laquo \raquo - Miscellaneous: \para \ordf
- Dash: – —
- Marks: ¡ ¿
- Quotations: « »
- Miscellaneous: ¶ ª
17.3.3 Commercial symbols
- Property marks: \copy \reg - Currency: \cent \EUR \yen \pound
- Property marks: © ®
- Currency: ¢ € ¥ £
17.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.
17.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: • *
17.3.6 Misc
- Zero-width non-joiner: \zwnj
# Smilies: \smiley \sad
- Suits: \clubs \spades
- Zero-width non-joiner:
- Suits: ♣ ♠
You can insert a real "zero-width space" Unicode character by pressing
C-x 8 RET zero width space RET or C-x 8 RET 200b RET.
18 Source code
18.1 Inline code
You can also evaluate code inline as follows: 1 + 1 is 1 + 1.
18.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.
18.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.
19 Math
19.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\).
19.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} \]
20 Miscellaneous effects
20.1 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.
21 Footnotes
22 Useful extensions
22.1 Todo extension
22.1.1 Dates
Timestamps: and .
22.1.2 TODO We need to achieve…
22.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.
22.1.4 TODO [#A] 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):
22.1.5 TODO [#B] 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?
22.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".
22.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!
22.2 Bigblow extension
The string fixme (in upper case) gets replaced by a "Fix Me!" image:
FIXME Delete this...
FIXME Delete this…
23 Citations
Cross-referenced to bibliography.
24 Appendix
Special sections.
24.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
24.2 Bibliography
The bibliography…
- Eric Steven Raymond. The Art of Unix Programming. Addison-Wesley. ISBN 0-13-142901-9.
24.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.
