1

I am looking for the code that allow me to append prefix "Chapter" to Chapter Entries only not for the front matter like Abstract, Declaration and also not for the Bibliography and appendices. Here below what I am looking for. I do not want Chapter to be printed before Candidate's Declaration, Abstract, Acknowledgment, LOF, LOT, List of abbreviations. I need it to be printed before Chapters only.

Here is what I used

\makeatletter

% Per-section appendicies
\newcounter{Appx}
\numberwithin{Appx}{chapter}
\def\@Appx[#1]#2{
\refstepcounter{Appx}
\section*{%
\addcontentsline{toc}{section}{\appendixname\ \Alph{Appx}\quad#1}%
\appendixname\ \Alph{Appx}\quad#2}
}
\def\@@Appx#1{\@Appx[#1]{#1}}
\def\Appx{\@ifnextchar[\@Appx\@@Appx}

% "Chapter" prefix in ToC
\let\@@l@chapter\l@chapter
\def\l@chapter#1{\@@l@chapter{\chaptername\ #1}}

\makeatother

Table of Contents

1
  • 1
    Please post not only a code snippet but a Minimum Working Example (MWE, starting with \documentclass and ending with \end{document}) that gives rise to the issue you're looking to fix. From the screenshot it would appear to be the case that you've customized the table of contents layout considerably -- in addition to providing an instruction that inserts "Chapter " before numbered and unnumbered "chapters". A solution to the "Chapter " business for unnumbered chapter-level entities will probably interact (interfere?!) with your other code, so it's important to know what you've done.
    – Mico
    May 9 '14 at 5:50
3

With titlese/titletocyou can do it. To mimick the formatting shown in your question, I had to load the etoolbox package in order not to include the table of contents in itself. As it seems to be rather complex to patch the abstract environment, I suggest you turn it into a \chapter* command. I supposed you were using the report class, which has no \front/mainmatter commands, so I provided them, to have roman numbering for \frontmatter — actually, I used small caps roman numbering (an old tradition in French typography), but that's easy to change if you don't like it.

    \documentclass[11pt, a4paper, twoside]{report}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{fourier}
    \usepackage{heuristica}
    \usepackage{microtype}

    \usepackage[pagestyles, explicit]{titlesec}%
    \usepackage{titletoc}%

    \usepackage{etoolbox}
    \newbool{addtoc}%initial value:  false
    \pretocmd{\lsstyle}{\SetTracking[no ligatures = {f}]{encoding = *}{50}}{}{}%

    \titleformat{name = \chapter}[display]%
    {\lsstyle\bfseries\Large\filcenter\vskip-4\baselineskip}
    {\LARGE\chaptername~\thechapter}
    {0.5pc}
    {\vspace{0.5pc}\Huge#1}%
    \titlespacing{\chapter}{0pt}{3\baselineskip}{8\baselineskip}

    \titleformat{name=\chapter, numberless}[display]
    {\vskip-4\baselineskip\lsstyle\bfseries\itshape\large\filcenter}
    {}
    {0.5pc}
    {\vspace{0.5pc}#1}%
    [\ifbool{addtoc}{\addcontentsline{toc}{chapter}{#1}}]%
     \titlespacing{name = \chapter, numberless}{0pt}{2\baselineskip}{8\baselineskip}

      \titlecontents{chapter}[0em]{\lsstyle\smallskip\bfseries}%\vspace{1cm}%
      {\contentslabel[\chaptername~\thecontentslabel]{0em}\hspace{5.6em}}%
      {\renewcommand\thecontentslabel{\relax}\itshape}%numberless%
      {\hfill\contentspage}[\medskip]%
    %
     \titlecontents{section}[4.25em]{\smallskip}%
      {\contentslabel[\thecontentslabel]{2em}}%numbered
      {\hspace*{-1em}}%numberless
      {\hfill\contentspage}[\smallskip]%
    %
     \titlecontents{subsection}[7em]{}%
      {\contentslabel[\thecontentslabel]{2.75em}}%numbered
      {\hspace*{-1em}}%numberless
      {\hfill\contentspage}[\smallskip]

    \renewcommand*{\contentsname}{\upshape TABLE OF CONTENTS \vspace{3\baselineskip}\par \hrule height 1pt\vskip1.5ex Contents\hfill Page No \vskip 1.5ex\par\hrule height 1pt\vskip -8\baselineskip}%
    \apptocmd{\tableofcontents}{\booltrue{addtoc}}{}{}

    \providecommand\frontmatter{\renewcommand\thepage{\scshape\mdseries\roman{page}}}%
    \providecommand\mainmatter{\clearpage\pagenumbering{arabic}}

    \begin{document}

    \frontmatter
    \tableofcontents

     \chapter*{Candidate’s Declaration}
     \chapter*{Abstract}
    \chapter*{Acknowledgments}
    \listoffigures
    \listoftables
    \chapter*{List of Abbreviations}

    \mainmatter

    \chapter{INTRODUCTION}

    \section{Motivation}
    \section{Introduction to Data Mining}
    \newpage

    \section{Steps for Knowledge Discovery in Databases Process}
    \section{Architecture of Data Mining System}
    \newpage

    \section{Datamining Techniques}
    \newpage

    \section{Classification}
    \subsection{Naive Bayes}
    \subsection{J48}
    \newpage

    \subsection{OneR}
    \subsection{ZeroR}
    \subsection{IBk (k nearest neighbor)}
    \section{Association Techniques}
    \section{Description of Heart disease dataset used in Experiment}

    \end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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