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"]}]

または、TextCells のコレクション全体を 1 つの高レベルの CellGroup にラップし、CellGroup のオプションの 2 番目の引数で遊ぶこともできます。たとえば、これは最初の 3 つのセル グループのみを開きます。

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 に答える