2

If this question has been asked before and answered, I will remove it.

Consider the following output:

I'd like to remove the A, and likewise for all subsections following that appendix (there is only a single appendix). I've tried using \appendix command instead, but it doesn't insert "Appendix" and the space between "Appendix" and "Code" on default, both of which I'd like to keep. The output was produced with:

\documentclass[a4paper,12pt]{article}
\usepackage[title,titletoc]{appendix}

\begin{document}


\begin{appendices}
\section{Code}
\end{appendices}

\end{document}
2
  • What are the "numbers" of subsections in the appendix section supposed to look like? "A.1", "A.2", etc.; "1", "2", etc.; "a", "b", etc.' or something else? Please advise.
    – Mico
    Dec 28, 2020 at 4:57
  • Yes, should have included it. I guess simply 1,2, etc. Since there is none on the appendix, maybe even no numbering at all, which would be simply giving it a star.
    – psie
    Dec 28, 2020 at 11:35

2 Answers 2

0

Do you want something how this? I have used \section*{\appendixname\, Code} with a bit of space \, (or you can put \quad) because the two words are very close to each other that they seem to be united.

\documentclass[a4paper,12pt]{article}
\usepackage[title,titletoc]{appendix}

\begin{document}


\begin{appendices}
\section*{\appendixname\, Code}
\end{appendices}

\end{document}

enter image description here

6
  • 1
    Thanks for the reply and the easy solution. \quad seems to do it.
    – psie
    Dec 27, 2020 at 22:36
  • However, how does one keep the appendix in the table of contents? Putting a star in the section command seems to make it vanish.
    – psie
    Dec 27, 2020 at 22:38
  • @schn I honestly don't know :-( sorry. I only answered your question by looking at the manual.
    – Sebastiano
    Dec 27, 2020 at 22:46
  • 1
    I used \addcontentsline{toc}{section}{\appendixname \quad Code} and it works, however I get a hyperref warning saying that "token not allowed in a PDF string", which I think has something to do with using \quad.
    – psie
    Dec 27, 2020 at 22:54
  • 1
    @schn If you have a bit of time look this: tex.stackexchange.com/questions/53513/…
    – Sebastiano
    Dec 27, 2020 at 23:01
2

Some comments and suggestions:

  • I wouldn't use '1', '2', etc to denote the subsection numbers in the appendix, as that will needlessly invite confusion as the sections in the main body of the document are numbered '1', '2, etc as well.

  • Hence, I'd like to suggest that you keep the default numbering of the subsections in the appendix, viz., 'A.1', 'A.2', etc.

  • The code below shows how to modify the appearance of the appendix-level section header ("Code") in a way that doesn't mess the rest of the numbering system.

  • You may also want to modify the \appendix command to write a header such as "Appendix Material" to the header file.

enter image description here

\documentclass[a4paper,12pt]{article}

\usepackage{etoolbox}
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname\quad}%    default
   {\csname #1@cntformat\endcsname}}% enable individual control
\apptocmd\appendix{%
    \newcommand\section@cntformat{\appendixname:\ }
    \addtocontents{toc}{\bigskip\noindent\textbf{Appendix Material}\par}
    {}{}}
\makeatother
    
\begin{document}
\tableofcontents
\bigskip\hrule

\section{Hello}
\subsection{Uno}
\subsection{Due}

\appendix
\section{Code}
\subsection{One}
\subsection{Two}

\end{document}

You must log in to answer this question.

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