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

"Freezing" an Output cell?

96 views
Skip to first unread message

AES

unread,
Oct 2, 2009, 8:25:30 AM10/2/09
to
I'd like to understand the recommended way(s) to "freeze" an Output cell
created and displayed in a Mathematica notebook, so that one can delete
the Input cell(s) that created it and the Output cell remains as a
permanent "Text-like" cell in the notebook, visible to readers, and not
deleted by subsequent Cell >> Delete All Output menu commands.

Example: In the opening section of a notebook addressing some physical
problem I create a Graphic displaying the geometry and coordinate
systems associated with the problem, and maybe a Table displaying some
of the variable names I'll be using and some (possibly derived)
numerical values.

Hopefully, at some point, once I've gotten off to a good start, I can
delete the code that creates these displays, and not have to re-execute
them further, just retain the Output cells, essentially unchanged in
appearance. How to do this?

[And is there a better name than "freezing" for this process?]

For myself, I'd prefer a point and click method, e.g., choose a new
Style for these Output cells using the Format >> Style menu, over having
to put some special code in the Input cells that create them. But,
others may differ.

Thanks for any suggestions.

John Fultz

unread,
Oct 3, 2009, 9:02:15 AM10/3/09
to

Converting to Input style is easy enough. If you want to prevent the newly
created Input cell from subsequently evaluating when you evaluate an entire
notebook, you can use the Cell->Cell Properties->Evaluatable menu command to
prevent that.

Also, if you prefer to hide the code rather than delete it, you can
reverse-close the cell group by double-clicking on the cell bracket for the
output cell.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.

Hannes

unread,
Oct 3, 2009, 9:03:16 AM10/3/09
to
Hello,

here is one possible way:

Select the cell, type ctrl+shift+o to invoke the option inspector,
type GeneratedCell or CellAutoOverWrite followed by Enter in the
Lookup field, set both options to False. CellAutoOverWrite = False
prevents overwriting the cell when a preceeding input cell is
executed, GeneratedCell = False prevents deleting the cell by the menu
command Cell -> Delete all output.

Another way is to type Deletable in the option inspector followed by
Enter twice and set this option to False. Obviously you cannot cut and
paste the cell afterwards.

Best regards,
Hannes Kessler

Hannes

unread,
Oct 3, 2009, 9:03:38 AM10/3/09
to
On 2 Okt., 14:25, AES <sieg...@stanford.edu> wrote:

A programmed solution is shown in the following example

p = Plot[Sin[x], {x, 0, 2 \[Pi]}];
c = Cell[BoxData@ToBoxes[p], "Output", GeneratedCell -> False,
CellAutoOverwrite -> False];
CellPrint[c];

Best regards,
Hannes Kessler

Peter Breitfeld

unread,
Oct 3, 2009, 9:04:44 AM10/3/09
to
AES wrote:

Output Cells will be deleted with "Delete all Output" if the follow
directly an Input Cell. So you have to possibilities to freeze the cell:

1. Create a (empty) Text Cell immediately above the output Cell the go
to Cell/CellProperties and remove the mark of "open". Then the Text Cell
will be invisible and your output will never be deleted automatically.

2. Go to Cell/ShowExpression and change the cell type (last line) to
something different form Output e.g. "Text".

--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

David Reiss

unread,
Oct 3, 2009, 9:05:05 AM10/3/09
to
Here is an example of how to do this:

ClearAll[cleanNB];

cleanNB[nb_NotebookObject] :=
Quiet@Module[{},

NotebookFind[nb, "Input", All, CellStyle, AutoScroll -> False];
NotebookDelete[nb];
NotebookFind[nb, "Code", All, CellStyle, AutoScroll -> False];
NotebookDelete[nb];
NotebookFind[nb, "Output", All, CellStyle, AutoScroll -> False];
SetOptions[NotebookSelection[nb], GeneratedCell -> False,
CellAutoOverwrite -> False, CellLabel -> ""]
]

Best,
David

David Park

unread,
Oct 3, 2009, 9:05:16 AM10/3/09
to
If you have an Output cell that you want to keep from being deleted, copy it
and paste it just after some Text cell (or some non-Evaluable cell). Then it
won't be deleted by Menu -> Cell -> Delete All Output. Then, when you are
happy you can get rid of the cells that created it and the initial Output.


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

Kevin J. McCann

unread,
Oct 3, 2009, 9:06:01 AM10/3/09
to
I do this all the time. Make a plot, for example, then highlight the
bracket at the right and change the cell type to Figure. For the output
of a Mathematica operation, you might choose to change the output cell to either
Text or Equation or ...

BTW, a trick I learned from David Park is to keep the Plot command
around by highlighting the Input cell and type Alt-Shift CPO. This hides
the cell, but you can still see a tiny bracket at the right. This keeps
the "calculational" part around.

Kevin

Vince

unread,
Oct 3, 2009, 9:09:29 AM10/3/09
to
On Oct 2, 8:25 am, AES <sieg...@stanford.edu> wrote:

Is the following method too tedious (Windows key seqs.)?

1. Select (or Alt-select) an Output cell.
2. Ctl-Shift-O, brings up the Options Inspector
3. Type cellautooverwrite, and make the option False

Though, I haven't warmed to such interaction with the Option Explorer.
Even as a GUI, it's arcane and requires either expert knowledge, bold
assumptions, and/or a real sense of adventure.

Vince Virgilio

AES

unread,
Oct 4, 2009, 5:37:55 AM10/4/09
to
My initial query about

> > . . . .recommended way(s) to "freeze" an Output cell, so that

> > one can delete the Input cell(s) that created it and the Output cell
> > remains as a permanent "Text-like" cell in the notebook

has thus far elicited multiple suggestions, of which one of the simplest
seems to be to just insert a Text cell (either blank or maybe a caption
or title cell) just before the Output cell you want to keep.

I'm a bit surprised that only one reply suggested or commented on the
even simpler approach pf just changing the style of the Output cell in
the Format >> Style menu . . . namely a reply from "Kevin J. McCann"
<k...@KevinMcCann.com> who wrote:

> I do this all the time. Make a plot, for example, then highlight the
> bracket at the right and change the cell type to Figure. For the output
> of a Mathematica operation, you might choose to change the
> output cell to either Text or Equation or ...

I don't know what "Figure" is, or at least don't see any such style in
the Default style sheet. But if my Output cell is a Plot or other
graphic, my experiments also show that just changing the style of an
Output cell to Text (or one of the header styles) does what I want. My
only concern in doing this is that I don't know what other hidden
consequences this may be causing . . . ???

0 new messages