# Using the etoc package with appendices — how to make it say “appendix” instead of “chapter” in the TOCs?

I'm currently working on getting the senior thesis I've written to fit within the format requirements that I'm expected to adhere to. The last bit I'm hung up on is that the appendices must be called appendices and not chapters in the TOC. This is made slightly more complicated because I'm also using the verse package to typeset two poems, each of which should be counted as an appendix, in addition to the normal appendices that follow.

I'm using the titlesec package to strip the extra formatting (bold, font size changes, etcetera) from the document content and the etoc package to get rid of the extra formatting in the TOC.

I attempted to use the appendix package to handle the appendices (eg, make it so I could have the chapters be called appendices and numbered with \Alpha but for all other intents and purposes be identical in formatting to normal chapters) but etoc doesn't seem to play too nicely with it. I tried using \@chapapp, which appendix supposedly redefines as equal to \appendixname, but this change didn't seem to make any difference when I used it in my \etocsetstyle invocation for chapters. :/

Perhaps using the "partial appendix" functionality from another package such as titlesec (or whatever the accompanying TOC package is called) might allow me to use etoc's \etocsetstyle to just redefine the style to say "APPPENDIX" instead of "CHAPTER"?

I'm pretty sure there must be someone out there who has been in this situation before, since I consider it highly unlikely that there are many people who prefer to have their appendices identified as chapters in the table of contents. Any and all help would be appreciated at this point. I'm invoking LuaLaTeX via latexmk on Windows, in case that might be relevant (although I doubt it is in this particular instance).

Here is a basic MWE:

\documentclass{report}

\usepackage{lipsum}
\usepackage{fmtcount}
\usepackage{setspace}
\usepackage{verse}
\usepackage[backend=biber,%
%backref=true,%
\usepackage{makeidx}
\usepackage[nomain,translate=babel]{glossaries}
\usepackage{cleveref}
%\usepackage{etoc}% Moved below
\usepackage[indentafter,explicit,nobottomtitles*]{titlesec}

%\usepackage[page,toc,title,titletoc]{appendix}
%\usepackage[title]{appendix}
\usepackage{appendix}

\newdimen\myparindent
\myparindent=18pt\relax

\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\}%
{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}
\titlespacing{\subsubsection}{\myparindent}{0pt}{1.3\fontdimen2\font plus1.3\fontdimen3\font minus1.3\fontdimen4\font}

\titleformat{\part}[block]{%
\begin{minipage}[c][9in]{6in}%
\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}%
{\MakeUppercase{#1}}%
{0pt}%
{\\\end{centering}\end{minipage}}
\titlespacing{\block}{0pt}{0pt}{0pt}[0pt]
\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\
}{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{etoc}
\etocstandardlines % line entries' as without \usepackage{etoc}
\etocstandarddisplaystyle % toc display' as without \usepackage{etoc}
\etocsetnexttocdepth{subsection}
\etocnopar% same as \etocinline; switched back off by \etocdisplay
\etocsettocstyle{\vspace*{0.5in}% 1.5in from top edge of page
\begin{centering}\MakeUppercase{\contentsname}\\\end{centering}%
\ifvmode\message{YES IN VMODE}\else\message{NO NOT IN VMODE}\fi
}% Leave/exit/end in vertical mode, p.65
{\vspace{2\baselineskip}}

\makeatletter
\newcommand*{\Dots}{%
\hfill\nobreak
}%
\newcommand*{\DotsAndPage}{%
\hskip 2mm\Dots\hskip2mm%
\makebox[\width][r]{\normalsize\etocpage}\par}%
%
\etocsetstyle{part}% hlevelnamei
{\parindent 0pt% hstarti
\singlespacing
\nobreak
}%
{\pagebreak[3]\vspace{\baselineskip}}% hprefixi
{% hcontentsi
\normalfont\rmfamily\scshape
\rlap{\vbox to 0pt{\hrule width\textwidth height 0pt depth 1.75pt}}%
\etocname\par}%
{}% hfinishi
\etocsetstyle{chapter}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hstarti
\singlespacing
\nobreak%\vspace{\baselineskip}%\medskip
\etocskipfirstprefix
}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hprefixi
\pagebreak[1]}%\smallskip}%
{\normalfont\normalsize\rmfamily % hcontentsi
\etocifnumbered{CHAPTER~%
\noexpand\protect
\noexpand\NUMBERstringnum{\protect\etocthenumber}%
\char:{}\quad\protect}{}\etocthename}\DotsAndPage\fi}%
{\parfillskip 0pt plus 1fil\relax}% hfinishi
\etocsetstyle{section}%
{\leftskip1cm\rightskip .75cm \parfillskip-\rightskip
\singlespacing
\nobreak}%\vspace{\baselineskip}}%\smallskip}%
{}%{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalsize \etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\etocsetstyle{subsection}%
{\leftskip2cm\rightskip .75cm\parfillskip-\rightskip
\parfillskip 0pt plus 1fil\relax% hstarti
\singlespacing
\nobreak\etocskipfirstprefix}%\vspace{\baselineskip}}%\smallskip}%
{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily\itshape% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalfont\normalsize\etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\def\mytocpage{%
\begingroup
\tableofcontents
\endgroup
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dummypoem{%
\poemtitle[(short form of title)]{A Placeholder Rhyme}
\settowidth{\versewidth}{I sort of hate my life right now}%
\begin{verse}[\versewidth]
\begin{altverse}
I sort of hate my life right now;\\
I haven't slept in days.\\
I'm two weeks past my deadlines,\\
\end{altverse}
\end{verse}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\poemtoc}{chapter}

\begin{document}
\mytocpage
\part{(name of p1)}
\lipsum[1]\par
\chapter{(name of p1c1)}
\lipsum[2]\par
\section{(name of p1c1s1)}
\lipsum[3]\par
\subsection{(name of p1c1ss1)}
\lipsum[4]\par
\subsubsection{(name of p1c1ss1sss1)}
\lipsum[5]\par

\appendix % and/or
\part{APPENDICES}% and/or
\begin{appendices}% see appendix package options that I commented out
\chapter{(name of appendix a)}
\section{a.s1}
\lipsum[1]\par
\subsection{a.s2}
\lipsum[2]\par
\end{appendices}

\end{document}


Note: I've used appendices and tables of contents before, but not when in the context of using etoc to fight with TeX. I know how to do it the normal way.

• Evidently etoc redefines \numberline to add Chapter. Somehow you need to instruct etoc to replace Chapter with Appendix using a \addtocontents command midway through the TOC. Good luck! – John Kormylo Dec 16 '19 at 15:35

I replaced CHAPTER with \protect\MakeUppercase\chaptername then changed \chaptername to Appendix using \addtocontents. The change is local to the table of contents.

\documentclass{report}

\usepackage{lipsum}
\usepackage{fmtcount}
\usepackage{setspace}
\usepackage{verse}
\usepackage[backend=biber,%
%backref=true,%
\usepackage{makeidx}
\usepackage[nomain,translate=babel]{glossaries}
\usepackage{cleveref}
%\usepackage{etoc}% Moved below
\usepackage[indentafter,explicit,nobottomtitles*]{titlesec}

%\usepackage[page,toc,title,titletoc]{appendix}
%\usepackage[title]{appendix}
\usepackage{appendix}

\newdimen\myparindent
\myparindent=18pt\relax

\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\}%
{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}
\titlespacing{\subsubsection}{\myparindent}{0pt}{1.3\fontdimen2\font plus1.3\fontdimen3\font minus1.3\fontdimen4\font}

\titleformat{\part}[block]{%
\begin{minipage}[c][9in]{6in}%
\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}%
{\MakeUppercase{#1}}%
{0pt}%
{\\\end{centering}\end{minipage}}
\titlespacing{\block}{0pt}{0pt}{0pt}[0pt]
\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\
}{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{etoc}
\etocstandardlines % line entries' as without \usepackage{etoc}
\etocstandarddisplaystyle % toc display' as without \usepackage{etoc}
\etocsetnexttocdepth{subsection}
\etocnopar% same as \etocinline; switched back off by \etocdisplay
\etocsettocstyle{\vspace*{0.5in}% 1.5in from top edge of page
\begin{centering}\MakeUppercase{\contentsname}\\\end{centering}%
\ifvmode\message{YES IN VMODE}\else\message{NO NOT IN VMODE}\fi
}% Leave/exit/end in vertical mode, p.65
{\vspace{2\baselineskip}}

\makeatletter
\newcommand*{\Dots}{%
\hfill\nobreak
}%
\newcommand*{\DotsAndPage}{%
\hskip 2mm\Dots\hskip2mm%
\makebox[\width][r]{\normalsize\etocpage}\par}%
%
\etocsetstyle{part}% hlevelnamei
{\parindent 0pt% hstarti
\singlespacing
\nobreak
}%
{\pagebreak[3]\vspace{\baselineskip}}% hprefixi
{% hcontentsi
\normalfont\rmfamily\scshape
\rlap{\vbox to 0pt{\hrule width\textwidth height 0pt depth 1.75pt}}%
\etocname\par}%
{}% hfinishi
\etocsetstyle{chapter}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hstarti
\singlespacing
\nobreak%\vspace{\baselineskip}%\medskip
\etocskipfirstprefix
}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hprefixi
\pagebreak[1]}%\smallskip}%
{\normalfont\normalsize\rmfamily % hcontentsi
\etocifnumbered{\protect\MakeUppercase{\chaptername}~%
\noexpand\protect
\noexpand\NUMBERstringnum{\protect\etocthenumber}%
{\parfillskip 0pt plus 1fil\relax}% hfinishi
\etocsetstyle{section}%
{\leftskip1cm\rightskip .75cm \parfillskip-\rightskip
\singlespacing
\nobreak}%\vspace{\baselineskip}}%\smallskip}%
{}%{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalsize \etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\etocsetstyle{subsection}%
{\leftskip2cm\rightskip .75cm\parfillskip-\rightskip
\parfillskip 0pt plus 1fil\relax% hstarti
\singlespacing
\nobreak\etocskipfirstprefix}%\vspace{\baselineskip}}%\smallskip}%
{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily\itshape% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalfont\normalsize\etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\def\mytocpage{%
\begingroup
\tableofcontents
\endgroup
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dummypoem{%
\poemtitle[(short form of title)]{A Placeholder Rhyme}
\settowidth{\versewidth}{I sort of hate my life right now}%
\begin{verse}[\versewidth]
\begin{altverse}
I sort of hate my life right now;\\
I haven't slept in days.\\
I'm two weeks past my deadlines,\\
\end{altverse}
\end{verse}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\poemtoc}{chapter}

\begin{document}
\mytocpage
\part{(name of p1)}
\lipsum[1]\par
\chapter{(name of p1c1)}
\lipsum[2]\par
\section{(name of p1c1s1)}
\lipsum[3]\par
\subsection{(name of p1c1ss1)}
\lipsum[4]\par
\subsubsection{(name of p1c1ss1sss1)}
\lipsum[5]\par

\appendix % and/or
\begin{appendices}% see appendix package options that I commented out