[Tex/LaTex] Remove chapter from ToC

sectioningtable of contents

\documentclass{mwrep}    
\begin{document}
\tableofcontents
\chapter{c1}
\chapter{c2}
\chapter*{c3}
\chapter*{c4}
\section*{s}
\chapter{c5}
\end{document}

I know chapter* removes a chapter from numbering. How can I remove it also from ToC?
I want to remove c4 but not c3.

Best Answer

To remove from the ToC all the entries associated with \chapter* you need to redefine the \chapter@toc command implemented in mwrep.cls; the following example code includes the necessary redefinition:

\documentclass{mwrep} 

\makeatletter
\renewcommand*\chapter@toc{%
  \ifHeadingNumbered\typeout{\@chapapp\space\thechapter.}
  \addcontentsline{toc}{chapter}{%
        \ifHeadingNumbered
 \protect\numberline{\mw@seccntformat{\HeadingNumber}}%
        \fi
            \HeadingTOCText}\fi%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  }
\makeatother

\begin{document}
\tableofcontents
\chapter{c1}
\chapter{c2}
\chapter*{c3}
\end{document}

To remove from the ToC only a particular entry associated with \chapter* you could 1) use the tocvsec2 package:

\documentclass{mwrep} 
\usepackage{tocvsec2}

\begin{document}
\tableofcontents
\chapter{c1}
\chapter{c2}
\chapter*{c3}
\settocdepth{part}
\chapter*{c4}
\settocdepth{section}
\end{document}

or 2) Use \addtocontents to appropriately change the value of the tocdepth counter:

\documentclass{mwrep} 

\begin{document}
\tableofcontents
\chapter{c1}
\chapter{c2}
\chapter*{c3}
\addtocontents{toc}{\setcounter{tocdepth}{-1}}
\chapter*{c4}
\addtocontents{toc}{\setcounter{tocdepth}{2}}
\end{document}
Related Question