Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete unnecessary options from Notebook[]?

By default Notebook[] has a small set of Options:

In[4]:= Options[EvaluationNotebook[]]

Out[4]= {FrontEndVersion -> 
  "7.0 for Microsoft Windows (32-bit) (February 18, 2009)", 
 StyleDefinitions -> "Default.nb", 
 WindowMargins -> {{0, Automatic}, {Automatic, 0}}, 
 WindowSize -> {616, 537}}

Sometimes I wish to modify Notebook appearance and set additional Options. For example I like to have comments to be Plain rather than Bold:

SetOptions[EvaluationNotebook[], 
 AutoStyleOptions -> {"CommentStyle" -> {FontWeight -> Plain, 
     FontColor -> GrayLevel[0.6`], ShowAutoStyles -> False, 
     ShowSyntaxStyles -> False, AutoNumberFormatting -> False}}]

Now Options[EvaluationNotebook[]] will return also new option I have set.

But sometimes I wish to restore default behavior and delete additional Options. How can I do that?

like image 543
Alexey Popkov Avatar asked Mar 07 '11 09:03

Alexey Popkov


People also ask

How can I find a useless program on my computer?

Go to your Control Panel in Windows, click on Programs and then on Programs and Features. You'll see a list of everything that's installed on your machine. Go through that list, and ask yourself: do I *really* need this program? If the answer is no, hit the Uninstall/Change button and get rid of it.


1 Answers

Igor's answer is almost right. To remove the options set by

SetOptions[EvaluationNotebook[], 
 AutoStyleOptions -> {"CommentStyle" -> {FontWeight -> Plain, 
     FontColor -> GrayLevel[0.6`], ShowAutoStyles -> False, 
     ShowSyntaxStyles -> False, AutoNumberFormatting -> False}}]

You need to run

SetOptions[EvaluationNotebook[], 
 AutoStyleOptions -> {"CommentStyle" -> Inherited}]

But this only works for options that are standard and have a default to inherit (if it's a cell then from the enclosing section or notebook, if it's a notebook then from the stylesheet). What if you make up your own option, e.g.

Protect[HiddenData];
SetOptions[EvaluationNotebook[], HiddenData -> {"here's a string"}]

I don't know how to programmatically remove this option.


Edit:

Actually, to remove the HiddenData option created above, I can use something like

NotebookPut[DeleteCases[NotebookGet[EvaluationNotebook[]], 
                        $CellContext`HiddenData -> _], 
            EvaluationNotebook[]]

Edit 2:

Mr Wizard asked how to remove all user-set notebook options. Assuming that this means all options that can't be inherited, then I believe that the following should work:

NotebookPut[
 With[{nb = NotebookGet[EvaluationNotebook[]], opts = Options[Notebook][[All, 1]]}, 
  Prepend[Select[Rest@nb, MemberQ[opts, First[#]] &], First@nb]], 
 EvaluationNotebook[]]

But maybe there are options associated with the StyleSheet that I've ignored...

If he meant how do you get back to your system's default notebook options - then you can just delete all notebook options:

NotebookPut[Notebook[First@NotebookGet[EvaluationNotebook[]]], 
            EvaluationNotebook[]]
like image 118
Simon Avatar answered Nov 15 '22 08:11

Simon