1
$\begingroup$

I want to know if it is possible to temporally disable a cell temporally in Mathematica.

When I evaluate a notebook, there is a certain cell that should not be evaluated. I have seen the Evaluatable option for cells, but when I apply this option on to cell, it doesn't change anything.

$\endgroup$
6
  • 1
    $\begingroup$ How do you "apply this option on a cell"? It works for me. $\endgroup$
    – Kuba
    Jun 1, 2017 at 13:42
  • $\begingroup$ At least closely related: Is there a way to “lock” some cells in a notebook? $\endgroup$
    – Kuba
    Jun 1, 2017 at 13:44
  • $\begingroup$ You might change the cell style to "text", which will also serve as a reminder. That said, un-checking the "evaluatable" option in the cell menu works for me. $\endgroup$
    – george2079
    Jun 1, 2017 at 14:41
  • 1
    $\begingroup$ Have you tried selecting the cell and then toggling the Cell Properties > Evaluatable choice on the Cell menu? $\endgroup$
    – m_goldberg
    Jun 1, 2017 at 14:43
  • $\begingroup$ Well, by default, evaluatable was unchecked but it executed the cells. I checked it and the program still evaluates my cell so I don't understand. $\endgroup$
    – StarBucK
    Jun 1, 2017 at 15:47

1 Answer 1

2
$\begingroup$

I don't know why you are having trouble with the menu command. Please try this palette as an alternative.

Run this code to create the palette, then select the Cell you wish to disable (or simply put the cursor within it) and press the Disable Evaluation button.

CreatePalette @ 
 Button["Disable Evaluation",
   SelectionMove[SelectedNotebook[], All, Cell];
   SetOptions[NotebookSelection[SelectedNotebook[]], Evaluatable -> False]
 ]

You should see the cell bracket subtly change from the normal to disabled form:

enter image description here

$\endgroup$
7
  • $\begingroup$ I have two issues with this. The first is that in a notebook I usually have mixed text (as comment) and code cells. For a group of mixed content cells the evaluatable flag is off. The second is stylistic but important: the difference must be visible, it is laughable that I have to spot that pixel in the bracket to be able to see which cells I have disabled, and which I didnt... $\endgroup$
    – alessandro
    Jul 4, 2017 at 6:51
  • $\begingroup$ @alessandro (1) I don't know what you mean by mixed content cells. Comments delineated by (* *) should not affect the evaluation of cells. (2) I think it is good that no unwanted style is imposed on your cells. You can of course apply a style such as a different background color along with disabling cells, automated with palette buttons as above if desired. This is a more flexible design. Are you having trouble achieving this? $\endgroup$
    – Mr.Wizard
    Jul 4, 2017 at 11:25
  • $\begingroup$ (1) sorry for not being clear: at least for me, the need to enable/disable code regards often whole selections/parts of a notebook, and such parts usually have mixed content, i.e. include code, text cells for comments, section headings... that I'd like to disable. If you try and select any part of a notebook that doesnt contain only input cells, you'll see that Mathematica considers it as non-evaluatable. $\endgroup$
    – alessandro
    Jul 4, 2017 at 12:15
  • $\begingroup$ (2) in this I disagree strongly - I appreciate that M is flexible enough (although I'm not an expert in styles at all, and I dont know how to accomplish it...) - but in any programming environment I always expect that disabled code has a very different style from enabled code (as M comments, in fact) $\endgroup$
    – alessandro
    Jul 4, 2017 at 12:18
  • $\begingroup$ @alessandro (1) So you're saying you lack a function to toggle evaluation on only the input cells within a larger selection? Would you consider a Palette button for that action a solution? (2) Alright, I can accept that especially from the programming environment perspective. However Notebooks are also intended as documents in such a way that code and declaration are somewhat interchangeable. It makes sense for your document not to impose unwanted styles. This may be peculiar to the Notebook concept and at odds with a purely programmatic one. (continued) $\endgroup$
    – Mr.Wizard
    Jul 4, 2017 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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