以编程方式关闭Mathematica中的所有单元格组?

时间:2012-06-14 10:39:39

标签: wolfram-mathematica mathematica-8 mathematica-frontend

是否可以折叠当前笔记本中的所有单元格组?我试过了

nb = SelectedNotebook[];
SelectionMove[nb, Before, CellGroup]
FrontEndTokenExecute["OpenCloseGroup"]

但没有任何改变。

1 个答案:

答案 0 :(得分:1)

您可以使用

nb = SelectedNotebook[];
SelectionMove[nb, All, Notebook];
FrontEndTokenExecute[nb, "OpenCloseGroup"]

虽然它仅在笔记本电脑以单元格组开头而不是单独单元格时才有效。 (菜单项的行为方式相同。)

如果你知道有cellGroupCount组,你也可以这样做:

nb = SelectedNotebook[];
SelectionMove[nb, Before, Notebook]
Do[SelectionMove[nb, Next, CellGroup];
 FrontEndTokenExecute[nb, "OpenCloseGroup"], {cellGroupCount}]
相关问题