如何获取(不显示)节号
通过使用 Insert > 插入自动编号对象
菜单。但是,该对象仅控制节号的显示,我想获取其数值值以在程序中使用。知道该怎么做吗?CounterBox["Section"]
,可以对笔记本部分进行自动编号。自动编号...
编辑
我想使用它的原因在这里概述。
Notebook sections can be automatically numbered by inserting the automatically numbering object CounterBox["Section"]
using the Insert > Automatic Numbering...
menu. However this object only controls the display of the section number and I would like to get its numerical value to use in a program. Any idea how to do that?
Edit
The reason I want to use this is outlined here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用 TagBox 和已知标签包裹 CounterBox:
然后使用 FrontEnd`ObjectContents 将所有 DynamicBox/CounterBox/ValueBox 转换为文字并选出该 TagBox 的值:
如果您只想知道某种类型的计数器有多少个有你可以做的:
Wrap the CounterBox with a TagBox and a known tag:
Then use FrontEnd`ObjectContents to convert all DynamicBox/CounterBox/ValueBox to literals and pick out the value of that TagBox:
If all you want to know is how many of a certain type of counters there are you can do:
必须有更好的方法来做到这一点,但如果我明白你想做什么,这里有一些可行的方法。
创建一个笔记本来使用:
选择最后一个单元格,该单元格恰好是“部分”单元格。
倒数。
现在
sectionCnt
应该包含您想要的值。您可以轻松地回到原来的位置:There's got to be a better way to do this, but here's something that works, if I understand what you want to do.
Create a notebook to play with:
Select the last cell, which happens to be a Section cell.
Count backwards.
Now
sectionCnt
should hold the value that you want. You can move back to where you were easily enough: