细胞与mma中的细胞群
此问题以及引发此问题的评论和答案。如何在mathematica中有效地使用单元格和单元格组?我总是只在输入单元格内进行系统编程,在评估前一个单元格后在新单元格中输入下一行。环顾四周可用的不同选项,这似乎效率很低。
我如何更有效地使用这些?我尝试使用 command-5 将代码组织成部分和小节等。但是当我尝试使用 command-9 返回输入单元格时,它不会对其进行评估。我确信我做错了什么,所以非常感谢您的帮助。
This question and the comments and answers prompted this question. How do I effectively use Cells and CellGroups in mathematica? I've always only programmed systematically inside the input cells, entering the next line in a new cell after evaluating the previous. Looking around at the different options available, this seemed inefficient.
How do I use these more effectively? I tried organizing my code into sections using command-5 and into subsections, etc. But then when I try to get back to input cell with command-9, it doesn't evaluate it. I'm sure I'm doing something wrong, so help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
单元格组就是将单元格分组在一起的一种方式。这些组可以轻松选择、作为一个整体执行,并且打开/关闭(崩溃)。默认情况下,这些组由单元格右侧的一系列蓝色括号表示:
如上所示,输出单元格会自动与创建它们的输入单元格分组。此外,“部分”单元格会自动将其下方的“文本”、“输入”和“输出”单元格分组。最后,“标题”单元格对其下方的所有单元格进行分组,包括“部分”单元格。
可用的不同类别的单元格,例如标题、部分等,由活动的 样式表。它们的分组方式由选项 CellGroupingRules 控制。这是一个更高级的领域,细节可能在不同的问题中得到更好的解决。
小区分组可以自动、默认或手动完成,或者在有限程度上通过其组合完成。这全部由
Cell > 中的菜单命令处理。分组> ...
或那里列出的键盘快捷键。如果使用自动分组,则以分组(由 CellGroupingRules 控制)的样式设置单元格样式,将自动对“较小”单元格及其下方的单元格组进行分组。
要设置单元格样式,请选择整个单元格,而不仅仅是单元格内容,方法是:
单击蓝色单元格括号(或隐藏的区域)
在单元格内单击并使用 Alt+. 直到整个单元格都显示出来已选择
单击并从单元格上方(光标水平)拖动到单元格下方
然后,使用菜单
Format >风格> ...
,或相应的组合键。可以使用相同的方法来选择细胞组,而不是单个细胞。
要创建特定样式的新单元格:
在光标处于水平位置的现有单元格外部单击
这应该创建一条水平线,如前面的插图所示
指定样式,再次使用
Format >风格> ...
或键盘快捷键开始键入(或粘贴)新单元格的内容
要创建新的输入单元格(默认样式),只需执行步骤 (1),然后键入或粘贴输入。
Cell groups are just that, a way to group cells together. These groups can be easily selected, executed as one, and opened/closed (collapsed). By default these groups are indicated by a series of blue brackets to the right of the cells:
As seen above, output cells are automatically grouped with the input cell that created them. Also, the Section cell automatically groups the Text, Input, and Output cells below it. Finally the Title cell groups all cells below it, including the Section cell.
The different classes of cells that are available, such as Title, Section, etc., are determined by the active Stylesheet. The way they group is controlled by the option CellGroupingRules. This is a more advanced area, and details are probably better addressed in a different question.
Cell Grouping can be done either automatically, the default, or manually, or to a limited extent by a combination thereof. This is all handled by the menu commands in
Cell > Grouping > ...
or the keyboard shortcuts listed there.If using Automatic Grouping, then styling a cell in a style that groups (as controlled by CellGroupingRules) will automatically group "lesser" cells and cell groups beneath it.
To style a cell, select the entire cell, not just the cell contents, by either:
clicking on the blue cell bracket (or the area where it would be if it is hidden)
clicking within the cell and using Alt+. until the entire cell is selected
clicking and dragging from above the cell, where the cursor is horizontal, to below the cell
Then, use menu
Format > Style > ...
, or the corresponding key combinations.The same methods can be used to select cell groups, rather than individual cells.
To create a new cell of a particular style:
click outside of existing cells where the cursor is horizontal
this should create a horizontal rule as shown in earlier illustration
specify a style, again with
Format > Style > ...
or keyboard shortcutsstart typing (or paste) the contents of the new cell
To create a new Input cell, the default style, simply do step (1) and then type or paste the input.
这取决于您的样式表。输入不是每个样式表中的第九个编号样式。此外,您还必须选择单元格括号才能更改单元格的样式。
我使用部分特别是为了能够使用折叠,即双击单元组括号来隐藏排名较低的单元。这样就形成了一份干净的文档。它不会对输入单元格执行任何操作(上下文选项除外)。
It depends on your stylesheet. Input is not the nineth numbered style in every stylesheet. Also, you have to select the cell bracket to change a cell's style.
I use sections particularly to be able to use folding, i.e. the double clicking on the cell group bracket to hide the lower ranking cells. That makes for a clean document. It doesn't do anything with the Input cells (except for the context option).