How can I clean up a notebook?
Update
I have incorporated Kuba's improvement into the code.
Here is how I would do it.
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.
Now in the target notebook evaluate
EvaluationNotebook[]
This will return a notebook object which will look something like
$\qquad$
Cut the notebook object from the target notebook.
Select the first token
target
in the working notebook and paste the notebook object over it.Do the same thing for the other
target
token.Delete the
EvaluationNotebook[]
code from the target notebook.Evaluate the first of the two code cells.
After pasting the notebook object into working notebook, that notebook should look like this:
Another possibility is to modify the notebooks style sheet by defining a new "Screen Environment" that hides cell brackets and closes input cells:
SetOptions[
EvaluationNotebook[],
StyleDefinitions -> Notebook[{
Cell[StyleData[StyleDefinitions->"Default.nb"]],
Cell[StyleData[All, "Working"], MenuCommandKey->"D"],
Cell[StyleData[All, "Clean"],
MenuCommandKey->"C",
ShowCellBracket->False,
MenuSortingValue -> 10000
],
Cell[StyleData["Input", "Clean"],
CellOpen->False]
},
StyleDefinitions->"PrivateStylesheetFormatting.nb"
]
]
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:
Note that I used the keyboard shortcuts to switch at the end of the animation.