1

I have my appendices in the backmatter and in the table of contents I am getting the appendix title only and I want to have the appendix label before the appendix title e.g

Chapter 1...........XYZ
Chapter 2...........ABC
Appendix A..........Derivation of X
Appendix B..........Derivation of Y

I have tried the solutions provided to this question but none seems to be working for me. I am using Texlive 2022 (up to date) alongside Texstudio (latest version).

Also, I want to have a new chapter style for the Appendices only that is different from the rest of the other chapters. Is it possible? Below is the picture showing my problem and MWE respectively:

The picture indicating the problem I am facing

\documentclass[11pt,openany,twoside]{book} \raggedbottom \let\cleardoublepage=\clearpage \usepackage[a4paper]{geometry} \usepackage{parskip} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} \usepackage{array} \usepackage{xcolor, graphicx} \usepackage[dotinlabels]{titletoc} \usepackage{background} \backgroundsetup{contents={}} \usepackage{helvet} \usepackage{color} \usepackage{fancyhdr} \usepackage{hhline} \pagestyle{fancy} \usepackage{booktabs} \usepackage[noindentafter,calcwidth]{titlesec} \titleformat{\section} {\normalfont\Large\bfseries\color{black}} {\thesection}{1em}{} \titleformat{\subsection} {\normalfont\large\bfseries\color{black}} {\thesubsection}{1em}{} \usepackage{calc,pifont} \usepackage{longtable} \usepackage{multirow} \usepackage{colortbl} \newcommand*\myheaderfooterfont{\normalfont\bfseries} \makeatletter \renewcommand\@biblabel[1] {\textsuperscript{#1}} \makeatother \usepackage[nottoc]{tocbibind} \usepackage{verbatim} \usepackage[ragged]{sidecap} \usepackage{caption} \captionsetup[table]{skip=5pt} \usepackage[marginal]{footmisc} \renewcommand\footnoterule{\vspace*{-3pt}% \hrule width 2in height 1.4pt \vspace*{2.6pt}} \setlength\footnotemargin{10pt} \usepackage{tocloft} \renewcommand{\cfttoctitlefont}{\hfill\normalfont\bfseries\huge} \renewcommand{\cftloftitlefont}{\hfill\normalfont\bfseries\huge} \renewcommand{\cftlottitlefont}{\hfill\normalfont\bfseries\huge} \setlength{\cftbeforetoctitleskip}{-.3cm} \setlength{\cftbeforeloftitleskip}{-.3cm} \setlength{\cftbeforelottitleskip}{-.3cm} \setlength{\cftafterloftitleskip}{1.7cm} \setlength{\cftaftertoctitleskip}{1.4cm} \setlength{\cftafterlottitleskip}{1.7cm} \renewcommand{\cftchapfont}{\normalfont\bfseries} \renewcommand{\cftsecfont}{\normalfont} \renewcommand{\cftsubsecfont}{\normalfont} \usepackage{etoolbox} \usepackage{regexpatch} \usepackage{listings} \usepackage{float} \captionsetup[table]{labelsep=period,indention=45pt,justification=raggedright} \makeatletter \pretocmd{\chapter}{\addtocontents{toc}{\protect\addvspace{-4\p@}}}{}{} \makeatother \renewcommand\cftchapafterpnum{\vskip-4pt} \usepackage{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, } \usepackage[toc,header]{appendix} \begin{document} \frontmatter { \hypersetup{linkcolor=black} \sffamily\tableofcontents } \titlecontents{chapter} [6pc] {\addvspace{1pc}\normalfont\bfseries \filright} {\contentslabel [\chaptername \thecontentslabel]{6pc}} {}{\hfill\contentspage} [\addvspace{2pt}] \mainmatter \chapter{XYZ} rhrrgrrgryryryfyfyfr \chapter{ABC} dgdegegegegeggdddrr \backmatter %\makeatletter %\@mainmattertrue %\makeatother \begin{appendices} \addtocontents{toc}{\protect\renewcommand{\protect\cftchappresnum}{Appendix }} \renewcommand{\chaptername}{Appendix} \chapter{Derivation of X} The contents... \chapter{Derivation of Y} \end{appendices} %\appendix %\newappendix\label{firstappendix} %\section{First section} %This is Appendix~\ref{firstappendix} %\newappendix\label{secondappendix} %\section{Another section} %This is Appendix~\ref{secondappendix} \end{document} 
2
  • Just drop the \backmatter instruction. Commented Jul 6, 2022 at 13:46
  • Though I do not want to remove the \backmatter command, I tried dropping it but I still get Chapter A instead of Appendix A in the table of contents. Commented Jul 6, 2022 at 13:52

1 Answer 1

1

The code in the preamble of your document is quite convoluted. To the extent that I understood what's going on, it appears that various instructions contradict or override each other. My two main suggestions, which together let you achieve your stated formatting objective, are

  • Don't execute \backmatter, at least not before the appendices.

  • Repeat the \titlecontents macro after \begin{appendices}, but now with Appendix as the hard-coded prefix string.

enter image description here

If you don't need the "Appendices" line in the ToC, omit the toc option while loading the appendices package.


\documentclass[11pt,openany,twoside]{book} \raggedbottom \let\cleardoublepage\clearpage \usepackage[a4paper]{geometry} \usepackage{parskip} \usepackage{amsmath} %%\usepackage{amsfonts} % is loaded automatically by amssymb \usepackage{amssymb} \usepackage{amsthm} \usepackage{array} \usepackage[table]{xcolor} % note 'table' option (for 'colortbl') \usepackage{graphicx} \usepackage[dotinlabels]{titletoc} \usepackage{background} \backgroundsetup{contents={}} \usepackage{helvet} %%%\usepackage{color} % don't load both xcolor and color \usepackage{fancyhdr} \usepackage{hhline} \pagestyle{fancy} \usepackage{booktabs} \usepackage[noindentafter,calcwidth]{titlesec} \titleformat{\section}% {\normalfont\Large\bfseries\color{black}} {\thesection}{1em}{} \titleformat{\subsection}% {\normalfont\large\bfseries\color{black}} {\thesubsection}{1em}{} \usepackage{calc,pifont} \usepackage{longtable} \usepackage{multirow} %%%\usepackage{colortbl} % don't load colortbl independently of xcolor \newcommand*\myheaderfooterfont{\normalfont\bfseries} \makeatletter \renewcommand\@biblabel[1]{\textsuperscript{#1}} \makeatother \usepackage[nottoc]{tocbibind} \usepackage{verbatim} % are you sure you need this package? \usepackage[ragged]{sidecap} \usepackage{caption} \captionsetup[table]{skip=5pt} \usepackage[marginal]{footmisc} \renewcommand\footnoterule{\vspace*{-3pt}% \hrule width 2in height 1.4pt \vspace*{2.6pt}} \setlength\footnotemargin{10pt} \usepackage{tocloft} \renewcommand{\cfttoctitlefont}{\hfill\normalfont\bfseries\huge} \renewcommand{\cftloftitlefont}{\hfill\normalfont\bfseries\huge} \renewcommand{\cftlottitlefont}{\hfill\normalfont\bfseries\huge} \setlength{\cftbeforetoctitleskip}{-.3cm} \setlength{\cftbeforeloftitleskip}{-.3cm} \setlength{\cftbeforelottitleskip}{-.3cm} \setlength{\cftafterloftitleskip}{1.7cm} \setlength{\cftaftertoctitleskip}{1.4cm} \setlength{\cftafterlottitleskip}{1.7cm} \renewcommand{\cftchapfont}{\normalfont\bfseries} \renewcommand{\cftsecfont}{\normalfont} \renewcommand{\cftsubsecfont}{\normalfont} \renewcommand{\cftchapafterpnum}{\vskip-4pt} \usepackage{etoolbox} \usepackage{regexpatch} \usepackage{listings} \usepackage{float} \captionsetup[table]{labelsep=period, indention=45pt, justification=raggedright} \makeatletter \pretocmd{\chapter}{\addtocontents{toc}{\protect\addvspace{-4\p@}}}{}{} \makeatother \usepackage{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, } \usepackage[toc,header]{appendix} \begin{document} \frontmatter { \hypersetup{linkcolor=black} \sffamily \tableofcontents } \titlecontents{chapter}[7pc] {\addvspace{1pc}\normalfont\bfseries \filright} {\contentslabel [Chapter \thecontentslabel]{7pc}} {}{\hfill\contentspage} [\addvspace{2pt}] \mainmatter \chapter{XYZ} rhrrgrrgryryryfyfyfr \chapter{ABC} dgdegegegegeggdddrr \begin{appendices} %\addtocontents{toc}{\protect\renewcommand{\protect\cftchappresnum}{Appendix }} %% Rerun the \titlecontents macro, but now with 'Appendix' prefix string \titlecontents{chapter}[7pc] {\addvspace{1pc}\normalfont\bfseries \filright} {\contentslabel [Appendix \thecontentslabel]{7pc}} {}{\hfill\contentspage} [\addvspace{2pt}] \chapter{Derivation of X} The contents\dots \chapter{Derivation of Y} \end{appendices} \end{document} 
3
  • Thank you very much @Mico, it worked 100%. But I wanted the Appendices and Bibliography to be in the backmatter of my book. Is it possible? Commented Jul 6, 2022 at 17:41
  • @itc - The term “backmatter” has different meanings for different people. For use in some of the LaTeX document classes, the macro \backmatter has a very specific meaning: It refers to the final few chapters in a book that are not numbered by typographic convention. The bibliography, index, and glossary are examples of such chapters. Since you do want the appendix chapters to be numbered (or, rather, “lettered”?), they’re not technically part of the document’s “back matter”, at least not according to LaTeX terminology. Commented Jul 6, 2022 at 18:13
  • Well fathomed @Mico. Many thanks. Commented Jul 6, 2022 at 18:33

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.