1

I'm getting a weird behavior with the memoir class and the titletoc package. I'm printing a partial TOC after each chapter (works perfectly), but for the last chapter, the appendices are also added into that toc. The following code shows a MWE of the problem:

\documentclass[openright,twoside]{memoir}
\usepackage{titletoc}

\begin{document}

\chapter{chap1}
\startcontents[chapters]
\maxtocdepth{section}
\printcontents[chapters]{}{1}{\small}

\section{chap1sec1}
\section{chap1sec2}

% chap 2

\chapter{chap2}

\startcontents[chapters]
\maxtocdepth{section}
\printcontents[chapters]{}{1}{\small}

\section{chap2sec1}
\section{chap2sec2}

\stopcontents[chapters] % adding this command avoid having appendices in previous partial toc

\appendix

\chapter{Appendix1}
\chapter{Appendix2}

\end{document}

Maybe I'm doing something wrong. How can I avoid having the Appendix1 et Appendix2 in the partial table of content from chapter 2 ?

Thanks for any advice, Fabian

  • Isn't there a \stopcontents command? I remember somehow... – user31729 Sep 16 '14 at 12:05
  • Thanks for the hint. Works perfectly. I edited the MWE with right way to do it. – Fabian Sep 17 '14 at 9:58
  • Alternatively you could use minitoc for small tocs inside of chapters/sections... – user31729 Sep 17 '14 at 14:21
  • @ChristianHupfer Wanna write up an answer? – Johannes_B Nov 9 '14 at 16:30
  • @Johannes_B: Old, but I've done so :-D – user31729 Oct 4 '15 at 12:05
2

As proposed to the O.P. and to close this question: \stopcontents[chapter] will close the ToC file and any further sectioning command won't appear in the ToC.

I doubt that titletoc and memoir should be used together, however.

\documentclass[openright,twoside]{memoir}
\usepackage{titletoc}

\begin{document}

\chapter{chap1}
\startcontents[chapters]
\maxtocdepth{section}
\printcontents[chapters]{}{1}{\small}

\section{chap1sec1}
\section{chap1sec2}

% chap 2

\chapter{chap2}

\startcontents[chapters]
\maxtocdepth{section}
\printcontents[chapters]{}{1}{\small}

\section{chap2sec1}
\section{chap2sec2}

\stopcontents[chapters] % adding this command avoid having appendices in previous partial toc

\appendix

\chapter{Appendix1}
\chapter{Appendix2}

\end{document}
| improve this answer | |

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.