Mathematica 中的输入/输出单元标签是由什么生成的以及如何向它们添加自动计时?
当 Mathematica 计算单元格时,它会为输入单元格和输出单元格提供 CellLabel In[$Line]:=
和 Out[$Line]=
其中 $Line 是一个计数器,在每个计算的输入上递增。
如果您输入类似 TraditionalForm[expr]
或 TeXForm[expr]
(或 $OutputForms
中的任何其他 *Form)的名称,则表单也会添加到输出单元格的标签中。例如Out[1]//TraditionalForm=
。
我找不到任何自定义这些标签的方法。
可以在“首选项”对话框中禁用它们。
他们似乎不在 输入和的样式表选项 输出单元格 - 尽管选项 与 CellLabel 行为相关 在那里。
也不在笔记本选项中 - 尽管在选项检查器中:笔记本选项> 评估选项> valuationCompleteAction可以修改 通过添加时间戳来显示 CellLabels。 它还可以在 StatusArea 中显示 Timing, 一旦有其他东西打印在那里,它就会被删除。
也不是任何 init.m 类型 配置文件。
那么,有人知道这些 CellLabels 是在哪里生成的吗?
特别是,我有兴趣将 Timing
添加到输出单元格的 CellLabel 中。
When Mathematica evaluates a cell, it gives the Input cell and Output cell the CellLabels In[$Line]:=
and Out[$Line]=
where $Line is a counter that gets incremented on each evaluated input.
If you input something like TraditionalForm[expr]
or TeXForm[expr]
(or any other *Form from $OutputForms
) then the name of the form also gets added to the Output cell's label. eg Out[1]//TraditionalForm=
.
I can't find any way of customising these labels.
They can be disabled in the Preferences dialog.
They don't seem to be in the
StyleSheet options for Input and
Output cells - although the options
pertaining to the CellLabel behaviour
are there.Nor in the Notebook options -
although in the Option Inspector: Notebook Options >
Evaluation Options >
EvaluationCompletionAction can modify
the CellLabels by adding a TimeStamp.
It can also show the Timing in the StatusArea,
bit it gets removed as soon as something else prints there.Nor any of the init.m type
configuration files.
So, does anyone know where these CellLabels are generated?
In particular, I am interested in adding the Timing
to the CellLabel for Output cells.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一种方法是设置EvaluationCompletionAction -> “ShowTiming”,每次评估后都会在笔记本窗口的状态栏中显示计时信息。
Another way of doing this would be to set EvaluationCompletionAction -> "ShowTiming" which will display timing information in the status bar of the notebook window after each evaluation.
好的,物理论坛上的讨论导致了这个相当黑客的解决方案(现已清理)向上一点):
要使 CellLabels 持久,以便在保存和加载笔记本时不会丢失时间,您可以修改样式表,以便输出单元格具有选项
CellLabelAutoDelete ->;确实如此。 (编辑:现已添加到
CellPrint
命令中。)我们非常欢迎任何更好的解决方案。
OK, the discussion on Physics Forums has lead to this quite hackish solution (now cleaned up a little):
To make the CellLabels persistent so that you don't lose the timing when you Save and Load the notebook, you can modify the stylesheet so that the Output cells have the option
CellLabelAutoDelete -> True
. (Edit: Now added to theCellPrint
command.)Any better solutions are more than welcome.
通过在评估完成操作的选项检查器设置中选择“AddTimeStamp”,可以将评估时间戳添加到 Mathematica 单元格标签中。此外,可以通过编辑条目来给出选项列表,因此使用 {"ShowTiming","AddTimeStamp"} 我可以在状态栏中获得评估持续时间,并在单元格标签中获得输入和输出时间戳。
It's possible to add evaluation timestamps to Mathematica cell labels by selecting "AddTimeStamp" in the option inspector settings for EvaluationCompletionAction. Moreover, a list of options can be given by editing the entry, so using {"ShowTiming","AddTimeStamp"} I get both an evaluation duration in the status bar and input and output timestamps in the cell labels.