# Chapter Number Missing for Last Section in TOC and Footer

I have a document with a custom class that I was given, that is based on the book class, and uses the fancyhdr package. In the table of contents the last section of the document is missing the section number, as is the Appendices heading. The page number on these sections (in the footer) is also missing the section number and just has a dash and then the page number, -53 for example. See the image of the table of contents below

And here is the output I see in the footer for these pages (the rest of the document has correct page numbers in both the TOC and footers):

How do I get the section numbers to show up in the table of contents and in the page number shown in the footer on these pages?

Here are the relevant parts of the main .tex file:

\documentclass{byureview}

\begin{document}

\includepdf{titlepage.pdf}

\thispagestyle{empty}
\tableofcontents

\chapter{Chapter 1}

\includepdf{Chapter1.pdf}

% -------------- %

\chapter{Chapter 7}

% -------------- %

\section{List of awards or recognition for scholarship}
\label{sec:scholar_awards}

\input{scholar-awards}

\section{External review letters of scholarship and a copy of the waiver letter}

External review letters will be added by the department office.

\begin{appendices}

\chapter{Mechanical Engineering Departmental Rank and Status Policy}
\label{app:ME_AIR_policy}
\includepdf[pages=-]{ME_AIR_Policy_Nov29_2017_Approved}

\end{appendices}

\end{document}


And here is the contents of the class definition file:

\LoadClass{book}

% ---- packages ------
\RequirePackage[margin=1in]{geometry}
\RequirePackage{booktabs}  % better tables
\usepackage{titlesec}  % allow clear page for sections/subsections
\usepackage{caption}
%\captionsetup[table]{skip=5pt}  % better spacing of table
\captionsetup[figure]{font=small,labelfont={small,bf}} % make figure caption titles small and bold
\captionsetup[table]{skip=5pt,font=small,labelfont={small,bf}} % make table caption titles small and bold
\usepackage[parfill]{parskip}  % no indent and line skip between paragraphs
\usepackage{pdfpages}
\usepackage[toc,page]{appendix}
\usepackage{soul}
\usepackage[auto]{chappg}  % number pages within each chapter
\usepackage{fancyhdr}
\usepackage{color}
\definecolor{byublue}{RGB}{52, 90, 138}
\usepackage[stable]{footmisc}
\usepackage[capitalise]{cleveref}
\usepackage{rotating}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{pgfplots}

\usepackage{xcolor}
\definecolor{color1}{RGB}{16,43,78}
\definecolor{color2}{RGB}{28,66,106}
\definecolor{color3}{RGB}{112,139,184}
\definecolor{color4}{RGB}{199,214,238}
\definecolor{color5}{RGB}{205,194,175}
\definecolor{color6}{RGB}{228,210,188}
\definecolor{color7}{RGB}{255,230,202}
\definecolor{color8}{RGB}{255,241,226}

\usepackage{longtable}

\titleformat{\chapter}{\color{byublue}\bfseries\huge}{\thechapter.}{20pt}{\color{byublue}\bfseries\huge}%
[\thispagestyle{empty}\null\clearpage]

\renewcommand\thesection{\thechapter.\Alph{section}}

% new page for each section/subsection
\newcommand{\sectionbreak}{\clearpage}

% makes paragraphs with a carriage return after the title
\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}}

% page numbering per section
\renewcommand{\thepage}{\thechapter-\arabic{page}}

\pagestyle{fancy}
\fancyhf{}
\cfoot{\thepage}

\renewcommand\tableofcontents{%
\@starttoc{toc}%
}

% \makeatletter
% \patchcmd{\@sect}% <cmd>
%   {\protected@edef}% <search>
%   {\def\arg{#1}\def\arg@{section}%
%    \ifx\arg\arg@\stepcounter{page}\fi%
%    \protected@edef}% <replace>
%   {}{}% <success><failure>
% \makeatother

% ----- custom commands -------

\newcommand{\cvpar}[2][1.0]{\vspace{#1em}\noindent \emph{#2}}

\newenvironment{cvlist}%
{\begin{list}{}{%
\setlength{\topsep}{0pt}
\setlength{\leftmargin}{15pt}}}
{\unskip\end{list}}

% define subsubsubsection
\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\makeatother

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

• I guess the prefix you're referring to is the chapter number 7, not the section number 7.E. Correct? Also, what should the prefix be for Appendices since it's no numbered? – Werner Jan 17 '18 at 6:55

You can try this hack:

\newcounter{oldchapter}
\let\myoldchapter=\chapter
\makeatletter
\def\chapter{\@ifstar{\ifnum\value{chapter}>0 \setcounter{oldchapter}{\numexpr\value{chapter}+1\relax}\fi\myoldchapter}{\ifnum\value{chapter}>0 \setcounter{oldchapter}{\numexpr\value{chapter}+1\relax}\fi\myoldchapter}}
\makeatother
\xdef\AfterApp{0}

\newenvironment{myappendices}{\cleardoublepage\setcounter{page}{1}\setcounter{oldchapter}{\numexpr\value{chapter}-\value{oldchapter}}\begin{appendices}\xdef\AfterApp{1}}{\end{appendices}}

\renewcommand{\thepage}{
\ifnum\value{oldchapter}=0 App\else\ifnum\value{chapter}=0 \theoldchapter\else\ifnum\AfterApp=0 \thechapter\else\Alph{chapter}\fi\fi\fi-\arabic{page}
}


Just add these lines in your preamble and comment out your own \renwecommand{\thepage}... Also change the appendices environment to myappendices

Check if works and we can improve the hack for chapters with optional arguments etc. (I don't know what supposed to be shown in appendices start instead of chapter and just used an App there and set page to 1).

If it works we can improve it...