Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Documentation Center (v6): do-it-yourself Mathematica Book

4 views
Skip to first unread message

thomas

unread,
Aug 4, 2007, 6:12:48 AM8/4/07
to
Many users on this discussion group have complained about the absence
of "The Mathematica Book" in the new Documentation Center; mainly
because of a missing linear introductory text of Mathematica which was
present in the old Help system.

I completely agree. However, I noticed that the various tutorial files
in the Documentation center contain the text of "The Book". What is
really missing is the outline. So I decided to build my own do-it-
yourself version of the book. It turned out to be quite simple, thanks
to the ingenious naming rules of the tutorial files (all main chapter
TOC files end with "...Overview.nb".)

The following code opens a new notebook, and prints a collection of
hyperlinks to Documentation Center tutorials, laid out in the order of
the good old Mathematica book. Simply execute the code and save the
notebook for your own use. There are 11 chapters that I could not find
in "The Mathematica Book" of the v5.2 Help system, I integrated them
in an order that seemed most appropriate to me. The are marked by
"New: ".

Note that this link collection does not contain links to all
tutorials. For example, no links to the "Manipulate" tutorials exist.
Neither are the packages represented.

Also be warned that the code opens help files to extract hyperlinks
for incorporation in "The Book", and closes them again. Lots of
windows appearing and disappearing on the screen. There will also be
warnings and a "beeps" popping up because of a mismatch in cell
styles, which you can ignore. Everything works fine despite the
mismatch. At the end, just close the "Why the beep" dialog box.

Here is the code that you need to execute to build your own book in
v6.0.x:

fn = FileNames[
"*Overview.nb", $InstallationDirectory <>
"\\Documentation\\English\\System\\Tutorials\\"];
(*Find "Overview.nb" files in the tutorials-directory*)

nameList = {StringTake[#, {StringPosition[#, "\\"][[-1, 1]] +
1, -12}],
"paclet:tutorial/" <>
StringTake[#, {StringPosition[#, "\\"][[-1, 1]] +
1, -4}], #} & /@ fn;
(*create a list of strings needed for future code*)

Do[nameList[[i, 1]] =
"New: " <> nameList[[i, 1]], {i, {3, 6, 7, 8, 18, 28, 29, 40, 41,
46, 48}}];
(* mark the chapter not present in v5.2 with "New: "*)

orderOfChapters = {{36, 3, 8, 31, 4, 47, 1, 39, 32, 14, 20, 16, 18,
17, 11, 43}, {10, 13, 35, 48, 22, 45, 9, 27, 38, 42, 44, 23, 12,
26, 15, 40, 41}, {30, 25, 2, 21, 5, 7, 37, 19, 33, 34, 28, 29, 6,
46, 24}};
(*The file list is alphabetical-this is the order in which the \
chapters should appear*)

structure = Table[nameList[[i]], {k, 3}, {i, orderOfChapters[[k]]}];
(*needed for the code further down-represents the structure of the \
Matehmatica book*)

mainChapters = {"A practical introduction to Mathematica",
"Principles of Mathematica",
"Advanced Mathematics in Mathematica"};
(*The three main headings*)

d[x_] := Cell[
BoxData[TagBox[
ButtonBox[
PaneSelectorBox[{False -> x[[1]],
True -> StyleBox[x[[1]], "HyperlinkActive"]},
Dynamic[CurrentValue["MouseOver"]],
BaselinePosition -> Baseline, FrameMargins -> 0,
ImageSize -> Automatic], BaseStyle -> "Link",
ButtonData -> x[[2]], ButtonNote -> x[[2]]],
Annotation[#, x[[2]], "Hyperlink"] &]], "Subsection"];
(*Cell representing a hyperlink to the "...Overview.nb" files*)

nb = NotebookPut[];
SetOptions[nb, StyleDefinitions -> "Book\\Textbook.nb"];
NotebookWrite[
nb, {Cell["The Virtual Mathematica Book (v6)", "Title"],
Cell["A collection of links to the tutorials present in the \
Mathematica 6.0 Documentation Center, arranged in the order of \
chapters in \"The Mathematica Book\".", "Author"]}];
Do[NotebookWrite[nb, Cell[mainChapters[[k]], "Section"]];
Do[NotebookWrite[nb, d[i]];
With[{nb1 = NotebookOpen[i[[3]]]},
NotebookFind[nb1, "TOCChapter", All, CellStyle];
NotebookWrite[nb, NotebookRead[nb1]]; NotebookClose[nb1]], {i,
structure[[k]]}], {k, 3}];
SelectionMove[nb, All, Notebook]; FrontEndExecute[
FrontEndToken["SelectionCloseAllGroups"]]; FrontEndExecute[
FrontEndToken["OpenCloseGroup"]];
(*Creates the Mathematica Book.The With[...] block in the middle \
opens an "Overview.nb" file,extracts the embedded hyperlinks,and \
prints those into the Mathematica Book as well.*)

I hope that you might find this as helpful as I do!

Happy clicking,
Thomas


David Bailey

unread,
Aug 5, 2007, 4:55:30 AM8/5/07
to

This works and looks very, very useful!

David Bailey
http://www.dbaileyconsultancy.co.uk

David Reiss

unread,
Aug 5, 2007, 4:56:31 AM8/5/07
to
This is good!

I made a few small changes to your code so that it does not only work
on Windows. The following version makes it OS independent


--David


fn = FileNames["*Overview.nb",

ToFileName[{$InstallationDirectory, "Documentation", "English",
"System", "Tutorials"}]];


(*Find "Overview.nb" files in the tutorials-directory*)

nameList = With[{case = StringReplace[#, DirectoryName[#] -> ""]},
{StringReplace[case, "Overview.nb" -> ""],
"paclet:tutorial/" <> StringReplace[case, ".nb" -> ""], #}] & /@


fn;
(*create a list of strings needed for future code*)

Scan[(nameList[[#, 1]] = "New: " <> nameList[[#, 1]]) &, {3, 6, 7, 8,


18, 28, 29, 40, 41, 46, 48}];

(*mark the chapter not present in v5.2 with "New: "*)

StyleDefinitions -> ToFileName["Book", "Textbook.nb"]];


NotebookWrite[
nb, {Cell["The Virtual Mathematica Book (v6)", "Title"],
Cell["A collection of links to the tutorials present in the \
Mathematica 6.0 Documentation Center, arranged in the order of \
chapters in \"The Mathematica Book\".", "Author"]}];
Do[NotebookWrite[nb, Cell[mainChapters[[k]], "Section"]];
Do[NotebookWrite[nb, d[i]];
With[{nb1 = NotebookOpen[i[[3]]]},
NotebookFind[nb1, "TOCChapter", All, CellStyle];
NotebookWrite[nb, NotebookRead[nb1]]; NotebookClose[nb1]], {i,
structure[[k]]}], {k, 3}];
SelectionMove[nb, All, Notebook]; FrontEndExecute[
FrontEndToken["SelectionCloseAllGroups"]]; FrontEndExecute[
FrontEndToken["OpenCloseGroup"]];
(*Creates the Mathematica Book.The With[...] block in the middle \
opens an "Overview.nb" file,extracts the embedded hyperlinks,and \
prints those into the Mathematica Book as well.*)


On Aug 4, 6:12 am, thomas <thomas.mue...@gmail.com> wrote:
> Many users on this discussion group have complained about the absence
> of "The Mathematica Book" in the new Documentation Center; mainly
> because of a missing linear introductory text of Mathematica which was
> present in the old Help system.


<snip>


Selwyn Hollis

unread,
Aug 6, 2007, 3:46:31 AM8/6/07
to
Thanks for posting this. It wouldn't work on my Mac, so I fixed that
and did a bit of tidying-up so that it runs without squawking or
showing the notebooks that are opened and so that section title links
are in the right font and have spaces between words.

- Selwyn Hollis


fn = FileNames[
"*Overview.nb", ToFileName[{$InstallationDirectory ,
"Documentation", "English", "System", "Tutorials"}]];
(*Find "Overview.nb" files in the tutorials-directory*)

nameList = {StringTake[#,
{StringPosition[#, $PathnameSeparator][[-1, 1]] +1,-12}],
"paclet:tutorial/" <>
StringTake[#,
{StringPosition[#, $PathnameSeparator][[-1, 1]] +1,-4}], #}&/
@fn;


(*create a list of strings needed for future code*)

Do[nameList[[i, 1]] =
"New: " <> nameList[[i, 1]], {i, {3,6,7,8,18,28,29,40,41,46,48}}];

(* mark the chapter not present in v5.2 with "New: "*)


orderOfChapters = {{36, 3, 8, 31, 4, 47, 1, 39, 32, 14, 20, 16, 18,
17, 11, 43}, {10, 13, 35, 48, 22, 45, 9, 27, 38, 42, 44, 23,
12,
26, 15, 40, 41}, {30, 25, 2, 21, 5, 7, 37, 19, 33, 34, 28,
29, 6,
46, 24}};
(*The file list is alphabetical-this is the order in which the \
chapters should appear*)
structure = Table[nameList[[i]], {k, 3}, {i, orderOfChapters[[k]]}];
(*needed for the code further down-represents the structure of the \

Mathematica book*)
mainChapters = {"A Practical Introduction to Mathematica",


"Principles of Mathematica",
"Advanced Mathematics in Mathematica"};
(*The three main headings*)

d[x_] := Module[{sectitle = StringReplace[StringReplace[First[x],
{l1_?LowerCaseQ ~~ l2_?UpperCaseQ :> l1 <> " " <> l2}],
{" And " -> " and ", " Of " -> " of ", " In " -> " in ",
" The " -> " the ", " For " -> " for "}]},
Cell[
BoxData[TagBox[
ButtonBox[
PaneSelectorBox[{False -> sectitle,
True -> StyleBox[sectitle, "HyperlinkActive"]},


Dynamic[CurrentValue["MouseOver"]],
BaselinePosition -> Baseline, FrameMargins -> 0,
ImageSize -> Automatic],

BaseStyle -> {"Link", "Subsection"},


ButtonData -> x[[2]], ButtonNote -> x[[2]] ],

Annotation[#, x[[2]], "Hyperlink"] &]], "Subsection",
CellDingbat -> None, ShowGroupOpener -> True,
CellMargins -> {{36, 0}, {2, 7}}] ]


(*Cell representing a hyperlink to the "...Overview.nb" files*)
nb = NotebookPut[];

SetOptions[nb, StyleDefinitions -> "Book/Textbook.nb"];


NotebookWrite[
nb, {Cell["The Virtual Mathematica Book (v6)", "Title"],
Cell["A collection of links to the tutorials present in the \
Mathematica 6.0 Documentation Center, arranged in the order of \

chapters in \"The Mathematica Book\".", "Text",
CellMargins -> {{27, 0}, Inherited}] } ];


Do[NotebookWrite[nb, Cell[mainChapters[[k]], "Section"] ];
Do[NotebookWrite[nb, d[i]];

With[{nb1 = NotebookOpen[i[[3]], Visible -> False ]},


NotebookFind[nb1, "TOCChapter", All, CellStyle];

NotebookWrite[nb, NotebookRead[nb1] //.
"TOCChapter" -> Sequence @@
{"Text", CellMargins -> {{48, 0}, Inherited}}];


NotebookClose[nb1]], {i, structure[[k]]}], {k, 3}];
SelectionMove[nb, All, Notebook]; FrontEndExecute[
FrontEndToken["SelectionCloseAllGroups"]];
FrontEndExecute[ FrontEndToken["OpenCloseGroup"]];
(*Creates the Mathematica Book.The With[...] block in the middle \
opens an "Overview.nb" file,extracts the embedded hyperlinks,and \
prints those into the Mathematica Book as well.*)


On Aug 4, 2007, at 6:00 AM, thomas wrote:

> Many users on this discussion group have complained about the absence
> of "The Mathematica Book" in the new Documentation Center; mainly
> because of a missing linear introductory text of Mathematica which was
> present in the old Help system.
>

> I completely agree. However, I noticed that the various tutorial files
> in the Documentation center contain the text of "The Book". What is
> really missing is the outline. So I decided to build my own do-it-
> yourself version of the book. It turned out to be quite simple, thanks
> to the ingenious naming rules of the tutorial files (all main chapter
> TOC files end with "...Overview.nb".)
>
> The following code opens a new notebook, and prints a collection of
> hyperlinks to Documentation Center tutorials, laid out in the order of
> the good old Mathematica book. Simply execute the code and save the
> notebook for your own use. There are 11 chapters that I could not find
> in "The Mathematica Book" of the v5.2 Help system, I integrated them
> in an order that seemed most appropriate to me. The are marked by
> "New: ".
>
> Note that this link collection does not contain links to all
> tutorials. For example, no links to the "Manipulate" tutorials exist.
> Neither are the packages represented.
>
> Also be warned that the code opens help files to extract hyperlinks
> for incorporation in "The Book", and closes them again. Lots of
> windows appearing and disappearing on the screen. There will also be
> warnings and a "beeps" popping up because of a mismatch in cell
> styles, which you can ignore. Everything works fine despite the
> mismatch. At the end, just close the "Why the beep" dialog box.
>
> Here is the code that you need to execute to build your own book in
> v6.0.x:
>

> [...]

David Reiss

unread,
Aug 7, 2007, 1:38:01 AM8/7/07
to
Thanks for fixing whatever didn't work Selwyn. I wrote it on my Mac,
but perhaps something got broken in the transiion to the news group...

--David

0 new messages