org-mode - emacs 组织模式 : how many lines are in my table?

标签 org-mode

我的表的 $1 列只是一个 i++ 值,1, 2, 3 ... n,其中 n 是第二行和第三行之间的行数。是否有一个函数可以调用来告诉我表的该部分中有多少行,或者,如果我希望能够引用一个变量(即表中的行数),我是否必须跟踪像这样手动吗?所以我希望能够执行以下操作,而不必使用计数列。

@7$1 = Total(5), where "5" is the number of rows between the 2nd and 3rd hline

| num rows | x | y |
|----------+---+---|
|        1 |   |   |
|        2 |   |   |
|        3 |   |   |
|        4 |   |   |
|        5 |   |   |
|----------+---+---|
| Total(5) |   |   |
|----------+---+---|
#+TBLFM: @7$1=Total(@-1) 

这就是我现在所拥有的,我希望能够获取 2 个 hlines 之间的行数,而不必使用专用列来保留该计数。

最佳答案

我想到了两种变体,一种使用 Calc 的向量长度函数 vlen,另一种使用 elisp 的 length,它给出列表的大小:

| Item          |
|---------------|
| tomato        |
| banana        |
| space shuttle |
| orgmode       |
|---------------|
| 4             |
| 4             |
#+TBLFM: @6$1='(length '(@I..@II))::@7$1=vlen(@I..@II)

@I..@II 表示第一条和第二条 h 线之间的所有行。

关于org-mode - emacs 组织模式 : how many lines are in my table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23510547/

相关文章:

emacs - 如何使用 scp 或 rsync 使用 Tramp 传输文件

Emacs org-mode markdown 导出 : #+TITLE option not exported

emacs - 将剪贴板上的图像粘贴到 Emacs Org 模式文件而不保存它

emacs - 将整个组织模式文件重新归档为树?

org-mode babel python session 和内联图像不兼容?

html - 如何在 orgmode 中对 html 导出标记代码块评估?

emacs - 计算组织模式表中的时间范围

emacs - 组织模式时钟表和图表

python - 在 org 模式下调试 PYTHON 代码块 babel

java - 在 org 模式下执行 Java 代码块