# [NTG-context] toc and macro

Wolfgang Schuster schuster.wolfgang at gmail.com
Thu May 28 12:47:13 CEST 2015

> Am 27.05.2015 um 20:13 schrieb Harry <irgksjd at gmx.de>:
>
> Hi,
>
> I hope that this is the right address to post my question. If not I
> would be glad for a tip.
>
> I wanted to do something like this:
>
> _______________________
>
> \unprotect
>
> %This line uncommented leads to an error
> \def\tit{Oops!}
>
> \def\Teil{\dodoubleempty\doTeil}
> \def\doTeil[#1][#2]#3{%
>  \def\tit{#1}
> %...
>  \startchapter[title={\tit},reference={#2}]
>    #3
>  \stopchapter
> %...
> }
>
>
> \protect
>
> \starttext
>
>  \completecontent
>
>  \doTeil[Hallo][hallo]{Text Text Text Text Text Text Text}

Why do you \doTeil and not not \Teil?

> \stoptext
>
> _______________________
>
> It works if i use #1 direct (like this):
>  \startchapter[title=#1,reference={#2}]
> But how can I wrap it in the \tit?
> (wrapping #2 works fine)
>
> I wanted to programm \doTeil so, that I can nest it freely (for example
> with \input) and the table of content uses the hierarchy of the nesting
> to produce a nice TOC.

Is there a reason why you can use use \chapter[<reference>][<title>] in your document,
I can’t see any advantage with your command.

Wolfgang