org-mode and Worg
Table of Contents
- Homepage
- Examples
- TODO new exported was introduced in org 8.0
- shortcut
- inline image
- Table
- Ref
- Table of contents
- Paragraphs, line breaks, and quoting
- insert file or picture
- Include file content
- inner anchor
- LaTex
- Footnote
- Html export options
- 中文中,转成HTML时,换行符成空格符号
- Working with source code
- Some useful symbols
- upgrade org-mode
- Org babel
- check org version
Homepage
- http://orgmode.org/manual/index.html
- http://orgmode.org/worg/ src: git://orgmode.org/orgweb.git
Examples
- org publish el-code example org-publish-example.el
- https://github.com/joshuaeckroth/cse3521-website
- org-mode + jekyll + twitter bootstrap http://github.com/cinsk/jekyll-org/ , example:http://cinsk.github.com/jekyll-org/
- org-mode + jekyll: http://blog.jenkster.com/
- org-mode + Hyde
- https://github.com/dustinlacewell/ghorg A command-line utility for managing an org-mode Hyde blog
- https://github.com/punchagan/org-hyde Export org-mode trees to hyde ready html files
- http://sydi.org that generated by orgmode
- http://www.pirilampo.org/ is all made from Org mode (and only it)
- Web pages made with Org-Mode:http://orgmode.org/worg/org-web.html
- http://renard.github.com/o-blog/ - it's not strictly using org-mode, but an org-mode add-on
- Pelicorg: A Pelican Plugin for Emacs Org For every Org file in your content directory, the plugin will launch Emacs on the command line, process the Elisp you give it, and spit out the completed HTML.
TODO new exported was introduced in org 8.0
shortcut
- make a
begin_src
block is to type<s [TAB]
C-c ‘
to edit the source code in a separate buffer
TODO how to go back the upper level
inline image
Method1
C-c C-x C-v M-x org-toggle-inline-images
Method2
;; iimage mode (autoload 'iimage-mode "iimage" "Support Inline image minor mode." t) (autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t)
M-x iimage-mode RET
在当前模式里启动 iimage 这个 minor mode。
iimage-mode目前只能显示以文件方式链接的图片。
TODO Capture the image
: ;; screenshot in org-mode : ;; modified by gift.young@gmail.com : ;; based on [http://praktikanten.brueckenschlaeger.org/2010/11/28/screenshots-in-org-mode] : (defun my-screenshot () : "Take a screenshot into a unique-named file in the current buffer file : directory and insert a link to this file." : (interactive) : (setq filename : (concat (make-temp-name : (concat (file-name-directory (buffer-file-name)) "images/" ) ) ".png")) : (if (file-accessible-directory-p (concat (file-name-directory (buffer-file-name)) "images/")) : nil : (make-directory "images")) : (call-process-shell-command "scrot" nil nil nil nil "-s" (concat "\"" filename "\"" )) : (insert (concat "[[" filename "]]")) : (org-display-inline-images) : ) : : (global-set-key (kbd "s-s") 'my-screenshot)
按win-s键,然后用鼠标划要截屏的范围。这一部分会保存在当前org文件的目录下的images目录下,文件名随机。如果该目录不存在,会自动建立。
依赖; scrot 0.8-11 command line screen capture utility
Table
1
| Name | Phone | Age | |-------+-------+-----| | Peter | 1234 | 17 | | Anna | 4321 | 25 |
2
you would only type |Name|Phone|Age| |- and then press TAB to align the table
3
Even faster would be to type |Name|Phone|Age
followed by C-c RET
.
Ref
对于表格和图片,可以在前面增加标题和标签的说明,以方便交叉引用。比如在表格的前面添加:
#+CAPTION: This is the caption for the next table (or link) #+LABEL: tbl:table1
则在需要的地方可以通过
\ref{table1}
来引用该表格。
Table of contents1
Org normally inserts the table of contents directly before the first headline of the file. Org sets the TOC depth the same as the headline levels in the file. Use a lower number for lower TOC depth.
#+OPTIONS: toc:2 only include two levels in TOC #+OPTIONS: toc:nil no default TOC at all
To move the table of contents to a different location
#+OPTIONS: toc:nil no default TOC ... #+TOC: headlines 2 insert TOC here, with two headline levels
Paragraphs, line breaks, and quoting2
#+BEGIN_VERSE Great clouds overhead Tiny black birds rise and fall Snow covers Emacs -- AlexSchroeder #+END_VERSE
Great clouds overhead
Tiny black birds rise and fall
Snow covers Emacs
– AlexSchroeder
#+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
#+BEGIN_CENTER Everything should be made as simple as possible, \\ but not any simpler #+END_CENTER
Everything should be made as simple as possible,
but not any simpler
insert file or picture
[[pic_path]] [[file_path]]
As of Org 8.0, "Attribute lines now take plists" :
#+attr_html: :width 100px [[~/images/example.jpg]]
Include file content3
# +INCLUDE: "~/.emacs" src emacs-lisp # +INCLUDE: "~/.emacs" :lines "5-10" Include lines 5 to 10, 10 excluded # +INCLUDE: "~/.emacs" :lines "-10" Include lines 1 to 10, 10 excluded # +INCLUDE: "~/.emacs" :lines "10-" Include lines from 10 to EOF
inner anchor
定义锚点 <<my-anchor>>
[[my-anchor][anchor name] ]
LaTex4
The default is to use the MathJax system which should work out of the box with Org mode installation because http://orgmode.org serves MathJax for Org mode users for small applications and for testing purposes.
insert Latex code blocks
example SRC:
\begin{equation} \begin{align} \mbox{Union: } A\cup B = \{x\mid x\in A \mbox{ or } x\in B\} \newline \mbox{Concatenation: } A\circ B = \{xy\mid x\in A \mbox{ and } y\in B\} \\ \mbox{Star: } A^\star = \{x_1x_2\ldots x_k \mid k\geq 0 \mbox{ and each } x_i\in A\} \\ \end{align} \end{equation}
Output:
\begin{equation} \begin{align} \mbox{Union: } A\cup B = \{x\mid x\in A \mbox{ or } x\in B\} \newline \mbox{Concatenation: } A\circ B = \{xy\mid x\in A \mbox{ and } y\in B\} \\ \mbox{Star: } A^\star = \{x_1x_2\ldots x_k \mid k\geq 0 \mbox{ and each } x_i\in A\} \\ \end{align} \end{equation}insert inline Latex codes
example SRC:
If $a^2=b$ and \( b=2 \), then the solution must be either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
Output: If \(a^2=b\) and \( b=2 \), then the solution must be either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \].
Footnote
- C-c C-x f The footnote action command
- C-c C-c Jump between definition and reference.
Html export options
#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:nil skip:nil d:t tags:not-in-toc
中文中,转成HTML时,换行符成空格符号5
(defadvice org-html-paragraph (before org-html-paragraph-advice (paragraph contents info) activate) "Join consecutive Chinese lines into a single long line without unwanted space when exporting org-mode to html." (let* ((origin-contents (ad-get-arg 1)) (fix-regexp "[[:multibyte:]]") (fixed-contents (replace-regexp-in-string (concat "\\(" fix-regexp "\\) *\n *\\(" fix-regexp "\\)") "\\1\\2" origin-contents))) (ad-set-arg 1 fixed-contents)))
Working with source code
Include files
#+INCLUDE: "~/.emacs" src emacs-lisp
#+INCLUDE: "~/.emacs" :lines "5-10" Include lines 5 to 10, 10 excluded #+INCLUDE: "~/.emacs" :lines "-10" Include lines 1 to 10, 10 excluded #+INCLUDE: "~/.emacs" :lines "10-" Include lines from 10 to EOF
inline
1. =code=
2. ~code~
3. src_LANG[headers]{your code}
avoid repeated = and /
* Italics , - Your example simply works\\ , /cologne/dome/ , - It also works if your /example had / spaces within it/ , - It will only fail if / your /have spaces on one end or the other / * Code , Code blocks can be delimited in multiple ways: , ** Inline formatting , - Using ~ for verbatim text works\\ , ~<pre language="python">~ , - ~ renders the same as = for blocks =test= ~test~ , ** Code Blocks , - Single-line blocks , : <pre language="python"> , - Multi-line blocks , #+BEGIN_EXAMPLE , asdf , #+END_EXAMPLE
HTML Export
<div id="outline-container-1" class="outline-2"> <h2 id="sec-1"><span class="section-number-2">1</span> Italics</h2> <div class="outline-text-2" id="text-1"> <ul> <li>Your example simply works<br/> <i>cologne/dome</i> </li> <li>It also works if your <i>example had / spaces within it</i> </li> <li>It will only fail if / your /have spaces on one end or the other / </li> </ul> </div> </div> <div id="outline-container-2" class="outline-2"> <h2 id="sec-2"><span class="section-number-2">2</span> Code</h2> <div class="outline-text-2" id="text-2"> <p>Code blocks can be delimited in multiple ways: </p> </div> <div id="outline-container-2-1" class="outline-3"> <h3 id="sec-2-1"><span class="section-number-3">2.1</span> Inline formatting</h3> <div class="outline-text-3" id="text-2-1"> <ul> <li>Using ~ for verbatim text works<br/> <code><pre language="python"></code> </li> <li>~ renders the same as = for blocks <code>test</code> <code>test</code> </li> </ul> </div> </div> <div id="outline-container-2-2" class="outline-3"> <h3 id="sec-2-2"><span class="section-number-3">2.2</span> Code Blocks</h3> <div class="outline-text-3" id="text-2-2"> <ul> <li>Single-line blocks <pre class="example"> <pre language="python"> </pre> </li> <li>Multi-line blocks <pre class="example">asdf </pre> </li> </ul>
See Literal examples and Emphasis and monospace in the Org-Manual for full details.
Languages6
Additional documentation for some languages are at http://orgmode.org/worg/org-contrib/babel/languages.html.
Code blocks in the following languages are supported.
Language Identifier Language Identifier Asymptote asymptote Awk awk Emacs Calc calc C C C++ C++ Clojure clojure CSS css ditaa ditaa Graphviz dot Emacs Lisp emacs-lisp gnuplot gnuplot Haskell haskell Java java Javascript js LaTeX latex Ledger ledger Lisp lisp Lilypond lilypond MATLAB matlab Mscgen mscgen Objective Caml ocaml Octave octave Org mode org Oz oz Perl perl Plantuml plantuml Python python R R Ruby ruby Sass sass Scheme scheme GNU Screen screen shell sh SQL sql SQLite sqlite
Language-specific documentation is available for some languages. If available, it can be found at http://orgmode.org/worg/org-contrib/babel/languages.
Some useful symbols
\(\mathcal{O}(N)\)
$\mathcal{O}(N)$
upgrade org-mode
M-x list-packages Enter Ctrl+s org Enter Click the “Install Button”
“Invalid Function” org-with-silent-modifications
uninstalling org-mode and reinstall it.
M-x package-list Enter Ctrl+s org enter Type the letter d Then press x
Org babel
Inline GraphViz DOT evaluation for graphs7
Setup
follow the org-babel documentation to enable source codes evaluation for dot by setting:
(org-babel-do-load-languages ‘org-babel-load-languages ‘((dot . t)))
Embedding Dot in Emacs
create a new document, and the following dot source code sample:8
#+BEGIN_SRC dot :file dot_success.png :cmdline -Kdot -Tpng digraph { // graph from left to right rankdir=LR; splines=true; node [shape=box]; id [label="Install Graphviz"] conf [label="Configure org-babel"] dot [label="DOT in org-mode"] id -> conf conf -> dot dot -> "Profit" dot -> "Success" [style=dotted] } #+END_SRC
The Command Line
The section :cmdline -Kdot -Tpng
in the #+begin_src dot :file
dot_success.png :cmdline -Kdot -Tpng
section are command line
arguments. They tell dot how to render and display.
Kdot
use dot layout. The other layouts you can try are Kneato, Kcirco, Ktwopi, Kfdp and Ksfdp for different layoutsTpng
render as png- The full command line arguments can be found here: http://graphviz.org/content/command-line-invocation
press C-c C-c
to evaluate this code. Emacs will generate the
configured output file dot_success.png
and then link to it in an
automatically created #+RESULTS
section right below it.
press C-c C-x C-v
to toggle display of inline images to see it
directly in Emacs. Alternatively, use M-x org-display-inline-images
to
switch this on.
Result
More tutorial about Graphviz: http://wiki.dreamrunner.org/public_html/Misc/Software/graphviz.html
More Settings9
shebang lines
The configuration of shebang lines now lives in header arguments. So the shebang for a single file can be set at the code block level, e.g.
;; ensure this variable is defined defined (unless (boundp 'org-babel-default-header-args:sh) (setq org-babel-default-header-args:sh '())) ;; add a default shebang header argument (add-to-list 'org-babel-default-header-args:sh '(:shebang . "#!/bin/bash"))
confirmations evaluation
;; I don't want to be prompted on every code block evaluation (setq org-confirm-babel-evaluate nil)
remove code block evaluation keybinding and An additional keybinding
;; I don't want to execute code blocks with C-c C-c (setq org-babel-no-eval-on-ctrl-c-ctrl-c t)
An additional keybinding has been added for code block evaluation,
namely C-c C-v e
.
check org version
M-x org-version