# scrwfile removes partial Toc created with titletoc

I am using titletoc to create a partial toc at the beginning of each \part.

Now I introduced the package scrwfile to get more \write outputs. This however also removes the partial toc.

Is there a way to get it back using titletoc? Otherwise I would be interested in an alternative.

\documentclass{scrbook}
\usepackage{scrwfile}
\usepackage{titletoc}

\newcommand{\PartialToc}[1]{%
\startcontents[part]
\section*{\contentsname}
\printcontents[part]{}{0}{\setcounter{tocdepth}{#1}}
}

\begin{document}
\mainmatter
\tableofcontents

\PartialToc{1}
\chapter{first}
\chapter{second}
\stopcontents[part]

\PartialToc{1}
\chapter{One}
\chapter{Two}
\stopcontents[part]

\end{document}


I cannot say anything about the issue between scrwfile and titletoc other than Markus Kohm back in past frequently uttered about possible incompatibilities with such programs, that change KOMA-script class commands. I actually do not know, whether it is the case here. Regarding to titletoc’s “sister” package I wrote something about this a while ago, there may meanwhile have been changes for compatibility, though: Incompatibilities between KOMA-Script and titlesec.

But I can suggest an alternative: minitoc.

\documentclass{scrbook}

\usepackage{scrwfile}

\usepackage[nohints]{minitoc}
\mtcsetrules{parttoc}{off}
\mtcsettitle{parttoc}{Part Contents}
\mtcsettitlefont{parttoc}{\LARGE\bfseries\sffamily} % "\sffamily" is KOMA-script default

\newcommand{\setparttoc}[1]{%
\mtcsetdepth{parttoc}{#1} % "0" as usual chapter depth
\parttoc
}

\begin{document}
\doparttoc

\mainmatter
\tableofcontents

\setparttoc{0}

\chapter{First Chapter}
\section{First section}
\chapter{Second Chapter}
\section{First section, again}

\setparttoc{1}

\chapter{Chapter One}
\section{Another first section}
\chapter{Chapter Two}
\section{Why first sections only?}

\end{document}


Output of example in question (with scrwfile deactivated):

Output of example above in answer:

This can surely be more fine tuned, but it shows the idea. Adding

\renewcommand*{\mtcgapbeforeheads}{-50pt}

BTW for users, who know what they are doing: scrwfile prints out a warning into the log file claiming to be in Alpha state. This warning can be removed with the package silence.
• That you use titlesec you did not mention … There are working packages with last changes before 2008 … What do you mean with interface? Do you mean: The documentation is far from ideal. I made two of my edits, because the recommended command is mentioned much later than the older one, especially on the places, where the older commands are explained often no hint to the newer version is given. (I am not a regular user user until now.) Otherwise there are worse documentations. – Speravir Jan 21 '14 at 15:55