2

I'm using the book class and the following in my preamble:

\usepackage{sectsty}
\allsectionsfont{\large}
\chapterfont{}
\sectionfont{}
\subsectionfont{}
\subsubsectionfont{\vspace{-0.5\baselineskip}\bfseries}

My chapter titles look like this:

sssss

Now, I'd like to have appendices follow the same style, with "Chapter" replaced by "Appendix" and the number replaced by a letter. I'm currently using the following code at the beginning of each appendix:

\chapter*{Appendix A:\\Mathematica correlation code}
\addcontentsline{toc}{chapter}{Appendix A: Mathematica correlation code}

However, this doesn't achieve the desired result, since it removes the "Chapter N" line altogether, raises the appendix title to where the removed line used to be and writes "Appendix A" in the same font size as the appendix title:

enter image description here

Here's a MWE:

\documentclass[11pt,oneside]{book}

% BASE PACKAGES
    % symbol packages
        \usepackage{amsmath}
        \usepackage{amssymb}
        \usepackage{amsthm}
        \usepackage{mathrsfs}
        \usepackage{esvect}
        \usepackage{latexsym}
        \usepackage{mathtools}
    % graphics packages
        \usepackage{graphicx}
        \usepackage{epstopdf}
        \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `basename #1 .tif`.png}
        \usepackage{float}
        \usepackage{subfig}

% PAGE LAYOUT
    % base packages
        \usepackage[utf8]{inputenc}
        \usepackage{wasysym}
        \usepackage[cam,letter,center]{crop}
    % page margins
        \textheight 22.5cm
        \topmargin -0.5in
        \usepackage[margin=1.5in]{geometry}
    % page headers
        \usepackage{fancyhdr}
        \pagestyle{fancy}
        \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
        \renewcommand{\sectionmark}[1]{\markright{#1}}
        \fancyhf{}
        \fancyhead[LE,RO]{\thepage}
        \fancyhead[LO]{\nouppercase\rightmark}
        \fancyhead[RE]{\nouppercase\leftmark}

% FONTS
    % base packages
        \usepackage{amsfonts}
        \usepackage{mathspec}
    % font controls
        \setmainfont[Ligatures={Common,TeX},Numbers={OldStyle,Proportional}]{Calluna}
        \setsansfont[Ligatures={Common,TeX},Numbers={Lining,Proportional}]{Calluna}
        \setmathfont(Digits,Latin,Greek)[Arabic=Regular,Uppercase=Italic,Lowercase=Italic,Numbers={Lining,Monospaced}]{Calluna}
        \setmonofont[Ligatures={NoRequired,NoCommon,NoContextual},Numbers={Lining,Monospaced},Scale=0.8]{Courier New Bold}
    % line height
        \linespread{1.05}
    % non-italic Greek letters
        \usepackage{textgreek}

% TITLES
    % title styles
        \usepackage{sectsty}
        \allsectionsfont{\large}
        \chapterfont{}
        \sectionfont{}
        \subsectionfont{}
        \subsubsectionfont{\vspace{-0.5\baselineskip}\bfseries}
    % title spacing
        \makeatletter
        \def\@seccntformat#1{\@ifundefined{#1@cntformat}{\csname the#1\endcsname\quad}{\csname #1@cntformat\endcsname}}
        \def\section@cntformat{\thesection.\quad}
        \def\subsection@cntformat{\thesubsection.\quad}
        \makeatother
        \usepackage{titlesec}
        \titlespacing*{\subsection}{0pt}{0.7\baselineskip}{\baselineskip}

% TABLE OF CONTENTS
    % base packages
        \usepackage{titletoc}
    % formatting
        \titlecontents{chapter}[2.4em]{\addvspace{1pc}\bfseries}{\contentslabel{2em}}{}{\titlerule*[0.73pc]{ .}\contentspage}
        \titlecontents{section}[4.8em]{\addvspace{0pc}}{\contentslabel{3em}}{}{\titlerule*[0.73pc]{ .}\contentspage}
        \titlecontents{subsection}[7.2em]{\addvspace{0pc}}{\contentslabel{3.5em}}{}{\titlerule*[0.73pc]{ .}\contentspage}

% DUMMY TEXT
    % lipsum
        \usepackage{lipsum}

\begin{document}\sloppy

\tableofcontents

\mainmatter

\chapter{Preliminary concepts}

\lipsum

\chapter*{Appendix A:\\Mathematica correlation code}
\addcontentsline{toc}{chapter}{Appendix A: Mathematica correlation code}

\lipsum

\end{document}

Thanks in advance for any help.

2 Answers 2

3
\documentclass[
  fontsize=11pt,
  oneside=on,
  chapterprefix=on,
  appendixprefix=on]{scrbook}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\mainmatter
\chapter{Preliminary concepts}
\lipsum

\appendix
\chapter{Mathematica correlation code}

\lipsum
\end{document}

enter image description here

enter image description here

1
  • This works, thanks! :)
    – Rain
    Jun 6, 2019 at 19:43
3

You have not provided a compilable MWE so we don't even know what class you are using.

In the standard classes the \appendix command before your appendices code does what you want.

So, for example

...
\lipsum
\appendix
\chapter{Mathematica correlation code}
\lipsum
\end{document}

But if that does not work for you then the appendix package is probably your saviour; read the manual (> texdoc appendix).

1
  • Apologies, you're right. I will edit my question to include more information. I'll also have a look at that package.
    – Rain
    Jun 2, 2019 at 18:17

You must log in to answer this question.

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