3

For the thesis I am writing it is demanded that the appendix chapters come in the form of "Appendix A", "Appendix B", etc..

I wanted different formatting for the chapters than the standard one so I used the titlesec package. The formatting of the chapters became what I wanted, but it also removed the "Appendix" word in the appendix's chapters. I am not proficient with the titlesec formatting package, so below I post an example of what I mean in hopes someone can help.

\documentclass[10pt, twoside, openright, dvipsnames]{report}

\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage[table,xcdraw]{xcolor}

\titleformat{\chapter}[hang]{\normalfont\scshape\LARGE\color{MidnightBlue}}{\thechapter\hspace{0pt}\color{MidnightBlue}\hspace{10pt}}{0pt}{\LARGE}

\titleformat*{\section}{\normalfont\scshape\Large\color{MidnightBlue}}
\titleformat*{\subsection}{\normalfont\scshape\large\color{MidnightBlue}}
\titleformat*{\subsubsection}{\normalfont\scshape\normalsize\color{MidnightBlue}}


\usepackage[titletoc]{appendix}


\begin{document}

\chapter{Introduction}
\section{Intro}
\chapter{Development}
\section{Intro}

\appendix
\chapter{One}

\end{document}

Is it possible to keep that exact formatting and include the "Appendix" word before ?

2 Answers 2

4

You can use the fact that in the main part of the document, \@chapapp expands to \chaptername, but after \appendix it expands to \appendixname.

Also note the simplifications I made in the rest of the code.

\documentclass[10pt, twoside, openright]{report}

\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage[table,xcdraw,dvipsnames]{xcolor}

\makeatletter
\titleformat{\chapter}[hang]
  {\normalfont\scshape\LARGE\color{MidnightBlue}}
  {\expandafter\ifx\@chapapp\appendixname\appendixname\ \fi\thechapter}
  {10pt}
  {\LARGE}
\makeatother

\titleformat*{\section}{\normalfont\scshape\Large\color{MidnightBlue}}
\titleformat*{\subsection}{\normalfont\scshape\large\color{MidnightBlue}}
\titleformat*{\subsubsection}{\normalfont\scshape\normalsize\color{MidnightBlue}}

\usepackage[titletoc]{appendix}


\begin{document}

\chapter{Introduction}
\section{Intro}
\chapter{Development}
\section{Intro}

\appendix
\chapter{One}

\end{document}

enter image description here

enter image description here

1
  • Perfect! Thanks for the additional simplification. Commented Mar 15, 2020 at 15:11
3

The command \chaptername stores, what to display in a chapter head (e.g. in English it is Chapter, in German it's Kapitel). Same goes for \appendixname for appendices (Appendix or Anhang).

The command \chaptertitlename chooses, depending on whether you are in the \appendix or not, which of these two is called.

You could add \chaptertitlename to your titlesec definition and adjust the two commands above like this:

\renewcommand{\chaptername}{}
\renewcommand{\appendixname}{Appendix }
\titleformat{\chapter}[hang]{\normalfont\scshape\LARGE\color{MidnightBlue}}{\chaptertitlename\thechapter\hspace{0pt}\color{MidnightBlue}\hspace{10pt}}{0pt}{\LARGE}
1
  • Great explanation, it solved the problem too ! Commented Mar 15, 2020 at 15:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .