[Tex/LaTex] Matching TOC-name and title in document for appendix and keeping the defined title format

appendicessectioningtitlesec

I am not that good at Latex, but currently I am using a title format creating the titles for my chapters shown below.

Figure 1

The chapter, 6, and the chapter name, Conclusion, is corresponding to what is said in the Table of Contents;

enter image description here

However, this is not true for the appendix. The title for the appendix in the document is currently A – Stream Data, like the conclusion-title.

I would like it to be Appendix A – Stream Data with the same title format as for the other chapters. So I want it to say

Appendix A
Stream Data

Similarly to the first figure. How can I achieve this?

Best Answer

I can only guess what is inside the files. Following a minimal working example that achieves what you want. You can redefine the layout of chapter titles as often as you want, so you can do the redefinition right after switching to the appendix. But remember, consistency is often better.

notalatexguruTitlesecContents

notalatexguruTitlesecAppendix

\documentclass{report}
\usepackage{appendix}       
\usepackage{titlesec}       
\titleformat{\chapter}[display]
{\Huge\bfseries\filcenter}
{{\fontsize{50pt}{1em}\vspace{-4.2ex}\selectfont
\textnormal{\thechapter}}}{1ex}{}[]
\begin{document}
\tableofcontents
\chapter{Wombat}
\begin{appendices}
\titleformat{\chapter}[display]
{\Huge\bfseries\filcenter}
{{\fontsize{50pt}{1em}\vspace{-4.2ex}\selectfont
\textnormal{Appendix~\thechapter}}}{1ex}{}[]
    \chapter{Capybara}
\end{appendices}
\end{document}