3

MWE:

\documentclass[a4paper,oneside]{scrbook}
\usepackage{minitoc}
\setcounter{tocdepth}{0} 

\begin{document}
\doparttoc
\tableofcontents

\part{Part 1}
\parttoc
\addstarredchapter{Chapter}
\chapter*{Chapter}
\chapter{Chapter 1}
\chapter{Chapter 2}

\part{Part 2}
\parttoc
\addstarredchapter{Chapter}
\chapter*{Chapter}
\chapter{Chapter 3}
\chapter{Chapter 4}

\end{document}

Currently the TOC looks like this:

enter image description here

What I want it to look like is:

enter image description here

Without loosing it in \parttoc as in the following image:

enter image description here

I don't want to use titletoc as suggested here.

1 Answers1

3

You can use the mtchideinmaintoc environment to hide information in the main ToC:

\documentclass[a4paper,oneside]{scrbook}
\usepackage{minitoc}
\setcounter{tocdepth}{0} 

\begin{document}
\doparttoc
\tableofcontents

\part{Part 1}
\parttoc
\begin{mtchideinmaintoc}
\addstarredchapter{Chapter}
\chapter*{Chapter}
\end{mtchideinmaintoc}
\chapter{Chapter 1}
\chapter{Chapter 2}

\part{Part 2}
\parttoc
\begin{mtchideinmaintoc}
\addstarredchapter{Chapter}
\chapter*{Chapter}
\end{mtchideinmaintoc}
\chapter{Chapter 3}
\chapter{Chapter 4}

\end{document}

The main ToC:

enter image description here

An image of one of the partial ToCs:

enter image description here

One can define a command to do this in a more succinct way:

\documentclass[a4paper,oneside]{scrbook}
\usepackage{minitoc}
\setcounter{tocdepth}{0} 

\newcommand\Mychapter[1]{%
\begin{mtchideinmaintoc}
\addstarredchapter{#1}
\chapter*{#1}
\end{mtchideinmaintoc}}

\begin{document}
\doparttoc
\tableofcontents

\part{Part 1}
\parttoc
\Mychapter{Chapter}
\chapter{Chapter 1}
\chapter{Chapter 2}

\part{Part 2}
\parttoc
\Mychapter{Chapter}
\chapter{Chapter 3}
\chapter{Chapter 4}

\end{document}

Of course, one could also make this redefinition for the internal command \@schapter (in charge of starred chapters); but this might have undesired side-effects since internally \chapter* is used for several document units (ToC, LoF, LoT, bibliographies, indexes):

\documentclass[a4paper,oneside]{scrbook}
\usepackage{minitoc}
\setcounter{tocdepth}{0} 

\makeatletter
\renewcommand*{\@schapter}[1]{%
\begin{mtchideinmaintoc}
\addstarredchapter{#1}
  \if@twocolumn
    \if@at@twocolumn
      \@makeschapterhead{#1}%
    \else
      \@topnewpage[\@makeschapterhead{#1}]%
    \fi
  \else
    \@makeschapterhead{#1}%
    \@afterheading
  \fi
\end{mtchideinmaintoc}
}
\makeatother

\begin{document}
\doparttoc
\tableofcontents

\part{Part 1}
\parttoc
\chapter*{Chapter}
\chapter{Chapter 1}
\chapter{Chapter 2}

\part{Part 2}
\parttoc
\chapter*{Chapter}
\chapter{Chapter 3}
\chapter{Chapter 4}

\end{document}
Gonzalo Medina
  • 505,128
  • Is there a way to simplify this so that it doesn't have to be done for each chapter*? Like some sort of renewcommand? – Scott Wilton Jun 24 '13 at 19:53
  • @ScottWilton one quick way would be to define a new command; please see my updated answer. – Gonzalo Medina Jun 24 '13 at 19:56
  • 1
    @ScottWiltonone could also think of redefining \chaper* to do this, but then some units might be wrongly listed: the ToC, the LoF, the LoT, an eventual bibliography, and eventual index all use internally \chapter* and the redefinition might cause those units to appear in the partial ToCs, which might not be desirable. – Gonzalo Medina Jun 24 '13 at 20:05
  • @ScottWilton I added to my answer the code doing the redefinition for \chapter* directly, but (as I mentioned) this might cause undesired side-effects (although after some tests, it appears to work as expected). – Gonzalo Medina Jun 24 '13 at 20:13