29
$\begingroup$

By default, the Mathematica documentation opens with the "Details" section collapsed.

enter image description here

This is never what I'm looking for — in fact, I've lost count of the times I've sought help on a feature and not found it anywhere on the feature's Documentation page (at least not until I remember this shortcoming).

Is there a way to configure Mathematica so that the "Details" section of the Documentation is always expanded by default?

$\endgroup$
2
  • $\begingroup$ New edit should be more handy, what do you think? $\endgroup$
    – Kuba
    Commented Apr 29, 2015 at 13:50
  • 3
    $\begingroup$ Amazingly, 11.1 still does not do this, even though considerable hype is attached to showing an entirely useless and unreadable "preview" of the details section. $\endgroup$
    – orome
    Commented Mar 23, 2017 at 16:35

2 Answers 2

14
$\begingroup$

V11+ notes

Stylesheet solution does not seem to work and the section repeatedly opens and closes. I am not sure why yet.

If you are fine with details section permanently opened you can edit "Notebook" style and add:

NotebookDynamicExpression :> Refresh[
  CurrentValue[EvaluationNotebook[], {TaggingRules, "Openers", "NotesSection"}] = True
  ,
  None
]

I was expecting it to work fine but somehow the section can't be closed (is reopened).

Update 2015, stylesheet approach:

We can safely customize basic stylesheets by copying them first to $UserBaseDirectory:

styleDir = FileNameJoin[{"SystemFiles", "FrontEnd", "StyleSheets", "Wolfram"}]

If[! DirectoryQ@#, CreateDirectory@#] &@ FileNameJoin[{$UserBaseDirectory, styleDir}]


CopyFile @@ (
  FileNameJoin[{#, styleDir, "Reference.nb"}] & /@ {
   $InstallationDirectory, $UserBaseDirectory}
 )

SetOptions[NotebookOpen @ %, {Editable -> True, Saveable -> True}]

Now find "NotesSection" style definitions and add there

CellDynamicExpression :> Refresh[
  SelectionMove[EvaluationCell[], All, CellGroup];
  FrontEndExecute[ FrontEndToken[EvaluationNotebook[], "OpenCloseGroup"]]
  ,
  None
]

enter image description here

Save and done.


Old answer, programmatic approach

The idea is to capture F1 (take a look at the link at the bottom) and include a code that will expand this cell group.

I have not fully tested it (and I probably won't :P) but this works so far:

V9:

    Unprotect[Documentation`HelpLookup];
    Documentation`HelpLookup[link_String, nb_, lang_String, opts : OptionsPattern[]
     ] := Block[{$inblock = True, test},

                test = Documentation`HelpLookup[link, nb, opts];
                NotebookFind[test, "NotesSection", All, CellStyle];
                FrontEndTokenExecute[test, "OpenCloseGroup"]

               ] /; ! TrueQ[$inblock]

90% of credits goes to Simon Woods for this answer

One can put it to the init.m file so this becomes a default behaviour. I've never done this but I will try one day.

I was trying to do this via Cells[test, CellStyle->"NotesSection"] but it was terminating the session repeatedly.

This works on Win7 V9 but not on V8. Any comments appreciated.

V8:

I can't test it and it is ugly but works on V8, thanks Michael Hale for help:

Unprotect[Documentation`HelpLookup];
Documentation`HelpLookup[link_String, nb_, lang_String, opts : OptionsPattern[]
   ] := Block[{$inblock = True, test},

   Documentation`HelpLookup[link, nb, opts];
   Pause[1];
   test =
    Select[Notebooks[], (("DocumentType" /. NotebookInformation[#]) ===
          "Help") &][[1]];
   NotebookFind[test, "NotesSection", All, CellStyle];
   FrontEndTokenExecute[test, "OpenCloseGroup"]] /; ! TrueQ[$inblock]

Unfortunatelly I can't make it work without Pause since I can;t test it. If I find V8 among my friends I will try to make a proper code.

$\endgroup$
12
  • $\begingroup$ Very nice. Another Necromancer badge coming up I think :-) $\endgroup$ Commented Apr 27, 2014 at 20:43
  • $\begingroup$ @SimonWoods Thanks to you for a lesson and SjoerdC.deVries for showing this question :) $\endgroup$
    – Kuba
    Commented Apr 27, 2014 at 20:45
  • $\begingroup$ Perhaps "copying" instead of "moving" is an even safer instruction? [Seems like a trivial goal, opening the details section, but the use of CellDynamicExpression is certainly +1 material.] $\endgroup$
    – Michael E2
    Commented Apr 29, 2015 at 14:08
  • $\begingroup$ @MichaelE2 Good point. Yes, strange design choice that there are no CellGroup options and inheritance mechanisms for those options. And thanks for +1 :) $\endgroup$
    – Kuba
    Commented Apr 29, 2015 at 14:09
  • 1
    $\begingroup$ Adding AllowGroupClose->False to the same style (in addition to that CellDynamicExpression) seems to have solved it. The section cannot be manually closed, naturally, but I can perfectly live with that. :) $\endgroup$ Commented Jul 17, 2018 at 8:55
3
$\begingroup$

Based on Kuba's findings in this and this answers and also thanks to user1950580 who uncovered FrontEnd`Private`SetCurrentValue (his answer was the only place where this function was listed), here is my modification of Kuba's stylesheet approach which works well with version 11.1 and is tuned on to influence other versions installed as little as possible. In order to prevent the appearance of the dialog

screenshot

in earlier versions (the above screenshot is from version 8 installed on the same machine) when opening the Documentation center (which automatically opens modified "Reference.nb" stylesheet), I Export new stylesheet as "Package".

Here is the code:

systemStyleSubDir = FileNameJoin[{"SystemFiles", "FrontEnd", "StyleSheets", "Wolfram"}];

If[! DirectoryQ@#, CreateDirectory@#] &@
  FileNameJoin[{$UserBaseDirectory, systemStyleSubDir}];

Export[FileNameJoin[{$UserBaseDirectory, systemStyleSubDir, "Reference.nb"}],
 Notebook[{
   Cell[StyleData[
     StyleDefinitions -> 
      FrontEnd`FileName[{$InstallationDirectory, "SystemFiles", "FrontEnd", "StyleSheets",
         "Wolfram", "Reference.nb"}]]],
   Cell[StyleData["NotesSection"],
    CellDynamicExpression :> FEPrivate`If[FEPrivate`Equal[FEPrivate`$VersionNumber, 11.1],
      FrontEnd`Private`SetCurrentValue[
             FrontEnd`ButtonNotebook[], {TaggingRules, "Openers", "NotesSection"}, 
       True]]]},
  StyleDefinitions -> "PrivateStylesheetFormatting.nb"], "Package"]

Note that Refresh isn't necessary here. I also use safe FrontEnd`ButtonNotebook[] instead of dangerous SelectedNotebook[] with which the above CellDynamicExpression will modify not exclusively the Documentation Notebook from where it is running, but any selected or currently evaluating Notebook if a Cell with the modified "NotesSection" style is currently displayed on the screen...

$\endgroup$
3
  • $\begingroup$ I don't understand when and why are you facing this dialog. I also don't understand how could EvaluationNotebook[] refer to any other notebook that the stylesheet child it is in. Could you add a context/example? $\endgroup$
    – Kuba
    Commented May 10, 2017 at 11:27
  • $\begingroup$ @Kuba This dialog appears when I open Documentation center of version 8 installed on the same machine because it opens the "Reference.nb" stylesheet exported from version 11.1. I haven't checked it with EvaluationNotebook[] but SelectedNotebook[] does modify any (for example, new) Notebook which is selected at the time when the Documentation cell with the modified "NotesSection" style is displayed on-screen. $\endgroup$ Commented May 10, 2017 at 11:40
  • $\begingroup$ Strange, in 10.4 it does not complain on 11.1 Reference.nb. I'm not using SelectedNotebooks and you claim EvaluationNotebook I use is dangerous :) $\endgroup$
    – Kuba
    Commented May 10, 2017 at 11:49

Your Answer

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

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