2
%
%-------------------------------------------------------------------------- %
\documentclass[11pt]{book} %
%-------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amsfonts,amssymb} %
\usepackage{graphicx}
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} % more advanced but essential here
\usepackage{appendix} %
\usepackage[many]{tcolorbox}
\usepackage[english]{babel} %
\usepackage{fancyhdr} %
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm
\usepackage[dvips=true,pdftex=true,verbose]{geometry}
\usepackage{imakeidx}
\usepackage{stackengine}
\usepackage{pst-all}
\usepackage{pstricks-add}

\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm

\paperwidth=170mm
\paperheight=240mm
\setlength{\textwidth}{132mm} % width of text [133mm]
\setlength{\oddsidemargin}{0mm} % odd page, controls left margin [result: 25mm margin]
\setlength{\evensidemargin}{-12mm} % even page, controls right margin [result: 25mm margin]
\setlength{\headwidth}{\textwidth}
\setlength{\topmargin}{-20mm} % clear above header
\setlength{\headheight}{15mm} % height of head [15mm]
\setlength{\headsep}{6mm} % between header and text [6mm]
\setlength{\textheight}{195mm} % height of text exclusive of header/footer [195]

\setcounter{secnumdepth}{4} %
\setcounter{section}{1} % was 1
\setcounter{tocdepth}{2} % depth in contents lists

\definecolor{ThemeColour}{rgb}{0.44,0.00,0.44} % ThemeColour or navy blue
\definecolor{LightOrange}{rgb}{0.95,0.80,0.85} % ThemeColour or navy blue

\newcommand\Hrule{\noindent\color{ThemeColour}{\rule{\linewidth}{3pt}}} %
\newcommand\hseprule{\color{DarkRed}{\rule{\linewidth}{0.8pt}}} %

\begin{document} % start

% --------------- FORMATS for BODY HEADERS --------------------------------------- %

\titleformat{\chapter}[display]
{\color{ThemeColour}\bfseries\itshape\fontsize{30}{30}\selectfont}
{\Hrule\vspace*{6pt}\\ {\color{black}\,\chaptername\hspace{8pt}\normalfont\fontsize{42}{45}\selectfont{\thechapter}}}
{0pt}
{\bfseries\normalfont\fontsize{15}{18}\selectfont {#1} \\ \vspace*{-9pt}\Hrule} %
[\vspace{18pt}]
\titlespacing{\chapter}{0pt}{12pt}{6pt}[0pt] %
\renewcommand{\thechapter}{\arabic{chapter}} % make-up of the numbering

\tcbset{boxsep=5.4pt,height=18mm,boxrule=1.2pt,arc=3pt,outer arc=3.2pt,valign=center,width=\linewidth,
coltitle=white,colbacktitle=ThemeColour,after=\hfill,colframe=black,colback=LightOrange}

\newtcolorbox{sectionbox}[2][] % create sectionbox
{title={#2},fonttitle=\bfseries,#1}

\titleformat{\section} %
  {\normalfont\bfseries\itshape\fontsize{12}{14}\selectfont}
  {}{0pt}
{\begin{sectionbox}{\fontsize{14}{15}\selectfont{Section\hspace{5.4pt}\thetitle}}{\fontsize{12.8}{15}\selectfont{#1}}
\end{sectionbox}}
\titlespacing{\section}{0pt}{15pt}{6pt}[0pt] %
\renewcommand{\thesection}{\arabic{section}} % make-up of number

% -------------- TOC TOC TOC TOC TOC entries for \titletoc ------------------------- %

\newbool{numbered} % TOC
\titlecontents{chapter}[0pt] % TOC
    {\protect\vspace*{12pt}\bfseries\fontsize{13.2}{15}\selectfont} %
    {\global\booltrue{numbered} \hspace{12pt}\contentslabel[{\fontsize{18}{21}\selectfont\chaptername\hspace{5.4pt}\thecontentslabel}]
    {0pt}\brlap[1.35\baselineskip]}
    {\global\boolfalse{numbered}} %
    {\ifbool{numbered}{\hphantom{\chaptername\hspace{5.4pt}\thecontentslabel\hspace{10pt}}}{}
    \titlerule[0pt]\fontsize{12}{14}\normalfont\selectfont\contentspage\;} %
    [\addvspace{8pt}{\color{ThemeColour}\titlerule[2.4pt]}\addvspace{8pt}] % 12pt 2.4pt

\titlecontents{section}[4pt] % TOC
    {\addvspace{4.8pt}} % 2.4pt
    {\textbf{Section\hspace{3.2pt}\thecontentslabel}\hspace{7.2pt}} % 3.2pt 7.2pt
    {}{\;\normalfont\titlerule*[12pt]{.}\contentspage\:} % 12pt
    [\addvspace{-1pt}] % 1pt

\clearpage

\setcounter{page}{1} %
\tableofcontents

% -------------------------- MAINMATTER --------------------------------------------- %

\begin{mainmatter}

\chapter{Should be chapter ONE - OK}

\section{Should be Section 1 of chapter ONE - OK}

\chapter{Should be chapter TWO - OK}

\end{mainmatter}

% -------------------------- APPENDICES --------------------------------------------- %

\begin{appendix}

\renewcommand\chaptername{Appendix}

\chapter{Should be Appendix A - XXX in TOC}

\chapter{Should be Appendix B - XXX in TOC}

\end{appendix}

% ------------------------- BACKMATTER ---------------------------------------------- %

\begin{backmatter}

\; % bibliography, index - no entries

\end{backmatter}

\end{document}
0

1 Answer 1

7

Note that \mainmatter, \appendix and \backmatter are commands not environments.

Add the following lines in your preamble (notice that I've moved \renewcommand\chaptername{Appendix} here so you can delete that just after \appendix)

\makeatletter
\g@addto@macro{\appendix}{%
  \renewcommand\chaptername{Appendix}%
  \addtocontents{toc}{\protect\renewcommand*{\protect\chaptername}{\protect\appendixname}}%
}
\makeatother

and change the mentioned environments to the corresponding commands.

MWE

%
%-------------------------------------------------------------------------- %
\documentclass[11pt]{book} %
%-------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amsfonts,amssymb} %
\usepackage{graphicx}
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} % more advanced but essential here
\usepackage{appendix} %
\usepackage[many]{tcolorbox}
\usepackage[english]{babel} %
\usepackage{fancyhdr} %
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm
\usepackage[dvips=true,pdftex=true,verbose]{geometry}
\usepackage{imakeidx}
\usepackage{stackengine}
\usepackage{pst-all}
\usepackage{pstricks-add}

\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm

\paperwidth=170mm
\paperheight=240mm
\setlength{\textwidth}{132mm} % width of text [133mm]
\setlength{\oddsidemargin}{0mm} % odd page, controls left margin [result: 25mm margin]
\setlength{\evensidemargin}{-12mm} % even page, controls right margin [result: 25mm margin]
\setlength{\headwidth}{\textwidth}
\setlength{\topmargin}{-20mm} % clear above header
\setlength{\headheight}{15mm} % height of head [15mm]
\setlength{\headsep}{6mm} % between header and text [6mm]
\setlength{\textheight}{195mm} % height of text exclusive of header/footer [195]

\setcounter{secnumdepth}{4} %
\setcounter{section}{1} % was 1
\setcounter{tocdepth}{2} % depth in contents lists

\definecolor{ThemeColour}{rgb}{0.44,0.00,0.44} % ThemeColour or navy blue
\definecolor{LightOrange}{rgb}{0.95,0.80,0.85} % ThemeColour or navy blue

\newcommand\Hrule{\noindent\color{ThemeColour}{\rule{\linewidth}{3pt}}} %
\newcommand\hseprule{\color{DarkRed}{\rule{\linewidth}{0.8pt}}} %

\makeatletter
\g@addto@macro{\appendix}{%
  \renewcommand\chaptername{Appendix}%
  \addtocontents{toc}{\protect\renewcommand*{\protect\chaptername}{\protect\appendixname}}%
}
\makeatother

\begin{document} % start

% --------------- FORMATS for BODY HEADERS --------------------------------------- %

\titleformat{\chapter}[display]
{\color{ThemeColour}\bfseries\itshape\fontsize{30}{30}\selectfont}
{\Hrule\vspace*{6pt}\\ {\color{black}\,\chaptername\hspace{8pt}\normalfont\fontsize{42}{45}\selectfont{\thechapter}}}
{0pt}
{\bfseries\normalfont\fontsize{15}{18}\selectfont {#1} \\ \vspace*{-9pt}\Hrule} %
[\vspace{18pt}]
\titlespacing{\chapter}{0pt}{12pt}{6pt}[0pt] %
\renewcommand{\thechapter}{\arabic{chapter}} % make-up of the numbering

\tcbset{boxsep=5.4pt,height=18mm,boxrule=1.2pt,arc=3pt,outer arc=3.2pt,valign=center,width=\linewidth,
coltitle=white,colbacktitle=ThemeColour,after=\hfill,colframe=black,colback=LightOrange}

\newtcolorbox{sectionbox}[2][] % create sectionbox
{title={#2},fonttitle=\bfseries,#1}

\titleformat{\section} %
  {\normalfont\bfseries\itshape\fontsize{12}{14}\selectfont}
  {}{0pt}
{\begin{sectionbox}{\fontsize{14}{15}\selectfont{Section\hspace{5.4pt}\thetitle}}{\fontsize{12.8}{15}\selectfont{#1}}
\end{sectionbox}}
\titlespacing{\section}{0pt}{15pt}{6pt}[0pt] %
\renewcommand{\thesection}{\arabic{section}} % make-up of number

% -------------- TOC TOC TOC TOC TOC entries for \titletoc ------------------------- %

\newbool{numbered} % TOC
\titlecontents{chapter}[0pt] % TOC
    {\protect\vspace*{12pt}\bfseries\fontsize{13.2}{15}\selectfont} %
    {\global\booltrue{numbered} \hspace{12pt}\contentslabel[{\fontsize{18}{21}\selectfont\chaptername\hspace{5.4pt}\thecontentslabel}]
    {0pt}\brlap[1.35\baselineskip]}
    {\global\boolfalse{numbered}} %
    {\ifbool{numbered}{\hphantom{\chaptername\hspace{5.4pt}\thecontentslabel\hspace{10pt}}}{}
    \titlerule[0pt]\fontsize{12}{14}\normalfont\selectfont\contentspage\;} %
    [\addvspace{8pt}{\color{ThemeColour}\titlerule[2.4pt]}\addvspace{8pt}] % 12pt 2.4pt

\titlecontents{section}[4pt] % TOC
    {\addvspace{4.8pt}} % 2.4pt
    {\textbf{Section\hspace{3.2pt}\thecontentslabel}\hspace{7.2pt}} % 3.2pt 7.2pt
    {}{\;\normalfont\titlerule*[12pt]{.}\contentspage\:} % 12pt
    [\addvspace{-1pt}] % 1pt

\clearpage

\setcounter{page}{1} %
\tableofcontents

% -------------------------- MAINMATTER --------------------------------------------- %

\mainmatter

\chapter{Should be chapter ONE - OK}

\section{Should be Section 1 of chapter ONE - OK}

\chapter{Should be chapter TWO - OK}


% -------------------------- APPENDICES --------------------------------------------- %

\appendix

\chapter{Should be Appendix A - XXX in TOC}

\chapter{Should be Appendix B - XXX in TOC}

% ------------------------- BACKMATTER ---------------------------------------------- %

\backmatter

\; % bibliography, index - no entries


\end{document} 

Output

enter image description here


If you want to keep the appendices environment, instead of adding the above lines in your preamble, add the following:

\AtBeginEnvironment{appendices}{%
  \renewcommand\chaptername{Appendix}%
  \addtocontents{toc}{\protect\renewcommand*{\protect\chaptername}{\protect\appendixname}}%
}

MWE

%
%-------------------------------------------------------------------------- %
\documentclass[11pt]{book} %
%-------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amsfonts,amssymb} %
\usepackage{graphicx}
\usepackage[explicit]{titlesec} %
\usepackage{titletoc} % more advanced but essential here
\usepackage{appendix} %
\usepackage[many]{tcolorbox}
\usepackage[english]{babel} %
\usepackage{fancyhdr} %
\usepackage[a4,frame,center]{crop} % a4=210mm x 297mm
\usepackage[dvips=true,pdftex=true,verbose]{geometry}
\usepackage{imakeidx}
\usepackage{stackengine}
\usepackage{pst-all}
\usepackage{pstricks-add}

\setlength{\unitlength}{1mm} % 1mm=2.834646pt; 1pt=0.3515mm

\paperwidth=170mm
\paperheight=240mm
\setlength{\textwidth}{132mm} % width of text [133mm]
\setlength{\oddsidemargin}{0mm} % odd page, controls left margin [result: 25mm margin]
\setlength{\evensidemargin}{-12mm} % even page, controls right margin [result: 25mm margin]
\setlength{\headwidth}{\textwidth}
\setlength{\topmargin}{-20mm} % clear above header
\setlength{\headheight}{15mm} % height of head [15mm]
\setlength{\headsep}{6mm} % between header and text [6mm]
\setlength{\textheight}{195mm} % height of text exclusive of header/footer [195]

\setcounter{secnumdepth}{4} %
\setcounter{section}{1} % was 1
\setcounter{tocdepth}{2} % depth in contents lists

\definecolor{ThemeColour}{rgb}{0.44,0.00,0.44} % ThemeColour or navy blue
\definecolor{LightOrange}{rgb}{0.95,0.80,0.85} % ThemeColour or navy blue

\newcommand\Hrule{\noindent\color{ThemeColour}{\rule{\linewidth}{3pt}}} %
\newcommand\hseprule{\color{DarkRed}{\rule{\linewidth}{0.8pt}}} %

\AtBeginEnvironment{appendices}{%
  \renewcommand\chaptername{Appendix}%
  \addtocontents{toc}{\protect\renewcommand*{\protect\chaptername}{\protect\appendixname}}%
}

\begin{document} % start

% --------------- FORMATS for BODY HEADERS --------------------------------------- %

\titleformat{\chapter}[display]
{\color{ThemeColour}\bfseries\itshape\fontsize{30}{30}\selectfont}
{\Hrule\vspace*{6pt}\\ {\color{black}\,\chaptername\hspace{8pt}\normalfont\fontsize{42}{45}\selectfont{\thechapter}}}
{0pt}
{\bfseries\normalfont\fontsize{15}{18}\selectfont {#1} \\ \vspace*{-9pt}\Hrule} %
[\vspace{18pt}]
\titlespacing{\chapter}{0pt}{12pt}{6pt}[0pt] %
\renewcommand{\thechapter}{\arabic{chapter}} % make-up of the numbering

\tcbset{boxsep=5.4pt,height=18mm,boxrule=1.2pt,arc=3pt,outer arc=3.2pt,valign=center,width=\linewidth,
coltitle=white,colbacktitle=ThemeColour,after=\hfill,colframe=black,colback=LightOrange}

\newtcolorbox{sectionbox}[2][] % create sectionbox
{title={#2},fonttitle=\bfseries,#1}

\titleformat{\section} %
  {\normalfont\bfseries\itshape\fontsize{12}{14}\selectfont}
  {}{0pt}
{\begin{sectionbox}{\fontsize{14}{15}\selectfont{Section\hspace{5.4pt}\thetitle}}{\fontsize{12.8}{15}\selectfont{#1}}
\end{sectionbox}}
\titlespacing{\section}{0pt}{15pt}{6pt}[0pt] %
\renewcommand{\thesection}{\arabic{section}} % make-up of number

% -------------- TOC TOC TOC TOC TOC entries for \titletoc ------------------------- %

\newbool{numbered} % TOC
\titlecontents{chapter}[0pt] % TOC
    {\protect\vspace*{12pt}\bfseries\fontsize{13.2}{15}\selectfont} %
    {\global\booltrue{numbered} \hspace{12pt}\contentslabel[{\fontsize{18}{21}\selectfont\chaptername\hspace{5.4pt}\thecontentslabel}]
    {0pt}\brlap[1.35\baselineskip]}
    {\global\boolfalse{numbered}} %
    {\ifbool{numbered}{\hphantom{\chaptername\hspace{5.4pt}\thecontentslabel\hspace{10pt}}}{}
    \titlerule[0pt]\fontsize{12}{14}\normalfont\selectfont\contentspage\;} %
    [\addvspace{8pt}{\color{ThemeColour}\titlerule[2.4pt]}\addvspace{8pt}] % 12pt 2.4pt

\titlecontents{section}[4pt] % TOC
    {\addvspace{4.8pt}} % 2.4pt
    {\textbf{Section\hspace{3.2pt}\thecontentslabel}\hspace{7.2pt}} % 3.2pt 7.2pt
    {}{\;\normalfont\titlerule*[12pt]{.}\contentspage\:} % 12pt
    [\addvspace{-1pt}] % 1pt

\clearpage

\setcounter{page}{1} %
\tableofcontents

% -------------------------- MAINMATTER --------------------------------------------- %

\mainmatter

\chapter{Should be chapter ONE - OK}

\section{Should be Section 1 of chapter ONE - OK}

\chapter{Should be chapter TWO - OK}


% -------------------------- APPENDICES --------------------------------------------- %

\begin{appendices}

\chapter{Should be Appendix A - XXX in TOC}

\chapter{Should be Appendix B - XXX in TOC}

\end{appendices}

% ------------------------- BACKMATTER ---------------------------------------------- %

\backmatter

\; % bibliography, index - no entries


\end{document} 

The output is the same as above.

2

You must log in to answer this question.

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