Monday, 12 August 2013

How do I fix Memoir's header "Contents" in the Sniplets section?

How do I fix Memoir's header "Contents" in the Sniplets section?

In memoir I really like the way how custom entities are being referred to,
such as the sniplets in its manual. It lets you define a set of items just
like Figures and Tables. I'm reusing this code for other purposes, but I
noticed a small glitch that's also present in the memoir manual itself.
All pages in the Sniplets section have a header "Contents" as shown below.

I suspect that something in the \sniplettoc macro is causing this. The
relevant lines from the memsty.sty file:
%%%% SNIPLETS %%%%
\newcounter{sniplet}
\counterwithin{sniplet}{chapter}
\newcommand*\snipletname{Sniplet}
\newcommand*\snipletref[1]{\snipletname~\ref{#1} on~\pref{#1}}
\newenvironment{sniplet}[1][]{
\refstepcounter{sniplet}
\edef\mem@e{\@ifnotmtarg{#1}{~(#1)}}
\section*{\snipletname~\thesniplet\mem@e}
\phantomsection
\addcontentsline{toc}{section}{\snipletname\ \thesniplet\mem@e}
\renewenvironment{lcode}{%\@zeroseps
\renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
\small\setlength{\baselineskip}{\onelineskip}\verbatim}%
{\endverbatim
\vspace{-0.75\baselineskip}%
\noindent}
}{}
\let\normalchangetocdepth\changetocdepth
\newcommand\sniplettoc{%
\setcounter{@memmarkcntra}{\value{tocdepth}}%
\begingroup%
\let\changetocdepth\@gobble%
\normalchangetocdepth{-10}%
\cftinsertcode{start-sniplets}{\normalchangetocdepth{3}}%
\cftinsertcode{end-sniplets}{\normalchangetocdepth{-10}}%
\let\tocheadstart\relax%\@gobble
% \printtoctitle\@gobble
\renewcommand\printtoctitle[1]{\section*{Sniplet overview}}%
\let\aftertoctitle\relax%
\let\printtocnonum\relax%
\let\precistoctext\@gobble%
\setlength\cftsectionindent{0pt}%
\tableofcontents*
\endgroup
\setcounter{tocdepth}{\value{@memmarkcntra}}
}
How do I fix this?

No comments:

Post a Comment