Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I hide all input in a Mathematica notebook?

2,663 views
Skip to first unread message

michael.p...@googlemail.com

unread,
Mar 26, 2009, 6:20:19 AM3/26/09
to
Hi

I am using Mathematica to prepare a report for my boss. It has lots
of tables and pie charts - the sort of things bosses love. It also
has a lot of Mathematica commands which scares the wossname out of
him.

At the moment I am hiding the input cell by cell but this is a pain.
Is there a one click/one command solution?

Thanks,
Mike

www.walkingrandomly.com

dbr...@gmail.com

unread,
Mar 27, 2009, 6:33:50 AM3/27/09
to
One very clean way to do this would be to create a copy of the
notebook for delivery to your boss. Then in this copy execute

Module[{nb},
nb = EvaluationNotebook[];
NotebookFind[EvaluationNotebook[], "Input", All, CellStyle];
NotebookDelete[nb]]

Within your boss's notebook.


This will remove, rather than hide, the input cels in that copy of the
notebook.

However, if you wanted to just hid those cells you could execute

Module[{nb},
nb = EvaluationNotebook[];
NotebookFind[EvaluationNotebook[], "Input", All, CellStyle];
SetOptions[NotebookSelection[nb], CellOpen -> False,
ShowCellBracket -> False]
]

in that notebook...

Hope this helps....
More advanced methods using tagging could be used (see "The Joy of
Tagging: Manipulating and Mining Notebooks in Mathematica" at
http://scientificarts.com/worklife/notebooks/


I hope that this helps,

David


On Mar 26, 6:20 am, "michael.p.crouc...@googlemail.com"

David Park

unread,
Mar 27, 2009, 6:38:52 AM3/27/09
to
Mike,

The simplest solution would be to permanently close the Input cells when you
prepare the notebook. You do this by selecting the Input cell bracket and
using Menu -> Cell -> Cell Properties -> Open, or the key sequence Alt-CPO.
I don't know if there is a single command that will select all of the Input
cells at once, but having selected a set of them you can open or close them
all at once. This hides the Input cells as a set of thin cells. You could
then evaluate your entire notebook at once to obtain the displays.

One disadvantage I find with this method is that whenever I think a display
is finished and I close up the Input cell, I later find I want to make a
change and have to open it up again. A second disadvantage is that if you
want to evaluate the cells individual you might find they are difficult to
select because the cells are so thin. However, you don't have to click the
bracket itself - you can click anywhere in the cell.


In the Presentations package I have a number of commands for formatting
'page' displays and generating page displays by buttons that can be merged
into text cells, or that can form a structured group for moving through
various displays. The buttons allow either a page display in the notebook,
or will launch it in a separate window. I usually put the code for the page
displays in subsections that remain closed.

You could do a little bit of this yourself by putting your display code in
subsections. Give each display a name:

display1 = code that generates the display;

Then put a button in the main portion of the notebook:

Button["Sales by product line", display1]

Then copy the button to the open part of the notebook.

An advantage of the button method is that you can change the code in
display1, say, without having to change the button in the open part of the
notebook.

David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

dr DanW

unread,
Mar 28, 2009, 6:39:57 AM3/28/09
to
Here is an old trick that is probably not documented anymore:

Alt-click (option-click on a Mac) a cell bracket will select all cell
brackets of the same type. Alt-click on an input cell will select all
input cells. Then you can use Cell > Cell Properties > Open to toggle
the input cells between open and closed.

Dangling problem is that although the cells are hidden, vertical space
between the cells is not. This can leave large unexplained whitespace
in your report. If anyone has a suggestion to get around this, please
post.

Daniel

Bob F

unread,
Mar 28, 2009, 6:42:06 AM3/28/09
to
On Mar 26, 4:20 am, "michael.p.crouc...@googlemail.com"

One thing you might want to look at is using Cell Grouping to group
all of the things you want to hide in one such group and then hide/
show only that group depending on who you want to look at it. The
difficulty lies in structuring the notebook so that is easy to do.
Once cells are in a Group, you can double-click on any cell bracket in
that Group at multiple levels and the other cells in the Group will be
hidden or unhidden. I don't think it matters if a cell is an Input
cell or a Text cell or any other type, so you can mix/match cell types
in any group, and they do not have to be contiguous either, but if
they aren't then some of the intervening cells not in the group will
also be hidden. Play around with this Grouping (I think this is new as
of version 6 so keep that in mind) and see if that helps.

HTH...

-Bob

Vince

unread,
Mar 28, 2009, 6:45:12 AM3/28/09
to
On Mar 26, 6:20 am, "michael.p.crouc...@googlemail.com"

Mike,

You might modify your notebook's stylesheet, with the following
additional cell:

Cell[StyleData["Input"], CellOpen -> False]

Vince Virgilio

0 new messages