metadata

Table of Contents

文档元数据

  • TITLE 文章标题
  • AUTHOR 作者
  • DATE 日期
  • EMAIL 邮箱地址
  • DESCRIPTION 描述
  • LANGUAGE 导出的语言
  • KEYWORDS
  • BIND 在文档头部设置特定的 Emacs 变量的值

    #+BIND: VARIABLE VALUE
    
    #+BIND: org-html-head "<style>body { font-family: Arial; }</style>"
    

    使用 BIND 属性会临时更改 Emacs 的变量值,这可能带来安全风险。因此,默认情况下,Emacs 可能会提示你确认是否允许设置这些变量。

    可以通过设置 org-export-allow-bind-keywords 变量为 t 来允许使用 BIND 属性:

    (setq org-export-allow-bind-keywords t)
    
  • HTML_HEAD

    #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="/home/haoran/haoran/Notes/Org/Programming/static/css/vast.css" />
    
  • LATEX_HEADER
  • EXPORT_SELECT_TAGS
  • EXPORT_EXCLUDE_TAGS
  • INCLUDE 包含文件
    当导出文档时,你可以包含其他文件中的内容。比如,想包含你的“.emacs”文件,你可以用:

    #+INCLUDE: "~/.emacs" src emacs-lisp
    

    可选的第二个第三个参数是组织方式(例如,“quote”,“example”,或者“src”),如果是

    “src”,语言用来格式化内容。组织方式是可选的,如果不给出,文本会被当作 Org 模式的正常处理。用 C-c ,可以访问包含的文件。

OPTIONS

author:    turn on/off inclusion of author name/email into exported file
email:     turn on/off inclusion of author email into exported file
creator:   turn on/off inclusion of creator info into exported file
timestamp: turn on/off inclusion creation time into exported file
H:         set the number of headline levels for export
num:       turn on/off section-numbers
toc:       turn on/off table of contents, or set level limit (integer)
\n:        turn on/off line-break-preservation (DOES NOT WORK)
@:         turn on/off quoted HTML tags
::         turn on/off fixed-width sections
|:         turn on/off tables
^:         turn on/off TeX-like syntax for sub- and superscripts.
-:         turn on/off conversion of special strings.
f:         turn on/off footnotes like this[1].
todo:      turn on/off inclusion of TODO keywords into exported text
tasks:     turn on/off inclusion of tasks (TODO items), can be nil to remove all tasks, todo to remove DONE tasks, or list of kwds to keep
pri:       turn on/off priority cookies
tags:      turn on/off inclusion of tags, may also be not-in-toc
<:         turn on/off inclusion of any time/date stamps like DEADLINES
*:         turn on/off emphasized text (bold, italic, underlined)
TeX:       turn on/off simple TeX macros in plain text
LaTeX:     configure export of LaTeX fragments.  Default auto
skip:      turn on/off skipping the text before the first heading
d:         turn on/off inclusion of drawers

STARTUP 折叠程度

#+STARTUP: noindent showall
  • 折叠程度

    #+STARTUP: overview        # 仅显示一级标题
    #+STARTUP: content         # 所有标题
    #+STARTUP: showall         # 不包括 example 块
    #+STARTUP: showeverything  # 所有内容
    
  • 是否缩进

    #+STARTUP: noindent
    #+STARTUP: indent
    
  • 隐藏星星

    #+STARTUP: hidestars odd
    

内容元数据

通常在行首以 #+ 开头,可以有多种用途。

verse 分行区块

默认内容不换行,需要留出空行才能换行。定义了分行的区块可以实现普通换行:

#+BEGIN_VERSE
   Great clouds overhead
   Tiny black birds rise and fall
   Snow covers Emacs
           -- AlexSchroeder
#+END_VERSE

quote 引用

通常用于引用,与默认格式相比左右都会留出缩进:

#+BEGIN_QUOTE
缩进区块
#+END_QUOTE

center 居中

#+BEGIN_CENTER
Everything should be made as simple as possible, \\
but not any simpler
#+END_CENTER

src 代码

#+BEGIN_SRC ruby
  require 'redcarpet'
  md = Redcarpet.new("Hello, world.")
  puts md.to_html
#+END_SRC

example 例子

: 单行的例子以冒号开头

#+BEGIN_EXAMPLE
   多行的例子
   使用区块
#+END_EXAMPLE
hahaha

comment 注释

# 开头的行被看作注释,不会被导出

区块注释采用如下写法:

#+BEGIN_COMMENT
块注释
...
#+END_COMMENT

表格与图片

对于表格和图片,可以在前面增加标题和标签的说明,以方便交叉引用。

比如在表格的前面添加:

#+CAPTION: This is the caption for the next table (or link)
#+LABEL: tbl:table1

则在需要的地方可以通过 \ref{table1} 来引用该表格。

html export

对于导出html以及发布,嵌入html代码就很有用。比如下面的例子适用于格式化为cnblogs的代码块:

#+BEGIN_HTML
int main()
{
return 0;
}
#+END_HTML

相当于在cnblogs的网页编辑器中插入”c++”代码。

latex export

对于需要包含数学符号和特殊方程的科学笔记,Org 模式支持嵌入 LaTeX

代码到文件中。你可以直接使用类 TeX

的宏来输入特殊符号,输入方程,或者整个 LaTeX 环境。

Angles are written as Greek letters \alpha, \beta and \gamma. The mass if
the sun is M_sun = 1.989 x 10^30 kg. The radius of the sun is R_{sun} =
6.96 x 10^8 m. If $a^2=b$ and $b=2$, then the solution must be either
$a=+\sqrt{2}$ or $a=-\sqrt{2}$.
\begin{equation}
x=\sqrt{b}
\end{equation}

特殊设置之后,导出 HTML 时 LaTeX 代码片断会生成图片并包含进来。

内容属性

设置图片的长宽

#+ATTR_ORG: :width 330px
#+ATTR_HTML: :width 530px

plantuml