2

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

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

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

\end{document}
1

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

\part{Part Heading First}
\setparttoc{0}

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

\part{Part Heading Second}
\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 in question

Output of example above in answer:

output of example in answer

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

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

will the appearance adapt more to the one from question. The values are by the way the opposite of the defaults for these part toc commands.


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.

  • I have not tested your example in my template yet, but I intentionally removed minitoc from the template a long time ago, though I can not remember the reasons. It may be related to the fact that it causes likely incompatibilities, is not maintained anymore (since 2008) and has a horrible interface... – Matthias Pospiech Jan 21 '14 at 7:17
  • Here is a post about minitoc being incompatible with titlesec, which I also use: latex-community.org/forum/viewtopic.php?f=5&t=7182 – Matthias Pospiech Jan 21 '14 at 8:33
  • 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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.