1

Could anyone tell me how to modify the headings in Appendix of an article? I need to suppress the word 'Appendix' in the subsection headings to A.1. Subheading-1, A.2. Subheading-2 and so on (please see the attached screenshot).

screenshot of output

I'm using the following commands:

\documentclass[a4paper]{elsarticle}
\begin{document}
Main text
\appendix
\section{Main Heading - 1} 
\subsection{Subheading-1}
\subsection{Subheading-2}

\section{Main Heading - 2} 
\subsection{Subheading-1}
\subsection{Subheading-2}
\end{document}
1
  • 1
    Welcome to tex.sx. Commented Jul 20, 2022 at 1:32

1 Answer 1

1

This answer to the question How should equations in the appendix to be numbered, if the section they are in is unnumbered? notes that "the elsarticle document class modifies LaTeX's \appendix macro in a faulty way". [Shameless self-citation alert!] Applying the methods used in the cited answer, I suggest you modify the \appendix macro by running the following code in the preamble of your document:

\usepackage{etoolbox}
\makeatletter
% the next 4 lines are straight from "The LaTeX Companion", 2nd ed.
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname.\hskip0.5em}    % default
   {\csname #1@cntformat\endcsname}% enable individual control
}
\appto{\appendix}{%
    \renewcommand{\appendixname}{Appendix}
    \newcommand{\section@cntformat}{\appendixname~\Alph{section}.\hskip0.5em}
    \newcommand{\subsection@cntformat}{\Alph{section}.\arabic{subsection}.\hskip0.5em}}
\makeatother

A full MWE (minimum working example) and its output:

enter image description here

documentclass{elsarticle}
\usepackage{etoolbox}
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname.\hskip0.5em}    % default
   {\csname #1@cntformat\endcsname}% enable individual control
}
\appto{\appendix}{%
    \renewcommand{\appendixname}{Appendix}
    \newcommand{\section@cntformat}{\appendixname~\Alph{section}.\hskip0.5em}
    \newcommand{\subsection@cntformat}{\Alph{section}.\arabic{subsection}.\hskip0.5em}}
\makeatother

\begin{document}

\section{Bla}
\subsection{Ble}
\subsection{Bli}

\appendix

\section{Main Heading - 1} 
\subsection{Subheading-1}
\subsection{Subheading-2}

\section{Main Heading - 2} 
\subsection{Subheading-1}
\subsection{Subheading-2}
\end{document}
2
  • 1
    Thank you so much! It was super helpful.
    – Ana
    Commented Jul 20, 2022 at 4:41
  • @Ana - You're most welcome!
    – Mico
    Commented Jul 20, 2022 at 5:43

You must log in to answer this question.

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