在组织模式表中嵌入列表?

时间:2014-08-14 15:42:39

标签: emacs org-mode

我可以使用org-mode生成以下表格,

Day 1 | a) A |
      | b) B |
      | c) C |
Day 2 | a) D |
Day 3 | a) E |

2 个答案:

答案 0 :(得分:0)

喜欢这个吗?

|-----------+------|
| Monday    | a) A |
|           | b) B |
|           | c) C |
|-----------+------|
| Tuesday   | a) D |
|-----------+------|
| Wednesday | a) E |
|-----------+------|

我刚进入

|||

然后在表格内 RET 获取更多行,并使用 C-RET 获取行。填写并离开。似乎导出到HTML和文本就好......

答案 1 :(得分:0)

您还可以编写一个函数,将列表的任意省略列表转换为表格。调试列表列表(将“表”字符串发送到 Messages 缓冲区)可能很有用。 像这样:

(defun list-of-lists-to-org-table (lol &optional justify min-cell-width columns)
  (let ((buf (get-buffer-create "*org-tb*")))
    (with-current-buffer buf
      (erase-buffer)
      (mapcar (lambda (x)
                (mapcar (lambda (y) (insert (format "%s&" y))) x)(insert "\n")) lol)
      (table-capture 1 (point-max) "&" "\n" justify min-cell-width columns)
      (buffer-substring-no-properties (point-min) (point-max))
      )))

示例输入:
(list-of-lists-to-org-table '((Abc Def "xyz") (1 1 X1) (2 4 X2) (3 9 X3) (4 16 X4)))

示例输出:

+-----+-----+-----+
|Abc  |Def  |xyz  |
+-----+-----+-----+
|1    |1    |X1   |
+-----+-----+-----+
|2    |4    |X2   |
+-----+-----+-----+
|3    |9    |X3   |
+-----+-----+-----+
|4    |16   |X4   |
+-----+-----+-----+