GeneralSwitching off titletoc for some chapters

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
pippipalma
Posts: 23
Joined: Mon Aug 20, 2012 5:12 pm

Switching off titletoc for some chapters

Post by pippipalma »

Hi!
I have a twocolumn document and I should insert the minitoc in the first chapters with titlesec and titletoc. However, if I change the \titleformat before appendices, all the sections of the appendix chapters will appear within the last minitoc:

Code: Select all

\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}

\newcommand\partialtocname{\contentsname}
% depending on this boolean, \chapter will create or not a partial ToC
\newif\ifchapterwithtoc
\chapterwithtocfalse

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
  [\ifchapterwithtoc
      \vspace*{2pc}\titlerule\vspace*{1pc}%
      \startcontents\vbox{\Large\partialtocname}\vskip1ex
      \printcontents{l}{1}{\setcounter{tocdepth}{1}}\vspace*{1pc}\titlerule%
    \else\fi%
  ]

\titlecontents*{lsection}[0pt]
  {\small\normalfont}{\thecontentslabel\space}{}
  {,~\itshape\thecontentspage}[\space\textbullet\space][.]
\titlecontents*{lsubsection}[0pt]{}{}{}{}

\begin{document}

\frontmatter
\chapter*{Acknowledgements}
\chapter*{Preface}
\tableofcontents

\mainmatter
\chapterwithtoctrue

\chapter{Chapter One}
\section{Section One One}
\section{Section One Two}
\section{Section One Three}

\chapter{Chapter Two}
\section{Section Two One}
\section{Section Two Two}

\appendix
\chapterwithtocfalse

\chapter{Appenix One}
\section{Section A One}
\section{Section A Two}
\chapter{Appenix Two}
\section{Section B One}
\section{Section B Two}

\end{document}
Any suggestion?
Thanks!

Giuseppe

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10347
Joined: Mon Mar 10, 2008 9:44 pm

Switching off titletoc for some chapters

Post by Stefan Kottwitz »

Hi Giuseppe,

you could simply use \stopcontents at the beginning of the appendix to prevent that:

Code: Select all

\appendix
\chapterwithtocfalse
\stopcontents
\startcontents already stops the previous partial content, however to finally stop you need it here.

Stefan
LaTeX.org admin
pippipalma
Posts: 23
Joined: Mon Aug 20, 2012 5:12 pm

Re: Switching off titletoc for some chapters

Post by pippipalma »

Hi Stefan,
thanks a lot!

Giuseppe
Post Reply