0

I would like to have an A prefix in the appendix figures, but not in the section heading – and include the Appendix in the table of contents.

enter image description here

A MWE inspired be this answer.

\documentclass[a4paper,12pt,bibliography=totoc]{scrartcl}

\usepackage{blindtext} \usepackage{graphicx}

\setcounter{secnumdepth}{0} % remove numbers from section headings

%%%%%%%%%% \begin{document}

\tableofcontents

\section{Section 1}

\begin{figure}[!h] \includegraphics[width=0.3\textwidth]{example-image-duck} \caption{duck} \label{fig:duck} \end{figure}

\blindtext

\setcounter{secnumdepth}{3} % add numbers to section headings, needed for prefix in the figures \appendix \counterwithin{figure}{section}

\section{Appendix}\label{appendix}

\begin{figure}[!h] \includegraphics[width=0.3\textwidth]{example-image-a} \caption{Image in Appendix} \label{fig:image} \end{figure}

\end{document}

P.S. See also a related question in here (these were originally in the same post, but decided to seperate them for clarity.)

1 Answers1

1

Since you are using KOMA class, just use \addsec{}

MVE:

\documentclass[a4paper,12pt,bibliography=totoc]{scrartcl}

\usepackage{blindtext} \usepackage{graphicx}

\setcounter{secnumdepth}{0} % remove numbers from section headings

%%%%%%%%%%

\begin{document}

\tableofcontents

\section{Section 1}

\begin{figure}[!h]
    \includegraphics[width=0.3\textwidth]{example-image-duck}
    \caption{duck}
    \label{fig:duck}
\end{figure}

\blindtext


\setcounter{secnumdepth}{3} % add numbers to section headings, needed for prefix in the figures
\appendix
\counterwithin{figure}{section}
\stepcounter{section}
\addsec{Appendix}

\begin{figure}[!h]
    \includegraphics[width=0.3\textwidth]{example-image-a}
    \caption{Image in Appendix}
    \label{fig:image}
\end{figure}

\end{document}

An alternative non-KOMA class way (from a comment thread of this answer by Andrew Swann ):

"The easiest way would be to use \section* for the heading plus \refstepcounter{section} just after the heading. If you need a contents entry for the heading, you can add that with \addcontentsline{toc}{section}{Figures}"