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

Am trying to generate an Evaluatable cell which itself is an output cell which will be overwritten when the original Input cell will be evaluated again:

 ExpressionCell[Defer[1 + 1], "Output", Evaluatable -> True, 
  CellAutoOverwrite -> True, GeneratedCell -> True]]

Without Evaluatable -> True everyting works as expected: the generated output cell is automatically overwritten when the input cell is evaluated again. But adding Evaluatable -> True breaks this behavior.

Is it possible to generate Evaluatable cell which will be automatically overwritten?

share|improve this question
I would like to know the context of this question. Even without Evaluatable -> True I can still evaluate the 1 + 1 cell so I am wondering where Evaluatable -> True is necessary. – Mr.Wizard Apr 11 '13 at 19:36
@Mr.Wizard Evaluatable -> True is necessary for work of the InitializationCell -> True option. Without Evaluatable -> True initialization cells are simply ignored. – Alexey Popkov Apr 12 '13 at 0:04

This will do what you want, without having to resort to SelectionMove or something silly like that. Of course, it does not use CellAutoOverwrite, so possibly this is not the "yes" you would have hoped for. The same can probably be achieved using CellID, but I'm not sure how that works.

NotebookDelete[Cells[CellTags -> "@#$kill me"]]
      ExpressionCell[Defer[1 + 1], "Output", GeneratedCell -> True, 
       Evaluatable -> True, CellTags -> "@#$kill me" ]];

Edit: I misread a comment by you on an answer to your other question. I suppose you don't want to automatically evaluate the printed Cell after all, correct?

share|improve this answer
+1. Yes, I just need to print the cell, not to evaluate it. – Alexey Popkov Apr 11 '13 at 23:51
I'm sorry. It seems I accidentally downvoted your answer. It was not on purpose and you got now a +1 from me. – halirutan Apr 12 '13 at 10:31
@halirutan Maybe I care too much about votes, but I really appreciate your clarification :). – Jacob Akkerboom Apr 12 '13 at 11:28

This behavior does appear to be directly tied to the Evaluatable option as I will show.

Unfortunately I don't have a solution. I offer these observations:

With the code in the question:

ExpressionCell[Defer[1 + 1], "Output",
  CellAutoOverwrite -> True,
  GeneratedCell -> True
] // CellPrint

The generated cell is overwritten, and you can still evaluate the output cell by placing the cursor within it and using Shift+Enter. It is converted to an Input cell, but an "Output" cell is converted to Input even if the option Evaluatable -> True is used.

With style "Input" the generated cell is not overwritten:

ExpressionCell[Defer[1 + 1], "Input",
  CellAutoOverwrite -> True,
  GeneratedCell -> True
] // CellPrint

But it is overwritten if we add Evaluatable -> False:

ExpressionCell[Defer[1 + 1], "Input",
  CellAutoOverwrite -> True,
  GeneratedCell -> True,
  Evaluatable -> False
] // CellPrint
share|improve this answer
Note that the option Evaluatable determines whether we can use NotebookEvaluate to evaluate it, as well as SelectionEvaluate, as well as FrontEndExecute[FrontEndToken["EvaluateInitialization"]]. However we can extract the data using another cell, as I show here – Jacob Akkerboom Apr 11 '13 at 20:13
@Mr.Wizard The "Input" style contains Evaluatable -> True option. Even without style specification this option triggers the automatic overwriting. – Alexey Popkov Apr 12 '13 at 0:00
@Jacob Thanks, that makes sense. – Mr.Wizard Apr 12 '13 at 0:18
@Alexey Yes, that's my observation. I wish I had a solution but I do not. It would also let me answer this question in the way I had hoped to. – Mr.Wizard Apr 12 '13 at 0:20

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.