8

下面的代码块

CreateDocument[{
  TextCell["Title", "Title"],
  TextCell["Subtitle", "Subtitle"],
  TextCell["Section 1", "Section"],
  TextCell["Section 1.1", "Subsection"],
  TextCell["Section 1.2", "Subsection"],
  TextCell["Section 1.3", "Subsection"],
  TextCell["Section 2", "Section"],
  TextCell["Section 2.1", "Subsection"],
  TextCell["Section 2.2", "Subsection"],
  TextCell["Section 2.3", "Subsection"],
  TextCell["Section 3", "Section"],
  TextCell["Section 2.1", "Subsection"],
  TextCell["Section 2.2", "Subsection"],
  TextCell["Section 2.3", "Subsection"]}
 ]

将创建一个骨架笔记本。

是否可以创建该笔记本以折叠部分?这样笔记本将显示为好像(例如)已单击覆盖第 1 部分的单元格关闭器。第 2 节和第 3 节同上。

4

1 回答 1

11

使用 CellGroup 打开或关闭特定单元格 - 请参阅http://reference.wolfram.com/mathematica/ref/CellGroup.html

CreateDocument[{
  TextCell["Title", "Title"],
  TextCell["Subtitle", "Subtitle"],
  CellGroup[{
    TextCell["Section 1", "Section"],
    TextCell["Section 1.1", "Subsection"], 
    TextCell["Section 1.2", "Subsection"], 
    TextCell["Section 1.3", "Subsection"]
  }, Closed],
  TextCell["Section 2", "Section"],
  TextCell["Section 2.1", "Subsection"], 
  TextCell["Section 2.2", "Subsection"], 
  TextCell["Section 2.3", "Subsection"],
  TextCell["Section 3", "Section"],
  TextCell["Section 2.1", "Subsection"], 
  TextCell["Section 2.2", "Subsection"], 
  TextCell["Section 2.3", "Subsection"]}]

或者,您可以将整个 TextCell 集合包装在一个高级 CellGroup 中,并使用 CellGroup 的可选第二个参数。例如,这将只打开前三个单元组:

CreateDocument[{
  CellGroup[{
    TextCell["Title", "Title"],
    TextCell["Subtitle", "Subtitle"],
    TextCell["Section 1", "Section"],
    TextCell["Section 1.1", "Subsection"], 
    TextCell["Section 1.2", "Subsection"], 
    TextCell["Section 1.3", "Subsection"],
    TextCell["Section 2", "Section"],
    TextCell["Section 2.1", "Subsection"], 
    TextCell["Section 2.2", "Subsection"], 
    TextCell["Section 2.3", "Subsection"],
    TextCell["Section 3", "Section"],
    TextCell["Section 2.1", "Subsection"], 
    TextCell["Section 2.2", "Subsection"], 
    TextCell["Section 2.3", "Subsection"]
  }, {1, 2, 3}]
}]
于 2011-05-12T02:58:52.800 回答