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, Autom开发者_如何学编程atic}, {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?
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[]]
(1) Select Format -> Options Inspector
(or Shift+Ctrl+O
on Windows)
(2) For the two fields next to "Show option values" select Notebook
and as text
(3) Select and delete all text in the box below
(4) Click Apply
After understanding NotebookGet, I believe this works for full options reset.
NotebookPut[
Notebook@First@NotebookGet[EvaluationNotebook[]],
EvaluationNotebook[]]
Use:
SetOptions[EvaluationNotebook[], Background -> Inherited]
Igor
精彩评论