6
$\begingroup$

I created TOC programatically using instructions from

http://reference.wolfram.com/language/AuthorTools/tutorial/MakeContents.html

But it created second notebook TOC.nb. Is it possible to create TOC for example at the front of my notebook?

$\endgroup$
2
  • $\begingroup$ I meant, at the beginning, before the content, because now it's in seperate notebook $\endgroup$
    – adolzi
    May 15, 2015 at 19:01
  • $\begingroup$ Please take a tour. You can always upvote the answer you find useful too. $\endgroup$
    – Kuba
    May 20, 2015 at 9:27

3 Answers 3

0
$\begingroup$

I don't know much about this package but you can either NotebookGet created notebook and NotebookWrite boxes in your notebook, or do something like

<< AuthorTools`

SelectionMove[EvaluationNotebook[], Before, Notebook];

NotebookWrite[
 EvaluationNotebook[],
 AuthorTools`MakeContents`MakeContentsNotebook[
    NotebookFileName@EvaluationNotebook[], 
    "Simple"]
 ]
$\endgroup$
1
  • $\begingroup$ I have tried this answer. The problem is that you do not get the format of contents right. See below my answer... $\endgroup$ Aug 26, 2015 at 13:04
3
$\begingroup$

It is important to notice that the notebook must be saved first to use the functions Paginate and MakeContents

<< AuthorTools`

nbkObj = SelectedNotebook[];
Paginate[nbkObj]
contObj = MakeContents[nbkObj, "Book"];

I can get the contents in the same notebook with...

NotebookWrite[nbkObj, NotebookGet[contObj]]

but I am loosing the previous "Book" format.

It seems the problem is how to copy the cells from the TOCNotebook and paste them in the main Notebook. I have tried also

 SelectionMove[contObj, All, Notebook]
 NotebookWrite[nbkObj, NotebookRead[contObj]]

and even

 NotebookWrite[nbkObj, NotebookImport[contObj]]

but the content style is lost. Any alternatives to preserve also the style of contents while pasting in the same notebook? I was looking also in SE questions related to how one can copy and past cells from one notebook to another preserving the format. But I cannot find the right answer to my question.

$\endgroup$
0
$\begingroup$

"...but the content style is lost." The stylesheet used in the TOC.nb file is the HelpBrowser.nb file. I have copied TOCSection, TOCSubsection and TOCSubsubsection styles from the HelpBrowser.nb file to the style file I use for my writing notebooks. You will note that there is a TabSpacings setting in those styles which controls where the page number is printed.

$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .