# Appendix and space in TOC

I have the code below and it works, but not exactly the way I want.

\documentclass{report}
\usepackage[titles]{tocloft}
\usepackage{titlesec}
\renewcommand{\cftchappresnum}{CHAPTER }
\renewcommand{\cftchapnumwidth}{0pt}
\renewcommand{\cftchapaftersnumb}{\vspace{3mm}\\}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftdotsep}{1}

\titleformat{name=\chapter, numberless}[block]{\bfseries\large\filleft} {}{0em}{\MakeUppercase}[{\titlerule[1pt]}]
\titleformat{name=\chapter}[display]{\bfseries\huge\filleft} {\chaptername~\thechapter}{3ex}{\MakeUppercase}[{\titlerule[1pt]}]

\begin{document}
\tableofcontents

\chapter{FIRST CHAPTER}
\section{First Section}
\chapter{SECOND CHAPTER}
\chapter{THIRD CHAPTER}

\appendix
\chapter{ERASMUS POLICY}
\chapter{ERASMUS COUNTRY CODES}

\end{document}


Here is the output

What I need help with is

The appendix starts with the word "CHAPTER", whereas I want it to be "APPENDIX-A", "APPENDIX-B" and so on

You have two things to fix:

1. Your body text has appendices titled wrong as well. According to Page 4 of the documentation of the titlesec package, you should have used \chaptertitlename instead of \chaptername in your second \titleformat.
• Why would you need two \titleformat anyway? You should keep only one.
2. Now the fix for the table of contents and a quick search yields this answer. To accommodate your style, you would also use \MakeUppercase.

# MWE

\documentclass{report}
\usepackage[titles]{tocloft}
\usepackage{titlesec}
% Don't use this:
%\renewcommand{\cftchappresnum}{CHAPTER }
% Use this:
\renewcommand{\cftchappresnum}{\MakeUppercase{\chaptername}\space}
% Modified from https://tex.stackexchange.com/a/56845/164314
\makeatletter
\protect\renewcommand{\protect\cftchappresnum}{\MakeUppercase{\appendixname}-}%
}%
}
\makeatother
\renewcommand{\cftchapnumwidth}{0pt}
\renewcommand{\cftchapaftersnumb}{\vspace{3mm}\\}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cftdotsep}{1}

% You don't need to define title format twice
%\titleformat{name=\chapter, numberless}[block]{\bfseries\large\filleft} {}{0em}{\MakeUppercase}[{\titlerule[1pt]}]
%\titleformat{name=\chapter}[display]{\bfseries\huge\filleft} {\chaptername~\thechapter}{3ex}{\MakeUppercase}[{\titlerule[1pt]}]
% Use \chaptertitlename:
\titleformat{name=\chapter}[display]{\bfseries\huge\filleft} {\chaptertitlename~\thechapter}{3ex}{\MakeUppercase}[{\titlerule[1pt]}]

\begin{document}
\tableofcontents

\chapter{FIRST CHAPTER}
\section{First Section}
\chapter{SECOND CHAPTER}
\chapter{THIRD CHAPTER}

\appendix
\chapter{ERASMUS POLICY}
\chapter{ERASMUS COUNTRY CODES}

\end{document}