Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to insert a closed section? I know in .m files if you do (* ::Section::Closed:: *) and open the .m file using system editor, a closed section will be displayed. Is there a way to create a closed section in the notebook while using CreateDocument[]?

share|improve this question
up vote 3 down vote accepted

yes, but a notebook has a more involved structure than the .m files you have investigated. The code to do what you want isn't very complicated, though:

    TextCell["section", "Section"],
    TextCell["content", "Text"]
    }, Closed]}]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.