By cleaning up a notebook, I mean how can I hide all the codes in the notebook so that the end-users can't see it? I saw Eric Schulz's famous interactive calculus textbook, the users can't see the code, and there is no cell brackets on the right hand side of the CDF.

  • 2
    $\begingroup$ Please consider adding a reference to the textbook. $\endgroup$
    – Kuba
    Feb 27 '17 at 6:18
  • 2
    $\begingroup$ At least closely related: 113913, 14466, 680 $\endgroup$
    – Kuba
    Feb 27 '17 at 6:24
  • $\begingroup$ @Kuba This appears to be directly answered by mathematica.stackexchange.com/a/14470/121 therefore I am in favor of marking this as a duplicate. Do you disagree? $\endgroup$
    – Mr.Wizard
    Apr 10 '19 at 7:27
  • $\begingroup$ @Mr.Wizard I agree, sorry for delay, I should not read via mobile phone because then I forget to answer. $\endgroup$
    – Kuba
    Apr 10 '19 at 18:03


I have incorporated Kuba's improvement into the code.

Here is how I would do it.

  1. In a working notebook (not the target notebook) put the following code.

    With[{nb = target},
      SetOptions[nb, ShowCellBracket -> False];
      SetOptions[#, CellOpen -> False] & /@ Cells[nb, CellStyle -> "Input"];]
    With[{nb = taget},
      SetOptions[nb, ShowCellBracket -> True];
      SetOptions[#, CellOpen -> True] & /@ Cells[nb, CellStyle -> "Input"];]

    The first code cell will do the clean-up. The second lets you undo it if that becomes necessary.

  2. Now in the target notebook evaluate


    This will return a notebook object which will look something like


  3. Cut the notebook object from the target notebook.

  4. Select the first token target in the working notebook and paste the notebook object over it.

  5. Do the same thing for the other target token.

  6. Delete the EvaluationNotebook[] code from the target notebook.

  7. Evaluate the first of the two code cells.

After pasting the notebook object into working notebook, that notebook should look like this:


  • 1
    $\begingroup$ Awesome! Works great $\endgroup$ Feb 27 '17 at 16:55
  • $\begingroup$ Great solution ... $\endgroup$
    – mrz
    Mar 6 '17 at 11:20

Another possibility is to modify the notebooks style sheet by defining a new "Screen Environment" that hides cell brackets and closes input cells:

    StyleDefinitions -> Notebook[{
        Cell[StyleData[All, "Working"], MenuCommandKey->"D"],
        Cell[StyleData[All, "Clean"],
            MenuSortingValue -> 10000
        Cell[StyleData["Input", "Clean"],

The "Clean" environment hides cell brackets and closes input cells. I also gave it a keyboard short cut, so that using Command+c switches to the "Clean" environment, and Command+d switches back to the working environment. Here is an animation:

enter image description here

Note that I used the keyboard shortcuts to switch at the end of the animation.

  • $\begingroup$ Thank you for your answer! I've decided to to give the bounty to you because it provides a better solution. Thanks again! $\endgroup$
    – Jeel Shah
    Apr 15 '19 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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