Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Table of Contents

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85397] Re: Table of Contents
  • From: Larry <LJ2114 at yahoo.com>
  • Date: Sat, 9 Feb 2008 04:13:18 -0500 (EST)
  • References: <foejuo$huu$1@smc.vnet.net> <fogif4$3c1$1@smc.vnet.net>

Sir, I tried you code in two cells in one notebook but it 
produced no output.

Then I tried putting TOCForNotebook definition cell in one 
nb and the command TOCForNotebook[] in another nb, also no 
output. I'm curious how this is supposed to work. Thanks.

David Reiss wrote:
> Here is an example of a function that, when executed in the notebook
> in question, will generate a set fo cells at the top of the notebook
> that are hyperlinks to the section cells:
> 
> 
> ClearAll[TOCForNotebook];
> 
> 
> TOCForNotebook[] :=
>   Module[{nbr, data, cells, nb},
> 
>    nb = EvaluationNotebook[];
> 
>    SetOptions[nb, System`CellID -> True];
> 
>    SelectionMove[nb, All, Notebook, AutoScroll -> False];
>    NotebookWrite[nb, NotebookRead[nb]];
> 
>    NotebookFind[nb, "Section", All, CellStyle];
>    nbr = NotebookRead[nb];
>    data =
>     nbr /. {Cell[x_, "Section", ___, z : (CellID -> w_), ___] :> {x,
>         w}};
> 
>    cells = Function[x,
>         TextCell[
>          Button[TextCell[#[[1]], "Hyperlink"],
>           NotebookFind[x, #[[2]], All, CellID],
>           Appearance -> "Frameless"],
>          "Text"]][nb] & /@ data;
> 
>    cells = First[ToBoxes[#]] & /@ cells;
> 
>    SelectionMove[EvaluationNotebook[], Before, Notebook,
>     AutoScroll -> True];
> 
>    NotebookWrite[nb, cells];
> 
>    ];
> 
> 
> So, first execute this code somewhere in your current Mathematica
> session.  Then execute
> 
> TOCForNotebook[]
> 
> within the notebook in question.  If your Section cells have any
> formatting in them then this will not quite work as expected.  But it
> gives a start to others that would wish to modify this.  The code
> exposes several coding tricks that folks will perhaps find useful....
> 
> 
> -David
> A WorkLife FrameWork
> E x t e n d i n g MATHEMATICA's Reach...
> http://scientificarts.com/worklife/
> 
> On Feb 7, 4:44=A0am, =8Aer=FDch Jakub <Ser... at panska.cz> wrote:
>> I use some notebooks as the collections of many small examples, which I
>> allways start with cell styled as "Section" followed by usually one input =
> and
>> one output cell. The "Section" styled cell contains the name of the exampl=
> e.
>> Does anybody know, how to create Table of Contents based on these section
>> cells? Idealy it would contain interactive hyperlinks directly to the cell=
> s.
>> Thanks in advance
>>
>> Jakub
> 
> 


  • Prev by Date: Re: Bug in the FourierSinCoefficient function
  • Next by Date: Re: How should I start with mathematica?
  • Previous by thread: Re: Table of Contents
  • Next by thread: Re: Table of Contents