5
$\begingroup$

I am creating a 'Table of contents' (TOC) generator not unlike the AuthorTools. My "generator" creates cells like the following in the TOC.nb:

Cell[
  TextData[{
    CounterBox["Chapter",
               {FrontEnd`FileName[{$RootDirectory, "X:","Daten","fh-fsi-beuth",
                                                       "Test-HeaderFooter.nb"
                                  }, 
                                  CharacterEncoding -> "WindowsANSI"
                                 ], 
                    "testTag"
                   }
        ],
    "  Allgemeine Grundlagen",
    " ",
    Cell[
      TextData[
        ButtonBox[
          CounterBox["Page", 
                     {FrontEnd`FileName[{$RootDirectory, "X:","Daten","fh-fsi-beuth",
                                                         "Test-HeaderFooter.nb"
                                         }, CharacterEncoding -> "WindowsANSI"
                                       ], 
                      "tagTest"
                     }
          ],
          BaseStyle->"PageLink",
          ButtonData->{"X:\\Daten\\fh-fsi-beuth\\Test-HeaderFooter.nb", "tagTest"}
        ]
      ], 
    "TOCPage"
    ]
   }
  ], 
  "TOCChapter"
]

The link in the ButtonData-Rule works, I can jump right into the target notebook (which is assumed to be open). But neither the Chapter number nor the Page number is generated. Here the error message is, that the notebook is not found.

My question is, what is the right syntax for CounterBox["Chapter",{???????, "testTag"}] and how can I produce it from my "TOCgenerator"?

$\endgroup$
  • $\begingroup$ For the page number to work it might be that you have to set the option "Show Page Breaks" in File>Printing Settings. $\endgroup$ – Sjoerd C. de Vries Feb 29 '16 at 21:54
  • $\begingroup$ Related: 476. $\endgroup$ – Sjoerd C. de Vries Feb 29 '16 at 21:58
  • $\begingroup$ Thank you very much for your fast comment. This is one of the first steps I do with the target notebook. I found out it all depend on first saving both notebooks AND to evaluate just something in the TOC notebook (3+7). $\endgroup$ – Darwin1871 Feb 29 '16 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.