1

I am writing a document in Latex. I would like the word "Appendix" to appear in each section title. For example, the first section should be: "Appendix A: Proofs". Unfortunately, "Appendix" does not appear in the current titles: for example, the current title of the first section is just "A: Proofs".

Is there an easy way to fix this? Unfortunately, none of the solutions here worked (I have no idea why).

Here is a minimal(-ish) working example:

\documentclass[12pt]{article}

\usepackage{geometry,ulem,graphicx,caption,mathtools,natbib, xcolor,setspace,comment,pdflscape,array, parskip, booktabs, bbm, titlesec, lipsum, footmisc, color, amsthm, tikz, subfig}

\usepackage{footnotebackref}

\titleformat{\section}
  {\normalfont \scshape}{\thesection.}{0.5em}{}

\titleformat{name=\section,numberless}
  {\normalfont \scshape}{}{0em}{}

\usepackage[titletoc]{appendix}

\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}

\makeatletter
\renewcommand\hyper@natlinkbreak[2]{#1}
\makeatother

\begin{document}

\renewcommand{\appendixname}{}

\begin{appendices}

\textsc{Appendices.}

\section{Proofs}\label{app_sec_proofs}

\end{appendices}

\end{document}

1 Answer 1

2

IMHO this is an incompatibility of packages titlesec and appendix. Without titlesec it works. However, you can add a generic hook to change the \section formatting with titlesec, whenever environment appendices starts:

\documentclass[12pt]{article}

%\usepackage{geometry,ulem,graphicx,caption,mathtools,natbib,xcolor,setspace,comment,pdflscape,array, parskip,booktabs, bbm}
\usepackage{titlesec}% the only relevant package beside appendix
%\usepackage{ lipsum, footmisc, color, amsthm, tikz, subfig}

\usepackage{footnotebackref}

\titleformat{\section}
  {\normalfont \scshape}{\thesection.}{0.5em}{}

\titleformat{name=\section,numberless}
{\normalfont \scshape}{}{0em}{}

\AddToHook{env/appendices/begin}{%
  \titleformat{\section}
  {\normalfont \scshape}{\sectionname~\thesection.}{0.5em}{}
}

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

\makeatletter
\renewcommand\hyper@natlinkbreak[2]{#1}
\makeatother

\begin{document}


\begin{appendices}

\textsc{Appendices.}

\section{Proofs}\label{app_sec_proofs}

\end{appendices}

\end{document}

enter image description here

or with : instead of . and option page instead of a handmade page title:

\documentclass[12pt]{article}

%\usepackage{geometry,ulem,graphicx,caption,mathtools,natbib,xcolor,setspace,comment,pdflscape,array, parskip,booktabs, bbm}
\usepackage{titlesec}% the only relevant package beside appendix
%\usepackage{ lipsum, footmisc, color, amsthm, tikz, subfig}

\usepackage{footnotebackref}

\titleformat{\section}
  {\normalfont \scshape}{\thesection.}{0.5em}{}

\titleformat{name=\section,numberless}
{\normalfont \scshape}{}{0em}{}

\AddToHook{env/appendices/begin}{%
  \titleformat{\section}
  {\normalfont \scshape}{\sectionname~\thesection:}{0.5em}{}
}

\usepackage[title,titletoc]{appendix}

\makeatletter
\renewcommand\hyper@natlinkbreak[2]{#1}
\makeatother

\begin{document}

\begin{appendices}

\section{Proofs}\label{app_sec_proofs}

\end{appendices}

\end{document}

enter image description here

Please note, redefining \appendixname to an empty string, does not make sense, if you want "Appendix" prefixes in the table of contents or the titles, because options title and titletoc uses exactly, this \appendixname. For this reason, I've removed your \renewcommand{\appendixname}{}.

If you want to change the title "Appendices" either in the ToC or of the appendices page, see \appendixtocname and \appendixpagename in the appendix user guide.

For an alternative suggestion using scrartcl instead of article and package appendix see, e.g., this answer.

3
  • Thanks so much for the suggestions! I see that you have deleted: \renewcommand{\appendixname}{}. When I added this back (in order to get rid of the "Appendices" title which otherwise shows up at the start), the problem re-appears. Do you know if it's possible to solve my problem without re-introducing "Appendices" at the start?
    – afreelunch
    Mar 6 at 13:32
  • @afreelunch Not quite clear, what you are talking about. If you don't want the "Appendices" remove the page option in the second example and the \textsc{Appendices} in the first example. Redefining \appendixname to remove "Appendices" does not make sense, because \appendixname by default is not "Appendices", but "Appendix". If you have more follow-up questions please ask a new question..
    – cabohah
    Mar 6 at 13:40
  • Sorry, I think I was a little confused -- it all seems to work!
    – afreelunch
    Mar 6 at 14:16

You must log in to answer this question.

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