diff --git a/README.org b/README.org index dbc1a03..9a4954f 100644 --- a/README.org +++ b/README.org @@ -149,7 +149,7 @@ available." \\ * Demo -I've written a demo page for the themes that provides a maximal working support +I've written a [[file:org/org-mode-syntax-example.txt][demo page]] for the themes that provides a maximal working support of Org mode syntax. Please see the [[https://github.com/fniessen/refcard-org-mode][Org mode refcard]] page for full examples of headings, code, diff --git a/org/org-mode-syntax-example.txt b/org/org-mode-syntax-example.txt new file mode 100644 index 0000000..765b2e4 --- /dev/null +++ b/org/org-mode-syntax-example.txt @@ -0,0 +1,846 @@ +# Hey Emacs, this is a -*- org -*- file ... +#+TITLE: Org mode syntax example +#+AUTHOR: Fabrice Niessen +#+EMAIL: fniessen@pirilampo.org +#+DESCRIPTION: Org mode syntax example +#+KEYWORDS: syntax, org, document +#+LANGUAGE: en +#+OPTIONS: H:5 num:nil toc:2 p:t + +#+SETUPFILE: org/theme-bigblow-local.setup + +#+PROPERTY: header-args :eval never-export + +This is an Org mode document. + +*Org mode* is a easy-to-write /plain text/ formatting syntax for authoring LaTeX +documents, creating Web pages and much more! + +#+begin_html + +Tweet +#+end_html + +* Basics + +** Biggest heading + +New chapter. + +*** Bigger heading + +New section. + +**** Big heading + +New sub-section. + +**** Text breaks + +A single newline has no effect. +This line is part of the same paragraph. + +But an empty line + +demarcates paragraphs. + +By entering two consecutive backslashes, +you can force to break lines \\ +without starting a new paragraph. + +For an horizontal line, insert at least 5 dashes: this is some text above an +horizontal rule +----- +and some text below it. + +**** Numbered headings + +You can create numbered headings up to a certain level by setting an option: + +#+begin_src org +,#+OPTIONS: H:4 +#+end_src + +*** Text width + +# Premiere Elements, page 111 +# +# Vous pouvez créer ces objets en cliquant sur le bouton Nouvel| élément de le +# fenêtre Média. (Le Chapitre 14 explique comment créer| des titres ; le +# Chapitre 15 montre l'utilisation des barres et ton, de la| vidéo noir et de +# l'amorce SMPTE.) +# +# The principles of beautiful Web design, page 6 +# +# In a figurative sense, the concept of visual balance is similar to that of +# physical balance| illustrated by a seesaw. Just as physical objects have +# weight, so do the elements of a layout.| If the elements on either side of a +# layout are of equal weight, they balance one another.| There are two main forms +# of visual balance: symmetrical and asymmetrical. + +One morning, when Gregor Samsa woke from troubled dreams, he found himself +transformed in his bed into a horrible vermin. He lay on his armour-like back, +and if he lifted his head a little he could see his brown belly, slightly domed +and divided by arches into stiff sections. The bedding was hardly able to cover +it and seemed ready to slide off any moment. His many legs, pitifully thin +compared with the size of the rest of him, waved about helplessly as he looked. + +** Lists + +Org markup allows you to create bulleted or numbered lists. It allows any +combination of the two list types. + +*** Unordered lists + +Itemized lists are marked with bullets. They are convenient to: + +- organize data, and +- make the document + + prettier, and + + easier to read. + +Create them with a minus or a plus sign. + +*** Ordered lists + +Enumerated lists are marked with numbers or letters: + +1. First element + 1) First sub-item + 2) Last sub-item +2. Second element + +You can have ordered lists with jumping numbers: + +1. [@1] First +2. [@2] Second +5. [@5] Jump to 5th + +*** Definition lists + +- Definition list :: + List containing definitions. + +- Term to define :: + Explication of the term. + +** Miscellaneous effects + +*** Include Org files + +You can include another Org file and skip its title by using the ~:lines~ argument +to ~#+INCLUDE~: + +#+begin_src org +,#+INCLUDE: chapter1.org :lines "2-" +#+end_src + +#+begin_note +File inclusion, through INCLUDE keywords, is an *export-only feature*. +#+end_note + +*** Inline HTML + +You can include raw HTML in your Org documents and it will get kept as HTML +when it's exported. XXX + +#+HTML_BEGIN:
+Text can be preformatted (in a fixed-width font). +#+HTML_END:+ +It is especially useful for more advanced stuff like images or tables where you +need more control of the HTML options than Org mode actually gives you. + +Similarly, you can incorporate JS or do anything else you can do in a Web page +(such as importing a CSS file). + +You can create named classes (to get style control from your CSS) with: + +#+begin_example +,#+begin_info +,*Info example* \\ +Did you know... +,#+end_info +#+end_example + +You can also add interactive elements to the HTML such as interactive R plots. + +Finally, you can include an HTML file verbatim (during export) with: + +#+begin_src org +,#+INCLUDE: file.html html +#+end_src + +Don't edit the exported HTML file! + +*** Inline LaTeX + +You can also use raw LaTeX. XXX + +#+LaTeX_BEGIN: \begin{verbatim} +Text can be preformatted (in a fixed-width font). +#+LaTeX_END: \end{verbatim} + +*** Centered text + +#+begin_center +This text is centered! +#+end_center + +** Code blocks + +*** COMMENT Syntax highlighting + +The source code blocks support syntax highlighting: + +#+begin_src cpp :eval no +/* + * 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; +} +#+end_src + +The following language strings are currently recognized: + +#+begin_src emacs-lisp :results drawer :exports results +(concat (mapconcat (lambda (widget) + (widget-get widget :tag)) + (cl-remove-if-not (lambda (it) + (and (consp it) + (eq (car it) 'const))) + (cdr + (widget-get + (get + 'org-babel-load-languages 'custom-type) + :key-type))) + ", ") + ".") +#+end_src + +#+results: +:RESULTS: +Awk, C, R, Asymptote, Calc, Clojure, CSS, Ditaa, Dot, Emacs Lisp, Fortran, Gnuplot, Haskell, IO, J, Java, Javascript, LaTeX, Ledger, Lilypond, Lisp, Makefile, Maxima, Matlab, Mscgen, Ocaml, Octave, Org, Perl, Pico Lisp, PlantUML, Python, Ruby, Sass, Scala, Scheme, Screen, Shell Script, Shen, Sql, Sqlite, ebnf2ps. +:END: + +Code block with long lines: + +#+begin_src emacs-lisp :eval no +testing testing testing testing testing testing testing testing testing testing +0 1 2 3 4 5 6 7 8 9 +123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 +#+end_src + +For PDF (LaTeX), one solution is to surround the code block such as: + +#+latex: \scriptsize +#+begin_src R +print("This block is in scriptsize") +#+end_src +#+latex: \normalize + +*** Line numbers + +Both in ~example~ and in ~src~ snippets, you can add a ~-n~ switch to the end of the +~begin~ line, to get the lines of the example numbered. + +#+header: :eval no +#+begin_src emacs-lisp -n +(defun org-xor (a b) + "Exclusive or." +#+end_src + +If you use a ~+n~ switch, the numbering from the previous numbered snippet will +be continued in the current one: + +#+header: :eval no +#+begin_src emacs-lisp +n + (if a (not b) b)) +#+end_src + +In literal examples, Org will interpret strings like ~(ref:name)~ as labels, and +use them as targets for special hyperlinks like ~[[(name)]]~ (i.e., the reference +name enclosed in single parenthesis). In HTML, hovering the mouse over such +a link will remote-highlight the corresponding code line, which is kind of +cool. + +You can also add a ~-r~ switch which removes the labels from the source code. +With the ~-n~ switch, links to these references will be labeled by the line +numbers from the code listing, otherwise links will use the labels with no +parentheses. Here is an example: + +#+header: :eval no +#+begin_src emacs-lisp -n -r +(save-excursion ; (ref:sc) + (goto-char (point-min))) ; (ref:jump) +#+end_src + +In line [[(sc)]], we remember the current position. [[(jump)][Line (jump)]] jumps to +~point-min~. + +*** Output + +The output from the *execution* of programs, scripts or commands can be inserted +in the document itself, allowing you to work in the /reproducible research/ +mindset. + +**** Text + +A one-liner result: + +#+begin_src sh :exports both :results verbatim +date +"%Y-%m-%d" +#+end_src + +#+results: +: 2014-03-15 + +# A multiple-line result: +# +# #+name: list-of-styles +# #+begin_src sh :exports both :results verbatim +# # output all styles, but the default one (if any) +# ls styles | grep -v "default" +# #+end_src +# +# #+results: list-of-styles +# #+begin_example +# bigblow +# leuven +# maunakea +# #+end_example + +**** Graphics + +Data to be charted: + +#+name: data +| Month | Degrees | +|-------+---------| +| 1 | 3.8 | +| 2 | 4.1 | +| 3 | 6.3 | +| 4 | 9.0 | +| 5 | 11.9 | +| 6 | 15.1 | +| 7 | 17.1 | +| 8 | 17.4 | +| 9 | 15.7 | +| 10 | 11.8 | +| 11 | 7.7 | +| 12 | 4.8 | + +Code: + +#+name: R-plot +#+begin_src R :var data=data :results graphics :file ../../images/Rplot.png :exports both +plot(data, type="b", bty="l", col=c("#ABD249"), las=1, lwd=4) +grid(nx=NULL, ny=NULL, col=c("#E8E8E8"), lwd=1) +legend("bottom", legend=c("Degrees"), col=c("#ABD249"), pch=c(19)) +#+end_src + +The resulting chart: + +#+results: R-plot +[[file:../../images/Rplot.png]] + +**** R code block + +#+begin_src R +library(ggplot2) +summary(cars) +#+end_src + +Plot: + +#+begin_src R +library(ggplot2) +qplot(speed, dist, data = cars) + geom_smooth() +#+end_src + +** Inline code + +You can also evaluate code inline as follows: 1 + 1 is src_R{1 + 1}. + +** Notes at the footer + +It is possible to define named footnotes[fn:myfootnote], or ones with +automatic anchors[fn:2]. + +** Formatting text + +*** Text effects + +/Emphasize/ (italics), *strongly* (bold), and */very strongly/* (bold italics). + +Markup elements could 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* + +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} (for example: ~m/s^{2}~ gives m/s^{2}) +- text with_{subscript} + +*** Quotations + +Use the ~quote~ block to typeset quoted text. + +#+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 + +A short one: + +#+begin_quote +Everything should be made as simple as possible, +but not any simpler -- Albert Einstein +#+end_quote + +In a ~verse~ environment, there is an implicit line break at the end of each +line, and indentation and vertical space are preserved: + +#+begin_verse +Everything should be made as simple as possible, +but not any simpler -- Albert Einstein +#+end_verse + +Typically used for quoting passages of an email message: + +#+begin_verse +>> This is an email message with "nested" quoting. Lorem ipsum dolor sit amet, +>> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. +>> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. +> +> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem +> consectetuer libero luctus adipiscing. + +Itemized or unordered lists (~ul~): +- This is the first list item. +- This is the second list item. + +Enumerated or ordered Lists (~ol~): +1. This is the first list item. +2. This is the second list item. + +Maybe an equation here? + +See http://www.google.com/ for more information... +#+end_verse + +*** Spaces + +Using non-breaking spaces. + +Insert the Unicode character ~00A0~ to add a non-breaking space. FIXME +Or add/use an Org entity? + +** Mathematical formulae + +You can embed LaTeX math formatting in Org mode files using the following +syntax: + +- For *inline math* expressions, use ~\(...\)~: \(x^2\) or \(1 < 2\). + + It's /not/ advised to use the constructs ~$...$~ (both for Org and MathJax). + +- Centered display equation (the /Euler theorem/): + + \[ + \int_0^\infty e^{-x^2} dx = {{\sqrt{\pi}} \over {2}} + \] + + The use of ~\[...\]~ is for mathematical expressions which you want to make + *stand out, on their own lines*. + + LaTeX allows to inline such ~\[...\]~ constructs (/quadratic formula/): + \[ \frac{-b \pm \sqrt{b^2 - 4 a c}}{2a} \] + + *Double dollar signs (~$$~) should not be used*. + +- The /sinus theorem/ can then be written as the equation: + + \begin{equation} + \label{eqn:sinalpha} + \frac{\sin\alpha}{a}=\frac{\sin\beta}{b} + \end{equation} + +- See Equation [[the-first]], + + #+name: the-first + \begin{equation} + n_{i+1} = \frac{n_{i} (d-i) (e-1)}{(i+1)} + \end{equation} + + Only captioned equations are numbered + +- Other alternative: use \begin{equation*} or \begin{displaymath} (= the verbose + form of the ~\[...\]~ construct). M-q does not fill those. + +Differently from $...$ and \(...\), an equation environment produces a *numbered* +equation to which you can add a label and reference the equation by (label) +name in other parts of the text. This is not possibly with unnumbered math +environments ($$, ...). + +** Special characters + +Some of the widely used special characters (converted from text characters to +their typographically correct entitites): + +*** Accents + +\Agrave \Aacute + +*** Punctuation + +Dash: \ndash \mdash + +Marks: \iexcl \iquest + +Quotations: \laquo \raquo + +Miscellaneous: \para \ordf + +*** Commercial symbols + +Property marks: \copy \reg + +Currency: \cent \EUR \yen \pound + +*** Greek characters + +The Greek letters \alpha, \beta, and \gamma are used to denote angles. + +*** Math characters + +Science: \pm \div + +Arrows: \to \rarr \larr \harr \rArr \lArr \hArr + +Function names: \arccos \cos + +Signs and symbols: \bull \star + +*** Misc + +# Smilies: \smiley \sad + +Suits: \clubs \spades + +** Comments + +It's possible to add comments in the document. + +# This Org comment here won't be displayed. + +** Tables + +You can create tables with an optional header row (by using an horizontal line +of dashes to separate it from the rest of the table). + +#+CAPTION: An example of table +| Header 1 | Header 2 | Header 3 | +|-------------+---------------+----------| +| Top left | Top middle | | +| | | Right | +| Bottom left | Bottom middle | | + +Columns are automatically aligned: + +- Number-rich columns to the right, and +- String-rich columns to the left. + +If you want to override the automatic alignment, use ~