简体   繁体   English

在emacs org-mode中获取表外的值

[英]getting a value outside a table in emacs org-mode

Suppose I have a table created by org-mode 假设我有一个由org-mode创建的表

| thing | value |
| t1    | 1     |
| t2    | 3     |
| t3    |  21   |
|-------+-------|
| total | 25    |

Is there a way inside org mode document to get the value from the total value cell in the table? 在组织模式文档中是否有一种方法可以从表中的总值单元格中获取值? (apart from manually copy the value) (除了手动复制值)

The following post addresses your same question: http://permalink.gmane.org/gmane.emacs.orgmode/28056 以下帖子解决了您的同一问题: http//permalink.gmane.org/gmane.emacs.orgmode/28056

You should name your table first, then refer to it via an inline src call: 您应该首先命名您的表,然后通过内联src调用来引用它:

#+TBLNAME: test-table
| thing | value |
|-------+-------|
| t1    | 1     |
| t2    | 3     |
| t3    |  21   |
|-------+-------|
| total | 25    |

The result I wanted is src_emacs-lisp[:var d=test-table[6,1]]{d}

Explanation: you call a very trivial elisp inline source block that only prints the variable d , which was assigned to an element in the table. 说明:您调用一个非常简单的elisp内联源块,它只打印变量d ,该变量被分配给表中的元素。

If you want the second column of the last row, you can try: 如果您想要最后一行的第二列,可以尝试:

The result I wanted is src_emacs-lisp[:var tbl=test-table]{(nth 1 (nth (- (length tbl) 1) tbl))}

Where the 1 gets the 2nd item, and the (- (length tbl) 1) gets the last row (note that this last example is not purist LISP, just works). 其中1获得第2项, (- (length tbl) 1)获得最后一行(请注意,最后一个示例不是纯粹的LISP,只是起作用)。

Here we get the complete table into elisp (as a list of lists), and extract the desired item through list manipulation. 在这里,我们将完整的表格放入elisp(作为列表列表),并通过列表操作提取所需的项目。

Note that the actual result will be substituted during export. 请注意,实际结果将在导出期间替换。 You won't see it magically in the org-mode text itself. 你不会在组织模式文本中神奇地看到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM