% chaptoc.sty
% Kapitelstartseite mit Mini-TOC
% Format Mini-TOC
\newcommand{\l@chapentry}[2]
{\renewcommand{\numberline}[1]
 {\parbox[r]{2em}{##1}}
  #1\\}

% erweitere Mini-TOC bei jeder \section
\renewcommand{\sectionmark}[1]
{\markright{\sffamily\thesection\quad#1}
 \myaddtocont{\protect\contentsline{chapentry}%
    {\protect\numberline{\thesection}#1}{\thepage}}
}

%  Aus LaTeX.ltx mit Aenderungen fuer Mini-TOC
\renewcommand{\@makechapterhead}[1]
{\vspace*{3em}\noindent%
 \textsf{\Large\thechapter\quad #1}\\*[2em]
 \rule{\textwidth}{0.5pt}
 \noindent\@mystarttoc{t\thechapter}\par
 \vspace*{3em}}

% Sternform ohne TOC
\renewcommand{\@makeschapterhead}[1]
{\vspace*{3em}\noindent\textsf{\Large#1}\\*[3em]}

% allokiere einen einzigen Ausgabestream
\newwrite\shorttoc

% Uebernahme aus LaTeX.ltx mit Anpassungen ---
% liest Mini-TOC ein und setze Ausgabestream
% auf neue Datei. 
\newcommand{\@mystarttoc}[1]
{\begingroup
 \makeatletter
 \typeout{input jobname.#1}
 \@input{\jobname.#1}
 \protected@write\@auxout
   {\let\label\@gobble \let\index\@gobble
    \let\glossary\@gobble}%
   {\immediate\openout\shorttoc \jobname.#1\relax}
 \global\@nobreakfalse\endgroup}

\newcommand{\myaddtocont}[1]
{\protected@write \@auxout
  {\let\label\@gobble \let\index\@gobble
   \let\glossary\@gobble}%
  {\string\@mywritefile{#1}}}

\newcommand{\@mywritefile}[1]
{\@temptokena{#1}
 \immediate\write\shorttoc{\the\@temptokena}}

\AtEndDocument{\protected@write\@auxout
 {}{\immediate\closeout\shorttoc}}