2

Consider the following MWE:

\documentclass[ms, 12pt]{kfupm_thesis}
\usepackage{apptools, etoolbox}
% code to fix TOC appendix format, irrelevant for this question
\makeatletter
\patchcmd{\@chapter}{\protect {CHAPTER }}{\ifappendix{APPENDIX }\else{CHAPTER }\fi}{}{}
\makeatother

\begin{document}

\tableofcontents

\chapter{First Chapter}
\section{BLA}
\subsection{BLA-BLA}

\chapter{Second Chapter}
\section{BLA}
\subsection{BLA-BLA}

\appendix
\chapter{Parameters}
\section{BLA}
\subsection{BLA-BLA}

\end{document} 

Producing the following TOC:

enter image description here

In the TOC alone, I would like to keep the heading APPENDIX A PARAMETERS but hide all of its sub-entries i.e. A.1 BLA and A1.1.1 BLA-BLA. Can you suggest a way to do it. The class file kfupm_thesis.cls can be obtained from this dropbox link, needed to run MWE.

2 Answers 2

1

Here is a solution. Not very elegant: redefining \addcontentsline, but it works:

\documentclass[ms, 12pt]{kfupm_thesis}
\usepackage{apptools, etoolbox}
% code to fix TOC appendix format, irrelevant for this question
\makeatletter
\patchcmd{\@chapter}{\protect {CHAPTER }}{\ifappendix{APPENDIX }\else{CHAPTER }\fi}{}{}
\AtAppendix{%
\def\addcontentsline#1#2#3{%
  \ifstrequal{#2}{section}{\relax}{%
   \ifstrequal{#2}{subsection}{\relax}{\addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}}}
   }}%
   }%
\makeatother

\begin{document}

\tableofcontents

\chapter{First Chapter}
\section{BLA}
\subsection{BLA-BLA}

\chapter{Second Chapter}
\section{BLA}
\subsection{BLA-BLA}

\appendix
\chapter{Parameters}
\section{BLA}
\subsection{BLA-BLA}

\chapter{Other Parameters}

\end{document} 

enter image description here

2

If sections etc. should be hidden, set the tocdepth counter to 0, however, this might be done in place, i.e. write \setcounter{tocdepth}{0} to the .toc file, after \appendix.

(The 0 stands for \chapter, \section would have 1 etc., therefore 0 will restrict to toc levels down to \chapter only, which is normally \part and \chapter will appear.)

\documentclass[ms, 12pt]{kfupm_thesis}
\usepackage{apptools, etoolbox}
% code to fix TOC appendix format, irrelevant for this question
\makeatletter
\patchcmd{\@chapter}{\protect {CHAPTER }}{\ifappendix{APPENDIX }\else{CHAPTER }\fi}{}{}
\makeatother


\begin{document}

\tableofcontents

\chapter{First Chapter}
\section{BLA}
\subsection{BLA-BLA}

\chapter{Second Chapter}
\section{BLA}
\subsection{BLA-BLA}

\appendix
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}

\chapter{Parameters}
\section{BLA}
\subsection{BLA-BLA}

\end{document}

enter image description here

Update

A version for working LoT and LoF as well.

\documentclass[ms, 12pt]{kfupm_thesis}
\usepackage{apptools}
\usepackage{etoolbox}
% code to fix TOC appendix format, irrelevant for this question
\makeatletter
\patchcmd{\@chapter}{\protect {CHAPTER }}{\ifappendix{APPENDIX }\else{CHAPTER }\fi}{}{}
\pretocmd{\listoffigures}{\addtocontents{lof}{\protect\setcounter{tocdepth}{1}}}{}{}
\pretocmd{\listoftables}{\addtocontents{lot}{\protect\setcounter{tocdepth}{1}}}{}{}
\makeatother


\begin{document}

\tableofcontents
\listoffigures
\listoftables

\chapter{First Chapter}
\section{BLA}
\subsection{BLA-BLA}

\chapter{Second Chapter}
\section{BLA}
\subsection{BLA-BLA}

\appendix
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}

\chapter{Parameters}

\begin{figure}
\caption{A figure}
\end{figure}
\section{BLA}
\subsection{BLA-BLA}

\begin{table}
\caption{A table}
\end{table}

\end{document} 
4
  • This solution works, however, if there are tables and figures in the document, the LIST OF FIGURES and LIST OF TABLES vanish. They just display a blank page with headings only, no actual lists. Is there a work-around?
    – Adeel
    Jan 21, 2016 at 20:15
  • @AdeelSabir: Did you mention tables and figures at all? No, you didn't
    – user31729
    Jan 22, 2016 at 17:34
  • That's right, in the MWE there aren't any tables of figures. However, in that actual manuscript (very long) that I am writing, there are. It'd be great if you could suggest a solution that also take those into account. Thanks a lot for the input!
    – Adeel
    Jan 23, 2016 at 18:46
  • @AdeelSabir: See the update please!
    – user31729
    Jan 23, 2016 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .