Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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.

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

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}
share|improve this answer
    
And this makes every chapter* excluded? This is not what I want. I corrected my question because it was misleading. –  Ichibann Jul 27 '11 at 22:49
    
@Ichibann: Yes. I've updated my answer to provide a solution for the new requirement. –  Gonzalo Medina Jul 27 '11 at 23:00
    
Your secont way does not work (in example as in my edited question). First works without problems. –  Ichibann Jul 27 '11 at 23:54
    
@Ichibann: what exactly doesn't work? In your new edit what do you want to remove from the ToC? –  Gonzalo Medina Jul 28 '11 at 0:28
    
@GonzaloMedina Solution 2) makes the ToC disappear completely. Solution 1) works great. –  stanwise Sep 13 '12 at 15:23
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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